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
TComponentThe main type of the component this processor is looking for.
TDataThe type of the associated data.
- Inheritance
-
objectEntityProcessor<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
requiredAdditionalTypesType[]
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
entityEntityThe entity.
componentTComponent
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
entityEntityThe entity.
componentTComponentassociatedDataTDataThe 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
entityEntityThe entity.
componentTComponentdataTDataThe 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
entityEntityThe entity.
componentTComponentdataTDataThe 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
entityEntityThe entity.
entityComponentArgEntityComponentforceRemovebool
RemoveAllEntities()
Should be called prior removal, it will unregister all entities.
protected override void RemoveAllEntities()