Entitas  0.40.0
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Public Member Functions | Properties | Events | List of all members
Entitas.Entity Class Reference
Inheritance diagram for Entitas.Entity:
Entitas.IEntity

Public Member Functions

void Initialize (int creationIndex, int totalComponents, Stack< IComponent >[] componentPools, ContextInfo contextInfo=null)
 
void Reactivate (int creationIndex)
 
void AddComponent (int index, IComponent component)
 
void RemoveComponent (int index)
 
void ReplaceComponent (int index, IComponent component)
 
IComponent GetComponent (int index)
 
IComponent [] GetComponents ()
 Returns all added components.
 
int [] GetComponentIndices ()
 Returns all indices of added components.
 
bool HasComponent (int index)
 
bool HasComponents (int[] indices)
 
bool HasAnyComponent (int[] indices)
 
void RemoveAllComponents ()
 Removes all components.
 
Stack< IComponentGetComponentPool (int index)
 
IComponent CreateComponent (int index, Type type)
 
CreateComponent< T > (int index)
 
void Retain (object owner)
 
void Release (object owner)
 
void Destroy ()
 
void RemoveAllOnEntityReleasedHandlers ()
 
override string ToString ()
 

Properties

int totalComponents [get]
 The total amount of components an entity can possibly have.
 
int creationIndex [get]
 
bool isEnabled [get]
 
Stack< IComponent > [] componentPools [get]
 
ContextInfo contextInfo [get]
 
int retainCount [get]
 Returns the number of objects that retain this entity.
 
HashSet< object > owners [get]
 Returns all the objects that retain this entity.
 
- Properties inherited from Entitas.IEntity
int totalComponents [get]
 
int creationIndex [get]
 
bool isEnabled [get]
 
Stack< IComponent > [] componentPools [get]
 
ContextInfo contextInfo [get]
 
HashSet< object > owners [get]
 
int retainCount [get]
 

Events

EntityComponentChanged OnComponentAdded
 
EntityComponentChanged OnComponentRemoved
 
EntityComponentReplaced OnComponentReplaced
 
EntityReleased OnEntityReleased
 
- Events inherited from Entitas.IEntity
EntityComponentChanged OnComponentAdded
 
EntityComponentChanged OnComponentRemoved
 
EntityComponentReplaced OnComponentReplaced
 
EntityReleased OnEntityReleased
 

Detailed Description

Use context.CreateEntity() to create a new entity and context.DestroyEntity() to destroy it. You can add, replace and remove IComponent to an entity.

Definition at line 10 of file Entity.cs.

Member Function Documentation

◆ AddComponent()

void Entitas.Entity.AddComponent ( int  index,
IComponent  component 
)
inline

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 prefered way is to use the generated methods from the code generator.

Implements Entitas.IEntity.

Definition at line 99 of file Entity.cs.

◆ CreateComponent()

IComponent Entitas.Entity.CreateComponent ( int  index,
Type  type 
)
inline

Returns a new or reusable component from the componentPool for the specified component index.

Implements Entitas.IEntity.

Definition at line 312 of file Entity.cs.

◆ CreateComponent< T >()

T Entitas.Entity.CreateComponent< T > ( int  index)
inline

Returns a new or reusable component from the componentPool for the specified component index.

Implements Entitas.IEntity.

Type Constraints
T :new() 

Definition at line 321 of file Entity.cs.

◆ GetComponent()

IComponent Entitas.Entity.GetComponent ( int  index)
inline

Returns a component at the specified index. You can only get a component at an index if it exists. The prefered way is to use the generated methods from the code generator.

Implements Entitas.IEntity.

Definition at line 202 of file Entity.cs.

◆ GetComponentPool()

Stack<IComponent> Entitas.Entity.GetComponentPool ( int  index)
inline

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.

Implements Entitas.IEntity.

Definition at line 300 of file Entity.cs.

◆ HasAnyComponent()

bool Entitas.Entity.HasAnyComponent ( int []  indices)
inline

Determines whether this entity has a component at any of the specified indices.

Implements Entitas.IEntity.

Definition at line 274 of file Entity.cs.

◆ HasComponent()

bool Entitas.Entity.HasComponent ( int  index)
inline

Determines whether this entity has a component at the specified index.

Implements Entitas.IEntity.

Definition at line 256 of file Entity.cs.

◆ HasComponents()

bool Entitas.Entity.HasComponents ( int []  indices)
inline

Determines whether this entity has components at all the specified indices.

Implements Entitas.IEntity.

Definition at line 262 of file Entity.cs.

◆ Release()

void Entitas.Entity.Release ( object  owner)
inline

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.

Implements Entitas.IEntity.

Definition at line 359 of file Entity.cs.

◆ RemoveComponent()

void Entitas.Entity.RemoveComponent ( int  index)
inline

Removes a component at the specified index. You can only remove a component at an index if it exists. The prefered way is to use the generated methods from the code generator.

Implements Entitas.IEntity.

Definition at line 129 of file Entity.cs.

◆ ReplaceComponent()

void Entitas.Entity.ReplaceComponent ( int  index,
IComponent  component 
)
inline

Replaces an existing component at the specified index or adds it if it doesn't exist yet. The prefered way is to use the generated methods from the code generator.

Implements Entitas.IEntity.

Definition at line 153 of file Entity.cs.

◆ Retain()

void Entitas.Entity.Retain ( object  owner)
inline

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.

Implements Entitas.IEntity.

Definition at line 341 of file Entity.cs.

◆ ToString()

override string Entitas.Entity.ToString ( )
inline

Returns a cached string to describe the entity with the following format: Entity_{creationIndex}(*{retainCount})({list of components})

Definition at line 394 of file Entity.cs.

Property Documentation

◆ componentPools

Stack<IComponent> [] Entitas.Entity.componentPools
get

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.

Definition at line 50 of file Entity.cs.

◆ contextInfo

ContextInfo Entitas.Entity.contextInfo
get

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.

Definition at line 55 of file Entity.cs.

◆ creationIndex

int Entitas.Entity.creationIndex
get

Each entity has its own unique creationIndex which will be set by the context when you create the entity.

Definition at line 37 of file Entity.cs.

◆ isEnabled

bool Entitas.Entity.isEnabled
get

The context manages the state of an entity. Active entities are enabled, destroyed entities are not.

Definition at line 41 of file Entity.cs.

Event Documentation

◆ OnComponentAdded

EntityComponentChanged Entitas.Entity.OnComponentAdded

Occurs when a component gets added. All event handlers will be removed when the entity gets destroyed by the context.

Definition at line 15 of file Entity.cs.

◆ OnComponentRemoved

EntityComponentChanged Entitas.Entity.OnComponentRemoved

Occurs when a component gets removed. All event handlers will be removed when the entity gets destroyed by the context.

Definition at line 20 of file Entity.cs.

◆ OnComponentReplaced

EntityComponentReplaced Entitas.Entity.OnComponentReplaced

Occurs when a component gets replaced. All event handlers will be removed when the entity gets destroyed by the context.

Definition at line 25 of file Entity.cs.

◆ OnEntityReleased

EntityReleased Entitas.Entity.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.

Definition at line 30 of file Entity.cs.


The documentation for this class was generated from the following file: