Merge pull request #91 from NathanX-S/master

optimize: ManageSmoke is expensive.
This commit is contained in:
Blu-x92 2023-08-18 09:55:35 +02:00 committed by GitHub
commit a5cfdb442c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -549,9 +549,11 @@ if CLIENT then
end
function ENT:ManageSmoke()
local BaseEnt = self:GetBaseEnt()
if not IsValid( BaseEnt ) then return end
if LocalPlayer():GetPos():DistToSqr(self:GetPos()) > 6000 * 6000 or not BaseEnt:GetActive() then return end
local WheelOnGround = self:GetOnGround()
local GripLoss = self:GetGripLoss()
local Material = self:GetSurfaceMaterial()
@ -562,7 +564,7 @@ if CLIENT then
self.FadeHeat = self.FadeHeat * 0.995
end
local Scale = self.FadeHeat ^ 3 / 1000
local Scale = self.FadeHeat ^ 3 * 0.001
local SmokeOn = (self.FadeHeat >= 7)
local DirtOn = GripLoss > 0.05
local lcolor = BaseEnt:GetTireSmokeColor() * 255
@ -601,6 +603,7 @@ if CLIENT then
if (Speed > 150 or DirtOn) and OnRim then
self:MakeSparks( GripLoss, Dir, Pos, WheelSize )
end
end
function ENT:MakeSparks( Scale, Dir, Pos, WheelSize )
@ -622,4 +625,4 @@ if CLIENT then
function ENT:OnRemove()
end
end
end