struct ECS::Entity
- ECS::Entity
- Struct
- Value
- Object
Overview
Сontainer for components. Consists from UInt64 and pointer to World
Defined in:
myecs.cryaml.cr
Constructors
Instance Method Summary
-
#add(comp : Component)
Adds component to the entity.
-
#destroy
Destroys entity removing all components from it.
-
#destroy_if_empty
Destroys entity if it is empty.
- #get_yaml_component
- #get_yaml_component_ptr
- #getYAMLComponent
- #getYAMLComponent?
- #getYAMLComponent_ptr
-
#has?(typ : ComponentType)
Returns true if component of type
typ
exists on the entity -
#id : EntityID
ID of entity
- #inspect(io)
-
#remove(typ : ComponentType)
Removes component of type
typ
from the entity. -
#remove_if_present(typ : ComponentType)
Removes component of type
typ
from the entity if it exists. -
#replace(typ : ComponentType, comp : Component)
Deletes component of type
typ
and add componentcomp
to the entity -
#set(comp : Component)
Adds component to the entity or update existing component of same type
- #to_cannon_io(io)
- #to_yaml(yaml : YAML::Nodes::Builder) : Nil
- #to_yaml_comps(yaml : YAML::Nodes::Builder) : Nil
- #to_yaml_id(yaml : YAML::Nodes::Builder) : Nil
-
#update(comp : Component)
Update existing component of same type on the entity.
-
#world : World
World that contains entity
- #yaml_component?
Constructor Detail
Instance Method Detail
Adds component to the entity.
Will raise if component already exists (and doesn't have Multiple
annotation)
Destroys entity removing all components from it. Entity ID is marked as free and can be reused
Destroys entity if it is empty. It is done automatically when last component is removed So the only use case is when you create entity then want to destroy if no components was added to it.
Removes component of type typ
from the entity. Will raise if component isn't present on entity
Removes component of type typ
from the entity if it exists. Otherwise, do nothing
Deletes component of type typ
and add component comp
to the entity
Adds component to the entity or update existing component of same type
Update existing component of same type on the entity. Will raise if component of this type isn't present.