IEntityWorld Interface
Definition
Namespace: Brine2D.ECS
Interface for the entity world that manages all entities and systems.
Derived
↳ EntityWorld
Implements System.IDisposable
| Properties | |
|---|---|
| Entities | Gets all entities in the world. |
| EntityCount | Gets the number of entities currently active in the world. Prefer this over Entities.Count when you only need the count, as it avoids accessing the list wrapper. |
| FixedUpdateSystems | Gets all fixed update systems in this world. |
| RenderSystems | Gets all render systems in this world. |
| UpdateSystems | Gets all update systems in this world. |
| Methods | |
|---|---|
| AddSystem<T>\(Action<T>\) | Adds a system to this world, automatically creating it with dependency injection. Systems that implement IUpdateSystem are added to the update pipeline. Systems that implement IFixedUpdateSystem are added to the fixed update pipeline. Systems that implement IRenderSystem are added to the render pipeline. Systems can implement multiple interfaces. |
| AddSystem<T>\(T\) | Adds a pre-constructed system instance to this world, bypassing dependency injection. Use this when the system requires constructor arguments that are not registered in DI, or when the system was obtained from an object pool or factory. |
| Clear() | Clears all entities and systems from the world, disposing any systems that implement System.IDisposable. The world remains usable after this call. |
| ClearEntities() | Destroys all entities but keeps systems and their configuration intact. Useful for scene resets without reloading. |
| CreateCachedQuery<T1>() | Creates a cached query builder for better performance when querying repeatedly. |
| CreateEntity\(string\) | Creates a new entity in the world. |
| CreateEntity<T>\(string\) | Creates a new entity of a specific type. |
| DestroyEntity\(Entity\) | Destroys an entity and removes it from the world. |
| FindEntity\(Func<Entity,bool>\) | Finds the first entity that matches the specified predicate. Only searches active entities. |
| FindEntity\(Func<Entity,bool>, bool\) | Finds the first entity that matches the specified predicate, optionally including inactive entities. |
| FixedUpdate\(GameTime\) | Runs one fixed timestep for all fixed update systems and behaviors. Called by the game loop's accumulator; not intended for direct use. |
| Flush() | Forces immediate processing of all deferred operations. |
| ForEachWithBehavior<T>\(Action<Entity,T>\) | Invokes action for every active entity that has a behavior of type T, passing both the entity and the resolved behavior instance. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithBehavior<T>\(Action<Entity>\) | Invokes action for every active entity that has a behavior of type T. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithComponent<T>\(Action<Entity,T>\) | Invokes action for every active entity that has the specified component type, passing both the entity and the resolved component. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe. |
| ForEachWithComponent<T>\(Action<Entity>\) | Invokes action for every active entity that has the specified component type. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe. |
| ForEachWithComponents<T1,T2,T3,T4,T5>\(Action<Entity,T1,T2,T3,T4,T5>\) | Invokes action for every active entity that has all five component types, passing the entity and all five resolved components. Iterates the smallest pool internally for efficiency. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithComponents<T1,T2,T3,T4>\(Action<Entity,T1,T2,T3,T4>\) | Invokes action for every active entity that has all four component types, passing the entity and all four resolved components. Iterates the smallest pool internally for efficiency. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithComponents<T1,T2,T3>\(Action<Entity,T1,T2,T3>\) | Invokes action for every active entity that has all three component types, passing the entity and all three resolved components. Iterates the smallest pool internally for efficiency. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithComponents<T1,T2>\(Action<Entity,T1,T2>\) | Invokes action for every active entity that has both T1 and T2, passing the entity and both resolved components. Iterates the smaller pool internally for efficiency. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe. |
| ForEachWithTag\(string, Action<Entity>\) | Invokes action for every active entity that has the specified tag, using the internal tag index for O\(tagged entities\) lookup and an System.Buffers.ArrayPool<> snapshot for safe iteration when the action modifies tags. |
| GetEntitiesByTag\(string\) | Gets all active entities with a specific tag. |
| GetEntitiesByTag\(string, bool\) | Gets entities with a specific tag, optionally including inactive entities. |
| GetEntitiesWithBehavior<T>() | Gets all active entities that have a behavior of type T. |
| GetEntitiesWithComponent<T>() | Gets all entities with a specific component type. |
| GetEntitiesWithComponents<T1,T2,T3,T4,T5>() | Gets all entities that have all five specified component types. Iterates the smallest pool to minimise cross-resolves. |
| GetEntitiesWithComponents<T1,T2,T3,T4>() | Gets all entities that have all four specified component types. Iterates the smallest pool to minimise cross-resolves. |
| GetEntitiesWithComponents<T1,T2,T3>() | Gets all entities that have all three specified component types. Iterates the smallest pool to minimise cross-resolves. |
| GetEntitiesWithComponents<T1,T2>() | Gets all entities that have both specified component types. Iterates the smaller pool to minimise cross-resolves. |
| GetEntityById\(long\) | Gets an entity by its unique ID. |
| GetEntityByName\(string\) | Gets an entity by name \(returns first match\). |
| GetEntityByName\(string, bool\) | Gets an entity by name \(returns first match\), optionally including inactive entities. |
| GetFixedUpdateSystem<T>() | Gets a fixed update system of the specified type. |
| GetRenderSystem<T>() | Gets a render system of the specified type. |
| GetRequiredSystem<T>() | Gets a system of the specified type, throwing if it is not found. |
| GetSystem<T>() | Gets a system of the specified type \(checks all pipelines\). |
| GetUpdateSystem<T>() | Gets an update system of the specified type. |
| HasFixedUpdateSystem<T>() | Checks if a fixed update system of the specified type exists in this world. |
| HasRenderSystem<T>() | Checks if a render system of the specified type exists in this world. |
| HasSystem<T>() | Checks if a system of the specified type exists in this world \(checks all pipelines\). |
| HasUpdateSystem<T>() | Checks if an update system of the specified type exists in this world. |
| Query() | Creates a fluent query builder for searching entities. |
| RemoveSystem\(ISystem\) | Removes a system by instance reference. If the system implements multiple pipeline interfaces it will be removed from all. |
| RemoveSystem<T>() | Removes a system of the specified type from this world. If the system implements multiple pipeline interfaces it will be removed from all. |
| Render\(IRenderer, GameTime\) | Renders all systems and entities in the world. |
| Update\(GameTime\) | Updates all systems and entities in the world. |
| Events | |
|---|---|
| EntityCreated | Fired after an entity is fully initialized and committed to the world \(i\.e\., after [OnInitialize\(\)](../Entity/OnInitialize().md 'Brine2D.ECS.Entity.OnInitialize()') has run). |
| EntityDestroyed | Fired just before an entity is removed from the world and its World reference is cleared. |