public interface EntitySystem extends Iterable<Entity>
addEntity()
or addEntity(Entity)
.
They can be removed (and effectively destroyed) with removeEntity(Entity)
.
After an Entity is created, Components can be added to it to store domain-specific data
and configure its behaviors. The specifics of the data and behavior depends on the
Component implementations and Tasks used to process your data.
The Scheduler
of an EntitySystem can be used to create Jobs
composed of Tasks
that will process the
entities within an entity system in an organized fashion. Generally, the processing of
all controllers through their different phases constitutes a complete "frame".
When Entities are created by an EntitySystem, the created instance is assigned an ID
which represents its true identity.
Use EntitySystem.Factory.create()
to get a new instance of an EntitySystem.Modifier and Type | Interface and Description |
---|---|
static class |
EntitySystem.Factory |
Modifier and Type | Method and Description |
---|---|
Entity |
addEntity()
Add a new Entity to this EntitySystem.
|
Entity |
addEntity(Entity template)
Add a new Entity to this EntitySystem.
|
void |
compact()
Compact the entity and component data so that iteration is more efficient.
|
<T extends Component,P extends Property> |
decorate(Class<T> type,
PropertyFactory<P> factory)
Dynamically update the available properties of the given Component type by adding a
Property created by the given PropertyFactory.
|
ComponentIterator |
fastIterator()
Return a new ComponentIterator that must be configured with required and optional
components before use.
|
Collection<Class<? extends Component>> |
getComponentTypes()
Get all Component interfaces currently used by the EntitySystem.
|
<T extends Component> |
getComponentTypes(Class<T> type)
Get all Component types within this EntitySystem that have types assignable to the
input type.
|
Scheduler |
getScheduler()
Return the Scheduler for this EntitySystem that can be used to organize processing
of the system using
Task implementations. |
Iterator<Entity> |
iterator()
Return an iterator over all of the entities within the system.
|
<T extends Component> |
iterator(Class<T> type)
Return an iterator over all components of with the given type.
|
void |
removeEntity(Entity e)
Remove the given entity from this system.
|
<T extends Component> Collection<Class<? extends T>> getComponentTypes(Class<T> type)
type
- The query typeNullPointerException
- if type is nullCollection<Class<? extends Component>> getComponentTypes()
Scheduler getScheduler()
Task
implementations.Iterator<Entity> iterator()
removeEntity(Entity)
.<T extends Component> Iterator<T> iterator(Class<T> type)
ComponentIterator
in a standard Iterator
with a single required component type.type
- The type of component to iterate overComponentIterator fastIterator()
void compact()
Entity addEntity()
addEntity(Entity)
.Entity addEntity(Entity template)
PropertyFactory.clone(com.lhkbob.entreri.property.Property,
int, com.lhkbob.entreri.property.Property, int)
, but by default it follows Java's
reference/value rule.
Specifying a null template makes this behave identically to addEntity()
.template
- The template to cloneIllegalStateException
- if the template is not a live entityvoid removeEntity(Entity e)
e
- The entity to removeNullPointerException
- if e is nullIllegalArgumentException
- if the entity was not created by this system, or
already removed<T extends Component,P extends Property> P decorate(Class<T> type, PropertyFactory<P> factory)
P
- The created property typetype
- The component type to mutatefactory
- The property factory that creates the decorating propertyNullPointerException
- if type or factory are nullCopyright © 2013. All Rights Reserved.