struct ECS::Entity

Overview

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

Defined in:

myecs.cr
yaml.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_cannon_io(io) : self #

[View source]
def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]

Instance Method Detail

def add(comp : Component) #

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


[View source]
def destroy #

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


[View source]
def 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.


[View source]
def getYAMLComponent #

[View source]
def getYAMLComponent? #

[View source]
def getYAMLComponent_ptr #

[View source]
def has?(typ : ComponentType) #

Returns true if component of type typ exists on the entity


[View source]
def id : EntityID #

ID of entity


[View source]
def inspect(io) #

[View source]
def remove(typ : ComponentType) #

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


[View source]
def remove_if_present(typ : ComponentType) #

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


[View source]
def replace(typ : ComponentType, comp : Component) #

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


[View source]
def set(comp : Component) #

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


[View source]
def to_cannon_io(io) #

[View source]
def to_yaml(yaml : YAML::Nodes::Builder) : Nil #

[View source]
def to_yaml_comps(yaml : YAML::Nodes::Builder) : Nil #

[View source]
def to_yaml_id(yaml : YAML::Nodes::Builder) : Nil #

[View source]
def update(comp : Component) #

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


[View source]
def world : World #

World that contains entity


[View source]