@@ -15,13 +15,15 @@ function CFW.Classes.Family.create(ancestor)
15
15
setmetatable (fam , CFW .Classes .Family )
16
16
17
17
fam :Init ()
18
- fam :Add (ancestor )
18
+ fam :Add (ancestor , true )
19
19
20
20
return fam
21
21
end
22
22
23
23
do -- Class def
24
- local CLASS = CFW .Classes .Family ; CLASS .__index = CLASS
24
+ local CLASS = CFW .Classes .Family
25
+
26
+ CLASS .__index = CLASS
25
27
26
28
function CLASS :Init ()
27
29
CFW .Families [self ] = true
@@ -41,21 +43,24 @@ do -- Class def
41
43
CFW .Families [self ] = nil
42
44
end
43
45
44
- function CLASS :Add (entity )
46
+ function CLASS :Add (entity , isAncestor )
45
47
self .count = self .count + 1
46
48
self .ents [entity ] = true
47
49
48
50
entity ._family = self
49
51
50
52
hook .Run (" cfw.family.added" , self , entity )
51
53
54
+ if not isAncestor then
55
+ self .children [entity ] = true
56
+ end
57
+
52
58
for k , v in pairs (entity :GetChildren ()) do
53
59
local child = isnumber (k ) and v or k
54
60
if child == entity then continue end
55
61
if child .CFW_NO_FAMILY_TRAVERSAL then continue end
56
62
57
63
self :Add (child )
58
- self .children [v ] = true
59
64
end
60
65
end
61
66
@@ -69,13 +74,14 @@ do -- Class def
69
74
70
75
if isAncestor then return end
71
76
77
+ self .children [entity ] = nil
78
+
72
79
for k , v in pairs (entity :GetChildren ()) do
73
80
local child = isnumber (k ) and v or k
74
81
if child == entity then continue end
75
82
if child .CFW_NO_FAMILY_TRAVERSAL then continue end
76
83
77
84
self :Sub (child )
78
- self .children [v ] = nil
79
85
end
80
86
end
81
87
end
0 commit comments