Entitas  0.35.0
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Entitas.Pool Class Reference

Public Member Functions

delegate void PoolChanged (Pool pool, Entity entity)
 
delegate void GroupChanged (Pool pool, Group group)
 
 Pool (int totalComponents)
 
 Pool (int totalComponents, int startCreationIndex, PoolMetaData metaData)
 
virtual Entity CreateEntity ()
 
virtual void DestroyEntity (Entity entity)
 
virtual void DestroyAllEntities ()
 
virtual bool HasEntity (Entity entity)
 Determines whether the pool has the specified entity.
 
virtual Entity [] GetEntities ()
 Returns all entities which are currently in the pool.
 
virtual Group GetGroup (IMatcher matcher)
 
void ClearGroups ()
 
void AddEntityIndex (string name, IEntityIndex entityIndex)
 
IEntityIndex GetEntityIndex (string name)
 Gets the IEntityIndex for the specified name.
 
void DeactivateAndRemoveEntityIndices ()
 Deactivates and removes all entity indices.
 
void ResetCreationIndex ()
 Resets the creationIndex back to 0.
 
void ClearComponentPool (int index)
 Clears the componentPool at the specified index.
 
void ClearComponentPools ()
 Clears all componentPools.
 
void Reset ()
 
override string ToString ()
 

Properties

int totalComponents [get]
 
Stack< IComponent > [] componentPools [get]
 
PoolMetaData metaData [get]
 
int count [get]
 Returns the number of entities in the pool.
 
int reusableEntitiesCount [get]
 
int retainedEntitiesCount [get]
 

Events

PoolChanged OnEntityCreated
 Occurs when an entity gets created.
 
PoolChanged OnEntityWillBeDestroyed
 Occurs when an entity will be destroyed.
 
PoolChanged OnEntityDestroyed
 Occurs when an entity got destroyed.
 
GroupChanged OnGroupCreated
 Occurs when a group gets created for the first time.
 
GroupChanged OnGroupCleared
 Occurs when a group gets cleared.
 

Detailed Description

A pool manages the lifecycle of entities and groups. You can create and destroy entities and get groups of entities. The prefered way is to use the generated methods from the code generator to create a Pool, e.g. Pools.sharedInstance.pool = Pools.CreatePool();

Definition at line 10 of file Pool.cs.

Constructor & Destructor Documentation

§ Pool() [1/2]

Entitas.Pool.Pool ( int  totalComponents)
inline

The prefered way is to use the generated methods from the code generator to create a Pool, e.g. Pools.sharedInstance.pool = Pools.CreatePool();

Definition at line 95 of file Pool.cs.

§ Pool() [2/2]

Entitas.Pool.Pool ( int  totalComponents,
int  startCreationIndex,
PoolMetaData  metaData 
)
inline

The prefered way is to use the generated methods from the code generator to create a Pool, e.g. Pools.sharedInstance.pool = Pools.CreatePool();

Definition at line 101 of file Pool.cs.

Member Function Documentation

§ AddEntityIndex()

void Entitas.Pool.AddEntityIndex ( string  name,
IEntityIndex  entityIndex 
)
inline

Adds the IEntityIndex for the specified name. There can only be one IEntityIndex per name.

Definition at line 279 of file Pool.cs.

§ ClearGroups()

void Entitas.Pool.ClearGroups ( )
inline

Clears all groups. This is useful when you want to soft-restart your application.

Definition at line 258 of file Pool.cs.

§ CreateEntity()

virtual Entity Entitas.Pool.CreateEntity ( )
inlinevirtual

Creates a new entity or gets a reusable entity from the internal ObjectPool for entities.

Definition at line 141 of file Pool.cs.

§ DestroyAllEntities()

virtual void Entitas.Pool.DestroyAllEntities ( )
inlinevirtual

Destroys all entities in the pool. Throws an exception if there are still retained entities.

Definition at line 199 of file Pool.cs.

§ DestroyEntity()

virtual void Entitas.Pool.DestroyEntity ( Entity  entity)
inlinevirtual

Destroys the entity, removes all its components and pushs it back to the internal ObjectPool for entities.

Definition at line 164 of file Pool.cs.

§ GetGroup()

virtual Group Entitas.Pool.GetGroup ( IMatcher  matcher)
inlinevirtual

Returns a group for the specified matcher. Calling pool.GetGroup(matcher) with the same matcher will always return the same instance of the group.

Definition at line 230 of file Pool.cs.

§ Reset()

void Entitas.Pool.Reset ( )
inline

Resets the pool (clears all groups, destroys all entities and resets creationIndex back to 0).

Definition at line 328 of file Pool.cs.

Property Documentation

§ componentPools

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

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 40 of file Pool.cs.

§ metaData

PoolMetaData Entitas.Pool.metaData
get

The metaData contains information about the pool. It's used to provide better error messages.

Definition at line 46 of file Pool.cs.

§ retainedEntitiesCount

int Entitas.Pool.retainedEntitiesCount
get

Returns the number of entities that are currently retained by other objects (e.g. Group, GroupObserver, ReactiveSystem).

Definition at line 59 of file Pool.cs.

§ reusableEntitiesCount

int Entitas.Pool.reusableEntitiesCount
get

Returns the number of entities in the internal ObjectPool for entities which can be reused.

Definition at line 53 of file Pool.cs.

§ totalComponents

int Entitas.Pool.totalComponents
get

The total amount of components an entity can possibly have. This value is generated by the code generator, e.g ComponentIds.TotalComponents.

Definition at line 33 of file Pool.cs.


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