public class Entity extends java.lang.Object implements ComponentStore
Constructor and Description |
---|
Entity()
Creates a new
Entity with a generated ID and a DefaultComponentStore |
Entity(ComponentStore componentStore)
Creates a new
Entity with a generated ID with a specific ComponentStore implementaton |
Entity(int id)
Creates a new
Entity with a specific ID and a DefaultComponentStore |
Entity(int id,
ComponentStore componentStore)
Creates a new
Entity with a specific ID and ComponentStore implementation |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Entity child) |
void |
addComponent(Component component)
|
void |
addEntityListener(EntityListener listener)
Adds an
EntityListener to this Entity |
void |
destroy()
Destroys this
Entity and deallocates its ID |
java.util.List<Entity> |
getChildren() |
<T> T |
getComponent(java.lang.Class<T> clazz) |
<T> T |
getComponent(int componentTypeId) |
<T extends Component> |
getComponent(java.lang.String name,
java.lang.Class<T> clazz) |
<T extends Component> |
getComponent(java.lang.String name,
int componentTypeId) |
<T extends Component> |
getComponentInDescendants(java.lang.Class<T> clazz) |
<T extends Component> |
getComponentInDescendants(int componentTypeId) |
<T extends Component> |
getComponentInDescendants(java.lang.String name,
java.lang.Class<T> clazz) |
<T extends Component> |
getComponentInDescendants(java.lang.String name,
int componentTypeId) |
<T> java.util.SortedSet<T> |
getComponents(java.lang.Class<T> clazz)
Returns all
Component s that implement the specified the class or
interface |
<T> java.util.SortedSet<T> |
getComponents(int componentTypeId)
Returns all
Component s that implement the specified the class or
interface |
<T extends Component> |
getComponentsInDescendants(java.lang.Class<T> clazz) |
<T extends Component> |
getComponentsInDescendants(int componentTypeId) |
int |
getId() |
java.util.UUID |
getUUID() |
<T extends Component> |
removeAllComponentsOfType(java.lang.Class<T> clazz)
Removes all
Component s that implement a specific type |
<T extends Component> |
removeAllComponentsOfType(int componentTypeId)
Removes all
Component s that implement a specific type |
void |
removeChild(Entity child) |
void |
removeComponent(Component component)
|
void |
removeEntityListener(EntityListener listener)
Removes an
EntityListener from this Entity |
public Entity()
Entity
with a generated ID and a DefaultComponentStore
public Entity(int id)
Entity
with a specific ID and a DefaultComponentStore
id
- The ID to allocate this Entity
public Entity(ComponentStore componentStore)
Entity
with a generated ID with a specific ComponentStore
implementatoncomponentStore
- The ComponentStore
implementation to usepublic Entity(int id, ComponentStore componentStore)
Entity
with a specific ID and ComponentStore
implementationid
- The ID to allocate this Entity
componentStore
- The ComponentStore
implementation to usepublic void destroy()
Entity
and deallocates its IDpublic void addChild(Entity child)
public void removeChild(Entity child)
public java.util.List<Entity> getChildren()
public <T> T getComponent(java.lang.Class<T> clazz)
getComponent
in interface ComponentStore
public <T extends Component> T getComponent(java.lang.String name, java.lang.Class<T> clazz)
getComponent
in interface ComponentStore
public <T extends Component> T getComponent(java.lang.String name, int componentTypeId)
getComponent
in interface ComponentStore
public void addComponent(Component component)
addComponent
in interface ComponentStore
component
- An instance of Component
public <T> java.util.SortedSet<T> getComponents(java.lang.Class<T> clazz)
Component
s that implement the specified the class or
interfacegetComponents
in interface ComponentStore
clazz
- The Class
to search forList
if no such Component
s are attached
to this Entity
public void removeComponent(Component component)
removeComponent
in interface ComponentStore
component
- The Component
to removepublic <T extends Component> java.util.SortedSet<T> removeAllComponentsOfType(java.lang.Class<T> clazz)
Component
s that implement a specific typeremoveAllComponentsOfType
in interface ComponentStore
clazz
- The Class
to search forpublic <T> T getComponent(int componentTypeId)
getComponent
in interface ComponentStore
public <T> java.util.SortedSet<T> getComponents(int componentTypeId)
ComponentStore
Component
s that implement the specified the class or
interfacegetComponents
in interface ComponentStore
componentTypeId
- The unique identifier of the component typeList
if no such Component
s are attached
to this Entity
public <T extends Component> java.util.SortedSet<T> removeAllComponentsOfType(int componentTypeId)
ComponentStore
Component
s that implement a specific typeremoveAllComponentsOfType
in interface ComponentStore
componentTypeId
- The unique identifier of the component typepublic <T extends Component> T getComponentInDescendants(java.lang.Class<T> clazz)
public <T extends Component> T getComponentInDescendants(int componentTypeId)
public <T extends Component> T getComponentInDescendants(java.lang.String name, java.lang.Class<T> clazz)
public <T extends Component> T getComponentInDescendants(java.lang.String name, int componentTypeId)
public <T extends Component> java.util.SortedSet<T> getComponentsInDescendants(java.lang.Class<T> clazz)
public <T extends Component> java.util.SortedSet<T> getComponentsInDescendants(int componentTypeId)
public void addEntityListener(EntityListener listener)
EntityListener
to this Entity
listener
- The EntityListener
to addpublic void removeEntityListener(EntityListener listener)
EntityListener
from this Entity
listener
- The EntityListener
to be removedpublic java.util.UUID getUUID()
public int getId()