@woosh/meep-engine 2.46.10 → 2.46.12

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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "productName": "Meep",
5
5
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
6
6
  "author": "Alexander Goldring",
7
- "version": "2.46.10",
7
+ "version": "2.46.12",
8
8
  "main": "build/meep.module.js",
9
9
  "module": "build/meep.module.js",
10
10
  "scripts": {
@@ -126,6 +126,32 @@ export class NodeGraph {
126
126
  return true;
127
127
  }
128
128
 
129
+ /**
130
+ *
131
+ * @param {NodeDescription} description
132
+ * @returns {NodeInstance[]}
133
+ */
134
+ getNodesByDescription(description) {
135
+ assert.defined(description, 'description');
136
+ assert.notNull(description, 'description');
137
+ assert.equal(description.isNodeDescription, true, 'description.isNodeDescription !== true');
138
+
139
+ const result = [];
140
+
141
+ const nodes = this.nodes;
142
+ const n = nodes.length;
143
+
144
+ for (let i = 0; i < n; i++) {
145
+ const node = nodes.get(i);
146
+
147
+ if (node.description === description) {
148
+ result.push(node);
149
+ }
150
+ }
151
+
152
+ return result;
153
+ }
154
+
129
155
  /**
130
156
  *
131
157
  * @param {number} id
@@ -43,6 +43,7 @@ export class NodeRegistry {
43
43
  addNode(node) {
44
44
  assert.defined(node, "node");
45
45
  assert.notNull(node, "node");
46
+ assert.equal(node.isNodeDescription, true, 'node.isNodeDescription !== true');
46
47
 
47
48
  const existing_node = this.nodes.get(node.id);
48
49
 
@@ -66,6 +67,67 @@ export class NodeRegistry {
66
67
  return true;
67
68
  }
68
69
 
70
+ /**
71
+ *
72
+ * @param {NodeDescription} node
73
+ * @returns {boolean}
74
+ */
75
+ hasNode(node) {
76
+ assert.defined(node, "node");
77
+ assert.notNull(node, "node");
78
+ assert.equal(node.isNodeDescription, true, 'node.isNodeDescription !== true');
79
+
80
+ const existing = this.nodes.get(node.id);
81
+
82
+ if (existing === undefined) {
83
+ return false;
84
+ }
85
+
86
+ if (existing !== node) {
87
+ return false;
88
+ }
89
+
90
+ return true;
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @param {NodeDescription} node
96
+ * @returns {boolean}
97
+ */
98
+ removeNode(node) {
99
+ assert.defined(node, "node");
100
+ assert.notNull(node, "node");
101
+ assert.equal(node.isNodeDescription, true, 'node.isNodeDescription !== true');
102
+
103
+ if (!this.hasNode(node)) {
104
+ // not found
105
+ return false;
106
+ }
107
+
108
+ this.nodes.delete(node.id);
109
+
110
+ return true;
111
+ }
112
+
113
+ /**
114
+ * Given a class inheriting from NodeDescription, get all registered instances
115
+ * Matching is strict, instances of subclasses are not matched
116
+ * @param {Type<NodeDescription>} Klass
117
+ * @returns {NodeDescription[]}
118
+ */
119
+ getNodesByClass(Klass) {
120
+ const result = [];
121
+
122
+ for (const [id, node] of this.nodes) {
123
+ if (node.constructor === Klass) {
124
+ result.push(node);
125
+ }
126
+ }
127
+
128
+ return result;
129
+ }
130
+
69
131
  /**
70
132
  *
71
133
  * @param {DataType} type