java.lang.Object
technology.sola.ecs.Entity
-
Method Summary
Modifier and TypeMethodDescriptionaddComponent(Component component) Adds aComponentto this Entity.voiddestroy()Queues this Entity for destruction.<T extends Component>
@Nullable TgetComponent(Class<T> componentClass) Gets aComponentinstance for the class passed in.Returns a list of the currentComponentclasses that this entity has.intGets the integer id of this Entity.@Nullable StringgetName()Gets the name of this Entity.Gets the unique id of this entity that persists through serialization and deserialization.<T extends Component>
booleanhasComponent(Class<T> componentClass) booleanReturns whether this Entity should be considered disabled or not.voidremoveComponent(Class<? extends Component> componentClassToRemove) Removes aComponentfrom this Entity.setDisabled(boolean disabled) Updates the disabled state of this Entity.Sets the name of this Entity.
-
Method Details
-
getIndexInWorld
public int getIndexInWorld()Gets the integer id of this Entity.- Returns:
- the id of this Entity
-
getUniqueId
Gets the unique id of this entity that persists through serialization and deserialization.- Returns:
- the unique id of the Entity
-
getName
Gets the name of this Entity. A name is optional and will be null if not manually set.- Returns:
- the name of the Entity
-
setName
Sets the name of this Entity. A name can be used to look up an Entity viaWorld.findEntityByName(String).- Parameters:
name- the name of the Entity- Returns:
- this Entity
-
isDisabled
public boolean isDisabled()Returns whether this Entity should be considered disabled or not.- Returns:
- true if this Entity is disabled
-
setDisabled
Updates the disabled state of this Entity.- Parameters:
disabled- the new disabled state of this Entity- Returns:
- this
-
addComponent
Adds aComponentto this Entity.- Parameters:
component- theComponentto add- Returns:
- this Entity
-
removeComponent
Removes aComponentfrom this Entity.- Parameters:
componentClassToRemove- the Class of theComponentto remove
-
getComponent
Gets aComponentinstance for the class passed in.- Type Parameters:
T- the type of theComponentclass to get- Parameters:
componentClass- the class of theComponentto get- Returns:
- the
Componentinstance or null
-
hasComponent
- Type Parameters:
T- the type extendingComponent- Parameters:
componentClass-Componentclass to check for- Returns:
- true if
Entityhas theComponent
-
getCurrentComponents
Returns a list of the currentComponentclasses that this entity has.- Returns:
- the list of
Componentclasses
-
destroy
public void destroy()Queues this Entity for destruction. This typically should happen at the end of the current frame.
-