archetype-ecs-lib 0.6.0 → 0.6.1
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/README.md +1 -1
- package/lib/ecs/Schedule.js +47 -43
- package/lib/ecs/World.js +24 -5
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/ecs/Schedule.js
CHANGED
|
@@ -183,61 +183,65 @@ var Schedule = /** @class */ (function () {
|
|
|
183
183
|
}
|
|
184
184
|
var frameStart = worldInstance._profBeginFrame(dt);
|
|
185
185
|
try {
|
|
186
|
-
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
error.message
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
186
|
+
try {
|
|
187
|
+
for (var phases_1 = __values(phases), phases_1_1 = phases_1.next(); !phases_1_1.done; phases_1_1 = phases_1.next()) {
|
|
188
|
+
var phase = phases_1_1.value;
|
|
189
|
+
var phaseStart = performance.now();
|
|
190
|
+
var list = world._scheduleSystems.get(phase);
|
|
191
|
+
// Run systems only if they exist for this phase
|
|
192
|
+
if (list) {
|
|
193
|
+
try {
|
|
194
|
+
for (var list_1 = (e_2 = void 0, __values(list)), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
|
|
195
|
+
var fn = list_1_1.value;
|
|
196
|
+
var sysStart = performance.now();
|
|
197
|
+
try {
|
|
198
|
+
fn(world, dt);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
var sysName = fn.name && fn.name.length > 0 ? fn.name : "<anonymous>";
|
|
202
|
+
var msg = error.message !== undefined && typeof error.message === 'string' ?
|
|
203
|
+
error.message : JSON.stringify(error);
|
|
204
|
+
var e = new Error("[phase=".concat(phase, " system=").concat(sysName, "] ").concat(msg));
|
|
205
|
+
e.cause = error;
|
|
206
|
+
throw e;
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
var sysName = fn.name && fn.name.length > 0 ? fn.name : "<anonymous>";
|
|
210
|
+
worldInstance._profAddSystem("".concat(phase, ":").concat(sysName), performance.now() - sysStart);
|
|
211
|
+
}
|
|
206
212
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
}
|
|
214
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
215
|
+
finally {
|
|
216
|
+
try {
|
|
217
|
+
if (list_1_1 && !list_1_1.done && (_b = list_1.return)) _b.call(list_1);
|
|
210
218
|
}
|
|
219
|
+
finally { if (e_2) throw e_2.error; }
|
|
211
220
|
}
|
|
212
221
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
if (this.boundaryMode !== "manual") {
|
|
223
|
+
// apply deferred commands between phases
|
|
224
|
+
if (world.cmd().hasPending()) {
|
|
225
|
+
world.flush();
|
|
217
226
|
}
|
|
218
|
-
|
|
227
|
+
// deliver events emitted in this phase to the next phase
|
|
228
|
+
world.swapEvents();
|
|
219
229
|
}
|
|
230
|
+
worldInstance._profAddPhase(phase, performance.now() - phaseStart);
|
|
220
231
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// deliver events emitted in this phase to the next phase
|
|
227
|
-
world.swapEvents();
|
|
232
|
+
}
|
|
233
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
234
|
+
finally {
|
|
235
|
+
try {
|
|
236
|
+
if (phases_1_1 && !phases_1_1.done && (_a = phases_1.return)) _a.call(phases_1);
|
|
228
237
|
}
|
|
229
|
-
|
|
238
|
+
finally { if (e_1) throw e_1.error; }
|
|
230
239
|
}
|
|
231
240
|
}
|
|
232
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
233
241
|
finally {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
finally { if (e_1) throw e_1.error; }
|
|
242
|
+
worldInstance._profEndFrame(frameStart);
|
|
243
|
+
worldInstance.updateOverlay(worldInstance.stats(), worldInstance.statsHistory());
|
|
238
244
|
}
|
|
239
|
-
worldInstance._profEndFrame(frameStart);
|
|
240
|
-
worldInstance.updateOverlay(worldInstance.stats(), worldInstance.statsHistory());
|
|
241
245
|
};
|
|
242
246
|
/**
|
|
243
247
|
* Record a phase ordering constraint `before -> after`.
|
package/lib/ecs/World.js
CHANGED
|
@@ -271,6 +271,7 @@ var World = /** @class */ (function (_super) {
|
|
|
271
271
|
}
|
|
272
272
|
var frameStart = this._profBeginFrame(dt);
|
|
273
273
|
this._iterateDepth++;
|
|
274
|
+
var caughtError;
|
|
274
275
|
try {
|
|
275
276
|
try {
|
|
276
277
|
for (var _b = __values(this.systems), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -294,13 +295,25 @@ var World = /** @class */ (function (_super) {
|
|
|
294
295
|
finally { if (e_7) throw e_7.error; }
|
|
295
296
|
}
|
|
296
297
|
}
|
|
298
|
+
catch (e) {
|
|
299
|
+
caughtError = e;
|
|
300
|
+
}
|
|
297
301
|
finally {
|
|
298
302
|
this._iterateDepth--;
|
|
299
|
-
|
|
303
|
+
try {
|
|
304
|
+
this.flush();
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
// System error takes priority; flush error only surfaced when no system threw.
|
|
308
|
+
if (caughtError === undefined)
|
|
309
|
+
caughtError = e;
|
|
310
|
+
}
|
|
300
311
|
this.swapEvents();
|
|
301
312
|
this._profAddPhase("update", this._profilingEnabled ? (performance.now() - frameStart) : 0);
|
|
302
313
|
this._profEndFrame(frameStart);
|
|
303
314
|
}
|
|
315
|
+
if (caughtError !== undefined)
|
|
316
|
+
throw caughtError;
|
|
304
317
|
this.updateOverlay(this.stats(), this.statsHistory());
|
|
305
318
|
};
|
|
306
319
|
World.prototype.flush = function () {
|
|
@@ -668,11 +681,12 @@ var World = /** @class */ (function (_super) {
|
|
|
668
681
|
});
|
|
669
682
|
};
|
|
670
683
|
World.prototype.query = function () {
|
|
684
|
+
var _a;
|
|
671
685
|
var ctors = [];
|
|
672
686
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
673
687
|
ctors[_i] = arguments[_i];
|
|
674
688
|
}
|
|
675
|
-
var
|
|
689
|
+
var _b = World._buildQueryTypeIds(ctors), requested = _b.requested, needSorted = _b.needSorted;
|
|
676
690
|
function gen(world) {
|
|
677
691
|
var _a, _b, a, cols, i, row, e, out, i, e_16_1;
|
|
678
692
|
var e_16, _c;
|
|
@@ -735,14 +749,17 @@ var World = /** @class */ (function (_super) {
|
|
|
735
749
|
}
|
|
736
750
|
});
|
|
737
751
|
}
|
|
738
|
-
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
753
|
+
var self = this;
|
|
754
|
+
return _a = {}, _a[Symbol.iterator] = function () { return gen(self); }, _a;
|
|
739
755
|
};
|
|
740
756
|
World.prototype.queryTables = function () {
|
|
757
|
+
var _a;
|
|
741
758
|
var ctors = [];
|
|
742
759
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
743
760
|
ctors[_i] = arguments[_i];
|
|
744
761
|
}
|
|
745
|
-
var
|
|
762
|
+
var _b = World._buildQueryTypeIds(ctors), requested = _b.requested, needSorted = _b.needSorted;
|
|
746
763
|
function gen(world) {
|
|
747
764
|
var _a, _b, a, out, i, e_17_1;
|
|
748
765
|
var e_17, _c;
|
|
@@ -795,7 +812,9 @@ var World = /** @class */ (function (_super) {
|
|
|
795
812
|
}
|
|
796
813
|
});
|
|
797
814
|
}
|
|
798
|
-
|
|
815
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
816
|
+
var self = this;
|
|
817
|
+
return _a = {}, _a[Symbol.iterator] = function () { return gen(self); }, _a;
|
|
799
818
|
};
|
|
800
819
|
World.prototype.queryEach = function () {
|
|
801
820
|
var e_18, _a;
|