Entitas-0.32.0
Public Member Functions | Properties | Events | List of all members
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 ()
 Creates a new entity or gets a reusable entity from the internal ObjectPool for entities.
 
virtual void DestroyEntity (Entity entity)
 Destroys the entity, removes all its components and pushs it back to the internal ObjectPool for entities.
 
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 ()
 Clears all groups. This is useful when you want to soft-restart your application.
 
void AddEntityIndex (string name, IEntityIndex entityIndex)
 Adds the IEntityIndex for the specified name. There can only be one IEntityIndex per name.
 
IEntityIndex GetEntityIndex (string name)
 Gets the IEntityIndex for the specified name.
 
void DeactivateEntityIndices ()
 Deactivates 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 ()
 Resets the pool (clears all groups, destroys all entities and resets creationIndex back to 0).
 
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]
 Returns the number of entities in the internal ObjectPool for entities which can be reused.
 
int retainedEntitiesCount [get]
 Returns the number of entities that are currently retained by other objects (e.g. Group, GroupObserver, ReactiveSystem).
 

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();

Constructor & Destructor Documentation

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();

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();

Member Function Documentation

virtual void Entitas.Pool.DestroyAllEntities ( )
inlinevirtual

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

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.

Property Documentation

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.

PoolMetaData Entitas.Pool.metaData
get

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

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.


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