Package dev.prozilla.pine.core.system
Class SystemBase
java.lang.Object
dev.prozilla.pine.core.system.SystemBase
- 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 Applicationprotected Loggerprotected Sceneprotected World -
Constructor Summary
ConstructorsConstructorDescriptionSystemBase(Class<? extends Component>[] componentTypes) SystemBase(Class<? extends Component>[] componentTypes, boolean runOnce) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidforEach(Consumer<EntityChunk> action) Iterates over each entity that matches the query of this system.protected voidforEachReverse(Consumer<EntityChunk> action) Iterates over each entity that matches the query of this system in reverse.booleanReturns true if this system has any entity chunks.voidinitSystem(World world) Initializes this system and creates the query.voidprint()voidRegisters an entity in this system's query.protected final voidsetExcludedComponentTypes(Class<? extends Component>... componentTypes) protected voidsetRequiredTag(String tag) Restricts this system's query to entities with a given tag.protected voidsetRunWhenPaused(boolean runWhenPaused) booleanprotected voidsort(Comparator<EntityChunk> comparator) Sorts the entity chunks in this system based on a comparator.voidunregister(Entity entity) Unregisters an entity from this system's query.
-
Field Details
-
world
-
application
-
scene
-
logger
-
-
Constructor Details
-
SystemBase
-
SystemBase
-
-
Method Details
-
setRequiredTag
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
-
setRunWhenPaused
protected void setRunWhenPaused(boolean runWhenPaused) -
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:
-
shouldRun
public boolean shouldRun() -
print
public void print()
-