@woosh/meep-engine 2.50.1 → 2.50.3

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.
Files changed (78) hide show
  1. package/README.md +42 -0
  2. package/editor/Editor.js +5 -1
  3. package/editor/SelectionVisualizer.js +9 -3
  4. package/editor/tools/paint/TerrainTexturePaintTool.js +6 -1
  5. package/editor/view/EditorView.js +5 -1
  6. package/editor/view/ecs/EntityList.js +48 -37
  7. package/editor/view/makeEntityDecorators.js +125 -0
  8. package/package.json +7 -3
  9. package/samples/generation/README.md +6 -0
  10. package/{src/generation/example → samples/generation}/SampleGenerator0.js +60 -46
  11. package/{src/generation/example → samples/generation}/filters/SampleGroundMoistureFilter.js +14 -12
  12. package/samples/generation/filters/SampleNoise20_0.js +3 -0
  13. package/{src/generation/example → samples/generation}/generators/interactive/mir_generator_place_buff_objects.js +29 -23
  14. package/{src/generation/example → samples/generation}/generators/mir_generator_place_bases.js +33 -25
  15. package/{src/generation/example → samples/generation}/generators/mir_generator_place_road_decorators.js +16 -14
  16. package/samples/generation/generators/mir_generator_place_starting_point.js +60 -0
  17. package/{src/generation/example → samples/generation}/grid/configureMirGrid.js +2 -2
  18. package/{src/generation/example → samples/generation}/main.js +29 -28
  19. package/{src/generation/example → samples/generation}/rules/matcher_not_play_area.js +1 -1
  20. package/samples/generation/rules/matcher_play_area.js +5 -0
  21. package/{src/generation/example → samples/generation}/rules/matcher_tag_not_traversable.js +1 -1
  22. package/samples/generation/rules/matcher_tag_occupied.js +5 -0
  23. package/samples/generation/rules/matcher_tag_traversable.js +5 -0
  24. package/{src/generation/example → samples/generation}/rules/matcher_tag_traversable_unoccupied.js +1 -1
  25. package/{src/generation/example → samples/generation}/rules/matcher_tag_unoccupied.js +1 -1
  26. package/{src/generation/example → samples/generation}/rules/mir_matcher_attack_corridor.js +3 -3
  27. package/{src/generation/example → samples/generation}/themes/SampleTheme0.js +57 -47
  28. package/{src/generation/example → samples/generation}/themes/SampleTheme1.js +4 -4
  29. package/{src/generation/example → samples/generation}/themes/SampleTheme2.js +4 -4
  30. package/src/core/cache/Cache.d.ts +4 -0
  31. package/src/core/cache/Cache.js +31 -15
  32. package/src/core/cache/Cache.spec.js +33 -0
  33. package/src/core/cache/FrequencySketch.js +26 -23
  34. package/src/core/cache/FrequencySketch.spec.js +5 -0
  35. package/src/core/cache/LoadingCache.d.ts +2 -0
  36. package/src/core/cache/LoadingCache.js +16 -7
  37. package/src/core/cache/LoadingCache.spec.js +24 -0
  38. package/src/core/collection/HashMap.d.ts +2 -0
  39. package/src/core/collection/HashMap.spec.js +51 -2
  40. package/src/core/collection/list/List.d.ts +13 -1
  41. package/src/core/collection/list/List.js +702 -684
  42. package/src/core/collection/list/List.spec.js +93 -0
  43. package/src/core/collection/map/AsyncLoadingCache.js +1 -0
  44. package/src/core/fsm/simple/SimpleStateMachine.js +23 -22
  45. package/src/core/function/extractFunctionBody.spec.js +15 -0
  46. package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +69 -33
  47. package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.spec.js +33 -0
  48. package/src/core/geom/2d/convex-hull/orientation3.js +55 -10
  49. package/src/core/process/matcher/Matchers.js +1 -1
  50. package/src/engine/asset/loaders/image/png/PNG.spec.js +5 -0
  51. package/src/engine/asset/loaders/image/png/PNGReader.spec.js +5 -0
  52. package/src/engine/asset/loaders/image/png/crc.spec.js +15 -0
  53. package/src/engine/ecs/EntityBlueprint.js +4 -0
  54. package/src/engine/ecs/EntityBuilder.js +48 -49
  55. package/src/engine/ecs/EntityBuilderFlags.js +2 -2
  56. package/src/engine/ecs/guid/GUID.js +1 -0
  57. package/src/engine/ecs/{Blueprint.js → storage/json/Blueprint.js} +1 -1
  58. package/src/engine/ecs/{EntityFactory.js → storage/json/EntityFactory.js} +1 -1
  59. package/src/engine/ecs/storage/{JSONDeSerializer.js → json/JSONDeSerializer.js} +4 -4
  60. package/src/engine/ecs/storage/json/README.md +5 -0
  61. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +5 -0
  62. package/src/engine/intelligence/behavior/Behavior.d.ts +5 -0
  63. package/src/engine/intelligence/behavior/Behavior.js +19 -0
  64. package/src/engine/intelligence/behavior/SelectorBehavior.js +4 -2
  65. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +2 -0
  66. package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +3 -1
  67. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +2 -3
  68. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +2 -2
  69. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
  70. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  71. package/src/view/common/VirtualListView.js +2 -0
  72. package/src/generation/example/filters/SampleNoise20_0.js +0 -3
  73. package/src/generation/example/generators/mir_generator_place_starting_point.js +0 -52
  74. package/src/generation/example/rules/matcher_play_area.js +0 -5
  75. package/src/generation/example/rules/matcher_tag_occupied.js +0 -5
  76. package/src/generation/example/rules/matcher_tag_traversable.js +0 -5
  77. /package/{src/generation/example → samples/generation}/grid/MirGridLayers.js +0 -0
  78. /package/src/engine/ecs/storage/{JSONSerializer.js → json/JSONSerializer.js} +0 -0
@@ -107,3 +107,96 @@ test("add increases length", () => {
107
107
 
108
108
  expect(list.length).toBe(2);
109
109
  });
110
+
111
+
112
+ test("removeIf", () => {
113
+ const list = new List([1, 3, 1]);
114
+
115
+ list.removeIf(a => a === 1);
116
+
117
+ expect(list.length).toEqual(1);
118
+ expect(list.get(0)).toBe(3);
119
+ });
120
+
121
+ test("removeOneIf", () => {
122
+ const list = new List([1, 3, 1]);
123
+
124
+ list.removeOneIf(a => a === 1);
125
+
126
+ expect(list.length).toEqual(2);
127
+ expect(list.get(0)).toBe(3);
128
+ expect(list.get(1)).toBe(1);
129
+ });
130
+
131
+ test("find", () => {
132
+ const list = new List([1, 3, 1]);
133
+
134
+ const a = list.find(a => a === 3);
135
+
136
+ expect(a).toEqual(3);
137
+
138
+ const b = list.find(a => a === 5);
139
+
140
+ expect(b).toBeUndefined();
141
+ });
142
+
143
+ test("reset", () => {
144
+ const list = new List([1, 3, 1]);
145
+
146
+ list.reset();
147
+
148
+ expect(list.length).toEqual(0);
149
+
150
+ list.reset(); // test idempotence
151
+
152
+ expect(list.length).toEqual(0);
153
+
154
+ // check event handlers
155
+ const remove_callback = jest.fn();
156
+
157
+ list.on.removed.add(remove_callback);
158
+
159
+ list.add(3);
160
+
161
+ list.reset();
162
+
163
+ expect(list.length).toEqual(0);
164
+
165
+ expect(remove_callback).toHaveBeenCalledTimes(1);
166
+ expect(remove_callback).toHaveBeenLastCalledWith(3, 0);
167
+ });
168
+
169
+ test("insert", () => {
170
+
171
+ const list = new List();
172
+
173
+ const add_callback = jest.fn();
174
+ list.on.added.add(add_callback);
175
+
176
+ list.insert(0, "x");
177
+
178
+ expect(list.length).toEqual(1);
179
+ expect(list.get(0)).toBe("x");
180
+ expect(add_callback).toHaveBeenLastCalledWith("x", 0);
181
+
182
+ list.insert(0, 'y');
183
+
184
+ expect(list.length).toEqual(2);
185
+ expect(list.get(0)).toBe("y");
186
+ expect(list.get(1)).toBe("x");
187
+ expect(add_callback).toHaveBeenLastCalledWith("y", 0);
188
+
189
+ list.insert(2, "z");
190
+
191
+ expect(list.length).toEqual(3);
192
+ expect(list.get(0)).toBe("y");
193
+ expect(list.get(1)).toBe("x");
194
+ expect(list.get(2)).toBe("z");
195
+ expect(add_callback).toHaveBeenLastCalledWith("z", 2);
196
+ });
197
+
198
+ test("map", () => {
199
+ const list = new List([1, 2, 3]);
200
+
201
+ expect(list.map(a => a * 7)).toEqual([7, 14, 21]);
202
+ });
@@ -2,6 +2,7 @@ import { AbstractAsyncMap } from "./AbstractAsyncMap.js";
2
2
 
3
3
  /**
4
4
  * Cache wrapper that loads data when it's not found in the cache
5
+ * @deprecated prefer to use {@link LoadingCache} instead
5
6
  */
6
7
  export class AsyncLoadingCache extends AbstractAsyncMap {
7
8
  /**
@@ -4,6 +4,28 @@ import { noop } from "../../function/Functions.js";
4
4
  import { SimpleStateMachineDescription } from "./SimpleStateMachineDescription.js";
5
5
 
6
6
  export class SimpleStateMachine {
7
+
8
+ /**
9
+ *
10
+ * @type {number}
11
+ * @private
12
+ */
13
+ __state = -1;
14
+
15
+ /**
16
+ *
17
+ * @type {Array}
18
+ * @private
19
+ */
20
+ __eventHandlersStateEntry = [];
21
+
22
+ /**
23
+ *
24
+ * @type {Array}
25
+ * @private
26
+ */
27
+ __eventHandlersStateExit = [];
28
+
7
29
  /**
8
30
  *
9
31
  * @param {SimpleStateMachineDescription} description
@@ -16,27 +38,6 @@ export class SimpleStateMachine {
16
38
  * @type {SimpleStateMachineDescription}
17
39
  */
18
40
  this.description = description;
19
-
20
- /**
21
- *
22
- * @type {number}
23
- * @private
24
- */
25
- this.__state = -1;
26
-
27
- /**
28
- *
29
- * @type {Array}
30
- * @private
31
- */
32
- this.__eventHandlersStateEntry = [];
33
-
34
- /**
35
- *
36
- * @type {Array}
37
- * @private
38
- */
39
- this.__eventHandlersStateExit = [];
40
41
  }
41
42
 
42
43
  /**
@@ -212,7 +213,7 @@ export class SimpleStateMachine {
212
213
  const targetNodes = description.getOutgoingStates(this.__state);
213
214
 
214
215
  if (targetNodes.length !== 1) {
215
- //no selector, and number of targets is ambiguous
216
+ //no selector and number of targets is ambiguous
216
217
  return false;
217
218
  }
218
219
 
@@ -0,0 +1,15 @@
1
+ import { extractFunctionBody } from "./extractFunctionBody.js";
2
+
3
+ test("sanity", () => {
4
+
5
+ const a = function x(a, b, c) {
6
+ };
7
+
8
+ expect(extractFunctionBody(a)).toBe("");
9
+
10
+ const b = function x(a, b, c) {
11
+ return a + b + c;
12
+ };
13
+
14
+ expect(extractFunctionBody(b)).toBe("return a + b + c;");
15
+ });
@@ -1,82 +1,118 @@
1
- import { orientation3_v2 } from "./orientation3_v2.js";
1
+ import { assert } from "../../../assert.js";
2
+ import { orientation3_array } from "./orientation3_array.js";
2
3
 
3
4
  /**
4
5
  * Ported from https://github.com/mikolalysenko/monotone-convex-hull-2d
5
- * @param {number[][]} points
6
- * @returns {number}
6
+ * @param {number[]|Float32Array|Float64Array} points
7
+ * @param {number} [point_count]
8
+ * @returns {number[]}
7
9
  */
8
- export function convex_hull_monotone_2d(points) {
9
- var n = points.length
10
+ export function convex_hull_monotone_2d(points, point_count = points.length * 0.5) {
11
+ assert.isNumber(point_count, 'point_count');
12
+ assert.isNonNegativeInteger(point_count, 'point_count');
10
13
 
11
- if (n < 3) {
12
- var result = new Array(n)
13
- for (var i = 0; i < n; ++i) {
14
- result[i] = i
15
- }
14
+ if (point_count < 3) {
15
+
16
+ if (
17
+ point_count === 2
18
+ && points[0] === points[2]
19
+ && points[1] === points[3]
20
+ ) {
16
21
 
17
- if (n === 2 &&
18
- points[0][0] === points[1][0] &&
19
- points[0][1] === points[1][1]) {
20
22
  return [0]
23
+
24
+ }
25
+
26
+ const result = new Array(point_count)
27
+
28
+ for (let i = 0; i < point_count; ++i) {
29
+ result[i] = i
21
30
  }
22
31
 
23
32
  return result
24
33
  }
25
34
 
26
35
  //Sort point indices along x-axis
27
- var sorted = new Array(n)
28
- for (var i = 0; i < n; ++i) {
36
+ const sorted = new Array(point_count)
37
+
38
+ for (let i = 0; i < point_count; ++i) {
29
39
  sorted[i] = i
30
40
  }
41
+
31
42
  sorted.sort(function (a, b) {
32
- var d = points[a][0] - points[b][0]
43
+ const a2 = a * 2;
44
+ const b2 = b * 2;
45
+
46
+ var d = points[a2] - points[b2]
47
+
33
48
  if (d) {
34
49
  return d
35
50
  }
36
- return points[a][1] - points[b][1]
51
+
52
+ return points[a2 + 1] - points[b2 + 1]
37
53
  })
38
54
 
39
55
  //Construct upper and lower hulls
40
- var lower = [sorted[0], sorted[1]]
41
- var upper = [sorted[0], sorted[1]]
56
+ const lower = [sorted[0], sorted[1]]
57
+ const upper = [sorted[0], sorted[1]]
42
58
 
43
- for (var i = 2; i < n; ++i) {
44
- var idx = sorted[i]
45
- var p = points[idx]
59
+ for (let i = 2; i < point_count; ++i) {
60
+ const idx = sorted[i]
46
61
 
47
62
  //Insert into lower list
48
- var m = lower.length
49
- while (m > 1 && orientation3_v2(
50
- points[lower[m - 2]],
51
- points[lower[m - 1]],
52
- p) <= 0) {
63
+ let m = lower.length
64
+
65
+ while (
66
+ m > 1
67
+ && orientation3_array(
68
+ points,
69
+ lower[m - 2],
70
+ lower[m - 1],
71
+ idx) <= 0
72
+ ) {
73
+
53
74
  m -= 1
54
75
  lower.pop()
76
+
55
77
  }
78
+
56
79
  lower.push(idx)
57
80
 
58
81
  //Insert into upper list
59
82
  m = upper.length
60
- while (m > 1 && orientation3_v2(
61
- points[upper[m - 2]],
62
- points[upper[m - 1]],
63
- p) >= 0) {
83
+
84
+ while (
85
+ m > 1
86
+ && orientation3_array(
87
+ points,
88
+ upper[m - 2],
89
+ upper[m - 1],
90
+ idx) >= 0
91
+ ) {
92
+
64
93
  m -= 1
65
94
  upper.pop()
95
+
66
96
  }
97
+
67
98
  upper.push(idx)
99
+
68
100
  }
69
101
 
70
102
  //Merge lists together
71
- var result = new Array(upper.length + lower.length - 2)
72
- var ptr = 0
103
+ const result = new Array(upper.length + lower.length - 2)
104
+
105
+ let ptr = 0
106
+
73
107
  for (var i = 0, nl = lower.length; i < nl; ++i) {
74
108
  result[ptr++] = lower[i]
75
109
  }
110
+
76
111
  for (var j = upper.length - 2; j > 0; --j) {
77
112
  result[ptr++] = upper[j]
78
113
  }
79
114
 
115
+
80
116
  //Return result
81
117
  return result
82
118
  }
@@ -0,0 +1,33 @@
1
+ import { convex_hull_monotone_2d } from "./convex_hull_monotone_2d.js";
2
+
3
+ test("box with extra points", () => {
4
+ const hull = convex_hull_monotone_2d([
5
+ 0, 1,
6
+ -1, 0,
7
+ 1, 0,
8
+ 0, -1,
9
+ // extra points inside
10
+ 0.3, 0.3,
11
+ -0.3, -0.3,
12
+ 0.3, -0.3,
13
+ -0.3, 0.3
14
+ ]);
15
+
16
+ expect(hull.length).toBe(4);
17
+
18
+ expect(hull).toContain(0);
19
+ expect(hull).toContain(1);
20
+ expect(hull).toContain(2);
21
+ expect(hull).toContain(3);
22
+ });
23
+
24
+
25
+ test("exact triangle", () => {
26
+ const hull = convex_hull_monotone_2d([
27
+ 0, 0,
28
+ 1, 0,
29
+ 1, 1,
30
+ ]);
31
+
32
+ expect(hull.length).toBe(3);
33
+ });
@@ -4,6 +4,12 @@ const sum = linearExpansionSum;
4
4
  const prod = robustProduct;
5
5
  const sub = robustSubtract;
6
6
 
7
+ /**
8
+ *
9
+ * @param {number[]} e
10
+ * @param {number[]} f
11
+ * @return {number[]}
12
+ */
7
13
  function robustSubtract(e, f) {
8
14
  var ne = e.length;
9
15
  var nf = f.length;
@@ -141,14 +147,24 @@ function robustSubtract(e, f) {
141
147
  return g
142
148
  }
143
149
 
150
+ /**
151
+ *
152
+ * @param {number[]} a
153
+ * @param {number[]} b
154
+ * @return {number[]}
155
+ */
144
156
  function robustProduct(a, b) {
145
157
  let r = [0]
146
- if (a.length < b.length) {
147
- for (var i = 0; i < a.length; ++i) {
158
+
159
+ const a_count = a.length;
160
+ const b_count = b.length;
161
+
162
+ if (a_count < b_count) {
163
+ for (let i = 0; i < a_count; ++i) {
148
164
  r = linearExpansionSum(r, scaleLinearExpansion(b, a[i]))
149
165
  }
150
166
  } else {
151
- for (var i = 0; i < b.length; ++i) {
167
+ for (let i = 0; i < b_count; ++i) {
152
168
  r = linearExpansionSum(r, scaleLinearExpansion(a, b[i]))
153
169
  }
154
170
  }
@@ -157,6 +173,13 @@ function robustProduct(a, b) {
157
173
 
158
174
  var SPLITTER = +(Math.pow(2, 27) + 1.0)
159
175
 
176
+ /**
177
+ *
178
+ * @param {number} a
179
+ * @param {number} b
180
+ * @param {number[]} [result]
181
+ * @return {number[]}
182
+ */
160
183
  function twoProduct(a, b, result) {
161
184
  var x = a * b
162
185
 
@@ -185,6 +208,13 @@ function twoProduct(a, b, result) {
185
208
  return [y, x]
186
209
  }
187
210
 
211
+ /**
212
+ *
213
+ * @param {number[]} a
214
+ * @param {number[]} b
215
+ * @param {number[]} result
216
+ * @return {number[]}
217
+ */
188
218
  function twoSum(a, b, result) {
189
219
  var x = a + b
190
220
  var bv = x - a
@@ -199,6 +229,12 @@ function twoSum(a, b, result) {
199
229
  return [ar + br, x]
200
230
  }
201
231
 
232
+ /**
233
+ *
234
+ * @param {number[]} e
235
+ * @param {number} scale
236
+ * @return {number[]}
237
+ */
202
238
  function scaleLinearExpansion(e, scale) {
203
239
  var n = e.length
204
240
  if (n === 1) {
@@ -388,16 +424,25 @@ function linearExpansionSum(e, f) {
388
424
 
389
425
  /**
390
426
  *
391
- * @param {number[]} m0
392
- * @param {number[]} m1
393
- * @param {number[]} m2
427
+ * @param {number[][]} m0
428
+ * @param {number[][]} m1
429
+ * @param {number[][]} m2
394
430
  * @returns {number}
395
431
  */
396
432
  function orientation3Exact(m0, m1, m2) {
397
- const p = sum(sum(prod(m1[1], m2[0]), prod(-m2[1], m1[0])), sum(prod(m0[1], m1[0]), prod(-m1[1], m0[0])))
398
- const n = sum(prod(m0[1], m2[0]), prod(-m2[1], m0[0]))
399
- const d = sub(p, n)
400
- return d[d.length - 1]
433
+ const p = sum(
434
+ sum(prod(m1[1], m2[0]), prod(-m2[1], m1[0])),
435
+ sum(prod(m0[1], m1[0]), prod(-m1[1], m0[0]))
436
+ );
437
+
438
+ const n = sum(
439
+ prod(m0[1], m2[0]),
440
+ prod(-m2[1], m0[0])
441
+ );
442
+
443
+ const d = sub(p, n);
444
+
445
+ return d[d.length - 1];
401
446
  }
402
447
 
403
448
  /**
@@ -25,7 +25,7 @@ export function isDefined(value) {
25
25
 
26
26
  /**
27
27
  * performs instanceof match
28
- * @param {class} type
28
+ * @param {function} type
29
29
  * @returns {function(*): boolean}
30
30
  */
31
31
  export function isInstanceOf(type) {
@@ -0,0 +1,5 @@
1
+ import { PNG } from "./PNG.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ expect(() => new PNG()).not.toThrow()
5
+ });
@@ -0,0 +1,5 @@
1
+ import { PNGReader } from "./PNGReader.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ expect(() => new PNGReader(new ArrayBuffer(0))).not.toThrow();
5
+ });
@@ -0,0 +1,15 @@
1
+ import { crc } from "./crc.js";
2
+
3
+ test("sanity", () => {
4
+
5
+ const empty = crc(new Uint8Array(0), 0, 0);
6
+
7
+ expect(typeof empty).toBe("number");
8
+ expect(Number.isInteger(empty)).toBe(true);
9
+
10
+ const one = crc(new Uint8Array([1]), 0, 1);
11
+
12
+ expect(typeof one).toBe("number");
13
+ expect(Number.isInteger(one)).toBe(true);
14
+
15
+ });
@@ -56,6 +56,10 @@ function populateJsonTemplate(template, seed) {
56
56
  }
57
57
  }
58
58
 
59
+ /**
60
+ * Template for instantiating entities
61
+ * @class
62
+ */
59
63
  export class EntityBlueprint {
60
64
  constructor() {
61
65
  /**
@@ -15,59 +15,58 @@ const DEFAULT_FLAGS =
15
15
 
16
16
  /**
17
17
  * Representation of an entity, helps build entities and keep track of them without having to access {@link EntityComponentDataset} directly
18
+ * @class
18
19
  */
19
20
  class EntityBuilder {
21
+
22
+ /**
23
+ * @type {number}
24
+ */
25
+ entity = void 0;
26
+
27
+ /**
28
+ * Generation is a unique identifier coming from the dataset
29
+ * Generation of an existing entity must match for it to be considered "the same"
30
+ * @type {number}
31
+ */
32
+ generation = -1;
33
+
20
34
  /**
21
35
  *
22
- * @constructor
36
+ * @type {Array}
23
37
  */
24
- constructor() {
25
- /**
26
- * @type {number}
27
- */
28
- this.entity = void 0;
29
-
30
- /**
31
- * Generation is a unique identifier coming from the dataset
32
- * Generation of an existing entity must match for it to be considered "the same"
33
- * @type {number}
34
- */
35
- this.generation = -1;
36
-
37
- /**
38
- *
39
- * @type {Array}
40
- */
41
- this.element = [];
42
-
43
- /**
44
- *
45
- * @type {{name:string,listener:(function|Function), context:*}[]}
46
- */
47
- this.deferredListeners = [];
48
-
49
- /**
50
- *
51
- * @type {EntityComponentDataset}
52
- */
53
- this.dataset = null;
54
-
55
- /**
56
- *
57
- * @type {EntityBuilderFlags|number}
58
- */
59
- this.flags = DEFAULT_FLAGS;
60
-
61
- /**
62
- *
63
- * @type {Object}
64
- */
65
- this.properties = {};
66
-
67
- this.on = {
68
- built: new Signal()
69
- };
70
- }
38
+ element = [];
39
+
40
+ /**
41
+ *
42
+ * @type {{name:string,listener:(function|Function), context:*}[]}
43
+ */
44
+ deferredListeners = [];
45
+
46
+ /**
47
+ *
48
+ * @type {EntityComponentDataset}
49
+ */
50
+ dataset = null;
51
+
52
+ /**
53
+ *
54
+ * @type {EntityBuilderFlags|number}
55
+ */
56
+ flags = DEFAULT_FLAGS;
57
+
58
+ /**
59
+ *
60
+ * @type {Object}
61
+ */
62
+ properties = {};
63
+
64
+ /**
65
+ * @readonly
66
+ */
67
+ on = {
68
+ built: new Signal()
69
+ };
71
70
 
72
71
  /**
73
72
  * Handles event when entity is removed without invoking {@link #destroy} method
@@ -200,7 +199,7 @@ class EntityBuilder {
200
199
 
201
200
  /**
202
201
  *
203
- * @param {class} klass
202
+ * @param {function} klass
204
203
  * @returns {*|null}
205
204
  */
206
205
  removeComponent(klass) {
@@ -8,11 +8,11 @@ export const EntityBuilderFlags = {
8
8
  */
9
9
  Built: 1,
10
10
  /**
11
- * If component type is not registered on the {@link EntityComponentDataset} when calling {@link #build} - will register the component first
11
+ * If component type is not registered on the {@link EntityComponentDataset} when calling {@link EntityBuilder#build} - will register the component first
12
12
  */
13
13
  RegisterComponents: 2,
14
14
  /**
15
- * Entity builder will watch destruction of the entity (subscribe to event), this will make the EntityBuilder automatically
15
+ * Entity builder will watch destruction of the entity (subscribe to event), this will make the {@link EntityBuilder} automatically
16
16
  * recognize when the corresponding entity is destroyed outside the EntityBuilder API
17
17
  * NOTE: useful to turn off to save a bit of memory, as those event listeners take up a bit of space. Feel free to turn this flag off when you don't care to keep the reference to the EntityBuilder
18
18
  */
@@ -23,6 +23,7 @@ let _clockseq = ((randomUint8(random) << 8) | randomUint8(random)) & 0x3fff;
23
23
 
24
24
  /**
25
25
  * Globally unique identifier
26
+ * @class
26
27
  */
27
28
  export class GUID {
28
29
  #data = new Uint8Array(16);
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
  import EntityFactory from './EntityFactory.js';
7
- import { FunctionCompiler } from "../../core/function/FunctionCompiler.js";
7
+ import { FunctionCompiler } from "../../../../core/function/FunctionCompiler.js";
8
8
 
9
9
  function Blueprint() {
10
10
  this.element = [];