Pending
The Pending
class represents a pending state with removed, updated, and created states. It keeps track of changes made to actors, entities, and components.
Example Usage
// Create a new instance of the Pending classconst pending = new Pending();
// Add an actor input to the created inputs statepending.actorInput('actor1', 0);
// Change a component in the created statepending.changeComponent('created', 'entity1', 'component1');
// Mark an entity as createdpending.createEntity('entity2');
// Mark an actor as removedpending.removeActor('actor2');
// Mark a component as removedpending.removeComponent('entity3', 'component2');
// Mark an entity as removedpending.removeEntity('entity4');
// Reset the state of the Pending objectpending.reset();
// Mark an actor as spawnedpending.spawnActor('actor3');
// Insert or update a component in the created statepending.upsertComponent('created', 'entity5', 'component3');
// Add a symbol tuple to the symbols arraypending.addSymbol([symbol1, symbol2]);
// Replace the symbols array with a new array of symbol tuplespending.replaceSymbols(0, [symbol3, symbol4]);
Methods
constructor(isDiffed: boolean = false)
: Constructs a newPending
object and resets its state.actorInput(id: string, index: number): void
: Adds an actor input to the created inputs state.changeComponent(pendingType: string, id: string, key: string): void
: Changes a component in the specified pending state.createEntity(id: string): void
: Marks an entity as created in the created state.removeActor(id: string): void
: Marks an actor as removed in the removed state.removeComponent(id: string, key: string): void
: Marks a component as removed in the removed state.removeEntity(id: string): void
: Marks an entity as removed in the removed state.reset(): void
: Resets the state of thePending
object.spawnActor(id: string): void
: Marks an actor as spawned in the created state.upsertComponent(pendingType: string, id: string, key: string): void
: Inserts or updates a component in the specified pending state.addSymbol(symbolTuple: any)
: Adds a symbol tuple to the symbols array.replaceSymbols(offset: number, symbols: any[])
: Replaces the symbols array with a new array of symbol tuples.
Fields
removed: RemovedState
: The removed state.updated: UpdatedState
: The updated state.created: CreatedState
: The created state.symbols: (number | [InputPayload, number])[]
: The symbols array.isDiffed: boolean
: Indicates whether the pending state is diffed or not.