Skip to content

Commit 6f8480b

Browse files
Adjust children placement
1 parent 1a48030 commit 6f8480b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Diff for: lua/cfw/classes/family_sv.lua

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ function CFW.Classes.Family.create(ancestor)
1515
setmetatable(fam, CFW.Classes.Family)
1616

1717
fam:Init()
18-
fam:Add(ancestor)
18+
fam:Add(ancestor, true)
1919

2020
return fam
2121
end
2222

2323
do -- Class def
24-
local CLASS = CFW.Classes.Family; CLASS.__index = CLASS
24+
local CLASS = CFW.Classes.Family
25+
26+
CLASS.__index = CLASS
2527

2628
function CLASS:Init()
2729
CFW.Families[self] = true
@@ -41,21 +43,24 @@ do -- Class def
4143
CFW.Families[self] = nil
4244
end
4345

44-
function CLASS:Add(entity)
46+
function CLASS:Add(entity, isAncestor)
4547
self.count = self.count + 1
4648
self.ents[entity] = true
4749

4850
entity._family = self
4951

5052
hook.Run("cfw.family.added", self, entity)
5153

54+
if not isAncestor then
55+
self.children[entity] = true
56+
end
57+
5258
for k, v in pairs(entity:GetChildren()) do
5359
local child = isnumber(k) and v or k
5460
if child == entity then continue end
5561
if child.CFW_NO_FAMILY_TRAVERSAL then continue end
5662

5763
self:Add(child)
58-
self.children[v] = true
5964
end
6065
end
6166

@@ -69,13 +74,14 @@ do -- Class def
6974

7075
if isAncestor then return end
7176

77+
self.children[entity] = nil
78+
7279
for k, v in pairs(entity:GetChildren()) do
7380
local child = isnumber(k) and v or k
7481
if child == entity then continue end
7582
if child.CFW_NO_FAMILY_TRAVERSAL then continue end
7683

7784
self:Sub(child)
78-
self.children[v] = nil
7985
end
8086
end
8187
end

0 commit comments

Comments
 (0)