Skip to content

Commit

Permalink
Merge pull request #23 from wrefgtzweve/add-rotorwash
Browse files Browse the repository at this point in the history
Add rotorwash logic
  • Loading branch information
StyledStrike authored Dec 28, 2024
2 parents 5f436aa + 1f7e97d commit b370ec1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lua/entities/base_glide_heli/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@ function ENT:OnDriverExit()
end
end

-- Create a rotorwash entity
function ENT:CreateRotorWash()
if IsValid( self.rotorWash ) then
return self.rotorWash
end

local rotorWash = ents.Create( "env_rotorwash_emitter" )
self.rotorWash = rotorWash
rotorWash:SetPos( self:WorldSpaceCenter() )
rotorWash:SetParent( self )
rotorWash:Spawn()

self:DeleteOnRemove( rotorWash )

return rotorWash
end

-- Remove the rotorwash entity
function ENT:RemoveRotorWash()
if IsValid( self.rotorWash ) then
self.rotorWash:Remove()
self.rotorWash = nil
end
end

local IsValid = IsValid
local Approach = math.Approach
local ExpDecay = Glide.ExpDecay
Expand Down
5 changes: 5 additions & 0 deletions lua/entities/glide_rotor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ function ENT:Think()
if self.isSpinningFast ~= isSpinningFast then
self.isSpinningFast = isSpinningFast
self:SetModel( isSpinningFast and self.modelFast or self.modelSlow )
if isSpinningFast then
self:GetParent():CreateRotorWash()
else
self:GetParent():RemoveRotorWash()
end
end

local dt = FrameTime()
Expand Down

0 comments on commit b370ec1

Please sign in to comment.