Skip to content

Commit b18419e

Browse files
Reduce entity update boilerplate a bit
1 parent 2f6ad01 commit b18419e

File tree

4 files changed

+6
-54
lines changed

4 files changed

+6
-54
lines changed

lua/entities/acf_computer/init.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,7 @@ do -- Spawn and update function
231231

232232
Entity:UpdateOverlay(true)
233233

234-
do -- Mass entity mod removal
235-
local EntMods = Data and Data.EntityMods
236-
237-
if EntMods and EntMods.mass then
238-
EntMods.mass = nil
239-
end
240-
end
234+
duplicator.ClearEntityModifier(Entity, "mass")
241235

242236
CheckLegal(Entity)
243237

@@ -282,12 +276,6 @@ do -- Spawn and update function
282276

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

285-
self:UpdateOverlay(true)
286-
287-
net.Start("ACF_UpdateEntity")
288-
net.WriteEntity(self)
289-
net.Broadcast()
290-
291279
return true, "Computer updated successfully!"
292280
end
293281
end

lua/entities/acf_rack/init.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,7 @@ do -- Spawning and Updating --------------------
223223

224224
Rack:UpdateOverlay(true)
225225

226-
do -- Mass entity mod removal
227-
local EntMods = Data and Data.EntityMods
228-
229-
if EntMods and EntMods.mass then
230-
EntMods.mass = nil
231-
end
232-
end
226+
duplicator.ClearEntityModifier(Rack, "mass")
233227

234228
CheckLegal(Rack)
235229

@@ -294,12 +288,6 @@ do -- Spawning and Updating --------------------
294288
end
295289
end
296290

297-
self:UpdateOverlay(true)
298-
299-
net.Start("ACF_UpdateEntity")
300-
net.WriteEntity(self)
301-
net.Broadcast()
302-
303291
return true, "Rack updated successfully!"
304292
end
305293
end ---------------------------------------------

lua/entities/acf_radar/init.lua

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,7 @@ do -- Spawn and Update functions
423423

424424
Radar:UpdateOverlay(true)
425425

426-
do -- Mass entity mod removal
427-
local EntMods = Data and Data.EntityMods
428-
429-
if EntMods and EntMods.mass then
430-
EntMods.mass = nil
431-
end
432-
end
426+
duplicator.ClearEntityModifier(Radar, "mass")
433427

434428
CheckLegal(Radar)
435429

@@ -476,12 +470,6 @@ do -- Spawn and Update functions
476470

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

479-
self:UpdateOverlay(true)
480-
481-
net.Start("ACF_UpdateEntity")
482-
net.WriteEntity(self)
483-
net.Broadcast()
484-
485473
return true, "Radar updated successfully!"
486474
end
487475
end

lua/entities/acf_receiver/init.lua

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,7 @@ do -- Spawn and Update functions
210210

211211
Receiver:UpdateOverlay(true)
212212

213-
do -- Mass entity mod removal
214-
local EntMods = Data and Data.EntityMods
215-
216-
if EntMods and EntMods.mass then
217-
EntMods.mass = nil
218-
end
219-
end
213+
duplicator.ClearEntityModifier(Receiver, "mass")
220214

221215
CheckLegal(Receiver)
222216

@@ -240,7 +234,7 @@ do -- Spawn and Update functions
240234
OldClass.OnLast(self, OldClass)
241235
end
242236

243-
hook.Run("ACF_OnEntityLast", "acf_Receiver", self, OldClass)
237+
hook.Run("ACF_OnEntityLast", "acf_receiver", self, OldClass)
244238

245239
ACF.SaveEntity(self)
246240

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

255-
hook.Run("ACF_OnUpdateEntity", "acf_Receiver", self, Data, Class, Receiver)
256-
257-
self:UpdateOverlay(true)
258-
259-
net.Start("ACF_UpdateEntity")
260-
net.WriteEntity(self)
261-
net.Broadcast()
249+
hook.Run("ACF_OnUpdateEntity", "acf_receiver", self, Data, Class, Receiver)
262250

263251
return true, "Receiver updated successfully!"
264252
end

0 commit comments

Comments
 (0)