class

Entitas::Entity

Inherits Entitas::IEntity / Entitas::Helper::ComponentPools / Reference / Object

Constructors

new(creation_index : Int32, total_components : Int32, component_pools : Array(ComponentPool), context_info : Entitas::Context::Info | Nil = nil, aerc : SafeAERC | Nil = nil)
Source

Instance methods

add_component(index : Int32, component : Entitas::IComponent) : Entitas::IComponent

Will add the Entitas::Component at the provided index. You can only have one component at an index. Each component type must have its own constant index.

Source
aerc

Automatic Entity Reference Counting (AERC) is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point.

Source
context_info

The context_info is set by the context which created the entity and contains information about the context. It's used to provide better error messages.

Source
create_component(index : Entitas::Component::Index, **args)
Source
destroy

Dispatches OnDestroyEntity which will start the destroy process.

Source
destroy!
Source
get_component(index : Int32) : Entitas::IComponent

Will return the Entitas::Component at the provided index. You can only get a component at an index if it exists.

Source
get_component_indices

Returns all indices of added components.

Source
get_components

Returns all added components.

Source
has_any_component?(indices : Enumerable(Int32)) : Bool

Determines whether this entity has a component at any of the specified indices.

Source
has_any_component?(indices : Enumerable(Entitas::Component::Index)) : Bool
Source
has_component?(index : Int32) : Bool

Determines whether this entity has a component at the specified index.

Source
has_components?(indices : Enumerable(Int32)) : Bool

Determines whether this entity has components at all the specified indices.

Source
has_components?(indices : Enumerable(Entitas::Component::Index)) : Bool
Source
init(creation_index ct_index : Int32 = 0, context_info ctx_info : Entitas::Context::Info | Nil = nil, aerc _aerc : SafeAERC | Nil = nil)
Source
internal_destroy!

This method is used internally. Don't call it yourself. use destroy

Source
reactivate(creation_index : Int32, context_info : Entitas::Context::Info) : Entity

Re-enable the entity and set its creation index

Source
reactivate(creation_index : Int32) : Entity

Re-enable the entity and set its creation index

Source
release(owner)

Releases the entity. An owner can only release an entity if it retains it. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point.

Source
remove_all_components!

Removes all components.

Source
remove_all_on_entity_released_handlers
Source
remove_component(index : Int32) : Nil

Removes a component at the specified index. You can only remove a component at an index if it exists.

Source
replace_component(index : Int32, component : Entitas::IComponent | Nil)

Replaces an existing component at the specified index or adds it if it doesn't exist yet.

Source
retain(owner)

Retains the entity. An owner can only retain the same entity once. Retain/Release is part of AERC (Automatic Entity Reference Counting) and is used internally to prevent pooling retained entities. If you use retain manually you also have to release it manually at some point.

Source
retain_count

Returns the number of objects that retain this entity.

Source
retained_by?(owner)

Returns Bool if the owner retains this instance

Source
to_json(json : JSON::Builder)
Source
to_s(io)
Source

Nested types