public abstract class BaseComponentMapper<A extends Component> extends Object
| Modifier and Type | Field and Description |
|---|---|
ComponentType |
type
The type of components this mapper handles.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BaseComponentMapper(ComponentType type) |
| Modifier and Type | Method and Description |
|---|---|
A |
create(Entity entity)
Create component for this entity.
|
abstract A |
create(int entityId) |
A |
get(Entity e)
Fast but unsafe retrieval of a component for this entity.
|
abstract A |
get(int entityId)
Fast but unsafe retrieval of a component for this entity.
|
static <T extends Component> |
getFor(Class<T> type,
World world)
Returns a component mapper for this type of components.
|
A |
getSafe(Entity entity,
A fallback)
Fast and safe retrieval of a component for this entity.
|
A |
getSafe(int entityId,
A fallback)
Fast and safe retrieval of a component for this entity.
|
ComponentType |
getType()
Returns the ComponentType of this ComponentMapper.
|
boolean |
has(Entity e)
Checks if the entity has this type of component.
|
abstract boolean |
has(int entityId) |
abstract A |
internalCreate(int entityId) |
protected abstract void |
internalRemove(int entityId) |
void |
remove(Entity entity)
Remove component from entity.
|
abstract void |
remove(int entityId) |
A |
set(Entity entity,
boolean value)
Create or remove a component from an entity.
|
A |
set(int entityId,
boolean value)
Create or remove a component from an entity.
|
String |
toString() |
public final ComponentType type
protected BaseComponentMapper(ComponentType type)
public static <T extends Component> BaseComponentMapper<T> getFor(Class<T> type, World world)
T - the class type of componentstype - the class of components this mapper usesworld - the world that this component mapper should usepublic A get(Entity e) throws ArrayIndexOutOfBoundsException
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.e - the entity that should possess the componentArrayIndexOutOfBoundsExceptionpublic abstract A get(int entityId) throws ArrayIndexOutOfBoundsException
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.entityId - the entity that should possess the componentArrayIndexOutOfBoundsExceptionpublic boolean has(Entity e) throws ArrayIndexOutOfBoundsException
e - the entity to checkArrayIndexOutOfBoundsExceptionpublic abstract boolean has(int entityId)
public A create(Entity entity)
entity - the entity that should possess the componentpublic abstract void remove(int entityId)
public void remove(Entity entity)
entity - entity to remove.protected abstract void internalRemove(int entityId)
public abstract A create(int entityId)
public abstract A internalCreate(int entityId)
public A getSafe(int entityId, A fallback)
entityId - Entity that should possess the componentfallback - fallback component to return, or null to return null.public A set(int entityId, boolean value)
entityId - Entity id to change.value - true to create component (if missing), false to remove (if exists).null if removed.public A set(Entity entity, boolean value)
entity - Entity to change.value - true to create component (if missing), false to remove (if exists).null if removed.public A getSafe(Entity entity, A fallback)
entity - Entity that should possess the componentfallback - fallback component to return, or null to return null.public ComponentType getType()
typeCopyright © 2019. All rights reserved.