Package rosequartz.ecb
Class ECB
java.lang.Object
rosequartz.ecb.ECB
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 Summary
Modifier and TypeMethodDescriptionstatic voidAdds a pipeline to the base-pipelines, which can not be removed later.static voidstatic voidAdds entities to the ECB.static voidAdds pipelines to the ECB.static voidRemoves all entities from the ECB.static voidRemoves all pipelines from the ECB.static Entity[]get()Gets all entities in the ecb.static <C extends Component>
voidget(Class<C> component, BiConsumer<Entity,C> action)Executes the given function for all entities with the given component.static Entity[]getCopy()Gets all entities (copied) in the ecb.static intGets the amount of Pipelines in the ecb.static voidRemoves entities from the ECB.static voidRemoves pipelines from the ECB.
-
Method Details
-
_addBasePipeline
Adds a pipeline to the base-pipelines, which can not be removed later. -
_runPipelines
- Throws:
CallerNotEngineRuntimeException
-
add
Adds entities to the ECB.- Parameters:
e- the entities to add
-
remove
Removes entities from the ECB.- Parameters:
e- the entities to remove
-
clearEntities
public static void clearEntities()Removes all entities from the ECB. -
add
Adds pipelines to the ECB. This freezes the pipeline.- Parameters:
p- the pipelines to add
-
remove
Removes pipelines from the ECB.- Parameters:
p- the pipelines to remove
-
clearPipelines
public static void clearPipelines()Removes all pipelines from the ECB. -
get
Executes the given function for all entities with the given component.- Parameters:
component- class of the component all entities need to haveaction- the function to execute for each
-
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
Gets all entities (copied) in the ecb.- Returns:
- all entities copied
-