From e8ef6437423a3dcae6c958ea1c78e51d461826f8 Mon Sep 17 00:00:00 2001 From: stickz Date: Mon, 4 Apr 2016 18:41:55 -0400 Subject: [PATCH] Cleanup 'ent_glowstick_fly' Code - Remove think code and use a timer to destroy the entity. (significantly faster) --- .../entities/ent_glowstick_fly/init.lua | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_glowstick_fly/init.lua b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_glowstick_fly/init.lua index 4ac98c9..7598c80 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_glowstick_fly/init.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_glowstick_fly/init.lua @@ -10,28 +10,21 @@ function ENT:Initialize() self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end - self.Death = CurTime() + 90 + + timer.Simple(90, function() if self.Entity then self.Entity:Remove() end end) end function ENT:SpawnFunction( ply, tr ) - if ( !tr.Hit ) then return end - local ent = ents.Create("ent_glowstick_fly") - ent:SetPos( tr.HitPos + tr.HitNormal * 16 ) - ent:Spawn() - ent:Activate() - - return ent -end - -function ENT:OnRemove() -end - -function ENT:Think() - if self.Death && self.Death < CurTime() then - self:Remove() - end + if ( !tr.Hit ) then return end + + local ent = ents.Create("ent_glowstick_fly") + ent:SetPos( tr.HitPos + tr.HitNormal * 16 ) + ent:Spawn() + ent:Activate() + + return ent end function ENT:Use( activator, caller ) self.Entity:Remove() -end \ No newline at end of file +end