mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
61
lua/entities/lvs_base/sv_engine.lua
Normal file
61
lua/entities/lvs_base/sv_engine.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
| 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
|
||||
Reference in New Issue
Block a user