Entitas Redux
JCMG.EntitasRedux.Group< TEntity > Class Template Reference

Use context.GetGroup(matcher) to get a group of entities which match the specified matcher. Calling context.GetGroup(matcher) with the same matcher will always return the same instance of the group. The created group is managed by the context and will always be up to date. It will automatically add entities that match the matcher or remove entities as soon as they don't match the matcher anymore. More...

Inheritance diagram for JCMG.EntitasRedux.Group< TEntity >:
JCMG.EntitasRedux.IGroup< TEntity >

Public Member Functions

 Group (IMatcher< TEntity > matcher)
 Use context.GetGroup(matcher) to get a group of entities which match the specified matcher. More...
 
override string ToString ()
 
void HandleEntitySilently (TEntity entity)
 This is used by the context to manage the group. More...
 
void HandleEntity (TEntity entity, int index, IComponent component)
 This is used by the context to manage the group. More...
 
void UpdateEntity (TEntity entity, int index, IComponent previousComponent, IComponent newComponent)
 This is used by the context to manage the group. More...
 
void RemoveAllEventHandlers ()
 Removes all event handlers from this group. Keep in mind that this will break reactive systems and entity indices which rely on this group. More...
 
GroupChanged< TEntity > HandleEntity (TEntity entity)
 
bool ContainsEntity (TEntity entity)
 Determines whether this group has the specified entity. More...
 
TEntity[] GetEntities ()
 Returns all entities which are currently in this group. More...
 
List< TEntity > GetEntities (List< TEntity > buffer)
 Fills the buffer with all entities which are currently in this group. More...
 
IEnumerable< TEntity > AsEnumerable ()
 
HashSet< TEntity >.Enumerator GetEnumerator ()
 
TEntity GetSingleEntity ()
 Returns the only entity in this group. It will return null if the group is empty. It will throw an exception if the group has more than one entity. More...
 

Public Attributes

int Count => _entities.Count
 Returns the number of entities in the group. More...
 
IMatcher< TEntity > Matcher => _matcher
 Returns the matcher which was used to create this group. More...
 

Events

GroupChanged< TEntity > OnEntityAdded
 Occurs when an entity gets added. More...
 
GroupChanged< TEntity > OnEntityRemoved
 Occurs when an entity gets removed. More...
 
GroupUpdated< TEntity > OnEntityUpdated
 Occurs when a component of an entity in the group gets replaced. More...
 

Detailed Description

Use context.GetGroup(matcher) to get a group of entities which match the specified matcher. Calling context.GetGroup(matcher) with the same matcher will always return the same instance of the group. The created group is managed by the context and will always be up to date. It will automatically add entities that match the matcher or remove entities as soon as they don't match the matcher anymore.

Template Parameters
TEntity
Type Constraints
TEntity :class 
TEntity :IEntity 

Definition at line 39 of file Group.cs.

Constructor & Destructor Documentation

◆ Group()

JCMG.EntitasRedux.Group< TEntity >.Group ( IMatcher< TEntity >  matcher)

Use context.GetGroup(matcher) to get a group of entities which match the specified matcher.

Parameters
matcher

Definition at line 55 of file Group.cs.

Member Function Documentation

◆ AsEnumerable()

IEnumerable<TEntity> JCMG.EntitasRedux.Group< TEntity >.AsEnumerable ( )

Definition at line 280 of file Group.cs.

◆ ContainsEntity()

bool JCMG.EntitasRedux.Group< TEntity >.ContainsEntity ( TEntity  entity)

Determines whether this group has the specified entity.

Parameters
entity
Returns

Definition at line 248 of file Group.cs.

◆ GetEntities() [1/2]

TEntity [] JCMG.EntitasRedux.Group< TEntity >.GetEntities ( )

Returns all entities which are currently in this group.

Returns

Definition at line 257 of file Group.cs.

◆ GetEntities() [2/2]

List<TEntity> JCMG.EntitasRedux.Group< TEntity >.GetEntities ( List< TEntity >  buffer)

Fills the buffer with all entities which are currently in this group.

Parameters
buffer
Returns

Definition at line 273 of file Group.cs.

◆ GetEnumerator()

HashSet<TEntity>.Enumerator JCMG.EntitasRedux.Group< TEntity >.GetEnumerator ( )

Definition at line 285 of file Group.cs.

◆ GetSingleEntity()

TEntity JCMG.EntitasRedux.Group< TEntity >.GetSingleEntity ( )

Returns the only entity in this group. It will return null if the group is empty. It will throw an exception if the group has more than one entity.

Returns

Definition at line 296 of file Group.cs.

◆ HandleEntity() [1/2]

GroupChanged<TEntity> JCMG.EntitasRedux.Group< TEntity >.HandleEntity ( TEntity  entity)

Definition at line 234 of file Group.cs.

◆ HandleEntity() [2/2]

void JCMG.EntitasRedux.Group< TEntity >.HandleEntity ( TEntity  entity,
int  index,
IComponent  component 
)

This is used by the context to manage the group.

Parameters
entity
index
component

Definition at line 178 of file Group.cs.

◆ HandleEntitySilently()

void JCMG.EntitasRedux.Group< TEntity >.HandleEntitySilently ( TEntity  entity)

This is used by the context to manage the group.

Parameters
entity

Definition at line 160 of file Group.cs.

◆ RemoveAllEventHandlers()

void JCMG.EntitasRedux.Group< TEntity >.RemoveAllEventHandlers ( )

Removes all event handlers from this group. Keep in mind that this will break reactive systems and entity indices which rely on this group.

Definition at line 227 of file Group.cs.

◆ ToString()

override string JCMG.EntitasRedux.Group< TEntity >.ToString ( )

Definition at line 121 of file Group.cs.

◆ UpdateEntity()

void JCMG.EntitasRedux.Group< TEntity >.UpdateEntity ( TEntity  entity,
int  index,
IComponent  previousComponent,
IComponent  newComponent 
)

This is used by the context to manage the group.

Parameters
entity
index
previousComponent
newComponent

Definition at line 197 of file Group.cs.

Member Data Documentation

◆ Count

int JCMG.EntitasRedux.Group< TEntity >.Count => _entities.Count

Returns the number of entities in the group.

Definition at line 149 of file Group.cs.

◆ Matcher

IMatcher<TEntity> JCMG.EntitasRedux.Group< TEntity >.Matcher => _matcher

Returns the matcher which was used to create this group.

Definition at line 154 of file Group.cs.

Event Documentation

◆ OnEntityAdded

GroupChanged<TEntity> JCMG.EntitasRedux.Group< TEntity >.OnEntityAdded

Occurs when an entity gets added.

Definition at line 134 of file Group.cs.

◆ OnEntityRemoved

GroupChanged<TEntity> JCMG.EntitasRedux.Group< TEntity >.OnEntityRemoved

Occurs when an entity gets removed.

Definition at line 139 of file Group.cs.

◆ OnEntityUpdated

GroupUpdated<TEntity> JCMG.EntitasRedux.Group< TEntity >.OnEntityUpdated

Occurs when a component of an entity in the group gets replaced.

Definition at line 144 of file Group.cs.


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