@woosh/meep-engine 2.122.3 → 2.122.4

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 (26) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  3. package/src/core/bvh2/bvh3/BVH.js +19 -3
  4. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  5. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +0 -1
  6. package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.d.ts.map +1 -1
  7. package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.js +12 -6
  8. package/src/core/bvh2/bvh3/ebvh_update_hierarchy_bounds.d.ts +8 -0
  9. package/src/core/bvh2/bvh3/ebvh_update_hierarchy_bounds.d.ts.map +1 -0
  10. package/src/core/bvh2/bvh3/ebvh_update_hierarchy_bounds.js +147 -0
  11. package/src/core/geom/Vector1.d.ts +177 -35
  12. package/src/core/graph/Edge.d.ts +0 -1
  13. package/src/core/graph/Edge.d.ts.map +1 -1
  14. package/src/core/graph/Edge.js +1 -1
  15. package/src/core/graph/v2/Graph.d.ts +24 -9
  16. package/src/core/graph/v2/Graph.d.ts.map +1 -1
  17. package/src/core/graph/v2/Graph.js +48 -10
  18. package/src/engine/ecs/animation/AnimationClip.d.ts +2 -2
  19. package/src/engine/ecs/fow/FogOfWarRevealer.d.ts +1 -1
  20. package/src/engine/graphics/ecs/water/Water.d.ts +1 -1
  21. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts +7 -5
  22. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts.map +1 -1
  23. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +13 -12
  24. package/src/engine/intelligence/behavior/util/DelayBehavior.d.ts.map +1 -1
  25. package/src/engine/intelligence/behavior/util/DelayBehavior.js +12 -15
  26. package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts +1 -1
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.122.3",
8
+ "version": "2.122.4",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"BVH.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/BVH.js"],"names":[],"mappings":"AASA,4BAA6B,CAAC,CAAC;AAC/B,6BAA8B,CAAC,CAAC;AAChC,6BAA8B,CAAC,CAAC;AAChC,4BAA6B,CAAC,CAAC;AAE/B;;;;;GAKG;AACH,+BAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEqB;AAiBrC;;;;;;GAMG;AACH;IAEI;;;;OAIG;IACH,sBAA2E;IAE3E;;;;;OAKG;IACH,mBAFa,WAAW,CAIvB;IAED;;;;OAIG;IACH,uBAAsD;IAEtD;;;OAGG;IACH,oBAFY,YAAY,CAIvB;IAED;;;;OAIG;IACH,sBAAoD;IAEpD;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,eAAW;IAEX;;;;OAIG;IACH,eAAY;IAEZ;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAmB;IAUnB;;;OAGG;IACH,YAFW,MAAM,EAIhB;IAdD;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAUD;;;;OAIG;IACH,YAFY,MAAM,CAIjB;IAUD;;;OAGG;IACH,qBAFW,MAAM,EAQhB;IAlBD;;;OAGG;IACH,qBAFa,MAAM,CAIlB;IAcD,wBAgBC;IAED;;;;OAIG;IACH,uBA6BC;IAED;;OAEG;IACH,aAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAqDlB;IAED;;;;OAIG;IACH,iBAFW,MAAM,QAMhB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AI,CA0GhB;IAED;;;;;OAKG;IACH,wBAqBC;IAED;;;;OAIG;IACH,yBA4BC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,IAAI,CA6ChB;IAED;;;;;;OAMG;IACH,gBAoMC;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,WACN,MAAM,WACN,MAAM,QAMhB;IAED;;;;;;;OAOG;IACH,kCAJW,MAAM,WACN,MAAM,WACN,MAAM,QAmBhB;IAED;;;OAGG;IACH,oBAIC;IAED;;;;OAIG;IACH,8BAFW,GAAC,QAgCX;IAED;;;;;OAKG;IACH,+BAJW,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,0BA6BC;IAED;;;;;OAKG;IACH,cAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAsCnB;CACJ"}
@@ -1053,14 +1053,30 @@ export class BVH {
1053
1053
  node_assign_children(parent, child_1, child_2) {
1054
1054
  this.node_set_combined_aabb(parent, child_1, child_2);
1055
1055
 
1056
- this.node_set_child1(parent, child_1);
1057
- this.node_set_child2(parent, child_2);
1056
+ this.node_assign_children_only(parent, child_1, child_2);
1057
+ }
1058
+
1059
+ /**
1060
+ * Utility method for assigning both children at once
1061
+ * Children must be valid nodes (non-null)
1062
+ * Does not update bounds.
1063
+ * @param {number} parent
1064
+ * @param {number} child_1
1065
+ * @param {number} child_2
1066
+ */
1067
+ node_assign_children_only(parent, child_1, child_2) {
1068
+ assert.isNonNegativeInteger(parent, 'parent');
1069
+ assert.isNonNegativeInteger(child_1, 'child_1');
1070
+ assert.isNonNegativeInteger(child_2, 'child_2');
1058
1071
 
1059
1072
  this.node_set_parent(child_1, parent);
1060
1073
  this.node_set_parent(child_2, parent);
1061
1074
 
1075
+ this.node_set_child1(parent, child_1);
1076
+ this.node_set_child2(parent, child_2);
1077
+
1062
1078
  this.node_set_height(parent,
1063
- 1+ Math.max(
1079
+ 1 + Math.max(
1064
1080
  this.node_get_height(child_1),
1065
1081
  this.node_get_height(child_2),
1066
1082
  )
@@ -1 +1 @@
1
- {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AACH,oDAPW,GAAG,eACH,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,kBAChC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,WAAW,WACX,KAAK,YACL,MAAM,QAsHhB;sBAvIqB,6BAA6B"}
1
+ {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AACH,oDAPW,GAAG,eACH,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,kBAChC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,WAAW,WACX,KAAK,YACL,MAAM,QAsHhB;sBAtIqB,6BAA6B"}
@@ -8,7 +8,6 @@ import { max2 } from "../../math/max2.js";
8
8
  import { build_triangle_morton_codes } from "./build_triangle_morton_codes.js";
9
9
  import { COLUMN_CHILD_1, COLUMN_HEIGHT, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
10
10
  import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
11
- import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
12
11
 
13
12
  /**
14
13
  * Build the BVH bottom-up using spatial hash sorting
@@ -1 +1 @@
1
- {"version":3,"file":"ebvh_build_hierarchy_radix.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.js"],"names":[],"mappings":"AA0MA;;;;;;;;GAQG;AACH,gDAPW,GAAG,cACH,MAAM,EAAE,GAAC,WAAW,uBACpB,MAAM,EAAE,cACR,MAAM,kBACN,MAAM,EAAE,GACN,MAAM,CAiElB"}
1
+ {"version":3,"file":"ebvh_build_hierarchy_radix.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.js"],"names":[],"mappings":"AA4MA;;;;;;;;GAQG;AACH,gDAPW,GAAG,cACH,MAAM,EAAE,GAAC,WAAW,uBACpB,MAAM,EAAE,cACR,MAAM,kBACN,MAAM,EAAE,GACN,MAAM,CAqElB"}
@@ -2,6 +2,7 @@ import { assert } from "../../assert.js";
2
2
  import { clz32 } from "../../binary/clz32.js";
3
3
  import { clamp } from "../../math/clamp.js";
4
4
  import { NULL_NODE } from "./BVH.js";
5
+ import { ebvh_update_hierarchy_bounds } from "./ebvh_update_hierarchy_bounds.js";
5
6
 
6
7
  /**
7
8
  *
@@ -57,10 +58,10 @@ function find_split(
57
58
 
58
59
  /**
59
60
  *
60
- * @param indexA
61
- * @param indexB
62
- * @param elementCount
63
- * @param mortonCodes
61
+ * @param {number} indexA
62
+ * @param {number} indexB
63
+ * @param {number} elementCount
64
+ * @param {number[]} mortonCodes
64
65
  * @return {number}
65
66
  * @see https://github.com/turanszkij/WickedEngine/blob/506749de321c2ab66fd33fbe41efb95afbbb7ff8/WickedEngine/shaders/bvh_hierarchyCS.hlsl#L28C1-L48C2
66
67
  */
@@ -122,6 +123,7 @@ function determineRangeW(output, sortedMortonCodes, numTriangles, idx) {
122
123
 
123
124
  }
124
125
 
126
+
125
127
  /**
126
128
  * @see https://github.com/mbartling/cuda-bvh/blob/7f2f98d9d29956c3559632e59104ba66f31f80b8/kernels/bvh.cu#L276C1-L352C2
127
129
  * @param {number[]|Uint32Array} output
@@ -227,7 +229,8 @@ export function ebvh_build_hierarchy_radix(
227
229
  const range = new Uint32Array(2);
228
230
 
229
231
  // Construct internal nodes.
230
- for (let idx = 0; idx < leaf_count - 1; idx++) // in parallel
232
+ const intermediate_node_count = leaf_count - 1;
233
+ for (let idx = 0; idx < intermediate_node_count; idx++) // in parallel
231
234
  {
232
235
  // Find out which range of objects the node corresponds to.
233
236
  // (This is where the magic happens!)
@@ -263,7 +266,7 @@ export function ebvh_build_hierarchy_radix(
263
266
  // Record parent-child relationships.
264
267
  const parent = internal_nodes[idx];
265
268
 
266
- bvh.node_assign_children(parent, childA, childB);
269
+ bvh.node_assign_children_only(parent, childA, childB);
267
270
  }
268
271
 
269
272
  // Node 0 is the root.
@@ -271,5 +274,8 @@ export function ebvh_build_hierarchy_radix(
271
274
 
272
275
  bvh.node_set_parent(root, NULL_NODE);
273
276
 
277
+ // update bounds
278
+ ebvh_update_hierarchy_bounds(bvh, root);
279
+
274
280
  return root;
275
281
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Traverses the tree bottom-up, updating bounds as it goes
3
+ * @param {BVH} bvh
4
+ * @param {number} root
5
+ * @returns {void}
6
+ */
7
+ export function ebvh_update_hierarchy_bounds(bvh: BVH, root?: number): void;
8
+ //# sourceMappingURL=ebvh_update_hierarchy_bounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ebvh_update_hierarchy_bounds.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_update_hierarchy_bounds.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,kDAJW,GAAG,SACH,MAAM,GACJ,IAAI,CAuIhB"}
@@ -0,0 +1,147 @@
1
+ import { assert } from "../../assert.js";
2
+ import { NULL_NODE } from "./BVH.js";
3
+
4
+ const CAME_FROM_TYPE_PARENT = 0;
5
+ const CAME_FROM_TYPE_CHILD_1 = 1;
6
+ const CAME_FROM_TYPE_CHILD_2 = 2;
7
+
8
+ /**
9
+ * Traverses the tree bottom-up, updating bounds as it goes
10
+ * @param {BVH} bvh
11
+ * @param {number} root
12
+ * @returns {void}
13
+ */
14
+ export function ebvh_update_hierarchy_bounds(bvh, root = bvh.root) {
15
+ assert.isNonNegativeInteger(root, 'root');
16
+
17
+ if (root === NULL_NODE) {
18
+ // special case
19
+ return;
20
+ }
21
+
22
+ if (bvh.node_is_leaf(root)) {
23
+ // special case
24
+ return;
25
+ }
26
+
27
+ // we traverse depth-first using stack-less scheme
28
+ let came_from_node = root;
29
+
30
+ let came_from_type = CAME_FROM_TYPE_PARENT;
31
+
32
+ let node = bvh.node_get_child1(came_from_node);
33
+ if (node === NULL_NODE) {
34
+ node = bvh.node_get_child2(came_from_node);
35
+ }
36
+
37
+ if (node === NULL_NODE) {
38
+ // no children, done
39
+ return;
40
+ }
41
+
42
+ // do a stackless traversal
43
+ while (true) {
44
+
45
+
46
+ if (
47
+ came_from_type === CAME_FROM_TYPE_CHILD_2
48
+ ) {
49
+ // moving up last time, lets calculate
50
+ const child_1 = bvh.node_get_child1(node);
51
+ const child_2 = bvh.node_get_child2(node);
52
+
53
+ bvh.node_set_combined_aabb(node, child_1, child_2);
54
+ }
55
+
56
+ // only add to treelet when traversing up, not down
57
+
58
+ if (bvh.node_is_leaf(node)) {
59
+
60
+ assert.equal(came_from_type, CAME_FROM_TYPE_PARENT);
61
+
62
+ const parent = came_from_node;
63
+ const parent_child_1 = bvh.node_get_child1(parent);
64
+
65
+ if (parent_child_1 === node) {
66
+ came_from_type = CAME_FROM_TYPE_CHILD_1;
67
+ } else {
68
+ came_from_type = CAME_FROM_TYPE_CHILD_2;
69
+ }
70
+
71
+ came_from_node = node;
72
+
73
+ node = parent;
74
+ } else if (came_from_type === CAME_FROM_TYPE_CHILD_2) {
75
+ // finishing traversal of this branch
76
+ came_from_node = node;
77
+ const parent = bvh.node_get_parent(node);
78
+
79
+ if (bvh.node_get_child1(parent) === node) {
80
+ came_from_type = CAME_FROM_TYPE_CHILD_1;
81
+ } else {
82
+ came_from_type = CAME_FROM_TYPE_CHILD_2;
83
+ }
84
+
85
+ if (node === root) {
86
+ // traversed all the way back up
87
+ break;
88
+ }
89
+
90
+ node = parent;
91
+
92
+ } else if (came_from_type === CAME_FROM_TYPE_CHILD_1) {
93
+ // traversing up from left child
94
+ const child2 = bvh.node_get_child2(node);
95
+
96
+ came_from_node = node;
97
+
98
+ if (child2 === NULL_NODE) {
99
+ // no right child, finish this branch
100
+ came_from_type = CAME_FROM_TYPE_CHILD_2; // indicate end
101
+
102
+ node = bvh.node_get_parent(node);
103
+ } else {
104
+ came_from_type = CAME_FROM_TYPE_PARENT;
105
+ node = child2;
106
+ }
107
+
108
+ } else if (came_from_type === CAME_FROM_TYPE_PARENT) {
109
+ const child1 = bvh.node_get_child1(node);
110
+ const child2 = bvh.node_get_child1(node);
111
+
112
+ if (child1 !== NULL_NODE) {
113
+ came_from_type = CAME_FROM_TYPE_PARENT;
114
+ came_from_node = node;
115
+ node = child1;
116
+ } else if (child2 !== NULL_NODE) {
117
+ came_from_type = CAME_FROM_TYPE_PARENT;
118
+ came_from_node = node;
119
+ node = child2;
120
+ } else {
121
+ // this should not happen, as this would mean that node is empty and completely pointless
122
+ // we remove the node and traverse up
123
+
124
+
125
+ const parent_child1 = bvh.node_get_child1(came_from_node);
126
+
127
+ bvh.release_node(node);
128
+
129
+ if (parent_child1 === node) {
130
+ // we are left child
131
+ bvh.node_set_child1(came_from_node, NULL_NODE);
132
+ came_from_node = NULL_NODE;
133
+ came_from_type = CAME_FROM_TYPE_CHILD_1;
134
+ } else {
135
+ bvh.node_set_child2(came_from_node, NULL_NODE);
136
+ came_from_node = NULL_NODE;
137
+ came_from_type = CAME_FROM_TYPE_CHILD_2;
138
+ }
139
+
140
+ node = came_from_node;
141
+ }
142
+
143
+
144
+ }
145
+
146
+ }
147
+ }
@@ -1,35 +1,177 @@
1
- import Signal from "../events/signal/Signal";
2
-
3
- export default class Vector1 {
4
- x: number
5
-
6
- 0: number
7
-
8
- readonly onChanged: Signal<number,number>
9
-
10
- constructor()
11
-
12
- constructor(x: number)
13
-
14
- set(v: number) : void
15
-
16
- getValue(): number
17
-
18
- _add(v: number): void
19
-
20
- _sub(v: number): void
21
-
22
- isZero(): boolean
23
-
24
- process(callback: (x) => any): void
25
-
26
- toJSON(): any
27
-
28
- fromJSON(j: any): void
29
-
30
- readFromArray(array: ArrayLike<number>, offset?: number): void
31
-
32
- writeToArray(array: ArrayLike<number>, offset?: number): void
33
-
34
- asArray(): number[]
35
- }
1
+ /**
2
+ * @author Alex Goldring
3
+ * @copyright Company Named Limited (c) 2025
4
+ */
5
+ export class Vector1 extends Number {
6
+ /**
7
+ *
8
+ * @param {Vector1} a
9
+ * @param {Vector1} b
10
+ * @return {number}
11
+ */
12
+ static compare(a: Vector1, b: Vector1): number;
13
+ /**
14
+ *
15
+ * @param {number} [x=0]
16
+ * @constructor
17
+ * @class
18
+ * @property {number} x
19
+ */
20
+ constructor(x?: number);
21
+ x: number;
22
+ onChanged: Signal<any, any, any, any, any, any, any, any>;
23
+ /**
24
+ *
25
+ * @returns {string}
26
+ */
27
+ toString(): string;
28
+ /**
29
+ * Currently held value
30
+ * @returns {number}
31
+ */
32
+ getValue(): number;
33
+ /**
34
+ * Useful for sorting
35
+ * @param {Vector1} other
36
+ * @returns {number}
37
+ */
38
+ compareTo(other: Vector1): number;
39
+ /**
40
+ *
41
+ * @param {number} x
42
+ * @returns {Vector1}
43
+ */
44
+ set(x: number): Vector1;
45
+ /**
46
+ * Set value without triggering {@link #onChanged} signal
47
+ * @param {number} x
48
+ */
49
+ setSilent(x: number): void;
50
+ /**
51
+ *
52
+ * @return {boolean}
53
+ */
54
+ isZero(): boolean;
55
+ /**
56
+ * Increase value by 1.
57
+ * `value++`
58
+ */
59
+ increment(): void;
60
+ /**
61
+ * Decrease value by 1.
62
+ * `value--`
63
+ */
64
+ decrement(): void;
65
+ /**
66
+ *
67
+ * @param {Number} v
68
+ * @return {Vector1}
69
+ */
70
+ _add(v: number): Vector1;
71
+ /**
72
+ *
73
+ * @param {Vector1|Vector2|Vector3|Vector4} other
74
+ */
75
+ add(other: Vector1 | Vector2 | Vector3 | Vector4): Vector1;
76
+ /**
77
+ *
78
+ * @param {Number} v
79
+ * @return {Vector1}
80
+ */
81
+ _sub(v: number): Vector1;
82
+ /**
83
+ *
84
+ * @param {Vector1} other
85
+ * @returns {Vector1}
86
+ */
87
+ sub(other: Vector1): Vector1;
88
+ /**
89
+ *
90
+ * @param {Vector1} other
91
+ * @returns {Vector1}
92
+ */
93
+ multiply(other: Vector1): Vector1;
94
+ /**
95
+ *
96
+ * @param {number} v
97
+ */
98
+ multiplyScalar(v: number): void;
99
+ /**
100
+ *
101
+ * @param {number} low
102
+ * @param {number} high
103
+ * @returns {Vector1}
104
+ */
105
+ clamp(low: number, high: number): Vector1;
106
+ /**
107
+ * Negate sign of the value, if value is 7, it will become -7 and vice versa
108
+ * Zero is unaffected
109
+ */
110
+ negate(): void;
111
+ /**
112
+ *
113
+ * @param {Vector1|Vector2|Vector3|Vector4} other
114
+ */
115
+ copy(other: Vector1 | Vector2 | Vector3 | Vector4): void;
116
+ /**
117
+ *
118
+ * @returns {Vector1}
119
+ */
120
+ clone(): Vector1;
121
+ /**
122
+ *
123
+ * @param {Vector1} other
124
+ * @returns {boolean}
125
+ */
126
+ equals(other: Vector1): boolean;
127
+ /**
128
+ * @returns {number}
129
+ */
130
+ hash(): number;
131
+ /**
132
+ *
133
+ * @param {function(newValue:number, oldValue:number)} handler
134
+ */
135
+ process(handler: any): void;
136
+ toJSON(): number;
137
+ fromJSON(val: any): void;
138
+ /**
139
+ *
140
+ * @param {number[]} array
141
+ * @param {number} offset
142
+ */
143
+ readFromArray(array: number[], offset?: number): void;
144
+ /**
145
+ *
146
+ * @param {number[]} array
147
+ * @param {number} offset
148
+ */
149
+ writeToArray(array: number[], offset?: number): void;
150
+ asArray(): number[];
151
+ /**
152
+ *
153
+ * @param {BinaryBuffer} buffer
154
+ */
155
+ toBinaryBuffer(buffer: BinaryBuffer): void;
156
+ /**
157
+ *
158
+ * @param {BinaryBuffer} buffer
159
+ */
160
+ fromBinaryBuffer(buffer: BinaryBuffer): void;
161
+ set 0(v: number);
162
+ get 0(): number;
163
+ /**
164
+ * @readonly
165
+ * @type {boolean}
166
+ */
167
+ readonly isVector1: boolean;
168
+ [Symbol.iterator](): Generator<number, void, unknown>;
169
+ }
170
+ export namespace Vector1 {
171
+ let typeName: string;
172
+ let zero: Vector1;
173
+ let one: Vector1;
174
+ }
175
+ export default Vector1;
176
+ import Signal from "../events/signal/Signal.js";
177
+ //# sourceMappingURL=Vector1.d.ts.map
@@ -12,7 +12,6 @@ export class Edge<N> {
12
12
  * @template N
13
13
  * @param {N} a
14
14
  * @param {N} b
15
- * @constructor
16
15
  */
17
16
  constructor(a: N_1, b: N_1);
18
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"gCAKU,MAAM;;;;;;AAQhB;;GAEG;AACH,kBAFa,CAAC;IAGV;;;;;OAKG;IACH,eAJW,GAAC,KACD,GAAC,EAsBX;IAfG;;;OAGG;IACH,OAFU,GAAC,CAEG;IACd;;;OAGG;IACH,QAFU,GAAC,CAEI;IAEf;;OAEG;IACH,WAFU,iBAAiB,CAEkB;IAGjD;;;;OAIG;IACH,eAHW,CAAC,GACA,OAAO,CAIlB;IAED;;;;;OAKG;IACH,2BAJW,CAAC,UACD,CAAC,GACC,OAAO,CASnB;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,CAAC,CAIb;IAED;;;OAGG;IACH,sBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,uBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,wBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,aAFa,CAAC,EAAE,CAIf;IAED,mBAEC;IAIL;;;OAGG;IACH,QAFU,OAAO,CAEI;CANpB"}
1
+ {"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"gCAKU,MAAM;;;;;;AAQhB;;GAEG;AACH,kBAFa,CAAC;IAGV;;;;OAIG;IACH,eAHW,GAAC,KACD,GAAC,EAsBX;IAhBG;;;OAGG;IACH,OAFU,GAAC,CAEG;IAEd;;;OAGG;IACH,QAFU,GAAC,CAEI;IAEf;;OAEG;IACH,WAFU,iBAAiB,CAEkB;IAGjD;;;;OAIG;IACH,eAHW,CAAC,GACA,OAAO,CAIlB;IAED;;;;;OAKG;IACH,2BAJW,CAAC,UACD,CAAC,GACC,OAAO,CASnB;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,CAAC,CAIb;IAED;;;OAGG;IACH,sBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,uBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,wBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,aAFa,CAAC,EAAE,CAIf;IAED,mBAEC;IAIL;;;OAGG;IACH,QAFU,OAAO,CAEI;CANpB"}
@@ -19,7 +19,6 @@ export class Edge {
19
19
  * @template N
20
20
  * @param {N} a
21
21
  * @param {N} b
22
- * @constructor
23
22
  */
24
23
  constructor(a, b) {
25
24
  assert.defined(a, 'a');
@@ -30,6 +29,7 @@ export class Edge {
30
29
  * @type {N}
31
30
  */
32
31
  this.first = a;
32
+
33
33
  /**
34
34
  *
35
35
  * @type {N}
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * Graph structure, consisting of nodes(vertices) and directed edges.
3
+ * @see https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)
4
+ * @see https://en.wikipedia.org/wiki/Graph_(abstract_data_type)
2
5
  * @template N
3
6
  */
4
7
  export class Graph<N> {
@@ -55,9 +58,13 @@ export class Graph<N> {
55
58
  * @param {*} [thisArg]
56
59
  */
57
60
  traverseNodes(visitor: (arg0: N) => any, thisArg?: any): void;
61
+ /**
62
+ * Number of nodes in the graph
63
+ * @return {number}
64
+ */
58
65
  get nodeCount(): number;
59
66
  /**
60
- *
67
+ * @deprecated use {@link nodeCount} property instead
61
68
  * @returns {number}
62
69
  */
63
70
  getNodeCount(): number;
@@ -65,11 +72,13 @@ export class Graph<N> {
65
72
  *
66
73
  * @param {function(N):boolean} filter
67
74
  * @param {*} [thisArg]
68
- * @returns {N|undefined}
75
+ * @returns {N|undefined} first node that is matched by the filter
69
76
  */
70
77
  findNode(filter: (arg0: N) => boolean, thisArg?: any): N | undefined;
71
78
  /**
72
- *
79
+ * Access internal representation of a node.
80
+ * Useful for performance optimization.
81
+ * Do not modify obtained value.
73
82
  * @param {N} node
74
83
  * @returns {NodeContainer<N>|undefined}
75
84
  */
@@ -96,24 +105,25 @@ export class Graph<N> {
96
105
  */
97
106
  getEdges(): Set<Edge<N>>;
98
107
  /**
99
- *
108
+ * Introduce a new edge into the graph. Nodes must already be a part of the graph.
100
109
  * @param {N} source
101
110
  * @param {N} target
102
111
  * @param {EdgeDirectionType} [direction] Undirected by default
103
112
  * @returns {Edge<N>}
113
+ * @throws {Error} if one or both nodes are not part of the graph
104
114
  */
105
115
  createEdge(source: N, target: N, direction?: EdgeDirectionType): Edge<N>;
106
116
  /**
107
117
  * Both nodes that the edge is attached to must be present
108
118
  * @param {Edge<N>} edge
109
119
  * @returns {boolean} true if edge was added, false if edge was already present
110
- * @throws if one or both nodes are not contained in the graph
120
+ * @throws {Error} if one or both nodes are not contained in the graph
111
121
  */
112
122
  addEdge(edge: Edge<N>): boolean;
113
123
  /**
114
124
  *
115
125
  * @param {Edge<N>} edge
116
- * @returns {boolean}
126
+ * @returns {boolean} true if edge was removed, false if edge was not found
117
127
  */
118
128
  removeEdge(edge: Edge<N>): boolean;
119
129
  /**
@@ -128,9 +138,14 @@ export class Graph<N> {
128
138
  * @param {*} [thisArg]
129
139
  */
130
140
  traverseEdges(visitor: (arg0: Edge<N>) => any, thisArg?: any): void;
141
+ /**
142
+ * Number of edges in the graph
143
+ * @return {number}
144
+ */
131
145
  get edgeCount(): number;
132
146
  /**
133
- *
147
+ * checks if there is an edge between two given nodes.
148
+ * Direction is ignored.
134
149
  * @param {N} a
135
150
  * @param {N} b
136
151
  * @returns {boolean}
@@ -152,9 +167,9 @@ export class Graph<N> {
152
167
  getAnyDirectedEdge(from: N, to: N): Edge<N> | undefined;
153
168
  /**
154
169
  *
155
- * @param {Edge<N>[]} result
170
+ * @param {Edge<N>[]} result found edges will be put here
156
171
  * @param {N} node
157
- * @returns {number}
172
+ * @returns {number} number of edges found
158
173
  */
159
174
  getAttachedEdges(result: Edge<N>[], node: N): number;
160
175
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/v2/Graph.js"],"names":[],"mappings":"AAyBA;;GAEG;AACH,mBAFa,CAAC;IAIV;;;;;OAKG;IACH,yBAAoB;IACpB;;;;;OAKG;IACH,yBAAoB;IAEpB;;OAEG;IACH;QACI;;WAEG;mBADO,MAAM,CAAC,CAAC,EAAC,IAAI,CAAC;QAGxB;;WAEG;qBADO,MAAM,CAAC,CAAC,EAAC,IAAI,CAAC;;;MAK1B;IAGF;;;;OAIG;IACH,cAHW,CAAC,GACC,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,CAAC,GACC,OAAO,CAenB;IAED;;;;OAIG;IACH,iBAHW,CAAC,GACC,OAAO,CAiBnB;IAED;;;;OAIG;IACH,uBAHW,CAAS,IAAC,EAAD,CAAC,QAAC,YACX,GAAC,QAMX;IAED,wBAEC;IAED;;;OAGG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,iBAJW,CAAS,IAAC,EAAD,CAAC,KAAE,OAAO,YACnB,GAAC,GACC,CAAC,GAAC,SAAS,CAgBvB;IAED;;;;OAIG;IACH,uBAHW,CAAC,GACC,aAAa,CAAC,CAAC,CAAC,GAAC,SAAS,CAItC;IAED;;;;OAIG;IACH,oBAHW,CAAC,GACA,MAAM,CAUjB;IAED;;;OAGG;IACH,aAFa,CAAC,EAAE,CAIf;IAED;;;OAGG;IACH,YAFY,QAAQ,CAAC,CAAC,CAAC,CAItB;IAED;;;OAGG;IACH,YAFY,GAAG,CAAC,IAAI,CAA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AC,CAAC,CAAC,GACL,OAAO,CAQnB;IAED;;;;OAIG;IACH,uBAHW,CAAS,IAAO,EAAP,IAAI,CAAC,CAAC,CAAC,QAAC,YACjB,GAAC,QAMX;IAED;;;OAGG;IACH,iBAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,qBAJW,CAAC,KACD,CAAC,GACC,OAAO,CAcnB;IAED;;;;;OAKG;IACH,qBAJW,CAAC,KACD,CAAC,GACC,IAAI,CAAC,CAAC,CAAC,GAAC,SAAS,CAmB7B;IAED;;;;;OAKG;IACH,yBAJW,CAAC,MACD,CAAC,GACC,IAAI,CAAC,CAAC,CAAC,GAAC,SAAS,CAc7B;IAED;;;;;OAKG;IACH,yBAJW,IAAI,CAAC,CAAC,CAAC,EAAE,QACT,CAAC,GACC,MAAM,CA2BlB;IAED;;;;OAIG;IACH,oBAHW,CAAC,GACC,CAAC,EAAE,CAYf;IAED;;;;OAIG;IACH,mBAHW,CAAC,GACC,OAAO,CAanB;IAED;;;;;OAKG;IACH,gBAJW,CAAC,QACD,CAAC,GACC,IAAI,GAAC,CAAC,EAAE,CA4EpB;IAED;;OAEG;IACH,cAGC;IAED;;;OAGG;IACH,YAFW,KAAK,CAAC,CAAC,CAAC,QAOlB;IAED;;OAEG;IACH,SAFa,KAAK,CAAC,CAAC,CAAC,CAQpB;CACJ;mBA5kBkB,+BAA+B;8BAEpB,oBAAoB;qBADV,YAAY;kCAAZ,YAAY"}
@@ -24,6 +24,9 @@ function construct_path(goal_node_container, came_from) {
24
24
  }
25
25
 
26
26
  /**
27
+ * Graph structure, consisting of nodes(vertices) and directed edges.
28
+ * @see https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)
29
+ * @see https://en.wikipedia.org/wiki/Graph_(abstract_data_type)
27
30
  * @template N
28
31
  */
29
32
  export class Graph {
@@ -35,6 +38,7 @@ export class Graph {
35
38
  * @private
36
39
  */
37
40
  __nodes = new Map();
41
+
38
42
  /**
39
43
  *
40
44
  * @type {Set<Edge<N>>}
@@ -66,6 +70,8 @@ export class Graph {
66
70
  * @returns {boolean}
67
71
  */
68
72
  hasNode(node) {
73
+ assert.defined(node, 'node');
74
+
69
75
  return this.__nodes.has(node);
70
76
  }
71
77
 
@@ -95,6 +101,7 @@ export class Graph {
95
101
  * @returns {boolean}
96
102
  */
97
103
  removeNode(node) {
104
+ assert.defined(node, 'node');
98
105
 
99
106
  const context = this.__nodes.get(node);
100
107
  if (context === undefined) {
@@ -122,12 +129,16 @@ export class Graph {
122
129
  }
123
130
  }
124
131
 
132
+ /**
133
+ * Number of nodes in the graph
134
+ * @return {number}
135
+ */
125
136
  get nodeCount() {
126
137
  return this.__nodes.size;
127
138
  }
128
139
 
129
140
  /**
130
- *
141
+ * @deprecated use {@link nodeCount} property instead
131
142
  * @returns {number}
132
143
  */
133
144
  getNodeCount() {
@@ -138,7 +149,7 @@ export class Graph {
138
149
  *
139
150
  * @param {function(N):boolean} filter
140
151
  * @param {*} [thisArg]
141
- * @returns {N|undefined}
152
+ * @returns {N|undefined} first node that is matched by the filter
142
153
  */
143
154
  findNode(filter, thisArg) {
144
155
  const nodes = this.__nodes;
@@ -157,11 +168,15 @@ export class Graph {
157
168
  }
158
169
 
159
170
  /**
160
- *
171
+ * Access internal representation of a node.
172
+ * Useful for performance optimization.
173
+ * Do not modify obtained value.
161
174
  * @param {N} node
162
175
  * @returns {NodeContainer<N>|undefined}
163
176
  */
164
177
  getNodeContainer(node) {
178
+ assert.defined(node, 'node');
179
+
165
180
  return this.__nodes.get(node);
166
181
  }
167
182
 
@@ -171,6 +186,8 @@ export class Graph {
171
186
  * @return {number}
172
187
  */
173
188
  getNodeDegree(node) {
189
+ assert.defined(node, 'node');
190
+
174
191
  const container = this.__nodes.get(node);
175
192
 
176
193
  if (container === undefined) {
@@ -205,17 +222,21 @@ export class Graph {
205
222
  }
206
223
 
207
224
  /**
208
- *
225
+ * Introduce a new edge into the graph. Nodes must already be a part of the graph.
209
226
  * @param {N} source
210
227
  * @param {N} target
211
228
  * @param {EdgeDirectionType} [direction] Undirected by default
212
229
  * @returns {Edge<N>}
230
+ * @throws {Error} if one or both nodes are not part of the graph
213
231
  */
214
232
  createEdge(
215
233
  source,
216
234
  target,
217
235
  direction = EdgeDirectionType.Undirected
218
236
  ) {
237
+ assert.defined(source, 'source');
238
+ assert.defined(target, 'target');
239
+
219
240
  assert.enum(direction, EdgeDirectionType, 'direction');
220
241
 
221
242
  const edge = new Edge(source, target);
@@ -231,7 +252,7 @@ export class Graph {
231
252
  * Both nodes that the edge is attached to must be present
232
253
  * @param {Edge<N>} edge
233
254
  * @returns {boolean} true if edge was added, false if edge was already present
234
- * @throws if one or both nodes are not contained in the graph
255
+ * @throws {Error} if one or both nodes are not contained in the graph
235
256
  */
236
257
  addEdge(edge) {
237
258
  if (this.hasEdge(edge)) {
@@ -263,7 +284,7 @@ export class Graph {
263
284
  /**
264
285
  *
265
286
  * @param {Edge<N>} edge
266
- * @returns {boolean}
287
+ * @returns {boolean} true if edge was removed, false if edge was not found
267
288
  */
268
289
  removeEdge(edge) {
269
290
  if (!this.hasEdge(edge)) {
@@ -313,21 +334,29 @@ export class Graph {
313
334
  }
314
335
  }
315
336
 
337
+ /**
338
+ * Number of edges in the graph
339
+ * @return {number}
340
+ */
316
341
  get edgeCount() {
317
342
  return this.__edges.size;
318
343
  }
319
344
 
320
345
  /**
321
- *
346
+ * checks if there is an edge between two given nodes.
347
+ * Direction is ignored.
322
348
  * @param {N} a
323
349
  * @param {N} b
324
350
  * @returns {boolean}
325
351
  */
326
352
  edgeExistsBetween(a, b) {
353
+ assert.defined(a, 'a');
354
+ assert.defined(b, 'b');
355
+
327
356
  const context_a = this.__nodes.get(a);
328
357
 
329
358
  if (context_a === undefined) {
330
- // a is not in the graph
359
+ // 'a' is not in the graph
331
360
  return false;
332
361
  }
333
362
 
@@ -341,6 +370,8 @@ export class Graph {
341
370
  * @returns {Edge<N>|undefined}
342
371
  */
343
372
  getAnyEdgeBetween(a, b) {
373
+ assert.defined(a, 'a');
374
+ assert.defined(b, 'b');
344
375
 
345
376
  const context_a = this.__nodes.get(a);
346
377
 
@@ -364,9 +395,13 @@ export class Graph {
364
395
  * @returns {Edge<N>|undefined}
365
396
  */
366
397
  getAnyDirectedEdge(from, to) {
398
+ assert.defined(from, 'from');
399
+ assert.defined(to, 'to');
400
+
367
401
  const ctx_a = this.__nodes.get(from);
368
402
 
369
403
  if (ctx_a === undefined) {
404
+ // 'from' doesn't exist
370
405
  return undefined;
371
406
  }
372
407
 
@@ -375,9 +410,9 @@ export class Graph {
375
410
 
376
411
  /**
377
412
  *
378
- * @param {Edge<N>[]} result
413
+ * @param {Edge<N>[]} result found edges will be put here
379
414
  * @param {N} node
380
- * @returns {number}
415
+ * @returns {number} number of edges found
381
416
  */
382
417
  getAttachedEdges(result, node) {
383
418
  assert.defined(result, 'result');
@@ -412,6 +447,8 @@ export class Graph {
412
447
  * @returns {N[]}
413
448
  */
414
449
  getNeighbours(node) {
450
+ assert.defined(node, 'node');
451
+
415
452
  const container = this.__nodes.get(node);
416
453
 
417
454
  if (container === undefined) {
@@ -427,6 +464,7 @@ export class Graph {
427
464
  * @returns {boolean}
428
465
  */
429
466
  nodeHasEdges(node) {
467
+ assert.defined(node, 'node');
430
468
 
431
469
  const context = this.__nodes.get(node);
432
470
 
@@ -43,8 +43,8 @@ export class AnimationClip {
43
43
  toJSON(): {
44
44
  name: string;
45
45
  repeatCount: number;
46
- weight: any;
47
- timeScale: any;
46
+ weight: number;
47
+ timeScale: number;
48
48
  flags: number;
49
49
  };
50
50
  /**
@@ -2,7 +2,7 @@ export class FogOfWarRevealer {
2
2
  static fromJSON(j: any): FogOfWarRevealer;
3
3
  radius: Vector1;
4
4
  toJSON(): {
5
- radius: any;
5
+ radius: number;
6
6
  };
7
7
  fromJSON({ radius }: {
8
8
  radius: any;
@@ -60,7 +60,7 @@ declare class Water {
60
60
  writeShaderUniforms(): void;
61
61
  fromJSON(json: any): void;
62
62
  toJSON(): {
63
- level: any;
63
+ level: number;
64
64
  color: any;
65
65
  };
66
66
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Wait for a given entity event via {@link EntityComponentDataset#addEntityEventListener}
3
+ * No failure condition, will wait forever until the event is detected
4
+ */
1
5
  export class WaitForEventBehavior extends EntityBehavior {
2
6
  /**
3
7
  *
@@ -11,12 +15,13 @@ export class WaitForEventBehavior extends EntityBehavior {
11
15
  */
12
16
  event: string;
13
17
  /**
14
- *
18
+ * Has the even occurred already?
15
19
  * @type {boolean}
16
20
  */
17
21
  detected: boolean;
18
22
  /**
19
23
  * Entity to listen event on
24
+ * If value is negative - will assume value of the entity to which the behavior is bound
20
25
  * @type {number}
21
26
  */
22
27
  target: number;
@@ -25,10 +30,7 @@ export class WaitForEventBehavior extends EntityBehavior {
25
30
  target?: number;
26
31
  }): void;
27
32
  tick(timeDelta: any): BehaviorStatus.Running | BehaviorStatus.Succeeded;
28
- /**
29
- * @private
30
- */
31
- private listener;
33
+ #private;
32
34
  }
33
35
  export namespace WaitForEventBehavior {
34
36
  let typeName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"WaitForEventBehavior.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/WaitForEventBehavior.js"],"names":[],"mappings":"AAIA;IA6BI;;;;OAIG;IACH,4BAFY,oBAAoB,CAQ/B;IArCD;;;OAGG;IACH,OAFU,MAAM,CAEL;IAEX;;;OAGG;IACH,UAFU,OAAO,CAEA;IAEjB;;;OAGG;IACH,QAFU,MAAM,CAEJ;IAGZ;;;aAKC;IAeD,wEAMC;IAED;;OAEG;IACH,iBAIC;CAoBJ;;kBAIS,MAAM;;+BAnFe,qBAAqB;+BADrB,sBAAsB"}
1
+ {"version":3,"file":"WaitForEventBehavior.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/WaitForEventBehavior.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH;IA6BI;;;;OAIG;IACH,4BAFY,oBAAoB,CAQ/B;IAtCD;;;OAGG;IACH,OAFU,MAAM,CAEL;IAEX;;;OAGG;IACH,UAFU,OAAO,CAEA;IAEjB;;;;OAIG;IACH,QAFU,MAAM,CAEJ;IAEZ;;;aAMC;IAeD,wEAMC;;CA0BJ;;kBAIS,MAAM;;+BApFe,qBAAqB;+BADrB,sBAAsB"}
@@ -2,9 +2,12 @@ import { assert } from "../../../../core/assert.js";
2
2
  import { BehaviorStatus } from "../BehaviorStatus.js";
3
3
  import { EntityBehavior } from "./EntityBehavior.js";
4
4
 
5
+ /**
6
+ * Wait for a given entity event via {@link EntityComponentDataset#addEntityEventListener}
7
+ * No failure condition, will wait forever until the event is detected
8
+ */
5
9
  export class WaitForEventBehavior extends EntityBehavior {
6
10
 
7
-
8
11
  /**
9
12
  * Event name
10
13
  * @type {string}
@@ -12,20 +15,21 @@ export class WaitForEventBehavior extends EntityBehavior {
12
15
  event = "";
13
16
 
14
17
  /**
15
- *
18
+ * Has the even occurred already?
16
19
  * @type {boolean}
17
20
  */
18
21
  detected = false;
19
22
 
20
23
  /**
21
24
  * Entity to listen event on
25
+ * If value is negative - will assume value of the entity to which the behavior is bound
22
26
  * @type {number}
23
27
  */
24
- target = -1;
25
-
28
+ target = -1; // TODO replace target with an EntityReference instead for tighter binding
26
29
 
27
30
  fromJSON({ event, target = -1 }) {
28
31
  assert.isString(event, 'event');
32
+ assert.isInteger(target, 'target');
29
33
 
30
34
  this.event = event;
31
35
  this.target = target;
@@ -52,13 +56,10 @@ export class WaitForEventBehavior extends EntityBehavior {
52
56
  return BehaviorStatus.Running;
53
57
  }
54
58
 
55
- /**
56
- * @private
57
- */
58
- listener() {
59
+ #listener() {
59
60
  this.detected = true;
60
61
 
61
- this.ecd.removeEntityEventListener(this.target, this.event, this.listener, this);
62
+ this.ecd.removeEntityEventListener(this.target, this.event, this.#listener, this);
62
63
  }
63
64
 
64
65
  initialize(context) {
@@ -67,17 +68,17 @@ export class WaitForEventBehavior extends EntityBehavior {
67
68
  //reset detection flag
68
69
  this.detected = false;
69
70
 
70
- if (this.target === -1) {
71
+ if (this.target < 0) {
71
72
  this.target = this.entity;
72
73
  }
73
74
 
74
- this.ecd.addEntityEventListener(this.target, this.event, this.listener, this);
75
+ this.ecd.addEntityEventListener(this.target, this.event, this.#listener, this);
75
76
  }
76
77
 
77
78
  finalize() {
78
79
  super.finalize();
79
80
 
80
- this.ecd.removeEntityEventListener(this.target, this.event, this.listener, this);
81
+ this.ecd.removeEntityEventListener(this.target, this.event, this.#listener, this);
81
82
  }
82
83
  }
83
84
 
@@ -1 +1 @@
1
- {"version":3,"file":"DelayBehavior.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/util/DelayBehavior.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IAuBI;;;;OAIG;IACH,4BAFY,aAAa,CAMxB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,aAAa,CAYxB;IAhDD,cAeC;IAZG;;;OAGG;IACH,OAFU,MAAM,CAEF;IAEd;;;;OAIG;IACH,gBAAgB;IAGpB;;;aAGC;IA8BD,2BAIC;IAED,wEAQC;CACJ;yBAzEwB,gBAAgB;+BACV,sBAAsB"}
1
+ {"version":3,"file":"DelayBehavior.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/util/DelayBehavior.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IAoBI;;;;OAIG;IACH,4BAFY,aAAa,CAMxB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,aAAa,CAYxB;;IA5CD;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,gBAAY;IAEZ;;;aAGC;IA8BD,2BAIC;IAED,wEAQC;CACJ;yBArEwB,gBAAgB;+BACV,sBAAsB"}
@@ -1,27 +1,24 @@
1
+ import { assert } from "../../../../core/assert.js";
1
2
  import { Behavior } from "../Behavior.js";
2
3
  import { BehaviorStatus } from "../BehaviorStatus.js";
3
- import { assert } from "../../../../core/assert.js";
4
4
 
5
5
  /**
6
6
  * Wait for a certain amount of time
7
7
  */
8
8
  export class DelayBehavior extends Behavior {
9
- constructor() {
10
- super();
11
9
 
12
- /**
13
- * Delay value in seconds
14
- * @type {number}
15
- */
16
- this.value = 0;
10
+ /**
11
+ * Delay value in seconds
12
+ * @type {number}
13
+ */
14
+ value = 0;
17
15
 
18
- /**
19
- * Time elapsed
20
- * @private
21
- * @type {number}
22
- */
23
- this.elapsed = 0;
24
- }
16
+ /**
17
+ * Time elapsed
18
+ * @private
19
+ * @type {number}
20
+ */
21
+ elapsed = 0;
25
22
 
26
23
  fromJSON({ value, elapsed = 0 }) {
27
24
  this.value = value;
@@ -193,7 +193,7 @@ export class SoundEmitter {
193
193
  isPositioned: boolean;
194
194
  isAttenuated: boolean;
195
195
  channel: any;
196
- volume: any;
196
+ volume: number;
197
197
  tracks: any;
198
198
  distanceMin: number;
199
199
  distanceMax: number;