@@ -27,7 +27,7 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
2727 * Maps entity ID to set of {sourceEntityId, componentType} pairs where componentType uses this entity
2828 * This includes both relation components and direct usage of entities as component types
2929 */
30- private entityAsComponentReverseIndex = new Map < EntityId , Set < { sourceEntityId : EntityId ; componentType : EntityId } > > ( ) ;
30+ private entityReverseIndex = new Map < EntityId , Set < { sourceEntityId : EntityId ; componentType : EntityId } > > ( ) ;
3131
3232 constructor ( ) {
3333 this . commandBuffer = new CommandBuffer ( ( entityId , commands ) => this . executeEntityCommands ( entityId , commands ) ) ;
@@ -94,7 +94,7 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
9494 }
9595
9696 // Clean up the reverse index for this entity
97- this . entityAsComponentReverseIndex . delete ( entityId ) ;
97+ this . entityReverseIndex . delete ( entityId ) ;
9898
9999 archetype . removeEntity ( entityId ) ;
100100 this . entityToArchetype . delete ( entityId ) ;
@@ -286,14 +286,14 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
286286 queryEntities ( componentTypes : EntityId < any > [ ] ) : EntityId [ ] ;
287287 queryEntities < const T extends readonly EntityId < any > [ ] > (
288288 componentTypes : T ,
289- includeComponents : true ,
289+ includeComponents : true
290290 ) : Array < {
291291 entity : EntityId ;
292292 components : ComponentTuple < T > ;
293293 } > ;
294294 queryEntities (
295295 componentTypes : EntityId < any > [ ] ,
296- includeComponents ?: boolean ,
296+ includeComponents ?: boolean
297297 ) :
298298 | EntityId [ ]
299299 | Array < {
@@ -472,10 +472,10 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
472472 * @param targetEntityId The entity being used as component type
473473 */
474474 private addComponentReference ( sourceEntityId : EntityId , componentType : EntityId , targetEntityId : EntityId ) : void {
475- if ( ! this . entityAsComponentReverseIndex . has ( targetEntityId ) ) {
476- this . entityAsComponentReverseIndex . set ( targetEntityId , new Set ( ) ) ;
475+ if ( ! this . entityReverseIndex . has ( targetEntityId ) ) {
476+ this . entityReverseIndex . set ( targetEntityId , new Set ( ) ) ;
477477 }
478- this . entityAsComponentReverseIndex . get ( targetEntityId ) ! . add ( { sourceEntityId, componentType } ) ;
478+ this . entityReverseIndex . get ( targetEntityId ) ! . add ( { sourceEntityId, componentType } ) ;
479479 }
480480
481481 /**
@@ -485,15 +485,15 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
485485 * @param targetEntityId The entity being used as component type
486486 */
487487 private removeComponentReference ( sourceEntityId : EntityId , componentType : EntityId , targetEntityId : EntityId ) : void {
488- const references = this . entityAsComponentReverseIndex . get ( targetEntityId ) ;
488+ const references = this . entityReverseIndex . get ( targetEntityId ) ;
489489 if ( references ) {
490- references . forEach ( ref => {
490+ references . forEach ( ( ref ) => {
491491 if ( ref . sourceEntityId === sourceEntityId && ref . componentType === componentType ) {
492492 references . delete ( ref ) ;
493493 }
494494 } ) ;
495495 if ( references . size === 0 ) {
496- this . entityAsComponentReverseIndex . delete ( targetEntityId ) ;
496+ this . entityReverseIndex . delete ( targetEntityId ) ;
497497 }
498498 }
499499 }
@@ -503,8 +503,10 @@ export class World<ExtraParams extends any[] = [deltaTime: number]> {
503503 * @param targetEntityId The target entity
504504 * @returns Array of {sourceEntityId, componentType} pairs
505505 */
506- private getComponentReferences ( targetEntityId : EntityId ) : Array < { sourceEntityId : EntityId ; componentType : EntityId } > {
507- const references = this . entityAsComponentReverseIndex . get ( targetEntityId ) ;
506+ private getComponentReferences (
507+ targetEntityId : EntityId
508+ ) : Array < { sourceEntityId : EntityId ; componentType : EntityId } > {
509+ const references = this . entityReverseIndex . get ( targetEntityId ) ;
508510 return references ? Array . from ( references ) : [ ] ;
509511 }
510512}
0 commit comments