### SystemBuilder.setup Method Source: https://nsstc.github.io/sim-ecs/classes/SystemBuilder Adds a setup function that is called when the system is instantiated, for example, on a new world run. This method returns the SystemBuilder instance for chaining. ```TypeScript setup( fn: TSystemFunction>, ) => SystemBuilder> ``` -------------------------------- ### SystemBuilder.withSetupFunction Method Source: https://nsstc.github.io/sim-ecs/classes/SystemBuilder Adds a setup function that executes during system instantiation, such as at the start of a new world run. Returns the SystemBuilder for fluent chaining. ```TypeScript withSetupFunction( fn: TSystemFunction>, ): SystemBuilder> ``` -------------------------------- ### Build and Run Pong Example Source: https://nsstc.github.io/sim-ecs/index Builds and runs the 'pong' example, a full game demonstrating all sim-ecs features in the browser. It includes components, systems, states, and prefabs. ```bash $cd examples/pong && npm install && npm run start ``` -------------------------------- ### ISystemBuilder.withSetupFunction() Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISystemBuilder Adds a setup function to the system. This function is executed once when the system is initialized, typically at the start of a new simulation or world instance. ```TypeScript withSetupFunction( fn: TSystemFunction>, ): ISystemBuilder> ``` -------------------------------- ### Run Counter Example Source: https://nsstc.github.io/sim-ecs/index Executes the 'counter' example provided with sim-ecs. This example is minimal and demonstrates basic functionality by incrementing a number. ```bash $npm run example-counter ``` -------------------------------- ### Run Events Example Source: https://nsstc.github.io/sim-ecs/index Runs the 'events' example, showcasing the use of the event bus for writing and reading events. It prints a message every second. ```bash $npm run example-events ``` -------------------------------- ### RuntimeWorld: prepare method Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Prepares the simulation world for execution, performing necessary setup operations. ```TypeScript prepare(): Promise ``` -------------------------------- ### IRuntimeWorld Methods Source: https://nsstc.github.io/sim-ecs/interfaces/IRuntimeWorld This section outlines the methods available on the IRuntimeWorld interface. These include querying entities, getting resources, checking for entities and resources, replacing systems, refreshing entity registrations, and managing the world's lifecycle (start, step, stop). ```TypeScript getEntities(query?: Readonly): IterableIterator; getGroupEntities(groupHandle: number): IterableIterator; getResource(type: TTypeProto): T; getResources( types?: readonly TExistenceQueryParameter[], ): IterableIterator; hasEntity(entity: Readonly): boolean; hasResource(type: T | TTypeProto): boolean; hmrReplaceSystem(newSystem: ISystem): void; refreshEntityQueryRegistration(entity: Readonly): void; replaceResource( obj: T | TTypeProto, ...args: readonly unknown[], ): Promise; save(options?: Readonly>): ISerialFormat; start(): Promise; step(): Promise; stop(): void; ``` -------------------------------- ### Install sim-ecs with npm Source: https://nsstc.github.io/sim-ecs/index Installs the sim-ecs package using npm. This is the standard way to add the library to your project for use in Node.js or browser environments. ```bash $npm install sim-ecs ``` -------------------------------- ### RuntimeWorld: start method Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Starts the continuous execution of the simulation world. The returned Promise resolves when the execution terminates. ```TypeScript start(): Promise ``` -------------------------------- ### Set and Get Resources (JavaScript) Source: https://nsstc.github.io/sim-ecs/index Demonstrates how to add and retrieve resources from the world. Resources are objects that hold specific data, such as the start DateTime. ```javascript // this call implicitely creates a new object of type Date. You can also pass an instance instead. // you can pass arguments to the constructor by passing them as additional parameters here prepWorld.addResource(Date); console.log(world.getResource(Date).getDate()); ``` -------------------------------- ### Prepare Runtime World Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Asynchronously prepares a runtime environment from the current `PreptimeWorld`. Optional preparation options can be passed to customize the runtime setup. ```TypeScript prepareRun( options?: Readonly>, ): Promise ``` -------------------------------- ### ISystemBuilder.setup() Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISystemBuilder An alias for the withSetupFunction method, the setup method accepts a system function that is invoked when the system is instantiated, typically at the beginning of a new world run. ```TypeScript setup( fn: TSystemFunction>, ): ISystemBuilder> ``` -------------------------------- ### start - sim-ecs Source: https://nsstc.github.io/sim-ecs/interfaces/IRuntimeWorld Initiates continuous execution of the world's systems. The returned Promise resolves once the execution is terminated. ```TypeScript start(): Promise ``` -------------------------------- ### Run System Error Example Source: https://nsstc.github.io/sim-ecs/index Executes the 'system-error' example, demonstrating how sim-ecs handles errors using its event system. Errors are caught and handled without aborting execution. ```bash $npm run example-system-error ``` -------------------------------- ### SimECS System Creation and Management Source: https://nsstc.github.io/sim-ecs/classes/SerDe Utilities for creating, querying, and managing systems within SimECS. This includes getting system run parameters and swapping systems during runtime. ```TypeScript createSystem getQueriesFromSystem getSystemRunParameters hmrSwapSystem ``` -------------------------------- ### State create Method Source: https://nsstc.github.io/sim-ecs/classes/State Executes tasks when the state is created within the PDA. This method implements the IState.create interface, handling initial setup for the state. ```TypeScript create(_actions: Readonly): void | Promise ``` -------------------------------- ### Get All Resources Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Retrieves all resources currently stored within the world. This is particularly useful for debugging purposes. It accepts an optional array of existence query parameters. ```TypeScript getResources: ( this: PreptimeWorld | RuntimeWorld, types?: readonly TExistenceQueryParameter[] ) => IterableIterator ``` -------------------------------- ### Create Prepare-Time World (JavaScript) Source: https://nsstc.github.io/sim-ecs/index Initializes a prepare-time world for simulation setup. This world is used for defining and preparing all simulation elements before execution. ```javascript const prepWorld = buildWorld().build(); ``` -------------------------------- ### Configuration and Initialization in SimECS Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld This snippet covers the configuration options and initialization process for SimECS, including setting up the world and its components. ```TypeScript interface IRuntimeWorldInitConfig { // ... } class WorldBuilder { static create(config?: IRuntimeWorldInitConfig): WorldBuilder; build(): World; } // Example initialization: const worldConfig = { // ... }; const world = WorldBuilder.create(worldConfig).build(); ``` -------------------------------- ### PreptimeWorld Constructor Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Initializes a new instance of the PreptimeWorld class. It can optionally accept a name, configuration object, and initial data. ```TypeScript constructor( name?: string, $config?: Partial, $data?: Partial ): PreptimeWorld ``` -------------------------------- ### Start sim-ecs Simulation Source: https://nsstc.github.io/sim-ecs/index Starts the simulation loop for sim-ecs. The simulation runs based on the provided world data. It includes basic error handling for non-fatal errors and logs completion. ```JavaScript runWorld.start() .catch(console.error) .then(() =>console.log('Finished.')); ``` -------------------------------- ### World Builder and Configuration Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder Interfaces for building and configuring worlds, including runtime initialization options. ```Rust WorldBuilder IWorld IWorldBuilder IRuntimeWorld IRuntimeWorldData IRuntimeWorldInitConfig IRuntimeWorldInitData IImmutableWorld IMutableWorld IPreptimeWorld IPreptimeWorldConfig IPreptimeData IPreptimeOptions IObjectRegistrationOptions ``` -------------------------------- ### World Building and System Creation Source: https://nsstc.github.io/sim-ecs/interfaces/IImmutableWorld Utilities for constructing and configuring SimECS worlds and systems. This includes building worlds from configurations, creating new systems, and managing system execution. ```Rust buildWorld() createSystem() getQueriesFromSystem() getSystemRunParameters() ``` -------------------------------- ### Get Resource - sim-ecs RuntimeWorld Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Retrieves a stored resource by its type. Implements IRuntimeWorld.getResource. ```TypeScript getResource: (this: RuntimeWorld, type: TTypeProto) => T = getResource // Get a resource which was previously stored // Implementation of IRuntimeWorld.getResource // Defined in src/world/runtime/runtime-world.ts:399 ``` -------------------------------- ### System Creation and Execution Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder Utilities for creating, configuring, and running systems within the ECS framework, including parameter handling and error management. ```Rust createSystem() getQueriesFromSystem() getSystemRunParameters() hmrSwapSystem() SystemBuilder SystemError ISystem ISystemActions ISystemBuilder ISystemError ISystemResource TSystemFunction TSystemParameter TSystemParameterDesc TExecutionFunction ``` -------------------------------- ### Get Resource in sim-ecs Source: https://nsstc.github.io/sim-ecs/interfaces/IWorld Retrieves a previously stored resource based on its type. Inherited from IImmutableWorld. ```TypeScript getResource(type: TTypeProto): T ``` -------------------------------- ### World and System Configuration Source: https://nsstc.github.io/sim-ecs/interfaces/IImmutableWorld Provides interfaces and types for configuring worlds and systems, including access descriptors, query descriptors, and options for registration and initialization. ```Rust IAccessDescriptor IAccessQuery IComponentsQuery IComponentsQueryDescriptor IDeserializerOutput IEntitiesQuery IEntitiesQueryDescriptor IEntity IEntityBuilder IEventBus IEventMap IExistenceDescriptor IImmutableWorld IIStateProto IMutableWorld IObjectRegistrationOptions IPipeline IPreptimeData IPreptimeOptions IPreptimeWorld IPreptimeWorldConfig IPushDownAutomaton IQuery IQueryDescriptor IReadOnlyEntity IResourceRegistrationOptions IRuntimeWorld IRuntimeWorldData IRuntimeWorldInitConfig IRuntimeWorldInitData IScheduler ISerDe ISerDeDataSet ISerDeOperations ISerDeOptions ISerialFormat IStage IState IStateProto ISyncPoint ISyncPointPrefab ISystem ISystemActions ISystemBuilder ISystemError ISystemResource ITransitionActions IWorld IWorldBuilder ``` -------------------------------- ### Get Existing Runtime Worlds Source: https://nsstc.github.io/sim-ecs/interfaces/IPreptimeWorld Retrieves a list of RuntimeWorlds that have been generated from this PreptimeWorld. This method is defined in `preptime-world.spec.ts`. ```TypeScript getExistingRuntimeWorlds(): readonly IRuntimeWorld[] ``` -------------------------------- ### Get Resources - sim-ecs RuntimeWorld Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Retrieves all resources stored in the world, useful for debugging. Implements IRuntimeWorld.getResources. ```TypeScript getResources: ( this: PreptimeWorld | RuntimeWorld, types?: readonly TExistenceQueryParameter[], ) => IterableIterator = getResources // Get all resources stored in this world. Useful for debugging // Implementation of IRuntimeWorld.getResources // Defined in src/world/runtime/runtime-world.ts:400 ``` -------------------------------- ### SimECS Commands and Queries Source: https://nsstc.github.io/sim-ecs/interfaces/ISystemActions Provides functions for interacting with the ECS world, such as getting entities, resources, and querying components. ```Rust commands currentState getEntities getResource hasResource queryComponents queryEntities Read ReadEntity ReadEvents ReadOptional ReadResource Storage With Without WithoutTag WithTag Write WriteEvents WriteOptional WriteResource ``` -------------------------------- ### sim-ecs: System Creation and Configuration Source: https://nsstc.github.io/sim-ecs/classes/SyncPoint Functions for creating and configuring systems within the sim-ecs framework. This includes creating new systems, defining their scheduling algorithms, and retrieving query information. ```TypeScript createSystem(config: ISystemBuilder): ISystem defaultSchedulingAlgorithm: TSchedulingAlgorithm defaultStageSchedulingAlgorithm: TStageSchedulingAlgorithm getQueriesFromSystem(system: ISystem): IQueryDescriptor[] ``` -------------------------------- ### sim-ecs: Utility Functions and Markers Source: https://nsstc.github.io/sim-ecs/interfaces/IQuery This snippet includes utility functions for managing ECS worlds and sync points, as well as various marker types used internally by the sim-ecs library. These utilities facilitate common operations like world creation, system registration, and synchronization. ```C# Actions CIdMarker CMarkerSeparator CRefMarker CResourceMarker CResourceMarkerValue CTagMarker addSyncPoint addWorld buildWorld clearRegistry createSystem defaultSchedulingAlgorithm defaultStageSchedulingAlgorithm getEntity getQueriesFromSystem getSyncPoint getSystemRunParameters getWorld getWorlds hmrSwapSystem queryComponents queryEntities registerEntity removeSyncPoint removeWorld unregisterEntity unregisterEntityId ``` -------------------------------- ### Get Existing Runtime Worlds Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Returns a read-only array of `IRuntimeWorld` instances that have been generated from the current `PreptimeWorld`. ```TypeScript getExistingRuntimeWorlds(): readonly IRuntimeWorld[] ``` -------------------------------- ### Get Existing Runtime Worlds Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Retrieves existing runtime worlds. This method is part of the IPreptimeWorld interface. ```TypeScript getExistingRuntimeWorlds: () => RuntimeWorld[] ``` -------------------------------- ### System Creation and Execution in SimECS Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld This snippet explains how to define and run systems in SimECS. Systems are functions that operate on entities and resources. It covers system creation, defining dependencies, and execution. ```TypeScript class SystemBuilder { static create(fn: TSystemFunction): SystemBuilder; } // Example system: const movementSystem = SystemBuilder.create((world: IMutableWorld) => { const entities = world.getEntities(); for (const entity of entities) { // Update entity position } }); world.addSystem(movementSystem); world.runSystems(); ``` -------------------------------- ### ECS System Creation and Configuration Source: https://nsstc.github.io/sim-ecs/interfaces/IRuntimeWorld Details the creation and configuration of systems within the sim-ecs framework. This includes functions for creating new systems, defining their run parameters, and swapping systems during runtime (hot module replacement). ```TypeScript createSystem getQueriesFromSystem getSystemRunParameters hmrSwapSystem ``` -------------------------------- ### Get Group Entities - sim-ecs RuntimeWorld Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Retrieves all entities associated with a specific group handle. Implements IRuntimeWorld.getGroupEntities. ```TypeScript getGroupEntities: ( this: PreptimeWorld | RuntimeWorld, groupHandle: number, ) => IterableIterator = getGroupEntities // Get all entities associated with a group // Implementation of IRuntimeWorld.getGroupEntities // Defined in src/world/runtime/runtime-world.ts:374 ``` -------------------------------- ### create Method Source: https://nsstc.github.io/sim-ecs/interfaces/IState The create method is called to run tasks when a state is initially created within the PDA. It accepts transition actions and may return a promise. ```TypeScript create(actions: Readonly): void | Promise ``` -------------------------------- ### PushDownAutomaton State Accessor Source: https://nsstc.github.io/sim-ecs/classes/PushDownAutomaton Gets the current state of the PushDownAutomaton. The state is read-only and can be of type T or undefined. This is an implementation of IPushDownAutomaton.state. ```TypeScript pda.state ``` -------------------------------- ### Get Group Entities in sim-ecs Source: https://nsstc.github.io/sim-ecs/interfaces/IWorld Retrieves all entities associated with a specific group, identified by its handle. Inherited from IImmutableWorld. ```TypeScript getGroupEntities(groupHandle: number): IterableIterator ``` -------------------------------- ### TypeScript Method: prepareRun Source: https://nsstc.github.io/sim-ecs/interfaces/IPreptimeWorld Prepares the world for runtime execution, returning a Promise that resolves to the IRuntimeWorld. Accepts optional preptime options. ```TypeScript prepareRun( options?: Readonly>, ): Promise ``` -------------------------------- ### SimECS Commands Source: https://nsstc.github.io/sim-ecs/interfaces/ITransitionActions Provides functions for interacting with the SimECS world, such as flushing commands, getting entities, and managing state. ```typescript flushCommands() currentState() getEntities() getResource() hasResource() popState() pushState() save() ``` -------------------------------- ### State Proto and Transitions Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder Interfaces for state prototypes and actions related to state transitions. ```Rust IIStateProto IStateProto ITransitionActions ``` -------------------------------- ### Get Resource Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Retrieves a resource that has been previously stored in the world. This method is generic and requires the type of the resource to be specified. ```TypeScript getResource: (this: RuntimeWorld, type: TTypeProto) => T ``` -------------------------------- ### TypeScript Array: length Property Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat The length property gets or sets the number of elements in an array. It is one greater than the highest index. ```TypeScript length: number; ``` -------------------------------- ### Tagging and Markers Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder Utilities for tagging entities and managing marker types within the ECS. ```Rust CMarkerSeparator CIdMarker CRefMarker CResourceMarker CResourceMarkerValue CTagMarker TTag ``` -------------------------------- ### Get Resources in sim-ecs Source: https://nsstc.github.io/sim-ecs/interfaces/IWorld Retrieves all resources stored in the world, optionally filtered by type. Useful for debugging. Inherited from IImmutableWorld. ```TypeScript getResources(types?: readonly TExistenceQueryParameter[]): IterableIterator ``` -------------------------------- ### Get Group Entities in Sim-ECS World Source: https://nsstc.github.io/sim-ecs/interfaces/IPreptimeWorld Retrieves all entities associated with a specific group handle. This method is inherited from the IWorld interface. ```TypeScript getGroupEntities(groupHandle: number): IterableIterator ``` -------------------------------- ### SystemBuilder.build Method Source: https://nsstc.github.io/sim-ecs/classes/SystemBuilder Builds and returns the configured system as a read-only ISystem instance. This method finalizes the system construction process. ```TypeScript build(): Readonly>> ``` -------------------------------- ### Get Entities by Group Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Fetches all entities associated with a given group handle. This method is defined within the `IPreptimeWorld` interface. ```TypeScript getGroupEntities: ( this: PreptimeWorld | RuntimeWorld, groupHandle: number, ) => IterableIterator ``` -------------------------------- ### Build Entity Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Provides a convenience builder for creating new entities. This method is part of the IPreptimeWorld interface. ```TypeScript buildEntity: (this: IMutableWorld, uuid?: string) => IEntityBuilder = buildEntity ``` -------------------------------- ### SimECS Entity Operations Source: https://nsstc.github.io/sim-ecs/classes/SerDe Functions for interacting with entities, such as getting, registering, and unregistering them. Also includes operations for entity builders and cloning. ```TypeScript getEntity registerEntity unregisterEntity unregisterEntityId ``` -------------------------------- ### Sim-ECS System Creation and Execution Source: https://nsstc.github.io/sim-ecs/interfaces/ISystemBuilder This snippet covers the creation and execution of systems in sim-ecs. It includes functions for creating new systems, defining their execution parameters, and managing their scheduling. ```C# namespace SimECS { public static class SystemFactory { public static ISystem createSystem(TSystemFunction function, TSystemParameter parameter) { /* ... */ } public static TSystemParameterDesc getSystemRunParameters(ISystem system) { /* ... */ } public static TSchedulingAlgorithm defaultSchedulingAlgorithm() { /* ... */ } // ... other system-related functions } } ``` -------------------------------- ### TypeScript: indexOf Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat Returns the index of the first occurrence of a value in an array, or -1 if it is not present. The search can optionally start from a specified fromIndex. ```typescript indexOf(searchElement: TEntity, fromIndex?: number): number ``` -------------------------------- ### TypeScript Array fill Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat Changes all elements in an array to a static value, from a start index to an end index. It returns the modified array. ```TypeScript fill(value: TEntity, start?: number, end?: number): this ``` -------------------------------- ### Resource Registration Methods (r, resource, withResource, withResources) Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder These methods are used to register resources within the simulation world. They accept resource definitions and optional registration options. 'r' and 'resource' are aliases for 'withResource'. ```TypeScript r( Resource: Readonly, options?: Readonly>, ): IWorldBuilder; ``` ```TypeScript resource( Resource: Readonly, options?: Readonly>, ): IWorldBuilder; ``` ```TypeScript withResource( Resource: Readonly, options?: Readonly>, ): IWorldBuilder; ``` ```TypeScript withResources(Resources: readonly Readonly[]): IWorldBuilder; ``` -------------------------------- ### SimECS Sync Point Management Source: https://nsstc.github.io/sim-ecs/classes/SerDe Functions for managing synchronization points within SimECS, including adding, getting, and removing sync points. ```TypeScript addSyncPoint getSyncPoint removeSyncPoint ``` -------------------------------- ### TypeScript: includes Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat Determines whether an array includes a certain element, returning true or false. It searches for an element starting from an optional fromIndex. ```typescript includes(searchElement: TEntity, fromIndex?: number): boolean ``` -------------------------------- ### System Creation and Management Source: https://nsstc.github.io/sim-ecs/interfaces/IWorld Provides functions for creating and managing systems within the SimECS framework. This includes creating new systems and retrieving their run parameters. ```typescript createSystem(system: TSystemFunction): void; getSystemRunParameters(system: TSystemFunction): TSystemParameterDesc[]; ``` -------------------------------- ### IPreptimeOptions Properties: initialState Source: https://nsstc.github.io/sim-ecs/interfaces/IPreptimeOptions Details the 'initialState' property within the IPreptimeOptions interface. This property is of type IIStateProto and represents the starting state for the preptime execution. ```TypeScript initialState: IIStateProto ``` -------------------------------- ### Sim-ECS: System Execution and Parameters Source: https://nsstc.github.io/sim-ecs/interfaces/ISyncPoint Defines how systems are created, executed, and parameterized within Sim-ECS. Includes system builders, execution functions, and parameter descriptors for defining system behavior. ```C# sim-ecs - v0.6.5 * SystemBuilder * SystemError * ISystem * ISystemActions * ISystemBuilder * ISystemError * ISystemResource * ITransitionActions * TExecutionFunction * TSystemFunction * TSystemParameter * TSystemParameterDesc * createSystem * getSystemRunParameters ``` -------------------------------- ### Get Resource by Type in Sim-ECS World Source: https://nsstc.github.io/sim-ecs/interfaces/IPreptimeWorld Retrieves a resource previously stored in the Sim-ECS world based on its type. This method is inherited from the IWorld interface. ```TypeScript getResource(type: TTypeProto): T ``` -------------------------------- ### Get System Run Parameters Source: https://nsstc.github.io/sim-ecs/functions/getSystemRunParameters Retrieves the run parameters for a given system within the ECS world. This function is crucial for understanding how a system is configured and executed. ```typescript getSystemRunParameters( system: Readonly, world: Readonly, ): TSystemParameterDesc ``` -------------------------------- ### sim-ecs: World Builder and Configuration Source: https://nsstc.github.io/sim-ecs/classes/SyncPoint Types for building and configuring worlds. ```TypeScript WorldBuilder IWorldBuilder ``` -------------------------------- ### Get Entities - sim-ecs RuntimeWorld Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld Queries entities based on component combinations. Use getEntity() for single entity retrieval by ID. Implements IRuntimeWorld.getEntities. ```TypeScript getEntities: ( this: PreptimeWorld | RuntimeWorld, query?: Readonly, ) => IterableIterator = getEntities // Query entities and find the ones with a certain combination of component. To get a single entity by ID, please use the global function `getEntity()` // Implementation of IRuntimeWorld.getEntities // Defined in src/world/runtime/runtime-world.ts:359 ``` -------------------------------- ### State Management with PushDownAutomaton in SimECS Source: https://nsstc.github.io/sim-ecs/classes/RuntimeWorld This section explains the PushDownAutomaton (PDA) for managing states within SimECS. It covers pushing and popping states, and how the PDA transitions between different states. ```TypeScript class PushDownAutomaton { pushState(state: T): void; popState(): void; } // Example usage: const pda = new PushDownAutomaton(); pda.pushState('MainMenu'); // ... later pda.popState(); ``` -------------------------------- ### Scheduling Configuration Methods Source: https://nsstc.github.io/sim-ecs/interfaces/IWorldBuilder Methods for configuring the scheduler and scheduling logic for the simulation world. This includes setting default schedulers and custom planners. ```TypeScript withDefaultScheduler(scheduler: Readonly): IWorldBuilder; ``` ```TypeScript withDefaultScheduling(planner: (root: ISyncPoint) => void): IWorldBuilder; ``` ```TypeScript withStateScheduler( state: Readonly, scheduler: Readonly, ): IWorldBuilder; ``` ```TypeScript withStateScheduling( state: Readonly, planner: (root: ISyncPoint) => void, ): IWorldBuilder; ``` -------------------------------- ### Get Entity by ID Source: https://nsstc.github.io/sim-ecs/functions/getEntity Retrieves a tracked entity by its unique string ID. Returns the entity if found, otherwise returns undefined. This function is defined in src/ecs/ecs-entity.ts. ```TypeScript getEntity(id: string): undefined | IEntity ``` -------------------------------- ### WorldBuilder Build Source: https://nsstc.github.io/sim-ecs/classes/WorldBuilder Constructs and returns the simulation world. This method finalizes the world building process and returns a PreptimeWorld instance. ```TypeScript build(): PreptimeWorld ``` -------------------------------- ### Add Resource Source: https://nsstc.github.io/sim-ecs/classes/PreptimeWorld Adds a resource of a specified type to the world and returns an instance of that resource. It accepts the resource type and constructor arguments. ```TypeScript addResource: ( this: PreptimeWorld, Type: T | TTypeProto, ...args: readonly unknown[] ) => T | TTypeProto = addResource ``` -------------------------------- ### TypeScript Array lastIndexOf Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat Finds the last index of a specified element in an array. It searches backward from an optional starting index. Returns -1 if the element is not found. ```TypeScript lastIndexOf(searchElement: TEntity, fromIndex?: number): number ``` -------------------------------- ### sim-ecs: Resource and System Registration Source: https://nsstc.github.io/sim-ecs/classes/SyncPoint Types for registering resources and systems. ```TypeScript SimECSSystemAddResourceEvent SimECSSystemReplaceResourceEvent ``` -------------------------------- ### SimECS World and System Management Functions Source: https://nsstc.github.io/sim-ecs/classes/Query This snippet outlines key functions for managing worlds and systems, including creation, addition, removal, and querying of entities and components. ```typescript function addSyncPoint(world: IWorld, name: string) function addWorld(world: IWorld) function buildWorld(builder: IWorldBuilder): IWorld function clearRegistry() function createSystem(fn: TSystemFunction, parameters: TSystemParameter[]): ISystem function getEntity(id: TEntityId): IEntity function getQueriesFromSystem(system: ISystem): IQueryDescriptor[] function getSyncPoint(name: string): ISyncPoint function getSystemRunParameters(system: ISystem): TSystemParameterDesc[] function getWorld(id: string): IWorld function getWorlds(): IWorld[] function hmrSwapSystem(oldSystem: ISystem, newSystem: ISystem) function queryComponents(descriptor: IComponentsQueryDescriptor): TAccessQueryData function queryEntities(descriptor: IEntitiesQueryDescriptor): TAccessQueryData function registerEntity(entity: IEntity) function removeSyncPoint(name: string) function removeWorld(id: string) function unregisterEntity(entity: IEntity) function unregisterEntityId(id: TEntityId) ``` -------------------------------- ### Stage Class Constructor Source: https://nsstc.github.io/sim-ecs/classes/Stage Initializes a new instance of the Stage class. This constructor is part of the core setup for managing stages within the sim-ecs pipeline. ```TypeScript new Stage(): Stage ``` -------------------------------- ### SimECS System Creation and Management Source: https://nsstc.github.io/sim-ecs/classes/Scheduler Details functions for creating and managing systems in SimECS. This includes creating new systems from functions, retrieving system run parameters, and swapping systems during runtime. ```TypeScript export function createSystem(system: TSystemFunction): void; export function getSystemRunParameters(system: ISystem): TSystemParameterDesc[]; export function hmrSwapSystem(oldSystem: ISystem, newSystem: ISystem): void; ``` -------------------------------- ### IRuntimeWorldInitData Interface Definition Source: https://nsstc.github.io/sim-ecs/interfaces/IRuntimeWorldInitData Defines the structure for initial data required to set up a runtime world. It includes sets of entities, group information with entity links and next handle, and maps of resources. ```TypeScript interface IRuntimeWorldInitData { entities: ReadonlySet>; groups: { entityLinks: Map>>; nextHandle: number; }; resources: ReadonlyMap; } ``` -------------------------------- ### TypeScript Array copyWithin Method Source: https://nsstc.github.io/sim-ecs/interfaces/ISerialFormat Copies a section of an array to another position within the same array. It returns the modified array. The target, start, and end parameters can be negative. ```TypeScript copyWithin(target: number, start: number, end?: number): this ```