wgge 2.0.29 → 2.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,6 +17,11 @@ export default class ActivatedTreeNode {
|
|
|
17
17
|
*/
|
|
18
18
|
isActivated;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @type boolean
|
|
22
|
+
*/
|
|
23
|
+
isRemoved= false;
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
*
|
|
22
27
|
* @type array
|
|
@@ -26,6 +31,11 @@ export default class ActivatedTreeNode {
|
|
|
26
31
|
*/
|
|
27
32
|
autoRegisterEvents = null;
|
|
28
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @type number
|
|
36
|
+
*/
|
|
37
|
+
childrenRemoved = 0;
|
|
38
|
+
|
|
29
39
|
constructor() {
|
|
30
40
|
this.isActivated = false;
|
|
31
41
|
this.parent = null;
|
|
@@ -55,24 +65,19 @@ export default class ActivatedTreeNode {
|
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
hasChildren() {
|
|
58
|
-
return this.children.length >
|
|
68
|
+
return this.children.length > this.childrenRemoved;
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
removeChild(node) {
|
|
62
72
|
const index = this.children.indexOf(node);
|
|
63
73
|
if (index >= 0) {
|
|
64
|
-
this.
|
|
74
|
+
this.childrenRemoved++;
|
|
65
75
|
node.deactivate();
|
|
76
|
+
node.isRemoved = true;
|
|
66
77
|
node.parent = null;
|
|
67
78
|
return node;
|
|
68
79
|
}
|
|
69
|
-
|
|
70
|
-
const child = this.children[i];
|
|
71
|
-
const result = child.removeChild(node);
|
|
72
|
-
if (result) {
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
80
|
+
return undefined;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
removeMyself() {
|
|
@@ -84,16 +89,21 @@ export default class ActivatedTreeNode {
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
resetChildren() {
|
|
87
|
-
this.children.
|
|
92
|
+
for (let i = 0, max = this.children.length; i < max; i++) {
|
|
93
|
+
this.children[i].deactivate();
|
|
94
|
+
}
|
|
88
95
|
this.children = [];
|
|
96
|
+
this.childrenRemoved = 0;
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
updateRemovedChildren() {
|
|
100
|
+
if (this.childrenRemoved === 0) return;
|
|
101
|
+
let w = 0;
|
|
93
102
|
for (let i = 0, max = this.children.length; i < max; i++) {
|
|
94
|
-
|
|
95
|
-
child.forEach(func);
|
|
103
|
+
if (!this.children[i].isRemoved) this.children[w++] = this.children[i];
|
|
96
104
|
}
|
|
105
|
+
this.children.length = w;
|
|
106
|
+
this.childrenRemoved = 0;
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
activate() {
|
|
@@ -43,17 +43,12 @@ export default class ControllerBase extends ActivatedTreeNode {
|
|
|
43
43
|
|
|
44
44
|
this.updateInternal(delta);
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const child = this.children[i];
|
|
50
|
-
this.updateActions.push(() => child.update(delta));
|
|
51
|
-
}
|
|
52
|
-
for (let i = 0, max = this.updateActions.length; i < max; i++) {
|
|
53
|
-
this.updateActions[i]();
|
|
54
|
-
}
|
|
55
|
-
this.updateActions = [];
|
|
46
|
+
for (let i = 0, max = this.children.length; i < max; i++) {
|
|
47
|
+
const child = this.children[i];
|
|
48
|
+
if (!child.isRemoved) child.update(delta);
|
|
56
49
|
}
|
|
50
|
+
|
|
51
|
+
this.updateRemovedChildren();
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
updateInternal(delta) {
|
|
@@ -20,7 +20,6 @@ export default class RendererBase extends ActivatedTreeNode {
|
|
|
20
20
|
super();
|
|
21
21
|
this.game = game;
|
|
22
22
|
this.model = model;
|
|
23
|
-
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
render() {
|
|
@@ -33,7 +32,12 @@ export default class RendererBase extends ActivatedTreeNode {
|
|
|
33
32
|
|
|
34
33
|
this.renderInternal();
|
|
35
34
|
|
|
36
|
-
this.children.
|
|
35
|
+
for (let i = 0, max = this.children.length; i < max; i++) {
|
|
36
|
+
const child = this.children[i];
|
|
37
|
+
if (!child.isRemoved) child.render();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.updateRemovedChildren();
|
|
37
41
|
|
|
38
42
|
if (this.isRoot()) {
|
|
39
43
|
this.model.clean();
|