public abstract class EntitySystem extends BaseEntitySystem implements EntitySubscription.SubscriptionListener
BaseEntitySystem
, but uses Entity references instead of int.
This system exists as a convenience for users migrating from other Artemis
clones or older versions of odb. We recommend using the int systems over
the Entity variants.subscription
world
Constructor and Description |
---|
EntitySystem() |
EntitySystem(Aspect.Builder aspect)
Creates an entity system that uses the specified aspect as a matcher
against entities.
|
Modifier and Type | Method and Description |
---|---|
Bag<Entity> |
getEntities()
Gets the entities processed by this system.
|
void |
inserted(Entity e)
Called if entity has come into scope for this system, e.g
created or a component was added to it.
|
protected void |
inserted(int entityId)
Called if entity has come into scope for this system, e.g created or a component was added to it.
|
void |
inserted(IntBag entities)
Called after entities match an
EntitySubscription . |
void |
removed(Entity e)
Called if entity has gone out of scope of this system, e.g deleted
or had one of it's components removed.
|
protected void |
removed(int entityId)
Called if entity has gone out of scope of this system, e.g deleted
or had one of it's components removed.
|
void |
removed(IntBag entities)
Called if entity has gone out of scope of this system, e.g deleted
or had one of it's components removed.
|
protected void |
setWorld(World world)
Set the world this system works on.
|
getEntityIds, getSubscription
begin, checkProcessing, dispose, end, getWorld, initialize, isEnabled, process, processSystem, setEnabled
public EntitySystem(Aspect.Builder aspect)
aspect
- to match against entitiespublic EntitySystem()
protected void setWorld(World world)
setWorld
in class BaseEntitySystem
world
- the world to setpublic final void inserted(IntBag entities)
EntitySubscription.SubscriptionListener
EntitySubscription
.
Triggers right after a system finishes processing. Adding and immediately removing a component does not
permanently change the composition and will prevent this method from being called.
Not triggered for entities that have been destroyed immediately after being created (within a system).inserted
in interface EntitySubscription.SubscriptionListener
inserted
in class BaseEntitySystem
protected final void inserted(int entityId)
BaseEntitySystem
inserted
in class BaseEntitySystem
entityId
- the entity that was added to this systempublic final void removed(IntBag entities)
BaseEntitySystem
Called if entity has gone out of scope of this system, e.g deleted or had one of it's components removed.
Explicitly removed components are only retrievable at this point
if annotated with DelayedComponentRemoval
.
Deleted entities retain all their components - until all listeners have been informed.
removed
in interface EntitySubscription.SubscriptionListener
removed
in class BaseEntitySystem
entities
- entities removed from this system.protected final void removed(int entityId)
BaseEntitySystem
Called if entity has gone out of scope of this system, e.g deleted or had one of it's components removed.
Important note on accessing components:
Using ComponentMapper.get(int)
to retrieve a component is unsafe, unless:
- You annotate the component with DelayedComponentRemoval
.
- World.isAlwaysDelayComponentRemoval()
is enabled to make accessing all components safe,
for a small performance hit.
ComponentMapper.has(int)
always returns false
, even for DelayedComponentRemoval components.
Can trigger for entities that have been destroyed immediately after being created (within a system).
removed
in class BaseEntitySystem
entityId
- the entity that was removed from this systempublic void inserted(Entity e)
e
- the entity that was added to this systempublic void removed(Entity e)
Called if entity has gone out of scope of this system, e.g deleted or had one of it's components removed.
Explicitly removed components are only retrievable at this point
if annotated with DelayedComponentRemoval
.
Deleted entities retain all their components - until all listeners have been informed.
e
- the entity that was removed from this systemCopyright © 2019. All rights reserved.