### Run Pong Example Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Demonstrates how to build and run the Pong game example using sim-ecs. This involves navigating to the example directory, installing dependencies, and starting the application. ```bash cd examples/pong && npm install && npm run start ``` -------------------------------- ### Run Pong Example Source: https://github.com/nsstc/sim-ecs/blob/master/README.md Instructions to build and run the Pong game example using npm. This example demonstrates a full game with components, systems, states, prefabs, and saving capabilities, suitable for browser execution. ```bash cd examples/pong && npm install && npm run start ``` -------------------------------- ### Run Counter Example Source: https://github.com/nsstc/sim-ecs/blob/master/README.md This command executes the 'counter' example for sim-ecs using npm scripts. The counter example is a minimal demonstration showcasing basic ECS functionality, such as incrementing a value. ```shell $ npm run example-counter ``` -------------------------------- ### setup - Add setup function to system Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISystemBuilder.html The `setup` method is an alias for `withSetupFunction`. It adds a setup function that is called when the system is instantiated, such as on a new world run. It accepts a `TSystemFunction` and returns an `ISystemBuilder`. ```TypeScript setup( fn: TSystemFunction> ): ISystemBuilder>[] ``` -------------------------------- ### Run Counter Example Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Executes the 'counter' example using npm scripts, which demonstrates a basic ECS functionality. ```Shell npm run example-counter ``` -------------------------------- ### TypeScript - Configure System Setup Function Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SystemBuilder.html Adds a setup function that is called when the system is instantiated, typically at the beginning of a new world run. This function receives a TSystemFunction. ```TypeScript setup: ( fn: TSystemFunction> ) => SystemBuilder> = ... // Implementation of ISystemBuilder.setup // Defined in src/system/system-builder.ts:70 ``` -------------------------------- ### Run Events Example Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Executes the 'events' example using npm scripts, showcasing the use of the event bus within sim-ecs. ```Shell npm run example-events ``` -------------------------------- ### Run Events Example Source: https://github.com/nsstc/sim-ecs/blob/master/README.md This command runs the 'events' example for sim-ecs via npm. The events example illustrates the usage of the event bus within sim-ecs, demonstrating how to write and read events, with a message printed every second. ```shell $ npm run example-events ``` -------------------------------- ### Start Simulation Update Loop in JavaScript Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Demonstrates how to start the sim-ecs simulation's update loop. The `start()` method drives the simulation based on the world's configuration. Error handling is included using `.catch()` for non-fatal errors. ```javascript runWorld.start() .catch(console.error) // this won't catch non-fatal errors, see error example! .then(() => console.log('Finished.')); ``` -------------------------------- ### Add Setup Function - TypeScript Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SystemBuilder.html Adds a setup function to the system builder. This function is invoked when the system is instantiated, such as at the beginning of a new world run. It takes a system function as a parameter and returns a SystemBuilder. ```typescript withSetupFunction( fn: TSystemFunction> ): SystemBuilder>[] ``` -------------------------------- ### Start Continuous Execution Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Starts a continuous execution of the simulation. The Promise resolves when the execution terminates. This is an implementation of the start method from the IRuntimeWorld interface. ```TypeScript start(): Promise ``` -------------------------------- ### Install sim-ecs with npm Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Installs the sim-ecs package using npm, a common package manager for Node.js projects. ```Shell npm install sim-ecs ``` -------------------------------- ### Set Setup Function with ISystemBuilder Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISystemBuilder.html The `setup` method configures the function that will be executed once when the ECS system is initialized. It takes a TSystemFunction and returns the ISystemBuilder. ```TypeScript setup( fn: TSystemFunction>, ): ISystemBuilder>; ``` -------------------------------- ### withSetupFunction - Add system setup function Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISystemBuilder.html The `withSetupFunction` method adds a setup function to the system. This function is executed during the system's instantiation, for instance, when a new world run commences. It takes a `TSystemFunction` and returns an `ISystemBuilder`. ```TypeScript withSetupFunction( fn: TSystemFunction> ): ISystemBuilder>[] ``` -------------------------------- ### Start the sim-ecs Update Loop Source: https://github.com/nsstc/sim-ecs/blob/master/README.md This code demonstrates how to start the simulation's update loop using sim-ecs. The `runWorld.start()` method drives the simulation based on the world's configuration. Error handling is included with `.catch(console.error)` for non-fatal errors, and `.then()` handles the completion of the loop. ```typescript runWorld.start() // run() will drive the simulation based on the data provided to set up the world .catch(console.error) // this won't catch non-fatal errors, see error example! .then(() => console.log('Finished.')); ``` -------------------------------- ### Add and Get Resources Source: https://github.com/nsstc/sim-ecs/blob/master/README.md Demonstrates how to add a resource to the world and retrieve it. Resources are objects that can hold data, such as a start DateTime. The `addResource` function implicitly creates a new object of a specified type, or you can pass an existing instance. The `getResource` function retrieves the instance. ```typescript prepWorld.addResource(Date); console.log(world.getResource(Date).getDate()); ``` -------------------------------- ### Run System Error Example Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Shows how to execute the System-Error example to demonstrate sim-ecs's error handling capabilities. Errors are caught and handled via an events system without aborting execution. ```bash npm run example-system-error ``` -------------------------------- ### Install sim-ecs with npm Source: https://github.com/nsstc/sim-ecs/blob/master/README.md This command installs the sim-ecs package using npm, a popular package manager for Node.js. It allows you to easily add the library to your project for use in simulation or game development. ```shell $ npm install sim-ecs ``` -------------------------------- ### Set Setup Function with withSetupFunction Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISystemBuilder.html The `withSetupFunction` method configures the initialization logic for the ECS system by accepting a TSystemFunction. It returns the ISystemBuilder for further method chaining. ```TypeScript withSetupFunction( fn: TSystemFunction>, ): ISystemBuilder>; ``` -------------------------------- ### Add and Get Resources Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Demonstrates adding a resource to the world, which can be a new instance or an existing one. It also shows how to retrieve a resource from the world using its type. ```TypeScript // 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()); ``` -------------------------------- ### Get Resources from PreptimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Retrieves all resources stored in the world, which is useful for debugging. This method is part of the IPreptimeWorld interface. ```TypeScript getResources: ( this: PreptimeWorld | RuntimeWorld, types?: readonly TExistenceQueryParameter[] ) => IterableIterator = getResources ``` -------------------------------- ### Schedule Systems with Stages Source: https://github.com/nsstc/sim-ecs/blob/master/README.md Example of defining a default scheduling configuration for an ECS world using sim-ecs. It demonstrates adding systems to stages and building the world with this configuration. ```typescript const prepWorld = buildWorld() .withDefaultScheduling(root => root .addNewStage(stage => stage .addSystem(CounterSystem) ) ) .build(); ``` -------------------------------- ### State Creation Method Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IState.html The 'create' method is invoked when a state is initially created within the state machine. It handles setup tasks and accepts an actions object, returning void or a Promise. ```TypeScript create(actions: Readonly<[ITransitionActions](ITransitionActions.html)>): void | Promise ``` -------------------------------- ### Initialize Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/Query.html Sets the document theme from local storage and displays the application page after a short delay. If the application is not ready, it removes the initial display:none style. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Show App Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IWorldBuilder.html This script initializes the application's theme from local storage and controls the initial display of the application. It sets the theme and then uses a timeout to ensure the application's main page is shown after a short delay, or immediately if the app object is available. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Show App Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/WorldBuilder.html Sets the document theme from local storage and conditionally displays the application after a short delay. If the app is not available, it removes the display:none property from the body. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Theme and Display Initialization Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IComponentsQueryDescriptor.html This snippet demonstrates how to initialize the theme from local storage and control the initial display of the body element, showing it after a short delay or when the application is ready. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/modules.html This JavaScript code snippet initializes the application's theme based on local storage or OS preference and then conditionally displays the main page content after a short delay. It ensures that the page content is not visible until the application is ready. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Display - JavaScript Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SyncPoint.html Sets the document's theme based on local storage or OS preference and controls the initial display of the body element, showing the app after a short delay. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/functions/With.html This snippet initializes the document's theme based on local storage and controls the initial display of the body, showing the page after a short delay or when the app is ready. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Display - JavaScript Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html This snippet sets the document's theme from local storage and controls the initial display of the body element, showing the app after a short delay. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### TypeScript: Fill array elements with a static value (fill) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISerialFormat.html The 'fill' method modifies an array by filling elements from a start index to an end index with a static value. It returns the modified array. Parameters include the value to fill with, and optional start and end indices. ```TypeScript fill(value: TEntity, start?: number, end?: number): this ``` -------------------------------- ### Initialize RuntimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Constructs a new RuntimeWorld instance. It requires a name and configuration, with an optional initial data object. This is the entry point for setting up the simulation world. ```TypeScript new RuntimeWorld( name: string, config: [IRuntimeWorldInitConfig](../interfaces/IRuntimeWorldInitConfig.html), $data?: Partial<[IRuntimeWorldInitData](../interfaces/IRuntimeWorldInitData.html)> ): RuntimeWorld ``` -------------------------------- ### Get Existing Runtime Worlds Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html Retrieves a list of RuntimeWorlds that have been generated from this PreptimeWorld. ```TypeScript getExistingRuntimeWorlds(): readonly IRuntimeWorld[][] ``` -------------------------------- ### Get RuntimeWorld Current State Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Advertises the current state of the RuntimeWorld. This accessor is an implementation of the IRuntimeWorld.currentState interface. ```TypeScript get currentState(): undefined | Readonly<[IState](../interfaces/IState.html)> ``` -------------------------------- ### Theme and Display Initialization (JavaScript) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/State.html This JavaScript code snippet demonstrates how to initialize the theme and control the display of the application. It sets the document's theme based on local storage or defaults to 'os', hides the body initially, and then shows the application page after a short delay or if the app object is available. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get World Name in PreptimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Retrieves the name of the world. This is an optional property and an implementation of IPreptimeWorld.name. ```TypeScript name?: string ``` -------------------------------- ### Initialize Scheduler Theme Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/Scheduler.html Sets the document theme based on local storage or OS preference, then hides the body and shows the app page after a short delay. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Display - JavaScript Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SimECSEvent.html This snippet sets the document theme based on local storage and controls the initial display of the body, revealing the app after a short delay. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get Array Iterator Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISerialFormat.html Provides an iterator for the array, yielding key-value pairs for each entry. Inherited from Array.entries. ```TypeScript entries(): ArrayIterator<[number, TEntity]>[] ``` -------------------------------- ### Get Group Entities Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html Retrieves all entities associated with a specific group handle. This method is inherited from the IWorld interface. ```typescript getGroupEntities(groupHandle: number): IterableIterator<[IEntity](#getgroupentities-1)>[] ``` -------------------------------- ### Get RuntimeWorld Configuration Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Accesses the initial configuration object for the RuntimeWorld. This property is defined within the IRuntimeWorld interface. ```TypeScript config: IRuntimeWorldInitConfig ``` -------------------------------- ### Get Current State Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SimECSPushDownAutomaton.html Retrieves the current state of the push-down automaton. The state can be undefined if no state has been set. ```typescript get state(): undefined | T ``` -------------------------------- ### Scheduler Pipeline Accessor Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/Scheduler.html Accessor to get and set the pipeline for the scheduler. Implements the pipeline property from the IScheduler interface. ```TypeScript * get pipeline(): [IPipeline](../interfaces/IPipeline.html) #### Returns [IPipeline](../interfaces/IPipeline.html) Implementation of [IScheduler](../interfaces/IScheduler.html).[pipeline](../interfaces/IScheduler.html#pipeline) * Defined in [src/scheduler/scheduler.ts:28](https://github.com/NSSTC/sim-ecs/blob/630d947c37e6468607ea0823aff49f8d12958b01/src/scheduler/scheduler.ts#L28) * set pipeline(newPipeline: Readonly<[IPipeline](../interfaces/IPipeline.html)>): void #### Parameters * newPipeline: Readonly<[IPipeline](../interfaces/IPipeline.html)> #### Returns void Implementation of [IScheduler](../interfaces/IScheduler.html).[pipeline](../interfaces/IScheduler.html#pipeline) * Defined in [src/scheduler/scheduler.ts:32](https://github.com/NSSTC/sim-ecs/blob/630d947c37e6468607ea0823aff49f8d12958b01/src/scheduler/scheduler.ts#L32) ``` -------------------------------- ### Initialize PreptimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Constructs a new PreptimeWorld instance. It can optionally be initialized with a name, configuration, and data. ```TypeScript new PreptimeWorld( name?: string, $config?: Partial, $data?: Partial ) ``` -------------------------------- ### Get All Tags of Entity Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntity.html Retrieves an iterator for all tags associated with the entity. This allows iteration over all the marker tags applied to the entity. ```TypeScript getTags(): IterableIterator ``` -------------------------------- ### Get RuntimeWorld Awaiter Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Provides an awaiter that resolves when the world's execution terminates. This accessor is part of the IRuntimeWorld interface. ```TypeScript get awaiter(): undefined | Promise ``` -------------------------------- ### Theme and Display Settings Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IExistenceDescriptor.html This snippet demonstrates how to set the theme based on local storage and control the initial display of the body element, revealing it after a short delay or when the app is ready. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get RuntimeWorld Name (TypeScript) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Retrieves the name of the RuntimeWorld. This property is part of the IRuntimeWorld interface and is defined in the runtime-world.ts file. ```TypeScript name: string ``` -------------------------------- ### Initialize SystemBuilder Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SystemBuilder.html Constructs a new SystemBuilder instance. It takes a read-only parameter description object which defines the parameters for the system. ```TypeScript new SystemBuilder(params: Readonly) ``` -------------------------------- ### Get Existing Runtime Worlds Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Retrieves a read-only list of RuntimeWorlds that have been generated from this PreptimeWorld. This method is an implementation of IPreptimeWorld.getExistingRuntimeWorlds. ```TypeScript getExistingRuntimeWorlds(): readonly IRuntimeWorld[][] ``` -------------------------------- ### Theme Initialization and Page Display Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SimECSAddEntityEvent.html This snippet demonstrates how to set the theme based on local storage and control the initial display of the page content. It applies a theme and then shows the page after a short delay, potentially invoking an app-specific showPage method. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get PreptimeWorld Configuration Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Accesses the configuration object for the PreptimeWorld, which defines how the runtime operates. This property holds IPreptimeWorldConfig. ```TypeScript config: IPreptimeWorldConfig ``` -------------------------------- ### Set Theme and Show Page (JavaScript) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html A JavaScript snippet that sets the document's theme based on local storage and controls the initial display of the application page. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get Array Iterator (Symbol.iterator) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISerialFormat.html Returns an ArrayIterator for the array, typically used for iteration protocols. Inherited from Array.[iterator]. ```TypeScript (): ArrayIterator[] ``` -------------------------------- ### Get Resource Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html Fetches a resource of a specified type that has been previously stored in the world. This method is generic and requires a type parameter for the resource. ```typescript getResource(type: TTypeProto<[T](#getresourcet)>): [T](#getresourcet)[] ``` -------------------------------- ### Set Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/hierarchy.html This snippet sets the document's theme based on local storage or defaults to 'os'. It then hides the body and uses a timeout to either show the application's page or remove the display property from the body, ensuring a smooth initial load. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get All Components of Entity Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntity.html Retrieves an iterator for all components attached to the entity. This allows iteration over every component instance present on the entity. ```TypeScript getComponents(): IterableIterator ``` -------------------------------- ### Theme and Display Initialization Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/ISystemError.html Initializes the document's theme based on local storage and sets up a delayed display for the application, ensuring the search index is prepared. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get RuntimeWorld System Actions Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Provides an object containing all actions that are available within a system. This accessor is an implementation of the IRuntimeWorld.systemActions interface. ```TypeScript get systemActions(): [ISystemActions](../interfaces/ISystemActions.html) ``` -------------------------------- ### Get Resource from RuntimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Retrieves a resource of a specific type that was previously stored in the RuntimeWorld. This method is part of the IPreptimeWorld interface. ```TypeScript getResource: (this: RuntimeWorld, type: TTypeProto) => T = getResource ``` -------------------------------- ### IQuery Methods Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IQuery.html This section outlines the methods available on the IQuery interface. These include 'execute' to run a query with a handler, 'getFirst' to retrieve a single result, 'iter' for iteration, 'matchesEntity' to check entity compatibility, and 'toArray' to get all results as an array. ```TypeScript execute(handler: (data: DATA) => void | Promise): Promise; getFirst(): undefined | DATA; iter(): IterableIterator; matchesEntity(entity: Readonly): boolean; toSArray(): DATA[]; ``` -------------------------------- ### Get Group Entities from PreptimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Retrieves all entities associated with a specific group handle. This method is part of the IPreptimeWorld interface. ```TypeScript getGroupEntities: ( this: PreptimeWorld | RuntimeWorld, groupHandle: number, ) => IterableIterator = getGroupEntities ``` -------------------------------- ### TypeScript ECS Benchmarks Overview Source: https://github.com/nsstc/sim-ecs/blob/master/README.md Provides an overview of the benchmark environment, including the platform, CPU, Node.js version, and the versions of sim-ecs and other compared libraries. This context is crucial for understanding the benchmark results. ```TypeScript -------------------------------------------------------------------------------- TypeScript ECS Bench -------------------------------------------------------------------------------- 22nd May 2024 Platform: Windows_NT win32 x64 v10.0.22631 CPU: AMD Ryzen 7 3700X 8-Core Processor@3600MHz NodeJS: v21.1.0 Bench v0.3.0 TypeScript v5.4.5 TS-Lib v2.6.2 TSX v4.10.5 Ape-ECS v1.3.1 bitecs v0.3.40 Javelin v1.0.0-alpha.13 sim-ecs v0.6.5 tick-knock v4.2.0 Measured in "points" for comparison. More is better! ``` -------------------------------- ### Start World Execution (TypeScript) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IRuntimeWorld.html Initiates the continuous execution of systems within the world. The returned Promise resolves when the execution loop terminates. ```typescript world.start() ``` -------------------------------- ### Get Resources Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html Retrieves all resources currently stored in the world. It can optionally filter resources based on provided types, making it useful for debugging. ```typescript getResources(types?: readonly [TExistenceQueryParameter](../types/TExistenceQueryParameter.html)[]): IterableIterator[] ``` -------------------------------- ### Theme and Display Initialization Source: https://github.com/nsstc/sim-ecs/blob/master/docs/types/TSerializable.html Initializes the document theme based on local storage and sets the body display to none, then shows the app page or removes the display property after a delay. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### TypeScript: Get Array Keys Iterator Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SerialFormat.html Returns an iterable of keys (indices) in the array. This allows for iteration over the array's indices. ```TypeScript /** * Returns an iterable of keys in the array * @returns ArrayIterator */ keys(): ArrayIterator[]; ``` -------------------------------- ### Set Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/variables/CTagMarker.html This snippet sets the document theme based on local storage or OS preference and then displays the application page after a short delay. It handles cases where the app might not be immediately available. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get Tags - sim-ecs Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IReadOnlyEntity.html Retrieves all tags associated with an entity. This method returns an iterable iterator of tags, allowing for efficient iteration over the tags. ```typescript getTags(): IterableIterator ``` -------------------------------- ### Set Theme and Show Page Source: https://github.com/nsstc/sim-ecs/blob/master/docs/types/TTag.html This snippet sets the document's theme based on local storage and controls the initial display of the body, showing the application page after a short delay. It handles cases where the app might not be immediately available. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get Components - sim-ecs Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IReadOnlyEntity.html Retrieves all components associated with an entity. This method returns an iterable iterator of objects, allowing for efficient iteration over the components. ```typescript getComponents(): IterableIterator ``` -------------------------------- ### Create Prepare-Time World Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Illustrates the creation of a prepare-time world in sim-ecs. This world is used for easily preparing simulations, defining and readying all components before runtime. ```typescript const prepWorld = buildWorld().build(); ``` -------------------------------- ### Get Stage Executor Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IStage.html The getExecutor method retrieves an executor to run the stage once. It requires an IEventBus object as input and returns a TExecutor. ```TypeScript getExecutor(eventBus: Readonly): TExecutor; ``` -------------------------------- ### Prepare Runtime Environment (sim-ecs) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IPreptimeWorld.html Prepares a runtime environment from the current world state. It accepts optional preptime options and returns an array of IRuntimeWorld objects. ```TypeScript prepareRun(options?: Readonly>): Promise[] ``` -------------------------------- ### Prepare Runtime Environment with prepareRun (TypeScript) Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html The prepareRun method prepares a runtime environment from the current world. It is an asynchronous function that returns a Promise resolving to an array of IRuntimeWorld objects. It accepts optional configuration options. ```TypeScript prepareRun( options?: Readonly> ): Promise[] ``` -------------------------------- ### Get Tag Count of Entity Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntity.html Returns the total number of tags associated with the entity. This count reflects the number of markers applied to the entity. ```TypeScript getTagCount(): number ``` -------------------------------- ### Schedule Systems from Prefab Source: https://github.com/nsstc/sim-ecs/blob/master/docs/index.html Builds a world using a data-driven approach by loading a schedule from a prefab. This allows for defining system execution order and parallelism using simple arrays. ```TypeScript import {buildWorld, ISyncPointPrefab} from "sim-ecs"; const gameSchedule: ISyncPointPrefab = { stages: [ // Stages are executed sequentially (order guaranteed!) [BeforeStepSystem], [InputSystem], [ // Systems inside a stage are executed in parallel, if possible (no order guaranteed!) MenuSystem, PaddleSystem, PauseSystem, ], [CollisionSystem], [BallSystem], [AnimationSystem], [ RenderGameSystem, RenderUISystem, ], [ErrorSystem], ], }; const prepWorld = buildWorld() .withDefaultScheduling(root => root.fromPrefab(gameSchedule)) .build(); ``` -------------------------------- ### Get Component Count of Entity Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntity.html Returns the total number of components currently associated with the entity. This provides a quick count of all attached components. ```TypeScript getComponentCount(): number ``` -------------------------------- ### Get First Entity from Query Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntitiesQuery.html The getFirst method retrieves the first entity that matches the query criteria. It returns undefined if no entities match. ```TypeScript getFirst(): undefined | IEntity ``` -------------------------------- ### Build Entity with PreptimeWorld Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/PreptimeWorld.html Provides a convenience builder to create a new entity. It returns an IEntityBuilder instance, allowing for chained configuration of the entity. ```TypeScript buildEntity(uuid?: string): IEntityBuilder ``` -------------------------------- ### Theme and Display Initialization Source: https://github.com/nsstc/sim-ecs/blob/master/docs/enums/EAccess.html Initializes the document's theme based on local storage or OS preference and controls the initial display of the body element, deferring its visibility until the application is ready. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get RuntimeWorld Transition Actions Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/RuntimeWorld.html Provides an object containing all actions that are available during step-to-step transitions and to states. This accessor implements the IRuntimeWorld.transitionActions interface. ```TypeScript get transitionActions(): [ITransitionActions](../interfaces/ITransitionActions.html) ``` -------------------------------- ### JavaScript - Theme and Display Settings Source: https://github.com/nsstc/sim-ecs/blob/master/docs/functions/createSystem.html JavaScript code snippet to set the theme from local storage and manage the initial display of the body element, often used for theme transitions. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Array toString() - Get String Representation Source: https://github.com/nsstc/sim-ecs/blob/master/docs/classes/SerialFormat.html The toString() method returns a string representation of an array. This implementation inherits from the standard Array.toString method. ```typescript toString(): string[] ``` -------------------------------- ### Theme and Display Initialization Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IDeserializerOutput.html This JavaScript snippet initializes the application's theme based on local storage settings and controls the initial display of the body element. It ensures the theme is applied correctly and manages the visibility of the application's main content. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Get Component from Entity Source: https://github.com/nsstc/sim-ecs/blob/master/docs/interfaces/IEntity.html Retrieves a specific component associated with an entity. The component type is determined by the provided TTypeProto. Returns undefined if the component is not found. ```TypeScript getComponent(component: TTypeProto): undefined | T ```