Skip to content

Commit

Permalink
Reduce entity update boilerplate a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Jan 16, 2025
1 parent 2f6ad01 commit b18419e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 54 deletions.
14 changes: 1 addition & 13 deletions lua/entities/acf_computer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,7 @@ do -- Spawn and update function

Entity:UpdateOverlay(true)

do -- Mass entity mod removal
local EntMods = Data and Data.EntityMods

if EntMods and EntMods.mass then
EntMods.mass = nil
end
end
duplicator.ClearEntityModifier(Entity, "mass")

CheckLegal(Entity)

Expand Down Expand Up @@ -282,12 +276,6 @@ do -- Spawn and update function

hook.Run("ACF_OnUpdateEntity", "acf_computer", self, Data, Class, Computer)

self:UpdateOverlay(true)

net.Start("ACF_UpdateEntity")
net.WriteEntity(self)
net.Broadcast()

return true, "Computer updated successfully!"
end
end
Expand Down
14 changes: 1 addition & 13 deletions lua/entities/acf_rack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,7 @@ do -- Spawning and Updating --------------------

Rack:UpdateOverlay(true)

do -- Mass entity mod removal
local EntMods = Data and Data.EntityMods

if EntMods and EntMods.mass then
EntMods.mass = nil
end
end
duplicator.ClearEntityModifier(Rack, "mass")

CheckLegal(Rack)

Expand Down Expand Up @@ -294,12 +288,6 @@ do -- Spawning and Updating --------------------
end
end

self:UpdateOverlay(true)

net.Start("ACF_UpdateEntity")
net.WriteEntity(self)
net.Broadcast()

return true, "Rack updated successfully!"
end
end ---------------------------------------------
Expand Down
14 changes: 1 addition & 13 deletions lua/entities/acf_radar/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,7 @@ do -- Spawn and Update functions

Radar:UpdateOverlay(true)

do -- Mass entity mod removal
local EntMods = Data and Data.EntityMods

if EntMods and EntMods.mass then
EntMods.mass = nil
end
end
duplicator.ClearEntityModifier(Radar, "mass")

CheckLegal(Radar)

Expand Down Expand Up @@ -476,12 +470,6 @@ do -- Spawn and Update functions

hook.Run("ACF_OnUpdateEntity", "acf_radar", self, Data, Class, Radar)

self:UpdateOverlay(true)

net.Start("ACF_UpdateEntity")
net.WriteEntity(self)
net.Broadcast()

return true, "Radar updated successfully!"
end
end
Expand Down
18 changes: 3 additions & 15 deletions lua/entities/acf_receiver/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,7 @@ do -- Spawn and Update functions

Receiver:UpdateOverlay(true)

do -- Mass entity mod removal
local EntMods = Data and Data.EntityMods

if EntMods and EntMods.mass then
EntMods.mass = nil
end
end
duplicator.ClearEntityModifier(Receiver, "mass")

CheckLegal(Receiver)

Expand All @@ -240,7 +234,7 @@ do -- Spawn and Update functions
OldClass.OnLast(self, OldClass)
end

hook.Run("ACF_OnEntityLast", "acf_Receiver", self, OldClass)
hook.Run("ACF_OnEntityLast", "acf_receiver", self, OldClass)

ACF.SaveEntity(self)

Expand All @@ -252,13 +246,7 @@ do -- Spawn and Update functions
Class.OnUpdate(self, Data, Class, Receiver)
end

hook.Run("ACF_OnUpdateEntity", "acf_Receiver", self, Data, Class, Receiver)

self:UpdateOverlay(true)

net.Start("ACF_UpdateEntity")
net.WriteEntity(self)
net.Broadcast()
hook.Run("ACF_OnUpdateEntity", "acf_receiver", self, Data, Class, Receiver)

return true, "Receiver updated successfully!"
end
Expand Down

0 comments on commit b18419e

Please sign in to comment.