Class SystemBase

java.lang.Object
dev.prozilla.pine.core.system.SystemBase
All Implemented Interfaces:
Lifecycle
Direct Known Subclasses:
InitSystemBase, InputSystemBase, RenderSystemBase, UpdateSystemBase

public abstract class SystemBase extends Object implements Lifecycle
Base class for system responsible for handling logic and behaviour for entities that match a query based on their components.
  • Field Details

    • world

      protected World world
    • application

      protected Application application
    • scene

      protected Scene scene
    • logger

      protected Logger logger
  • Constructor Details

    • SystemBase

      public SystemBase(Class<? extends Component>[] componentTypes)
    • SystemBase

      public SystemBase(Class<? extends Component>[] componentTypes, boolean runOnce)
  • Method Details

    • requireTag

      protected void requireTag(String tag) throws IllegalStateException
      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

      public void initSystem(World world)
      Initializes this system and creates the query. If there are already entities in the world, this will register each entity in this system.
    • register

      public void register(Entity entity)
      Registers an entity in this system's query.
      See Also:
    • unregister

      public void unregister(Entity entity)
      Unregisters an entity from this system's query.
      See Also:
    • forEach

      protected void forEach(Consumer<EntityChunk> action)
      Iterates over each entity that matches the query of this system.
      Parameters:
      action - Action to perform on each entity
    • forEachReverse

      protected void forEachReverse(Consumer<EntityChunk> action)
      Iterates over each entity that matches the query of this system in reverse.
      Parameters:
      action - Action to perform on each entity
    • sort

      protected void sort(Comparator<EntityChunk> comparator)
      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()