@woosh/meep-engine 2.46.15 → 2.46.16
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.
|
|
7
|
+
"version": "2.46.16",
|
|
8
8
|
"main": "build/meep.module.js",
|
|
9
9
|
"module": "build/meep.module.js",
|
|
10
10
|
"scripts": {
|
|
@@ -103,15 +103,17 @@ export class NodeGraph {
|
|
|
103
103
|
/**
|
|
104
104
|
* Merge another graph into this one
|
|
105
105
|
* Supplied graph does not change as a result
|
|
106
|
+
* @see {@link #mergeFragment}
|
|
106
107
|
* @param {NodeGraph} other
|
|
108
|
+
* @returns {{connections:Connection[], nodes:NodeInstance[]}}
|
|
107
109
|
*/
|
|
108
110
|
merge(other) {
|
|
109
111
|
if (other === this) {
|
|
110
|
-
// can't merge with self, operation
|
|
111
|
-
|
|
112
|
+
// can't merge with self, invalid operation
|
|
113
|
+
throw new Error("Can't merge with self, invalid operation");
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
this.mergeFragment({
|
|
116
|
+
return this.mergeFragment({
|
|
115
117
|
nodes: other.nodes.asArray(),
|
|
116
118
|
connections: other.connections.asArray()
|
|
117
119
|
});
|
|
@@ -122,11 +124,15 @@ export class NodeGraph {
|
|
|
122
124
|
* New node instances and connections will be created to reflect these inside this graph
|
|
123
125
|
* @param {NodeInstance[]} nodes
|
|
124
126
|
* @param {Connection[]} [connections]
|
|
127
|
+
* @returns {{connections:Connection[], nodes:NodeInstance[]}} local created instances
|
|
125
128
|
*/
|
|
126
129
|
mergeFragment({ nodes, connections = [] }) {
|
|
127
130
|
|
|
131
|
+
const previous_node_count = this.nodes.length;
|
|
132
|
+
const previous_connection_count = this.connections.length;
|
|
133
|
+
|
|
128
134
|
const other_nodes = nodes;
|
|
129
|
-
const
|
|
135
|
+
const additional_node_count = other_nodes.length;
|
|
130
136
|
|
|
131
137
|
/**
|
|
132
138
|
* Mapping from original IDs to IDs in this graph
|
|
@@ -134,16 +140,16 @@ export class NodeGraph {
|
|
|
134
140
|
*/
|
|
135
141
|
const this_nodes = {};
|
|
136
142
|
|
|
137
|
-
for (let i = 0; i <
|
|
143
|
+
for (let i = 0; i < additional_node_count; i++) {
|
|
138
144
|
const other_node = other_nodes[i];
|
|
139
145
|
this_nodes[other_node.id] = this.createNode(other_node.description);
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
// create connections
|
|
143
149
|
const other_connections = connections;
|
|
144
|
-
const
|
|
150
|
+
const additional_connection_count = other_connections.length;
|
|
145
151
|
|
|
146
|
-
for (let i = 0; i <
|
|
152
|
+
for (let i = 0; i < additional_connection_count; i++) {
|
|
147
153
|
const other_connection = other_connections[i];
|
|
148
154
|
|
|
149
155
|
const other_source = other_connection.source;
|
|
@@ -162,6 +168,10 @@ export class NodeGraph {
|
|
|
162
168
|
);
|
|
163
169
|
}
|
|
164
170
|
|
|
171
|
+
return {
|
|
172
|
+
connections: this.connections.asArray().slice(previous_connection_count, previous_connection_count + additional_connection_count),
|
|
173
|
+
nodes: this.nodes.asArray().slice(previous_node_count, previous_node_count + additional_node_count)
|
|
174
|
+
};
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
/**
|