Skip to content

Commit

Permalink
Use new detoured mass/model change functions
Browse files Browse the repository at this point in the history
Contraption.SetMass/Contraption.SetModel are convenience functions which will set Entity.ACF.Mass and Entity.ACF.Model respectively
  • Loading branch information
LiddulBOFH committed Feb 8, 2024
1 parent bf179b6 commit 8a84150
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
10 changes: 3 additions & 7 deletions lua/entities/acf_computer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ AddCSLuaFile("cl_init.lua")
include("shared.lua")

local ACF = ACF
local Contraption = ACF.Contraption
local Damage = ACF.Damage
local Utilities = ACF.Utilities
local Clock = Utilities.Clock
Expand Down Expand Up @@ -122,9 +123,8 @@ do -- Spawn and update function

local function UpdateComputer(Entity, Data, Class, Computer)
Entity.ACF = Entity.ACF or {}
Entity.ACF.Model = Computer.Model -- Must be set before changing model

Entity:SetModel(Computer.Model)
Contraption.SetModel(Entity, Computer.Model)

Entity:PhysicsInit(SOLID_VPHYSICS)
Entity:SetMoveType(MOVETYPE_VPHYSICS)
Expand Down Expand Up @@ -159,11 +159,7 @@ do -- Spawn and update function

ACF.Activate(Entity, true)

Entity.ACF.LegalMass = Computer.Mass
Entity.ACF.Model = Computer.Model

local Phys = Entity:GetPhysicsObject()
if IsValid(Phys) then Phys:SetMass(Computer.Mass) end
Contraption.SetMass(Entity, Computer.Mass)

if Entity.OnUpdate then
Entity:OnUpdate(Data, Class, Computer)
Expand Down
10 changes: 3 additions & 7 deletions lua/entities/acf_rack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include("shared.lua")
local EMPTY = { Type = "Empty", PropMass = 0, ProjMass = 0, Tracer = 0 }
local HookRun = hook.Run
local ACF = ACF
local Contraption = ACF.Contraption
local Classes = ACF.Classes
local Utilities = ACF.Utilities
local Clock = Utilities.Clock
Expand Down Expand Up @@ -79,9 +80,8 @@ do -- Spawning and Updating --------------------

local function UpdateRack(Entity, Data, Rack)
Entity.ACF = Entity.ACF or {}
Entity.ACF.Model = Rack.Model -- Must be set before changing model

Entity:SetModel(Rack.Model)
Contraption.SetModel(Entity, Rack.Model)

Entity:PhysicsInit(SOLID_VPHYSICS)
Entity:SetMoveType(MOVETYPE_VPHYSICS)
Expand Down Expand Up @@ -116,11 +116,7 @@ do -- Spawning and Updating --------------------

ACF.Activate(Entity, true)

Entity.ACF.Model = Rack.Model
Entity.ACF.LegalMass = Rack.Mass

local Phys = Entity:GetPhysicsObject()
if IsValid(Phys) then Phys:SetMass(Rack.Mass) end
Contraption.SetMass(Entity, Rack.Mass)

do -- Removing old missiles
local Missiles = Entity.Missiles
Expand Down
10 changes: 3 additions & 7 deletions lua/entities/acf_radar/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AddCSLuaFile("shared.lua")
include("shared.lua")

local ACF = ACF
local Contraption = ACF.Contraption

ACF.RegisterClassLink("acf_radar", "acf_rack", function(Radar, Target)
if Radar.Weapons[Target] then return false, "This rack is already linked to this radar!" end
Expand Down Expand Up @@ -333,9 +334,8 @@ do -- Spawn and Update functions
local Delay = Radar.ThinkDelay

Entity.ACF = Entity.ACF or {}
Entity.ACF.Model = Radar.Model -- Must be set before changing model

Entity:SetModel(Radar.Model)
Contraption.SetModel(Entity, Radar.Model)

Entity:PhysicsInit(SOLID_VPHYSICS)
Entity:SetMoveType(MOVETYPE_VPHYSICS)
Expand Down Expand Up @@ -371,11 +371,7 @@ do -- Spawn and Update functions

ACF.Activate(Entity, true)

Entity.ACF.Model = Radar.Model
Entity.ACF.LegalMass = Radar.Mass

local Phys = Entity:GetPhysicsObject()
if IsValid(Phys) then Phys:SetMass(Radar.Mass) end
Contraption.SetMass(Entity, Radar.Mass)
end

function MakeACF_Radar(Player, Pos, Angle, Data)
Expand Down
10 changes: 3 additions & 7 deletions lua/entities/acf_receiver/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ AddCSLuaFile("shared.lua")
include("shared.lua")

local ACF = ACF
local Contraption = ACF.Contraption

--===============================================================================================--
-- Local Funcs and Vars
Expand Down Expand Up @@ -132,9 +133,8 @@ do -- Spawn and Update functions
local Delay = Receiver.ThinkDelay

Entity.ACF = Entity.ACF or {}
Entity.ACF.Model = Receiver.Model -- Must be set before changing model

Entity:SetModel(Receiver.Model)
Contraption.SetModel(Entity, Receiver.Model)

Entity:PhysicsInit(SOLID_VPHYSICS)
Entity:SetMoveType(MOVETYPE_VPHYSICS)
Expand Down Expand Up @@ -170,11 +170,7 @@ do -- Spawn and Update functions

ACF.Activate(Entity, true)

Entity.ACF.Model = Receiver.Model
Entity.ACF.LegalMass = Receiver.Mass

local Phys = Entity:GetPhysicsObject()
if IsValid(Phys) then Phys:SetMass(Receiver.Mass) end
Contraption.SetMass(Entity, Receiver.Mass)
end

function MakeACF_Receiver(Player, Pos, Ang, Data)
Expand Down

0 comments on commit 8a84150

Please sign in to comment.