A - Component type to map.public class ComponentMapper<A extends Component> extends BaseComponentMapper<A>
This is the recommended way to mutate composition and access components. Component Mappers are as fast as Transmuters.
type| Constructor and Description |
|---|
ComponentMapper(Class<A> type,
World world) |
| Modifier and Type | Method and Description |
|---|---|
A |
create(int entityId)
Create component for this entity.
|
A |
get(int entityId)
Fast but unsafe retrieval of a component for this entity.
|
boolean |
has(int entityId)
Checks if the entity has this type of component.
|
A |
internalCreate(int entityId) |
protected void |
internalRemove(int entityId) |
void |
remove(int entityId)
Schedule component for removal.
|
public A get(int entityId) throws ArrayIndexOutOfBoundsException
This method trades performance for safety!
Might return null, throw ArrayIndexOutOfBoundsException or a partially recycled
component if called on in-system removed components.
Only exception are components marked with DelayedComponentRemoval, when calling
this method from within a subscription listener.
get in class BaseComponentMapper<A extends Component>entityId - the entity that should possess the componentArrayIndexOutOfBoundsExceptionpublic boolean has(int entityId)
Removed components flagged with DelayedComponentRemoval will report false
immediately after removal but will still be available using get(int).
has in class BaseComponentMapper<A extends Component>entityId - the id of entity to checktrue if the entity has this component type, false if it doesn't (or if it is scheduled for delayed removal).public void remove(int entityId)
Components annotated with DelayedComponentRemoval (or all components if World.isAlwaysDelayComponentRemoval()
mode is active) are removed after the system finishes processing and all subscribers have been called. However,
has(int) will immediately return false as if it was removed!
Non-delayed components are removed immediately. The component reference becomes invalid and should be discarded.
Immediate following calls to has(int) will return false, get(int) will return null.
AspectSubscriptions will reflect the changes only AFTER the system finishes processing.
Does nothing if already removed.
remove in class BaseComponentMapper<A extends Component>entityId - protected void internalRemove(int entityId)
internalRemove in class BaseComponentMapper<A extends Component>public A create(int entityId)
create in class BaseComponentMapper<A extends Component>entityId - the entity that should possess the componentpublic A internalCreate(int entityId)
internalCreate in class BaseComponentMapper<A extends Component>Copyright © 2019. All rights reserved.