Package nz.ac.massey.javaecs
Class Entity
- java.lang.Object
-
- nz.ac.massey.javaecs.Entity
-
public class Entity extends Object
Entity class. Whilst an entity is just an Integer, and using Integer values would be more performant (no function call, primitive arrays and etc.), it is encapsulated to help distinguish between entities and Integers. Also, in this form it may be extended to also include things like names, grouping, specific ordering etc
-
-
Constructor Summary
Constructors Constructor Description Entity(int value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addComponent(Type componentType, Object componentData)
Deprecated.This function is not ECS-like.static Entity
asEntity(int value)
Returns the int value wrapped as an entity.boolean
equals(Object obj)
Object
getComponent(Type componentType)
Deprecated.This function is not ECS-like.int
getValue()
int
hashCode()
boolean
removeComponent(Type componentType)
Deprecated.This function is not ECS-like.
-
-
-
Field Detail
-
engineRef
protected static Engine engineRef
-
-
Method Detail
-
getValue
public int getValue()
-
asEntity
public static Entity asEntity(int value)
Returns the int value wrapped as an entity. Used to provide a distinction between creating a new entity, and using an int value we assume is a valid entity.Functionally, this is no different to creating a new entity.
- Parameters:
value
- the integer value to read as an Entity- Returns:
- an Entity object representing the ID value
-
addComponent
@Deprecated public boolean addComponent(Type componentType, Object componentData)
Deprecated.This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO designAdds the provided component to this entity.This function calls Engine.addComponent(Entity, Type, Object), so that should be used instead.
- Parameters:
componentType
- the class type of the component to addcomponentData
- the component data- Returns:
- true if successful
-
removeComponent
@Deprecated public boolean removeComponent(Type componentType)
Deprecated.This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO designRemoves the provided component from this entity.This function calls Engine.removeComponent(Entity, Type), so that should be used instead.
- Parameters:
componentType
- the class type of the component to remove- Returns:
- true if successful
-
getComponent
@Deprecated public Object getComponent(Type componentType)
Deprecated.This function is not ECS-like. It is provided as an auxilliary method, that will be more intuitive to those familiar with OO designGets the component data associated to this entity.This function calls Engine.getComponentData(), so that should be used instead.
- Parameters:
componentType
- the class type of the component to fetch data from- Returns:
- the data Object, which requires casting
-
-