public final class Entity extends Object
Cannot be instantiated outside the framework, you must create new entities using World. The world creates entities via it's entity manager.
| Modifier | Constructor and Description |
|---|---|
protected |
Entity(World world,
int id)
Creates a new
Entity instance in the given world. |
protected |
Entity(World world,
int id,
UUID uuid)
Creates a new
Entity instance in the given world. |
| Modifier and Type | Method and Description |
|---|---|
Entity |
addComponent(Component component)
Deprecated.
See
edit() |
Entity |
addComponent(Component component,
ComponentType type)
Deprecated.
See
edit() |
void |
addToWorld()
Deprecated.
Automatically managed.
|
void |
changedInWorld()
Deprecated.
Automatically managed.
|
<T extends Component> |
createComponent(Class<T> componentKlazz)
Deprecated.
See
edit() |
void |
deleteFromWorld()
Delete this entity from the world.
|
void |
disable()
Deprecated.
create your own components to track state.
|
EntityEdit |
edit() |
void |
enable()
Deprecated.
create your own components to track state.
|
<T extends Component> |
getComponent(Class<T> type)
Slower retrieval of components from this entity.
|
Component |
getComponent(ComponentType type)
Retrieves component from this entity.
|
protected BitSet |
getComponentBits()
Returns a BitSet instance containing bits of the components the entity
possesses.
|
Bag<Component> |
getComponents(Bag<Component> fillBag)
Returns a bag of all components this entity has.
|
int |
getCompositionId() |
int |
getId()
The internal id for this entity within the framework.
|
UUID |
getUuid()
Get the UUID for this entity.
|
World |
getWorld()
Returns the world this entity belongs to.
|
boolean |
isActive()
Checks if the entity has been added to the world and has not been
deleted from it.
|
boolean |
isEnabled()
Deprecated.
use components to implement state instead.
|
Entity |
removeComponent(Class<? extends Component> type)
Deprecated.
See
edit() |
Entity |
removeComponent(Component component)
Deprecated.
See
edit() |
Entity |
removeComponent(ComponentType type)
Deprecated.
See
edit() |
void |
setUuid(UUID uuid) |
String |
toString() |
protected Entity(World world, int id)
Entity instance in the given world.
This will only be called by the world via it's entity manager, and not directly by the user, as the world handles creation of entities.
world - the world to create the entity inid - the id to setprotected Entity(World world, int id, UUID uuid)
Entity instance in the given world.
This will only be called by the world via it's entity manager, and not directly by the user, as the world handles creation of entities.
world - the world to create the entity inid - the id to setuuid - the UUID to setpublic int getId()
No other entity will have the same ID, but ID's are however reused so another entity may acquire this ID if the previous entity was deleted.
protected BitSet getComponentBits()
public EntityEdit edit()
@Deprecated public <T extends Component> T createComponent(Class<T> componentKlazz)
edit()@Deprecated public Entity addComponent(Component component)
edit()@Deprecated public Entity addComponent(Component component, ComponentType type)
edit()@Deprecated public Entity removeComponent(Component component)
edit()@Deprecated public Entity removeComponent(ComponentType type)
edit()@Deprecated public Entity removeComponent(Class<? extends Component> type)
edit()public boolean isActive()
If the entity has been disabled this will still return true.
true if it's active@Deprecated public boolean isEnabled()
By default all entities that are added to world are enabled, this will only return false if an entity has been explicitly disabled.
true if it's enabledpublic Component getComponent(ComponentType type)
It will provide good performance. But the recommended way to retrieve components from an entity is using the ComponentMapper.
type - in order to retrieve the component fast you must provide a
ComponentType instance for the expected componentpublic <T extends Component> T getComponent(Class<T> type)
Minimize usage of this, but is fine to use e.g. when creating new entities and setting data in components.
T - the expected return component class typetype - the expected return component class typepublic Bag<Component> getComponents(Bag<Component> fillBag)
You need to reset the bag yourself if you intend to fill it more than once.
fillBag - the bag to put the components into@Deprecated public void addToWorld()
@Deprecated public void changedInWorld()
public void deleteFromWorld()
@Deprecated public void enable()
Won't do anything unless it was already disabled.
@Deprecated public void disable()
Won't delete it, it will continue to exist but won't get processed.
public UUID getUuid()
This UUID is unique per entity (re-used entities get a new UUID).
public void setUuid(UUID uuid)
public World getWorld()
public int getCompositionId()
Copyright © 2014. All Rights Reserved.