public abstract class BaseEntitySystem extends BaseSystem implements EntitySubscription.SubscriptionListener
Modifier and Type | Field and Description |
---|---|
protected EntitySubscription |
subscription |
world
Constructor and Description |
---|
BaseEntitySystem() |
BaseEntitySystem(Aspect.Builder aspect)
Creates an entity system that uses the specified aspect as a matcher
against entities.
|
Modifier and Type | Method and Description |
---|---|
IntBag |
getEntityIds()
Gets the entities processed by this system.
|
EntitySubscription |
getSubscription() |
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 . |
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.
|
begin, checkProcessing, dispose, end, getWorld, initialize, isEnabled, process, processSystem, setEnabled
protected EntitySubscription subscription
public BaseEntitySystem()
public BaseEntitySystem(Aspect.Builder aspect)
aspect
- to match against entitiesprotected void setWorld(World world)
BaseSystem
setWorld
in class BaseSystem
world
- the world to setpublic EntitySubscription getSubscription()
public 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
public IntBag getEntityIds()
protected void inserted(int entityId)
entityId
- the entity that was added to this systempublic 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.
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
entities
- entities removed from this system.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.
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).
entityId
- the entity that was removed from this systemCopyright © 2019. All rights reserved.