struct

ECS::Entity

Inherits Struct / Value / Object

Сontainer for components. Consists from UInt64 and pointer to World

Constructors

from_cannon_io(io) : self
Source
new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source

Instance methods

add(comp : Component)

Adds component to the entity. Will raise if component already exists (and doesn't have Multiple annotation)

Source
destroy

Destroys entity removing all components from it. Entity ID is marked as free and can be reused

Source
destroy_if_empty

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.

Source
getYAMLComponent
Source
getYAMLComponent?
Source
getYAMLComponent_ptr
Source
has?(typ : ComponentType)

Returns true if component of type typ exists on the entity

Source
id

ID of entity

Source
inspect(io)
Source
remove(typ : ComponentType)

Removes component of type typ from the entity. Will raise if component isn't present on entity

Source
remove_if_present(typ : ComponentType)

Removes component of type typ from the entity if it exists. Otherwise, do nothing

Source
replace(typ : ComponentType, comp : Component)

Deletes component of type typ and add component comp to the entity

Source
set(comp : Component)

Adds component to the entity or update existing component of same type

Source
to_cannon_io(io)
Source
to_yaml(yaml : YAML::Nodes::Builder) : Nil
Source
to_yaml_comps(yaml : YAML::Nodes::Builder) : Nil
Source
to_yaml_id(yaml : YAML::Nodes::Builder) : Nil
Source
update(comp : Component)

Update existing component of same type on the entity. Will raise if component of this type isn't present.

Source
world

World that contains entity

Source