java.lang.Object
technology.sola.ecs.Entity
-
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component component) Adds aComponent
to this Entity.void
destroy()
Queues this Entity for destruction.<T extends Component>
@Nullable TgetComponent
(Class<T> componentClass) Gets aComponent
instance for the class passed in.Returns a list of the currentComponent
classes that this entity has.int
Gets the integer id of this Entity.@Nullable String
getName()
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) boolean
Returns whether this Entity should be considered disabled or not.void
removeComponent
(Class<? extends Component> componentClassToRemove) Removes aComponent
from 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
-
destroy
public void destroy()Queues this Entity for destruction. This typically should happen at the end of the current frame. -
addComponent
Adds aComponent
to this Entity.- Parameters:
component
- theComponent
to add- Returns:
- this Entity
-
getComponent
Gets aComponent
instance for the class passed in.- Type Parameters:
T
- the type of theComponent
class to get- Parameters:
componentClass
- the class of theComponent
to get- Returns:
- the
Component
instance or null
-
hasComponent
- Type Parameters:
T
- the type extendingComponent
- Parameters:
componentClass
-Component
class to check for- Returns:
- true if
Entity
has theComponent
-
removeComponent
Removes aComponent
from this Entity.- Parameters:
componentClassToRemove
- the Class of theComponent
to remove
-
getCurrentComponents
Returns a list of the currentComponent
classes that this entity has.- Returns:
- the list of
Component
classes
-