public class Entity
extends java.lang.Object
A group of components that exist and are processed together
Entity should usually not be extended; instead, users of this
class should create new Entities, give them components in
add(Object), and then add the Entity to the engine
with GameEngine.add(Entity).
| Constructor and Description |
|---|
Entity(java.lang.Object... components) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Object component)
Add a component to this
Entity if a component of the same type
does not already exist |
<T> T |
get(java.lang.Class<T> componentType)
Retrieves a component from this
Entity |
GameEngine |
getEngine() |
boolean |
hasAll(java.util.Collection<java.lang.Class<?>> componentTypes) |
boolean |
hasAny(java.util.Collection<java.lang.Class<?>> componentTypes) |
boolean |
hasNone(java.util.Collection<java.lang.Class<?>> componentTypes) |
boolean |
remove(java.lang.Class<?> componentType)
Removes a component from this
Entity |
void |
setEngine(GameEngine engine) |
public void setEngine(GameEngine engine)
public GameEngine getEngine()
public boolean add(java.lang.Object component)
Entity if a component of the same type
does not already existcomponent - The component to addtrue if the component was added, else falsepublic <T> T get(java.lang.Class<T> componentType)
EntitycomponentType - The class of the component to retrievenullpublic boolean remove(java.lang.Class<?> componentType)
EntitycomponentType - The class of the component to retrievetrue if a component was removed, else falsepublic boolean hasAll(java.util.Collection<java.lang.Class<?>> componentTypes)
componentTypes - Classes to match against this entity's componentstrue if there is a component of every listed type, else falsepublic boolean hasAny(java.util.Collection<java.lang.Class<?>> componentTypes)
componentTypes - Classes to match against this entity's componentstrue if there is a component of at least one listed type, else falsepublic boolean hasNone(java.util.Collection<java.lang.Class<?>> componentTypes)
componentTypes - Classes to match against this entity's componentstrue if there are no components of the listed types, else false