|
Entitas Redux
|
A context manages the lifecycle of entities and groups. You can create and destroy entities and get groups of entities. The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext(); More...
Public Member Functions | |
| Context (int totalComponents, Func< TEntity > entityFactory) | |
| The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext(); More... | |
| Context (int totalComponents, int startCreationIndex, ContextInfo contextInfo, Func< IEntity, IAERC > aercFactory, Func< TEntity > entityFactory) | |
| The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext(); More... | |
| override string | ToString () |
| TEntity | CreateEntity () |
| Creates a new entity or gets a reusable entity from the internal ObjectPool for entities. More... | |
| void | DestroyAllEntities () |
| Destroys all entities in the context. Throws an exception if there are still retained entities. More... | |
| bool | HasEntity (TEntity entity) |
| Determines whether the context has the specified entity. More... | |
| TEntity[] | GetEntities () |
| Returns all entities which are currently in the context. More... | |
| IGroup< TEntity > | GetGroup (IMatcher< TEntity > matcher) |
| Returns a group for the specified matcher. Calling context.GetGroup(matcher) with the same matcher will always return the same instance of the group. More... | |
| void | AddEntityIndex (IEntityIndex entityIndex) |
| Adds the IEntityIndex for the specified name. There can only be one IEntityIndex per name. More... | |
| IEntityIndex | GetEntityIndex (string name) |
| Gets the IEntityIndex for the specified name. More... | |
| void | ResetCreationIndex () |
| Resets the creationIndex back to 0. More... | |
| void | ClearComponentPool (int index) |
| Clears the componentPool at the specified index. More... | |
| void | ClearComponentPools () |
| Clears all componentPools. More... | |
| void | Reset () |
| Resets the context (destroys all entities and resets creationIndex back to 0). More... | |
| void | RemoveAllEventHandlers () |
| Removes all event handlers OnEntityCreated, OnEntityWillBeDestroyed, OnEntityDestroyed and OnGroupCreated More... | |
Public Attributes | |
| int | TotalComponents => _totalComponents |
| The total amount of components an entity can possibly have. This value is generated by the code generator, e.g ComponentLookup.TotalComponents. More... | |
| Stack< IComponent >[] | ComponentPools => _componentPools |
| Returns all componentPools. componentPools is used to reuse removed components. Removed components will be pushed to the componentPool. Use entity.CreateComponent(index, type) to get a new or reusable component from the componentPool. More... | |
| ContextInfo | ContextInfo => _contextInfo |
| The contextInfo contains information about the context. It's used to provide better error messages. More... | |
| int | Count => _entities.Count |
| Returns the number of entities in the context. More... | |
| int | ReusableEntitiesCount => _reusableEntities.Count |
| Returns the number of entities in the internal ObjectPool for entities which can be reused. More... | |
| int | RetainedEntitiesCount => _retainedEntities.Count |
| Returns the number of entities that are currently retained by other objects (e.g. Group, Collector, ReactiveSystem). More... | |
Events | |
| ContextEntityChanged | OnEntityCreated |
| Occurs when an entity gets created. More... | |
| ContextEntityChanged | OnEntityWillBeDestroyed |
| Occurs when an entity will be destroyed. More... | |
| ContextEntityChanged | OnEntityDestroyed |
| Occurs when an entity got destroyed. More... | |
| ContextGroupChanged | OnGroupCreated |
| Occurs when a group gets created for the first time. More... | |
A context manages the lifecycle of entities and groups. You can create and destroy entities and get groups of entities. The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext();
| TEntity |
| TEntity | : | class | |
| TEntity | : | IEntity |
Definition at line 39 of file Context.cs.
| JCMG.EntitasRedux.Context< TEntity >.Context | ( | int | totalComponents, |
| Func< TEntity > | entityFactory | ||
| ) |
The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext();
| totalComponents | |
| entityFactory |
Definition at line 78 of file Context.cs.
| JCMG.EntitasRedux.Context< TEntity >.Context | ( | int | totalComponents, |
| int | startCreationIndex, | ||
| ContextInfo | contextInfo, | ||
| Func< IEntity, IAERC > | aercFactory, | ||
| Func< TEntity > | entityFactory | ||
| ) |
The preferred way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext();
| totalComponents | |
| startCreationIndex | |
| contextInfo | |
| aercFactory | |
| entityFactory |
Definition at line 96 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.AddEntityIndex | ( | IEntityIndex | entityIndex | ) |
Adds the IEntityIndex for the specified name. There can only be one IEntityIndex per name.
| entityIndex |
Definition at line 431 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.ClearComponentPool | ( | int | index | ) |
Clears the componentPool at the specified index.
| index |
Definition at line 469 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.ClearComponentPools | ( | ) |
Clears all componentPools.
Definition at line 478 of file Context.cs.
| TEntity JCMG.EntitasRedux.Context< TEntity >.CreateEntity | ( | ) |
Creates a new entity or gets a reusable entity from the internal ObjectPool for entities.
Definition at line 308 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.DestroyAllEntities | ( | ) |
Destroys all entities in the context. Throws an exception if there are still retained entities.
Definition at line 347 of file Context.cs.
| TEntity [] JCMG.EntitasRedux.Context< TEntity >.GetEntities | ( | ) |
Returns all entities which are currently in the context.
Definition at line 377 of file Context.cs.
| IEntityIndex JCMG.EntitasRedux.Context< TEntity >.GetEntityIndex | ( | string | name | ) |
Gets the IEntityIndex for the specified name.
| name |
Definition at line 446 of file Context.cs.
| IGroup<TEntity> JCMG.EntitasRedux.Context< TEntity >.GetGroup | ( | IMatcher< TEntity > | matcher | ) |
Returns a group for the specified matcher. Calling context.GetGroup(matcher) with the same matcher will always return the same instance of the group.
| matcher |
Definition at line 395 of file Context.cs.
| bool JCMG.EntitasRedux.Context< TEntity >.HasEntity | ( | TEntity | entity | ) |
Determines whether the context has the specified entity.
| entity |
Definition at line 368 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.RemoveAllEventHandlers | ( | ) |
Removes all event handlers OnEntityCreated, OnEntityWillBeDestroyed, OnEntityDestroyed and OnGroupCreated
Definition at line 501 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.Reset | ( | ) |
Resets the context (destroys all entities and resets creationIndex back to 0).
Definition at line 490 of file Context.cs.
| void JCMG.EntitasRedux.Context< TEntity >.ResetCreationIndex | ( | ) |
Resets the creationIndex back to 0.
Definition at line 460 of file Context.cs.
| override string JCMG.EntitasRedux.Context< TEntity >.ToString | ( | ) |
Definition at line 144 of file Context.cs.
| Stack<IComponent> [] JCMG.EntitasRedux.Context< TEntity >.ComponentPools => _componentPools |
Returns all componentPools. componentPools is used to reuse removed components. Removed components will be pushed to the componentPool. Use entity.CreateComponent(index, type) to get a new or reusable component from the componentPool.
Definition at line 278 of file Context.cs.
| ContextInfo JCMG.EntitasRedux.Context< TEntity >.ContextInfo => _contextInfo |
The contextInfo contains information about the context. It's used to provide better error messages.
Definition at line 284 of file Context.cs.
| int JCMG.EntitasRedux.Context< TEntity >.Count => _entities.Count |
Returns the number of entities in the context.
Definition at line 289 of file Context.cs.
| int JCMG.EntitasRedux.Context< TEntity >.RetainedEntitiesCount => _retainedEntities.Count |
Returns the number of entities that are currently retained by other objects (e.g. Group, Collector, ReactiveSystem).
Definition at line 301 of file Context.cs.
| int JCMG.EntitasRedux.Context< TEntity >.ReusableEntitiesCount => _reusableEntities.Count |
Returns the number of entities in the internal ObjectPool for entities which can be reused.
Definition at line 295 of file Context.cs.
| int JCMG.EntitasRedux.Context< TEntity >.TotalComponents => _totalComponents |
The total amount of components an entity can possibly have. This value is generated by the code generator, e.g ComponentLookup.TotalComponents.
Definition at line 269 of file Context.cs.
| ContextEntityChanged JCMG.EntitasRedux.Context< TEntity >.OnEntityCreated |
Occurs when an entity gets created.
Definition at line 248 of file Context.cs.
| ContextEntityChanged JCMG.EntitasRedux.Context< TEntity >.OnEntityDestroyed |
Occurs when an entity got destroyed.
Definition at line 258 of file Context.cs.
| ContextEntityChanged JCMG.EntitasRedux.Context< TEntity >.OnEntityWillBeDestroyed |
Occurs when an entity will be destroyed.
Definition at line 253 of file Context.cs.
| ContextGroupChanged JCMG.EntitasRedux.Context< TEntity >.OnGroupCreated |
Occurs when a group gets created for the first time.
Definition at line 263 of file Context.cs.