Package dev.prozilla.pine.core.system
Class SystemBase
java.lang.Object
dev.prozilla.pine.core.system.SystemBase
- All Implemented Interfaces:
Lifecycle
- Direct Known Subclasses:
InitSystemBase
,InputSystemBase
,RenderSystemBase
,UpdateSystemBase
Base class for system responsible for handling logic and behaviour for entities that match a query based on their components.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Application
protected Logger
protected Scene
protected World
-
Constructor Summary
ConstructorsConstructorDescriptionSystemBase
(Class<? extends Component>[] componentTypes) SystemBase
(Class<? extends Component>[] componentTypes, boolean runOnce) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
forEach
(Consumer<EntityChunk> action) Iterates over each entity that matches the query of this system.protected void
forEachReverse
(Consumer<EntityChunk> action) Iterates over each entity that matches the query of this system in reverse.boolean
Returns true if this system has any entity chunks.void
initSystem
(World world) Initializes this system and creates the query.void
print()
void
Registers an entity in this system's query.protected void
requireTag
(String tag) Restricts this system's query to entities with a given tag.protected final void
setExcludedComponentTypes
(Class<? extends Component>... componentTypes) protected void
sort
(Comparator<EntityChunk> comparator) Sorts the entity chunks in this system based on a comparator.void
unregister
(Entity entity) Unregisters an entity from this system's query.
-
Field Details
-
world
-
application
-
scene
-
logger
-
-
Constructor Details
-
SystemBase
-
SystemBase
-
-
Method Details
-
requireTag
Restricts this system's query to entities with a given tag. If multiple entities have overlapping component types and you only want this system to process some of them, you can use tags to select the right entities.- Throws:
IllegalStateException
- If the query has already been created.- See Also:
-
setExcludedComponentTypes
@SafeVarargs protected final void setExcludedComponentTypes(Class<? extends Component>... componentTypes) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
initSystem
Initializes this system and creates the query. If there are already entities in the world, this will register each entity in this system. -
register
Registers an entity in this system's query.- See Also:
-
unregister
Unregisters an entity from this system's query.- See Also:
-
forEach
Iterates over each entity that matches the query of this system.- Parameters:
action
- Action to perform on each entity
-
forEachReverse
Iterates over each entity that matches the query of this system in reverse.- Parameters:
action
- Action to perform on each entity
-
sort
Sorts the entity chunks in this system based on a comparator. -
hasEntityChunks
public boolean hasEntityChunks()Returns true if this system has any entity chunks.- See Also:
-
print
public void print()
-