Skip to content

Commit

Permalink
Get ancestor via CFW instead
Browse files Browse the repository at this point in the history
This should be a bit of a performance improvement hopefully
  • Loading branch information
thecraftianman committed Jul 25, 2024
1 parent b81bf8e commit a0f8670
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lua/acf/contraption/contraption_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Contraption.GetAllChildren(Ent, Tab)
end

function Contraption.GetEnts(Ent)
local Ancestor = Contraption.GetAncestor(Ent)
local Ancestor = Ent:GetAncestor()
local Phys = Contraption.GetAllPhysicalEntities(Ancestor)
local Pare = {}

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/damage/ke_shove_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function ACF.KEShove(Target, Pos, Vec, KE)

if hook.Run("ACF_KEShove", Target, Pos, Vec, KE) == false then return end

local Ancestor = Contraption.GetAncestor(Target)
local Ancestor = Target:GetAncestor()
local Phys = Ancestor:GetPhysicsObject()

if IsValid(Phys) then
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/acf_ammo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ do -- ACF Activation and Damage -----------------
Sounds.SendSound(Entity, "ambient/explosions/explode_4.wav", 140, Pitch, 1)

BulletData.Pos = Entity:LocalToWorld(Entity:OBBCenter() + VectorRand() * Entity:GetSize() * 0.5) -- Random position in the ammo crate
BulletData.Flight = VectorRand():GetNormalized() * Speed * 39.37 + Contraption.GetAncestor(Entity):GetVelocity() -- Random direction including baseplate speed
BulletData.Flight = VectorRand():GetNormalized() * Speed * 39.37 + Entity:GetAncestor():GetVelocity() -- Random direction including baseplate speed

BulletData.Owner = Entity.Inflictor or Entity.Owner
BulletData.Gun = Entity
Expand Down
8 changes: 3 additions & 5 deletions lua/entities/acf_gearbox/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ do -- Movement -----------------------------------------
self.InGear = true
end

local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject()
local BoxPhys = self:GetAncestor():GetPhysicsObject()
local SelfWorld = BoxPhys:LocalToWorldVector(BoxPhys:GetAngleVelocity())
local Gear = self.Gear

Expand Down Expand Up @@ -884,7 +884,7 @@ do -- Movement -----------------------------------------
end

if ReactTq ~= 0 then
local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject()
local BoxPhys = self:GetAncestor():GetPhysicsObject()

if IsValid(BoxPhys) then
BoxPhys:ApplyTorqueCenter(self:GetRight() * Clamp(2 * deg(ReactTq * MassRatio) * DeltaTime, -500000, 500000))
Expand All @@ -896,8 +896,6 @@ do -- Movement -----------------------------------------
end ----------------------------------------------------

do -- Braking ------------------------------------------
local Contraption = ACF.Contraption

local function BrakeWheel(Link, Wheel, Brake)
local Phys = Wheel:GetPhysicsObject()
local AntiSpazz = 1
Expand All @@ -924,7 +922,7 @@ do -- Braking ------------------------------------------
if not next(self.Wheels) then return end -- No brakes for the non-wheel users
if self.LastBrake == Clock.CurTime then return end -- Don't run this twice in a tick

local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject()
local BoxPhys = self:GetAncestor():GetPhysicsObject()
local SelfWorld = BoxPhys:LocalToWorldVector(BoxPhys:GetAngleVelocity())
local DeltaTime = Clock.DeltaTime

Expand Down
2 changes: 1 addition & 1 deletion lua/entities/acf_gun/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ do -- Metamethods --------------------------------
local randUnitSquare = (self:GetUp() * (2 * math.random() - 1) + self:GetRight() * (2 * math.random() - 1))
local Spread = randUnitSquare:GetNormalized() * Cone * (math.random() ^ (1 / ACF.GunInaccuracyBias))
local Dir = (self:GetForward() + Spread):GetNormalized()
local Velocity = Contraption.GetAncestor(self):GetVelocity()
local Velocity = self:GetAncestor():GetVelocity()
local BulletData = self.BulletData
local AmmoType = AmmoTypes.Get(BulletData.Type)

Expand Down

0 comments on commit a0f8670

Please sign in to comment.