@woosh/meep-engine 2.123.2 → 2.123.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.
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAEI;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC
|
|
1
|
+
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAEI;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;OASG;IACH,2BAAkC;IAElC;;;;;OAKG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;OAGG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,MAAM,CAAC,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,MAAM,CAEe;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,iBALa,CAAC,EAAE,CAAC,UACN,GAAG,iBACH,CAAC,GACC,OAAO,CAAC,CAAC,CAAC,CAoCtB;IAED;;;;;OAKG;IACH,sBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,yBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAuDnB;IAED;;;OAGG;IACH,kBAFa,M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,aACN,MAAM,YACN,SAAU,YACV,GAAC,QA8BX;IAED;;;;;;;;OAQG;IACH,kCAPW,MAAM,aACN,MAAM,gCAEN,GAAC,GAEC,OAAO,CAwCnB;IAED;;;;;OAKG;IACH,2DAeC;IAED;;;;OAIG;IACH,iCAHW,MAAM,GACJ,OAAO,CAenB;IAED;;OAEG;IACH,cAMC;IAED;;;OAGG;IACH,iBAYC;IAED;;;;OAIG;IACH,wBAJa,CAAC,aACH,MAAM,GACJ,IAAI,cAAU,KAAK,CAAC,CAAC,CAAC,CAYlC;IAED;;;;OAIG;IACH,mBAFW,sBAAsB,iCA6DhC;IAED;;;;OAIG;IACH,+EAiDC;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,8CAFW,GAAC,QAgBX;IAGL;;;OAGG;IACH,mCAFU,OAAO,CAEwC;CANxD;mBA15DkB,oCAAoC"}
|
|
@@ -161,12 +161,20 @@ export class EntityComponentDataset {
|
|
|
161
161
|
entityGeneration = new Uint32Array(0);
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
+
* Bit table, if a bit is set - that means component is present.
|
|
165
|
+
* The format is
|
|
166
|
+
* entity_0: [component_0, component_1, ... component_n]
|
|
167
|
+
* entity_1: [component_0, component_1, ... component_n]
|
|
168
|
+
* ...
|
|
169
|
+
* entity_n: [component_0, component_1, ... component_n]
|
|
164
170
|
* @private
|
|
165
171
|
* @type {BitSet}
|
|
166
172
|
*/
|
|
167
173
|
componentOccupancy = new BitSet();
|
|
168
174
|
|
|
169
175
|
/**
|
|
176
|
+
* Do not modify directly.
|
|
177
|
+
* Use {@link setComponentTypeMap} instead.
|
|
170
178
|
* @private
|
|
171
179
|
* @type {Class[]}
|
|
172
180
|
*/
|
|
@@ -425,7 +433,7 @@ export class EntityComponentDataset {
|
|
|
425
433
|
/**
|
|
426
434
|
* Convenience method for retrieving a collection of components for a given entity
|
|
427
435
|
* @param {number} entity ID of the entity
|
|
428
|
-
* @param {
|
|
436
|
+
* @param {[]} componentClasses Classes of components to extract
|
|
429
437
|
* @returns {Array}
|
|
430
438
|
*/
|
|
431
439
|
getComponents(entity, componentClasses) {
|
|
@@ -495,6 +503,7 @@ export class EntityComponentDataset {
|
|
|
495
503
|
/**
|
|
496
504
|
* Modify dataset component mapping. Algorithm will attempt to mutate dataset even if entities exist, however, it will not remove component classes for which instances exist in the dataset.
|
|
497
505
|
* @param {Class[]} map collection of component classes
|
|
506
|
+
* @returns {void}
|
|
498
507
|
* @throws Error when attempting to remove component classes with live instances
|
|
499
508
|
*/
|
|
500
509
|
setComponentTypeMap(map) {
|
|
@@ -598,6 +607,8 @@ export class EntityComponentDataset {
|
|
|
598
607
|
for (i = 0, l = typesToAdd.length; i < l; i++) {
|
|
599
608
|
const type = typesToAdd[i];
|
|
600
609
|
|
|
610
|
+
assert.defined(type, 'type');
|
|
611
|
+
|
|
601
612
|
const newIndex = map.indexOf(type);
|
|
602
613
|
|
|
603
614
|
//initialize component store
|
|
@@ -683,10 +694,13 @@ export class EntityComponentDataset {
|
|
|
683
694
|
/**
|
|
684
695
|
*
|
|
685
696
|
* @param {Class[]} types
|
|
686
|
-
* @returns {boolean}
|
|
697
|
+
* @returns {boolean} true if all types are present, false otherwise
|
|
687
698
|
*/
|
|
688
699
|
areComponentTypesRegistered(types) {
|
|
689
|
-
|
|
700
|
+
assert.isArray(types, 'types');
|
|
701
|
+
|
|
702
|
+
const count = types.length;
|
|
703
|
+
for (let i = 0; i < count; i++) {
|
|
690
704
|
const type = types[i];
|
|
691
705
|
|
|
692
706
|
if (!this.isComponentTypeRegistered(type)) {
|
|
@@ -704,6 +718,9 @@ export class EntityComponentDataset {
|
|
|
704
718
|
* @return {boolean}
|
|
705
719
|
*/
|
|
706
720
|
isComponentTypeRegistered(type) {
|
|
721
|
+
assert.defined(type, 'type');
|
|
722
|
+
assert.notNull(type, 'type');
|
|
723
|
+
|
|
707
724
|
const componentTypeMap = this.getComponentTypeMap();
|
|
708
725
|
|
|
709
726
|
return componentTypeMap.indexOf(type) !== -1;
|
|
@@ -762,7 +779,8 @@ export class EntityComponentDataset {
|
|
|
762
779
|
* @returns {boolean} true iff component is removed, false if it was not registered
|
|
763
780
|
*/
|
|
764
781
|
unregisterComponentType(type) {
|
|
765
|
-
|
|
782
|
+
|
|
783
|
+
if (!this.isComponentTypeRegistered(type)) {
|
|
766
784
|
// not registered
|
|
767
785
|
return false;
|
|
768
786
|
}
|
|
@@ -806,7 +824,7 @@ export class EntityComponentDataset {
|
|
|
806
824
|
*/
|
|
807
825
|
getEntityGeneration(entity_id) {
|
|
808
826
|
assert.isNonNegativeInteger(entity_id, 'entity_id');
|
|
809
|
-
assert.ok(this.entityExists(entity_id)
|
|
827
|
+
assert.ok(this.entityExists(entity_id), `Entity ${entity_id} does not exist`);
|
|
810
828
|
|
|
811
829
|
return this.entityGeneration[entity_id];
|
|
812
830
|
}
|
|
@@ -1003,10 +1021,13 @@ export class EntityComponentDataset {
|
|
|
1003
1021
|
|
|
1004
1022
|
/**
|
|
1005
1023
|
*
|
|
1006
|
-
* @param klass
|
|
1024
|
+
* @param {Function|Class} klass
|
|
1007
1025
|
* @returns {number}
|
|
1008
1026
|
*/
|
|
1009
1027
|
computeComponentTypeIndex(klass) {
|
|
1028
|
+
assert.defined(klass, "klass");
|
|
1029
|
+
assert.notNull(klass, "klass");
|
|
1030
|
+
|
|
1010
1031
|
const idx = this.__type_to_index_map.get(klass);
|
|
1011
1032
|
|
|
1012
1033
|
if (idx === undefined) {
|
|
@@ -1399,13 +1420,15 @@ export class EntityComponentDataset {
|
|
|
1399
1420
|
traverseComponentsByIndex(componentTypeIndex, visitor, thisArg) {
|
|
1400
1421
|
|
|
1401
1422
|
assert.isNumber(componentTypeIndex, "componentTypeIndex");
|
|
1423
|
+
assert.isNonNegativeInteger(componentTypeIndex, "componentTypeIndex");
|
|
1402
1424
|
assert.isFunction(visitor, "visitor");
|
|
1403
1425
|
|
|
1404
1426
|
this.__traverseComponentsByIndex_via_property(componentTypeIndex, visitor, thisArg);
|
|
1405
1427
|
}
|
|
1406
1428
|
|
|
1407
1429
|
/**
|
|
1408
|
-
*
|
|
1430
|
+
* Alternative to {@link __traverseComponentsByIndex_via_property} as of 2020, appears to be significantly slower on Chrome with larger datasets
|
|
1431
|
+
* @private
|
|
1409
1432
|
* @param {number} componentTypeIndex
|
|
1410
1433
|
* @param {function} visitor
|
|
1411
1434
|
* @param {*} [thisArg]
|
|
@@ -1438,7 +1461,7 @@ export class EntityComponentDataset {
|
|
|
1438
1461
|
}
|
|
1439
1462
|
|
|
1440
1463
|
/**
|
|
1441
|
-
*
|
|
1464
|
+
* @private
|
|
1442
1465
|
* @param {number} componentTypeIndex
|
|
1443
1466
|
* @param {function} visitor
|
|
1444
1467
|
* @param {*} [thisArg]
|
|
@@ -1574,6 +1597,9 @@ export class EntityComponentDataset {
|
|
|
1574
1597
|
* @returns {boolean}
|
|
1575
1598
|
*/
|
|
1576
1599
|
removeAnyEventListener(entity, listener, thisArg) {
|
|
1600
|
+
assert.isNonNegativeInteger(entity, "entity");
|
|
1601
|
+
assert.isFunction(listener, "listener");
|
|
1602
|
+
|
|
1577
1603
|
const evl = this.__entityAnyEventListeners;
|
|
1578
1604
|
|
|
1579
1605
|
let handlers = evl[entity];
|
|
@@ -1609,7 +1635,7 @@ export class EntityComponentDataset {
|
|
|
1609
1635
|
* @param {*} [thisArg]
|
|
1610
1636
|
*/
|
|
1611
1637
|
addEntityEventListener(entity, eventName, listener, thisArg) {
|
|
1612
|
-
|
|
1638
|
+
assert.isNonNegativeInteger(entity, "entity");
|
|
1613
1639
|
assert.isString(eventName, "eventName");
|
|
1614
1640
|
assert.isFunction(listener, "listener");
|
|
1615
1641
|
|
|
@@ -1648,6 +1674,10 @@ export class EntityComponentDataset {
|
|
|
1648
1674
|
* @returns {boolean}
|
|
1649
1675
|
*/
|
|
1650
1676
|
removeEntityEventListener(entity, eventName, listener, thisArg) {
|
|
1677
|
+
assert.isNonNegativeInteger(entity, "entity");
|
|
1678
|
+
assert.isString(eventName, "eventName");
|
|
1679
|
+
assert.isFunction(listener, "listener");
|
|
1680
|
+
|
|
1651
1681
|
const evl = this.__entityEventListeners;
|
|
1652
1682
|
|
|
1653
1683
|
const hash = evl[entity];
|