Class EntityProcessor<TComponent, TData>
Helper class for EntityProcessor, that will keep track of Entity matching certain EntityComponent requirements.
public abstract class EntityProcessor<TComponent, TData> : EntityProcessor where TComponent : EntityComponent where TData : class
Type Parameters
TComponent
The main type of the component this processor is looking for.
TData
The type of the associated data.
- Inheritance
-
EntityProcessor<TComponent, TData>
- Derived
- Inherited Members
Remarks
Additional precomputed data will be stored alongside the Entity to offer faster accesses and iterations.
Constructors
EntityProcessor(params Type[])
protected EntityProcessor(params Type[] requiredAdditionalTypes)
Parameters
requiredAdditionalTypes
Type[]
Fields
ComponentDatas
protected readonly Dictionary<TComponent, TData> ComponentDatas
Field Value
- Dictionary<TComponent, TData>
Methods
GenerateComponentData(Entity, TComponent)
Generates associated data to the given entity.
protected abstract TData GenerateComponentData(Entity entity, TComponent component)
Parameters
entity
EntityThe entity.
component
TComponent
Returns
- TData
The associated data.
IsAssociatedDataValid(Entity, TComponent, TData)
Checks if the current associated data is valid, or if readding the entity is required.
protected virtual bool IsAssociatedDataValid(Entity entity, TComponent component, TData associatedData)
Parameters
entity
EntityThe entity.
component
TComponentassociatedData
TDataThe associated data.
Returns
- bool
True if the change in associated data requires the entity to be readded, false otherwise.
OnEntityComponentAdding(Entity, TComponent, TData)
Run when a matching entity is added to this entity processor.
protected virtual void OnEntityComponentAdding(Entity entity, TComponent component, TData data)
Parameters
entity
EntityThe entity.
component
TComponentdata
TDataThe associated data.
OnEntityComponentRemoved(Entity, TComponent, TData)
Run when a matching entity is removed from this entity processor.
protected virtual void OnEntityComponentRemoved(Entity entity, TComponent component, TData data)
Parameters
entity
EntityThe entity.
component
TComponentdata
TDataThe associated data.
OnSystemAdd()
Run when this EntityProcessor is added to an EntityManager.
protected override void OnSystemAdd()
OnSystemRemove()
Run when this EntityProcessor is removed from an EntityManager.
protected override void OnSystemRemove()
ProcessEntityComponent(Entity, EntityComponent, bool)
Checks if Entity needs to be either added or removed.
protected override void ProcessEntityComponent(Entity entity, EntityComponent entityComponentArg, bool forceRemove)
Parameters
entity
EntityThe entity.
entityComponentArg
EntityComponentforceRemove
bool
RemoveAllEntities()
Should be called prior removal, it will unregister all entities.
protected override void RemoveAllEntities()