Class EntityQueryPool

java.lang.Object
dev.prozilla.pine.core.entity.EntityQueryPool

public class EntityQueryPool extends Object
Represents a pool that creates and stores entity queries. Each world has its own pool, because each world has different entities and components. Certain entity queries are disposable, meaning the system that consumes them might dispose the results of that query. Disposable queries cannot be included in the pool as their results are temporary.
  • Constructor Details

    • EntityQueryPool

      public EntityQueryPool()
  • Method Details

    • getQuery

      public EntityQuery getQuery(Class<? extends Component>[] includedComponentTypes, Class<? extends Component>[] excludedComponentTypes, boolean disposable, String tag)
      Fetches an entity query from the pool or creates a new one if it doesn't exist yet. If disposable is set to true, a new query will always be created. Disposable queries are queries that are consumed by systems that might dispose the results of their query, which means the query cannot be reused by other systems.
      Parameters:
      includedComponentTypes - Component types of the query
      disposable - Indicates whether the system that will consume this query might dispose its results.
      tag - Tag that the entity must have
    • clear

      public void clear()
    • generateQueryKey

      public static String generateQueryKey(Class<? extends Component>[] includedComponentTypes, Class<? extends Component>[] excludedComponentTypes, String tag)
      Generates a unique string key based on an array of component types for an entity query. The key is generated by concatenating the names of the component types in alphabetical order, separated by colons ":".
      Parameters:
      includedComponentTypes - Component types of the query
      tag - Entity tag of the query
      Returns:
      String key