EntityLocation

View source

Records the storage location and generation for one entity slot.

World keeps one mutable record for each reusable entity-slot index. The identifiers connect an EntityHandle to the entity’s row in a Table and to the matching Archetype. World mutations update the identifiers when a row moves, update another entity’s row after dense removal, and reset the identifiers to -1 when an entity is despawned. The generation is incremented on a later World#spawn when the slot is reused.

Constructor


constructor(archetypeId?: ArchetypeId, index?: TableRow, tableId?: TableId)

View source

Creates a location record.

The storage identifiers default to -1, the invalid sentinel used for a location without a current entity row. Supplied identifiers are assigned as-is; the constructor does not register an entity or look up a table or archetype.

Parameters

NameDescriptionDefault
archetypeId?

Current archetype registry ID.

...
index?

Current row in the table.

...
tableId?

Current table ID.

...

Properties


tableId: TableId

View source

Table containing the entity’s current row.

-1 means that the location does not currently identify a table.

index: TableRow

View source

Row containing the entity in Table.

-1 means that the location does not currently identify a row. Because tables use dense storage, this value can change when rows are moved or removed.

generation: number

View source

Generation assigned to the entity slot.

A new location starts at 0. The world increments this value in World#spawn before creating the corresponding EntityHandle. It remains at its last value when World#despawn invalidates the location so a later reuse receives a new generation.

Default: 0

archetypeId: ArchetypeId

View source

Archetype describing the entity’s current component layout.

This is the ID assigned by the world, not an Archetype instance. -1 means that the location is invalid.