Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion lua/entities/base_glide_car/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ function ENT:OnUpdateMisc()
-- Set bodygroups to default
for _, v in ipairs( self.SirenLights ) do
if v.bodygroup then
self:SetBodygroup( v.bodygroup, 0 )
local ent = v.target and v.target > 0 and self.lightbars and self.lightbars[v.target] or self

ent:SetBodygroup( v.bodygroup, 0 )
end
end
end
Expand Down Expand Up @@ -465,6 +467,19 @@ end

DEFINE_BASECLASS( "base_glide" )

function ENT:OnRemove()
BaseClass.OnRemove( self )

if self.lightbars then
for _, lightbar in ipairs( self.lightbars ) do
if not IsValid( lightbar ) then continue end

lightbar:Remove()
end
self.lightbars = nil
end
end

local Floor = math.floor
local SimpleText = draw.SimpleText
local RoundedBox = draw.RoundedBox
Expand Down Expand Up @@ -553,3 +568,20 @@ function ENT:DrawVehicleHUD( screenW, screenH )
-- Current gear
DrawDataBox( GEAR_LABELS[self:GetGear()] or self:GetGear(), cornerRadius, x + size * 0.5, y + size * 0.78, size * 0.2, size * 0.1 )
end

function ENT:CreateLightbar( model, pos, ang )
local lightbar = ents.CreateClientProp( model )
if not IsValid( lightbar ) then return end

lightbar:SetModel( model )
lightbar:SetPos( self:LocalToWorld( pos ) )
lightbar:SetAngles( self:LocalToWorldAngles( ang ) )
lightbar:SetParent( self )
lightbar:Spawn()
lightbar:Activate()

self.lightbars = self.lightbars or {}
table.insert( self.lightbars, lightbar )

return lightbar
end