Class EntityQuery

java.lang.Object
dev.prozilla.pine.core.entity.EntityQuery
All Implemented Interfaces:
Lifecycle

public class EntityQuery extends Object implements Lifecycle
Utility class for querying entities with specific components to be processed by a system.
  • Field Details

    • entityChunks

      public final ArrayList<EntityChunk> entityChunks
      List of entities that match this query.
    • isIterating

      public boolean isIterating
  • Constructor Details

    • EntityQuery

      public EntityQuery(Class<? extends Component>[] includedComponentTypes, Class<? extends Component>[] excludedComponentTypes, boolean disposable, String tag)
  • Method Details

    • destroy

      public void destroy()
      Removes all component groups.
      Specified by:
      destroy in interface Lifecycle
    • startIteration

      public void startIteration() throws IllegalStateException
      Prepares this entity query for an iteration.
      Throws:
      IllegalStateException - If this entity query is already being iterated.
    • endIteration

      public void endIteration() throws IllegalStateException
      Marks the ongoing iteration of this entity query as done.
      Throws:
      IllegalStateException - If this entity query is not being iterated.
    • register

      public boolean register(Entity entity)
      Checks if an entity matches this query and if it does, adds the entity to the array of matches.
      Returns:
      True if the entity matches this query
    • unregister

      public boolean unregister(Entity entity)
      Unregisters an entity in this query.
      Parameters:
      entity - The entity
      Returns:
      True if this query was affected.
    • hasEntityChunks

      public boolean hasEntityChunks()
      Checks if this entity query has matched any entities.
    • print

      public void print()
    • print

      public void print(Logger logger)