Entitas Redux
|
Use context.CreateEntity() to create a new entity and entity.Destroy() to destroy it. You can add, replace and remove IComponent to an entity. More...
Public Member Functions | |
Entity () | |
override string | ToString () |
Returns a cached string to describe the entity with the following format: Entity_{creationIndex}(*{retainCount})({list of components}) More... | |
void | Initialize (int creationIndex, int totalComponents, Stack< IComponent >[] componentPools, ContextInfo contextInfo=null, IAERC aerc=null) |
void | Reactivate (int creationIndex) |
void | AddComponent (int index, IComponent component) |
Adds a component at the specified index. You can only have one component at an index. Each component type must have its own constant index. The preferred way is to use the generated methods from the code generator. More... | |
void | RemoveComponent (int index) |
Removes a component at the specified index. You can only remove a component at an index if it exists. The preferred way is to use the generated methods from the code generator. More... | |
void | ReplaceComponent (int index, IComponent component) |
Replaces an existing component at the specified index or adds it if it doesn't exist yet. The preferred way is to use the generated methods from the code generator. More... | |
IComponent | GetComponent (int index) |
Returns a component at the specified index. You can only get a component at an index if it exists. The preferred way is to use the generated methods from the code generator. More... | |
IComponent[] | GetComponents () |
Returns all added components. More... | |
int[] | GetComponentIndices () |
Returns all indices of added components. More... | |
bool | HasComponent (int index) |
Determines whether this entity has a component at the specified index. More... | |
bool | HasComponents (int[] indices) |
Determines whether this entity has components at all the specified indices. More... | |
bool | HasAnyComponent (int[] indices) |
Determines whether this entity has a component at any of the specified indices. More... | |
void | RemoveAllComponents () |
Removes all components. More... | |
Stack< IComponent > | GetComponentPool (int index) |
Returns the componentPool for the specified component index. componentPools is set by the context which created the entity and 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... | |
IComponent | CreateComponent (int index, Type type) |
Returns a new or reusable component from the componentPool for the specified component index. More... | |
T | CreateComponent< T > (int index) |
Returns a new or reusable component from the componentPool for the specified component index. More... | |
void | Retain (object owner) |
Retains the entity. An owner can only retain the same entity once. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point. More... | |
void | Release (object owner) |
Releases the entity. An owner can only release an entity if it retains it. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point. More... | |
void | Destroy () |
Dispatches OnDestroyEntity which will start the destroy process. More... | |
void | InternalDestroy () |
This method is used internally. Don't call it yourself. Use entity.Destroy(); More... | |
void | RemoveAllOnEntityReleasedHandlers () |
Do not call this method manually. This method is called by the context. More... | |
Public Attributes | |
int | TotalComponents => _totalComponents |
The total amount of components an entity can possibly have. More... | |
int | CreationIndex => _creationIndex |
Each entity has its own unique creationIndex which will be set by the context when you create the entity. More... | |
bool | IsEnabled => _isEnabled |
The context manages the state of an entity. Active entities are enabled, destroyed entities are not. More... | |
Stack< IComponent >[] | ComponentPools => _componentPools |
componentPools is set by the context which created the entity and 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. Use entity.GetComponentPool(index) to get a componentPool for a specific component index. More... | |
ContextInfo | ContextInfo => _contextInfo |
The contextInfo is set by the context which created the entity and contains information about the context. It's used to provide better error messages. More... | |
IAERC | AERC => _aerc |
Automatic Entity Reference Counting (AERC) is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point. More... | |
int | RetainCount => _aerc.RetainCount |
Returns the number of objects that retain this entity. More... | |
Events | |
EntityComponentChanged | OnComponentAdded |
Occurs when a component gets added. All event handlers will be removed when the entity gets destroyed by the context. More... | |
EntityComponentChanged | OnComponentRemoved |
Occurs when a component gets removed. All event handlers will be removed when the entity gets destroyed by the context. More... | |
EntityComponentReplaced | OnComponentReplaced |
Occurs when a component gets replaced. All event handlers will be removed when the entity gets destroyed by the context. More... | |
EntityEvent | OnEntityReleased |
Occurs when an entity gets released and is not retained anymore. All event handlers will be removed when the entity gets destroyed by the context. More... | |
EntityEvent | OnDestroyEntity |
Occurs when calling entity.Destroy(). All event handlers will be removed when the entity gets destroyed by the context. More... | |
![]() | |
EntityComponentChanged | OnComponentAdded |
EntityComponentChanged | OnComponentRemoved |
EntityComponentReplaced | OnComponentReplaced |
EntityEvent | OnEntityReleased |
EntityEvent | OnDestroyEntity |
Additional Inherited Members | |
![]() | |
int | TotalComponents [get] |
int | CreationIndex [get] |
bool | IsEnabled [get] |
Stack< IComponent >[] | ComponentPools [get] |
ContextInfo | ContextInfo [get] |
IAERC | AERC [get] |
![]() | |
int | RetainCount [get] |
Use context.CreateEntity() to create a new entity and entity.Destroy() to destroy it. You can add, replace and remove IComponent to an entity.
void JCMG.EntitasRedux.Entity.AddComponent | ( | int | index, |
IComponent | component | ||
) |
Adds a component at the specified index. You can only have one component at an index. Each component type must have its own constant index. The preferred way is to use the generated methods from the code generator.
index | |
component |
Implements JCMG.EntitasRedux.IEntity.
IComponent JCMG.EntitasRedux.Entity.CreateComponent | ( | int | index, |
Type | type | ||
) |
Returns a new or reusable component from the componentPool for the specified component index.
index | |
type |
Implements JCMG.EntitasRedux.IEntity.
T JCMG.EntitasRedux.Entity.CreateComponent< T > | ( | int | index | ) |
Returns a new or reusable component from the componentPool for the specified component index.
T |
index |
Implements JCMG.EntitasRedux.IEntity.
T | : | new() |
void JCMG.EntitasRedux.Entity.Destroy | ( | ) |
Dispatches OnDestroyEntity which will start the destroy process.
Implements JCMG.EntitasRedux.IEntity.
IComponent JCMG.EntitasRedux.Entity.GetComponent | ( | int | index | ) |
Returns a component at the specified index. You can only get a component at an index if it exists. The preferred way is to use the generated methods from the code generator.
index |
Implements JCMG.EntitasRedux.IEntity.
int [] JCMG.EntitasRedux.Entity.GetComponentIndices | ( | ) |
Stack<IComponent> JCMG.EntitasRedux.Entity.GetComponentPool | ( | int | index | ) |
Returns the componentPool for the specified component index. componentPools is set by the context which created the entity and 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.
index |
Implements JCMG.EntitasRedux.IEntity.
IComponent [] JCMG.EntitasRedux.Entity.GetComponents | ( | ) |
bool JCMG.EntitasRedux.Entity.HasAnyComponent | ( | int[] | indices | ) |
Determines whether this entity has a component at any of the specified indices.
indices |
Implements JCMG.EntitasRedux.IEntity.
bool JCMG.EntitasRedux.Entity.HasComponent | ( | int | index | ) |
Determines whether this entity has a component at the specified index.
index |
Implements JCMG.EntitasRedux.IEntity.
bool JCMG.EntitasRedux.Entity.HasComponents | ( | int[] | indices | ) |
Determines whether this entity has components at all the specified indices.
indices |
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.Initialize | ( | int | creationIndex, |
int | totalComponents, | ||
Stack< IComponent >[] | componentPools, | ||
ContextInfo | contextInfo = null , |
||
IAERC | aerc = null |
||
) |
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.InternalDestroy | ( | ) |
This method is used internally. Don't call it yourself. Use entity.Destroy();
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.Reactivate | ( | int | creationIndex | ) |
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.Release | ( | object | owner | ) |
Releases the entity. An owner can only release an entity if it retains it. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point.
owner |
Implements JCMG.EntitasRedux.IAERC.
void JCMG.EntitasRedux.Entity.RemoveAllComponents | ( | ) |
Removes all components.
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.RemoveAllOnEntityReleasedHandlers | ( | ) |
Do not call this method manually. This method is called by the context.
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.RemoveComponent | ( | int | index | ) |
Removes a component at the specified index. You can only remove a component at an index if it exists. The preferred way is to use the generated methods from the code generator.
index |
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.ReplaceComponent | ( | int | index, |
IComponent | component | ||
) |
Replaces an existing component at the specified index or adds it if it doesn't exist yet. The preferred way is to use the generated methods from the code generator.
index | |
component |
Implements JCMG.EntitasRedux.IEntity.
void JCMG.EntitasRedux.Entity.Retain | ( | object | owner | ) |
Retains the entity. An owner can only retain the same entity once. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point.
owner |
Implements JCMG.EntitasRedux.IAERC.
override string JCMG.EntitasRedux.Entity.ToString | ( | ) |
IAERC JCMG.EntitasRedux.Entity.AERC => _aerc |
Stack<IComponent> [] JCMG.EntitasRedux.Entity.ComponentPools => _componentPools |
componentPools is set by the context which created the entity and 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. Use entity.GetComponentPool(index) to get a componentPool for a specific component index.
ContextInfo JCMG.EntitasRedux.Entity.ContextInfo => _contextInfo |
int JCMG.EntitasRedux.Entity.CreationIndex => _creationIndex |
bool JCMG.EntitasRedux.Entity.IsEnabled => _isEnabled |
int JCMG.EntitasRedux.Entity.RetainCount => _aerc.RetainCount |
int JCMG.EntitasRedux.Entity.TotalComponents => _totalComponents |
EntityComponentChanged JCMG.EntitasRedux.Entity.OnComponentAdded |
EntityComponentChanged JCMG.EntitasRedux.Entity.OnComponentRemoved |
EntityComponentReplaced JCMG.EntitasRedux.Entity.OnComponentReplaced |
EntityEvent JCMG.EntitasRedux.Entity.OnDestroyEntity |
EntityEvent JCMG.EntitasRedux.Entity.OnEntityReleased |