@woosh/meep-engine 2.84.4 → 2.84.5
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/build/meep.cjs
CHANGED
|
@@ -72504,6 +72504,7 @@ class Entity {
|
|
|
72504
72504
|
* @returns {*|null}
|
|
72505
72505
|
*/
|
|
72506
72506
|
removeComponent(klass) {
|
|
72507
|
+
|
|
72507
72508
|
const elements = this.components;
|
|
72508
72509
|
const n = elements.length;
|
|
72509
72510
|
|
|
@@ -72629,6 +72630,7 @@ class Entity {
|
|
|
72629
72630
|
dataset.removeEntity(entity);
|
|
72630
72631
|
|
|
72631
72632
|
this.id = -1;
|
|
72633
|
+
this.generation = -1;
|
|
72632
72634
|
|
|
72633
72635
|
this.clearFlag(EntityFlags.Built);
|
|
72634
72636
|
|
|
@@ -72654,6 +72656,7 @@ class Entity {
|
|
|
72654
72656
|
}
|
|
72655
72657
|
|
|
72656
72658
|
const entity = this.id = dataset.createEntity();
|
|
72659
|
+
this.generation = dataset.getEntityGeneration(entity);
|
|
72657
72660
|
this.dataset = dataset;
|
|
72658
72661
|
|
|
72659
72662
|
let i;
|
|
@@ -72711,6 +72714,7 @@ class Entity {
|
|
|
72711
72714
|
r.setFlag(EntityFlags.Built);
|
|
72712
72715
|
r.id = entity;
|
|
72713
72716
|
r.dataset = dataset;
|
|
72717
|
+
r.generation = dataset.getEntityGeneration(entity);
|
|
72714
72718
|
|
|
72715
72719
|
return r;
|
|
72716
72720
|
}
|
|
@@ -84052,7 +84056,13 @@ class AssetDescription {
|
|
|
84052
84056
|
toString() {
|
|
84053
84057
|
return `{ type: '${this.type}', path: '${this.path}' }`;
|
|
84054
84058
|
}
|
|
84055
|
-
}
|
|
84059
|
+
}
|
|
84060
|
+
|
|
84061
|
+
/**
|
|
84062
|
+
* @readonly
|
|
84063
|
+
* @type {boolean}
|
|
84064
|
+
*/
|
|
84065
|
+
AssetDescription.prototype.isAssetDescription = true;
|
|
84056
84066
|
|
|
84057
84067
|
/**
|
|
84058
84068
|
* @enum {number}
|
|
@@ -92362,6 +92372,15 @@ class EntityComponentDataset {
|
|
|
92362
92372
|
* @type {BitSet}
|
|
92363
92373
|
*/
|
|
92364
92374
|
entityOccupancy = new BitSet();
|
|
92375
|
+
|
|
92376
|
+
/**
|
|
92377
|
+
* For each entity ID records generation when entity was created
|
|
92378
|
+
* Values are invalid for unused entity IDs
|
|
92379
|
+
* @private
|
|
92380
|
+
* @type {Uint32Array}
|
|
92381
|
+
*/
|
|
92382
|
+
entityGeneration = new Uint32Array(0);
|
|
92383
|
+
|
|
92365
92384
|
/**
|
|
92366
92385
|
* @private
|
|
92367
92386
|
* @type {BitSet}
|
|
@@ -92413,7 +92432,7 @@ class EntityComponentDataset {
|
|
|
92413
92432
|
|
|
92414
92433
|
/**
|
|
92415
92434
|
* @readonly
|
|
92416
|
-
* @type {Signal}
|
|
92435
|
+
* @type {Signal<number>}
|
|
92417
92436
|
*/
|
|
92418
92437
|
onEntityCreated = new Signal();
|
|
92419
92438
|
|
|
@@ -92963,38 +92982,79 @@ class EntityComponentDataset {
|
|
|
92963
92982
|
|
|
92964
92983
|
/**
|
|
92965
92984
|
*
|
|
92966
|
-
* @
|
|
92985
|
+
* @param {number} min_size
|
|
92967
92986
|
*/
|
|
92968
|
-
|
|
92969
|
-
const
|
|
92970
|
-
this.entityOccupancy.set(entityIndex, true);
|
|
92987
|
+
enlargeGenerationTable(min_size) {
|
|
92988
|
+
const old_generation_table_size = this.entityGeneration.length;
|
|
92971
92989
|
|
|
92972
|
-
|
|
92990
|
+
const new_size = max3(
|
|
92991
|
+
min_size,
|
|
92992
|
+
Math.ceil(old_generation_table_size * 1.2),
|
|
92993
|
+
old_generation_table_size + 16
|
|
92994
|
+
);
|
|
92973
92995
|
|
|
92974
|
-
|
|
92996
|
+
const new_generation_table = new Uint32Array(new_size);
|
|
92975
92997
|
|
|
92976
|
-
this.
|
|
92998
|
+
new_generation_table.set(this.entityGeneration);
|
|
92977
92999
|
|
|
92978
|
-
|
|
93000
|
+
this.entityGeneration = new_generation_table;
|
|
92979
93001
|
}
|
|
92980
93002
|
|
|
92981
93003
|
/**
|
|
92982
|
-
*
|
|
92983
|
-
* @param {number}
|
|
92984
|
-
* @
|
|
93004
|
+
* Produces generation ID for a given entity
|
|
93005
|
+
* @param {number} entity_id
|
|
93006
|
+
* @returns {number}
|
|
92985
93007
|
*/
|
|
92986
|
-
|
|
92987
|
-
|
|
92988
|
-
|
|
93008
|
+
getEntityGeneration(entity_id) {
|
|
93009
|
+
return this.entityGeneration[entity_id];
|
|
93010
|
+
}
|
|
93011
|
+
|
|
93012
|
+
/**
|
|
93013
|
+
* @private
|
|
93014
|
+
* @param {number} entity_id
|
|
93015
|
+
*/
|
|
93016
|
+
createEntityUnsafe(entity_id) {
|
|
93017
|
+
this.entityOccupancy.set(entity_id, true);
|
|
93018
|
+
|
|
93019
|
+
// record entity generation
|
|
93020
|
+
if (this.entityGeneration.length <= entity_id) {
|
|
93021
|
+
// needs to be resized
|
|
93022
|
+
this.enlargeGenerationTable(entity_id + 1);
|
|
92989
93023
|
}
|
|
92990
93024
|
|
|
92991
|
-
this.
|
|
93025
|
+
const current_generation = this.generation;
|
|
93026
|
+
this.generation = current_generation + 1;
|
|
93027
|
+
|
|
93028
|
+
this.entityGeneration[entity_id] = current_generation;
|
|
92992
93029
|
|
|
92993
93030
|
this.entityCount++;
|
|
92994
93031
|
|
|
92995
|
-
this.onEntityCreated.send1(
|
|
93032
|
+
this.onEntityCreated.send1(entity_id);
|
|
93033
|
+
}
|
|
93034
|
+
|
|
93035
|
+
/**
|
|
93036
|
+
*
|
|
93037
|
+
* @returns {number} entityIndex
|
|
93038
|
+
*/
|
|
93039
|
+
createEntity() {
|
|
93040
|
+
const entity_id = this.entityOccupancy.nextClearBit(0);
|
|
93041
|
+
|
|
93042
|
+
this.createEntityUnsafe(entity_id);
|
|
93043
|
+
|
|
93044
|
+
return entity_id;
|
|
93045
|
+
}
|
|
93046
|
+
|
|
93047
|
+
/**
|
|
93048
|
+
*
|
|
93049
|
+
* @param {number} entity_id
|
|
93050
|
+
* @throws {Error} if entity index is already in use
|
|
93051
|
+
*/
|
|
93052
|
+
createEntitySpecific(entity_id) {
|
|
93053
|
+
if (this.entityExists(entity_id)) {
|
|
93054
|
+
throw new Error(`EntityId ${entity_id} is already in use`);
|
|
93055
|
+
}
|
|
92996
93056
|
|
|
92997
|
-
this.
|
|
93057
|
+
this.createEntityUnsafe(entity_id);
|
|
92998
93058
|
}
|
|
92999
93059
|
|
|
93000
93060
|
/**
|
|
@@ -93119,7 +93179,7 @@ class EntityComponentDataset {
|
|
|
93119
93179
|
const componentClass = this.componentTypeMap[componentIndex];
|
|
93120
93180
|
|
|
93121
93181
|
//dispatch event to components
|
|
93122
|
-
this.sendEvent(entityIndex, EventType.ComponentRemoved, {klass: componentClass, instance: componentInstance});
|
|
93182
|
+
this.sendEvent(entityIndex, EventType.ComponentRemoved, { klass: componentClass, instance: componentInstance });
|
|
93123
93183
|
}
|
|
93124
93184
|
|
|
93125
93185
|
/**
|
|
@@ -93220,7 +93280,7 @@ class EntityComponentDataset {
|
|
|
93220
93280
|
const componentClass = this.componentTypeMap[componentIndex];
|
|
93221
93281
|
|
|
93222
93282
|
//dispatch event to components
|
|
93223
|
-
this.sendEvent(entityIndex, EventType.ComponentAdded, {klass: componentClass, instance: componentInstance});
|
|
93283
|
+
this.sendEvent(entityIndex, EventType.ComponentAdded, { klass: componentClass, instance: componentInstance });
|
|
93224
93284
|
}
|
|
93225
93285
|
|
|
93226
93286
|
/**
|