Package com.tenio.engine.ecs.base
Class Entity
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.engine.ecs.base.Entity
-
- All Implemented Interfaces:
IEntity
public class Entity extends AbstractLogger implements IEntity
An entity is something that exists in your game world. Again, an entity is little more than a list of components. Because they are so simple, most implementations won't define an entity as a concrete piece of data. Instead, an entity is a unique ID, and all components that make up an entity will be tagged with that ID.- Author:
- kong
- See Also:
IEntity
-
-
Constructor Summary
Constructors Constructor Description Entity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
IComponent
getComponent(int index)
Retrieves the component by indexIElementPool<IComponent>[]
getComponentPools()
Retrieves the list of component poolsIComponent[]
getComponents()
Retrieves a list of the current entityContextInfo
getContextInfo()
Retrieves the context informationjava.lang.String
getId()
Retrieves the entity's idboolean
hasAnyComponent(int... indices)
Check if one of components in list are existed or notboolean
hasComponent(int index)
Check if the component is existed or notboolean
hasComponents(int... indices)
Check if all the components in list are existed or notint
hashCode()
void
removeAllComponents()
Remove all componentsvoid
removeComponent(int index)
Remove component by indexvoid
replaceComponent(int index, IComponent component)
Replace old component by new component by indexvoid
reset()
Reset entityvoid
setComponent(int index, IComponent component)
Set new componentvoid
setComponentPools(IElementPool<IComponent>[] componentPools)
Set list of component pools, each component pool manages specific component typevoid
setContextInfo(ContextInfo contextInfo)
Set context informationvoid
setId(java.lang.String id)
Set new id
-
-
-
Method Detail
-
setId
public void setId(java.lang.String id)
Description copied from interface:IEntity
Set new id
-
getId
public java.lang.String getId()
Description copied from interface:IEntity
Retrieves the entity's id
-
setContextInfo
public void setContextInfo(ContextInfo contextInfo)
Description copied from interface:IEntity
Set context information- Specified by:
setContextInfo
in interfaceIEntity
- Parameters:
contextInfo
- seeContextInfo
-
setComponentPools
public void setComponentPools(IElementPool<IComponent>[] componentPools)
Description copied from interface:IEntity
Set list of component pools, each component pool manages specific component type- Specified by:
setComponentPools
in interfaceIEntity
- Parameters:
componentPools
- an array ofComponentPool
-
getComponentPools
public IElementPool<IComponent>[] getComponentPools()
Description copied from interface:IEntity
Retrieves the list of component pools- Specified by:
getComponentPools
in interfaceIEntity
- Returns:
- an array of
ComponentPool
-
getContextInfo
public ContextInfo getContextInfo()
Description copied from interface:IEntity
Retrieves the context information- Specified by:
getContextInfo
in interfaceIEntity
- Returns:
- see
ContextInfo
-
setComponent
public void setComponent(int index, IComponent component)
Description copied from interface:IEntity
Set new component- Specified by:
setComponent
in interfaceIEntity
- Parameters:
index
- the component indexcomponent
- the component object
-
removeComponent
public void removeComponent(int index)
Description copied from interface:IEntity
Remove component by index- Specified by:
removeComponent
in interfaceIEntity
- Parameters:
index
- the component index
-
replaceComponent
public void replaceComponent(int index, IComponent component)
Description copied from interface:IEntity
Replace old component by new component by index- Specified by:
replaceComponent
in interfaceIEntity
- Parameters:
index
- the component indexcomponent
- the component object
-
getComponent
public IComponent getComponent(int index)
Description copied from interface:IEntity
Retrieves the component by index- Specified by:
getComponent
in interfaceIEntity
- Parameters:
index
- the component index- Returns:
- the corresponding component
-
getComponents
public IComponent[] getComponents()
Description copied from interface:IEntity
Retrieves a list of the current entity- Specified by:
getComponents
in interfaceIEntity
- Returns:
- list of components
-
hasComponent
public boolean hasComponent(int index)
Description copied from interface:IEntity
Check if the component is existed or not- Specified by:
hasComponent
in interfaceIEntity
- Parameters:
index
- component index- Returns:
- true if the component is existed, false otherwise
-
hasComponents
public boolean hasComponents(int... indices)
Description copied from interface:IEntity
Check if all the components in list are existed or not- Specified by:
hasComponents
in interfaceIEntity
- Parameters:
indices
- list of component indices- Returns:
- true if the all components are existed, false otherwise
-
hasAnyComponent
public boolean hasAnyComponent(int... indices)
Description copied from interface:IEntity
Check if one of components in list are existed or not- Specified by:
hasAnyComponent
in interfaceIEntity
- Parameters:
indices
- list of component indices- Returns:
- true if the one of components in list is existed, false otherwise
-
removeAllComponents
public void removeAllComponents()
Description copied from interface:IEntity
Remove all components- Specified by:
removeAllComponents
in interfaceIEntity
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-