Class ECB

java.lang.Object
rosequartz.ecb.ECB

public final class ECB extends Object
Class for creating and accessing ECB objects. Recommended being statically imported. EntityComponentBehavior (ECB) structure:

 ┌──────────────────────────────────────────────────────────────────────┐
 │EntityComponentBehavior (ECB)                                         │
 │                                                                      │
 │ ┌───────────────────────────┐ ┌──────────────────────────────┐       │
 │ │Entity                     │ │Pipeline                      │       │
 │ │                           │ │                              │       │
 │ │Everything in your game is │ │All pipelines are executed    │       │
 │ │represented by an Entity.  │ │- one after the other -       │       │
 │ │                           │ │every game frame.             │       │
 │ │ ┌───────────────────────┐ │ │When a pipeline is executed,  │       │
 │ │ │Component              │ │ │all it's behaviors are        │       │
 │ │ │                       │ │ │executed AT THE SAME TIME.    │       │
 │ │ │Components hold data   │ │ │                              │       │
 │ │ │for entities.          │ │ │ ┌──────────────────────────┐ │       │
 │ │ │Each component should  │ │ │ │Behavior                  │ │       │
 │ │ │only hold data for     │ │ │ │                          │ │       │
 │ │ │ONE SPECIFIC           │ │ │ │Behaviors act upon        │ │       │
 │ │ │ATTRIBUTE.             │ │ │ │entities and their        │ │       │
 │ │ └───────────────────────┘ │ │ │components.               │ │       │
 │ │ more components...        │ │ │Each behavior should only │ │       │
 │ │                           │ │ │do ONE SPECIFIC THING.    │ │       │
 │ └───────────────────────────┘ │ └──────────────────────────┘ │       │
 │ more entities...              │ more behaviors...            │       │
 │                               │                              │       │
 │                               └──────────────────────────────┘       │
 │                               more pipelines...                      │
 │                                                                      │
 └──────────────────────────────────────────────────────────────────────┘
 
  • Method Details

    • _addBasePipeline

      public static void _addBasePipeline(Pipeline p)
      Adds a pipeline to the base-pipelines, which can not be removed later.
    • _runPipelines

      public static void _runPipelines() throws CallerNotEngineRuntimeException
      Throws:
      CallerNotEngineRuntimeException
    • add

      public static void add(Entity... e)
      Adds entities to the ECB.
      Parameters:
      e - the entities to add
    • remove

      public static void remove(Entity... e)
      Removes entities from the ECB.
      Parameters:
      e - the entities to remove
    • clearEntities

      public static void clearEntities()
      Removes all entities from the ECB.
    • add

      public static void add(Pipeline... p)
      Adds pipelines to the ECB. This freezes the pipeline.
      Parameters:
      p - the pipelines to add
    • remove

      public static void remove(Pipeline... p)
      Removes pipelines from the ECB.
      Parameters:
      p - the pipelines to remove
    • clearPipelines

      public static void clearPipelines()
      Removes all pipelines from the ECB.
    • get

      public static <C extends Component> void get(Class<C> component, BiConsumer<Entity,​C> action)
      Executes the given function for all entities with the given component.
      Parameters:
      component - class of the component all entities need to have
      action - the function to execute for each
    • get

      public static Entity[] get()
      Gets all entities in the ecb.
      Returns:
      all entities
    • getPipelineCount

      public static int getPipelineCount()
      Gets the amount of Pipelines in the ecb.
      Returns:
      pipeline count in ECB
    • getCopy

      public static Entity[] getCopy()
      Gets all entities (copied) in the ecb.
      Returns:
      all entities copied