mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
62 lines
1.2 KiB
Lua
62 lines
1.2 KiB
Lua
|
|
--[[
|
||
|
|
| This file was obtained through the combined efforts
|
||
|
|
| of Madbluntz & Plymouth Antiquarian Society.
|
||
|
|
|
|
||
|
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||
|
|
| Maloy, DrPepper10 @ RIP, Atle!
|
||
|
|
|
|
||
|
|
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||
|
|
--]]
|
||
|
|
|
||
|
|
|
||
|
|
function ENT:HandleStart()
|
||
|
|
local Driver = self:GetDriver()
|
||
|
|
|
||
|
|
if IsValid( Driver ) then
|
||
|
|
local KeyReload = Driver:lvsKeyDown( "ENGINE" )
|
||
|
|
|
||
|
|
if self.OldKeyReload ~= KeyReload then
|
||
|
|
self.OldKeyReload = KeyReload
|
||
|
|
|
||
|
|
if KeyReload then
|
||
|
|
self:ToggleEngine()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
function ENT:ToggleEngine()
|
||
|
|
if self:GetEngineActive() then
|
||
|
|
self:StopEngine()
|
||
|
|
else
|
||
|
|
self:StartEngine()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
function ENT:IsEngineStartAllowed()
|
||
|
|
if hook.Run( "LVS.IsEngineStartAllowed", self ) == false then return false end
|
||
|
|
|
||
|
|
if self:WaterLevel() > self.WaterLevelPreventStart then return false end
|
||
|
|
|
||
|
|
return true
|
||
|
|
end
|
||
|
|
|
||
|
|
function ENT:OnEngineActiveChanged( Active )
|
||
|
|
end
|
||
|
|
|
||
|
|
function ENT:StartEngine()
|
||
|
|
if self:GetEngineActive() or not self:IsEngineStartAllowed() then return end
|
||
|
|
|
||
|
|
self:PhysWake()
|
||
|
|
|
||
|
|
self:SetEngineActive( true )
|
||
|
|
self:OnEngineActiveChanged( true )
|
||
|
|
end
|
||
|
|
|
||
|
|
function ENT:StopEngine()
|
||
|
|
if not self:GetEngineActive() then return end
|
||
|
|
|
||
|
|
self:SetEngineActive( false )
|
||
|
|
self:OnEngineActiveChanged( false )
|
||
|
|
end
|