com.artemis
Class ComponentMapper<A extends Component>

java.lang.Object
  extended by com.artemis.ComponentMapper<A>
Type Parameters:
A - the class type of the component

public class ComponentMapper<A extends Component>
extends java.lang.Object

High performance component retrieval from entities. Use this wherever you need to retrieve components from entities often and fast.

Author:
Arni Arent

Method Summary
 A get(Entity e)
          Fast but unsafe retrieval of a component for this entity.
static
<T extends Component>
ComponentMapper<T>
getFor(java.lang.Class<T> type, World world)
          Returns a component mapper for this type of components.
 A getSafe(Entity e)
          Fast and safe retrieval of a component for this entity.
 boolean has(Entity e)
          Checks if the entity has this type of component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public A get(Entity e)
Fast but unsafe retrieval of a component for this entity. No bounding checks, so this could throw an ArrayIndexOutOfBoundsExeption, however in most scenarios you already know the entity possesses this component.

Parameters:
e - the entity that should possess the component
Returns:
the instance of the component

getSafe

public A getSafe(Entity e)
Fast and safe retrieval of a component for this entity. If the entity does not have this component then null is returned.

Parameters:
e - the entity that should possess the component
Returns:
the instance of the component

has

public boolean has(Entity e)
Checks if the entity has this type of component.

Parameters:
e - the entity to check
Returns:
true if the entity has this component type, false if it doesn't.

getFor

public static <T extends Component> ComponentMapper<T> getFor(java.lang.Class<T> type,
                                                              World world)
Returns a component mapper for this type of components.

Parameters:
type - the type of components this mapper uses.
world - the world that this component mapper should use.
Returns:
a new mapper.


Copyright © 2012 Gamadu. All Rights Reserved.