Class search

java.lang.Object
name.moore.kevin.ze.game.verbs.search

public class search extends Object
Search for data in the entity repository.
Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • foundentities

      private Set<com.simsilica.es.EntityId> foundentities
    • foundcomponents

      private Map<Class,​com.simsilica.es.EntityComponent> foundcomponents
    • haystack

      private com.simsilica.es.EntityId haystack
    • entityrepository

      @Inject public com.simsilica.es.EntityData entityrepository
  • Constructor Details

    • search

      public search()
  • Method Details

    • setEntity

      public search setEntity(com.simsilica.es.EntityId s)
      Before using the searches, we need an Entity either by a search or by setting directly.
      Parameters:
      s -
      Returns:
    • findbyName

      public search findbyName(reference key)
    • findbyName

      public search findbyName(reference key, Class appliesto)
      Update foundentities with Entity Ids that match the Name component. The results will be EMPTY_SET if nothing found.
      Parameters:
      key -
      appliesto - eg engine.class
      Returns:
    • findEntities

      public Set<com.simsilica.es.EntityId> findEntities(com.simsilica.es.ComponentFilter cf, Class[] clazzes)
    • findParts

      public search findParts()
      Use the entities 'parts' component (if it has one) of installed or required equipment to provide a parts list (which is a list of those parts' EntityIds).

      Update foundentities with results or EMPTY_SET if unable to locate a parts component.

      Returns:
    • getEntity

      public com.simsilica.es.EntityId getEntity()
      End a search that resulted in a single entityId.
      Returns:
      first entity in the foundentities set or NULL_ID if search had no results.
    • getEntities

      public Set<com.simsilica.es.EntityId> getEntities()
      Returns:
      foundentities
    • findComponent

      public search findComponent(Class clazz)
      Parameters:
      clazz -
      Returns:
    • findComponents

      public search findComponents(Class[] clazzes)
      Attempt to locate all the specified components - any that cant be found WONt be in the foundcomponents results.
      Parameters:
      clazzes -
      Returns:
    • getEntityComponent

      public com.simsilica.es.EntityComponent getEntityComponent()
      End a search involving components. We return just the component value and not the class since its assumed we know that from the query we originally asked!
      Returns:
      null if component not found.
    • getEntityComponents

      public Map<Class,​com.simsilica.es.EntityComponent> getEntityComponents()
    • getEntitySet

      public com.simsilica.es.EntitySet getEntitySet(Class[] clazzes)
      Parameters:
      clazzes -
      Returns:
    • typeOfEntity

      public Class typeOfEntity()
      Given an existing entityid, work out what class (from extends XMLbase) of 'thing' it represents eg a ship, a planet.
      Returns:
    • report

      public StringBuilder report(Class[] clazzes)
      Create a detailed report of the repository state for testing purposes.
      Parameters:
      clazzes - the component classes to be included.
      Returns:
      built report