Package gaiasky.scene.system
Class ParallelSystem
java.lang.Object
com.badlogic.ashley.core.EntitySystem
gaiasky.scene.system.ParallelSystem
public abstract class ParallelSystem
extends com.badlogic.ashley.core.EntitySystem
A simple EntitySystem that iterates over each entity in parallel and calls processEntity() for each entity every time the EntitySystem is
updated. The main difference with
IteratingSystem
is that this system processes the entities in the
family in parallel. There is an overhead each time the system is called to copy the list of entities to
a Java streams-ready collection for parallel streaming.-
Field Summary
Fields inherited from class com.badlogic.ashley.core.EntitySystem
priority
-
Constructor Summary
ConstructorDescriptionParallelSystem
(com.badlogic.ashley.core.Family family) Instantiates a system that will iterate over the entities described by the Family.ParallelSystem
(com.badlogic.ashley.core.Family family, int priority) Instantiates a system that will iterate over the entities described by the Family, with a specific priority. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addedToEngine
(com.badlogic.ashley.core.Engine engine) com.badlogic.ashley.utils.ImmutableArray<com.badlogic.ashley.core.Entity>
com.badlogic.ashley.core.Family
protected abstract void
processEntity
(com.badlogic.ashley.core.Entity entity, float deltaTime) This method is called on every entity on every update call of the EntitySystem.void
removedFromEngine
(com.badlogic.ashley.core.Engine engine) void
update
(float deltaTime) Methods inherited from class com.badlogic.ashley.core.EntitySystem
checkProcessing, getEngine, setProcessing
-
Constructor Details
-
ParallelSystem
public ParallelSystem(com.badlogic.ashley.core.Family family) Instantiates a system that will iterate over the entities described by the Family.- Parameters:
family
- The family of entities iterated over in this System
-
ParallelSystem
public ParallelSystem(com.badlogic.ashley.core.Family family, int priority) Instantiates a system that will iterate over the entities described by the Family, with a specific priority.- Parameters:
family
- The family of entities iterated over in this Systempriority
- The priority to execute this system with (lower means higher priority)
-
-
Method Details
-
addedToEngine
public void addedToEngine(com.badlogic.ashley.core.Engine engine) - Overrides:
addedToEngine
in classcom.badlogic.ashley.core.EntitySystem
-
removedFromEngine
public void removedFromEngine(com.badlogic.ashley.core.Engine engine) - Overrides:
removedFromEngine
in classcom.badlogic.ashley.core.EntitySystem
-
update
public void update(float deltaTime) - Overrides:
update
in classcom.badlogic.ashley.core.EntitySystem
-
getEntities
public com.badlogic.ashley.utils.ImmutableArray<com.badlogic.ashley.core.Entity> getEntities()- Returns:
- set of entities processed by the system
-
getFamily
public com.badlogic.ashley.core.Family getFamily()- Returns:
- the Family used when the system was created
-
processEntity
protected abstract void processEntity(com.badlogic.ashley.core.Entity entity, float deltaTime) This method is called on every entity on every update call of the EntitySystem. Override this to implement your system's specific processing.- Parameters:
entity
- The current Entity being processeddeltaTime
- The delta time between the last and current frame
-