Skip to content

Commit d610f87

Browse files
Track families on contraptions
1 parent b2adf3c commit d610f87

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lua/cfw/classes/contraption_sv.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function CFW.createContraption()
88
ents = {},
99
entsbyclass = {},
1010
count = 0,
11-
color = ColorRand(50, 255)
11+
color = ColorRand(50, 255),
12+
families = {}
1213
}
1314

1415
setmetatable(con, CFW.Classes.Contraption)

lua/cfw/classes/family_sv.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ do -- Class def
2929
function CLASS:Init()
3030
CFW.Families[self] = true
3131

32+
local con = self.ancestor:GetContraption()
33+
if con then con.families[self] = true end
34+
3235
hook.Run("cfw.family.created", self)
3336
end
3437

@@ -39,6 +42,9 @@ do -- Class def
3942
function CLASS:Delete()
4043
self:Sub(self.ancestor, true)
4144

45+
local con = self.ancestor:GetContraption()
46+
if con then con.families[self] = nil end
47+
4248
hook.Run("cfw.family.deleted", self)
4349

4450
CFW.Families[self] = nil

0 commit comments

Comments
 (0)