public abstract class EntitySystem extends Object implements EntityObserver
It should not typically be used, but you can create your own entity system handling by extending this.
| Modifier and Type | Field and Description |
|---|---|
protected World |
world
The world this system belongs to.
|
| Constructor and Description |
|---|
EntitySystem(Aspect aspect)
Creates an entity system that uses the specified aspect as a matcher
against entities.
|
| Modifier and Type | Method and Description |
|---|---|
void |
added(Entity e)
Call when an entity interesting to the system is added to the world.
|
void |
added(ImmutableBag<Entity> entities) |
protected void |
begin()
Called before processing of entities begins.
|
void |
changed(Entity e)
Call when an entity interesting to the system has changed in the world.
|
void |
changed(ImmutableBag<Entity> entities) |
protected void |
check(Entity e)
Will check if the entity is of interest to this system.
|
protected boolean |
checkProcessing()
Check if the system should be processed.
|
void |
deleted(Entity e)
Call when an entity interesting to the system was deleted from the
world.
|
void |
deleted(ImmutableBag<Entity> entities) |
void |
disabled(Entity e)
Call when an entity interesting to the system was disabled.
|
protected void |
dispose()
see
World.dispose() |
void |
enabled(Entity e)
Call when an entity interesting to the system was (re)enabled.
|
protected void |
end()
Called after the processing of entities ends.
|
ImmutableBag<Entity> |
getActives()
Get all entities being processed by this system.
|
protected void |
initialize()
Override to implement code that gets executed when systems are
initialized.
|
protected void |
inserted(Entity e)
Called if the system has received a entity it is interested in, e.g
created or a component was added to it.
|
boolean |
isEnabled()
Returns true if the system is enabled.
|
boolean |
isPassive()
Check if this system is passive.
|
void |
process()
Process all entities this system is interested in.
|
protected abstract void |
processEntities(ImmutableBag<Entity> entities)
Any implementing entity system must implement this method and the logic
to process the given entities of the system.
|
protected void |
removed(Entity e)
Called if a entity was removed from this system, e.g deleted or had one
of it's components removed.
|
void |
setEnabled(boolean enabled)
Enabled systems are run during
process(). |
protected void |
setPassive(boolean passive)
Set if the system is passive or not.
|
protected void |
setWorld(World world)
Set the world this manager works on.
|
protected World world
public EntitySystem(Aspect aspect)
aspect - to match against entitiesprotected void begin()
Nota Bene: Any entities created in this method won't become active until the next system starts processing or when a new processing rounds beings, whichever comes first.
public final void process()
protected void end()
protected abstract void processEntities(ImmutableBag<Entity> entities)
entities - the entities this system contains.protected boolean checkProcessing()
protected void initialize()
protected void inserted(Entity e)
e - the entity that was added to this systemprotected void removed(Entity e)
e - the entity that was removed from this systempublic boolean isEnabled()
true if enabled, otherwise falsepublic void setEnabled(boolean enabled)
process().
Systems are enabled by default.
enabled - system will not run when set to falseprotected final void check(Entity e)
e - entity to checkpublic final void added(Entity e)
Checks if the system is interested in the added entity, if so, will insert it in to the system.
added in interface EntityObservere - the added entitypublic final void added(ImmutableBag<Entity> entities)
added in interface EntityObserverpublic final void changed(ImmutableBag<Entity> entities)
changed in interface EntityObserverpublic final void deleted(ImmutableBag<Entity> entities)
deleted in interface EntityObserverpublic final void changed(Entity e)
Checks if the system is still interested after the entity has changed, e.g a component was removed.
changed in interface EntityObservere - the changed entitypublic final void deleted(Entity e)
If the deleted entity is in this system, it will be removed.
deleted in interface EntityObservere - the deleted entitypublic final void disabled(Entity e)
If the disabled entity is in this system it will be removed
disabled in interface EntityObservere - the disabled entitypublic final void enabled(Entity e)
If the enabled entity is of interest, in will be (re)inserted.
enabled in interface EntityObservere - the (re)enabled entityprotected final void setWorld(World world)
world - the world to setpublic boolean isPassive()
A passive system will not process when World.process()
is called.
true if the system is passiveprotected void setPassive(boolean passive)
A passive system will not process when World.process()
is called.
passive - true if passive, false if notpublic ImmutableBag<Entity> getActives()
protected void dispose()
World.dispose()Copyright © 2014. All Rights Reserved.