abstract class Entitas::Entity

Included Modules

Defined in:

entitas.cr
entitas/entity.cr
entitas/entity/components.cr

Constructors

Instance Method Summary

Instance methods inherited from module Entitas::IEntity

add_component(index : Int32, component : Entitas::IComponent)
add_component(index : Entitas::Component::Index, component : Entitas::IComponent) : Entitas::IComponent
add_component(component : Entitas::IComponent) : Entitas::IComponent
add_component
, aerc : AERC aerc, component_index(index) : Entitas::Component::Index component_index, component_index_class(index) : Entitas::Component::ComponentTypes component_index_class, component_index_value(index) : Int32 component_index_value, component_pools : Array(Entitas::ComponentPool) component_pools, context_info : Entitas::Context::Info context_info, create_component(_type : Entitas::Component::ComponentTypes, **args)
create_component(index : Entitas::Component::Index, **args)
create_component
, creation_index : Int32 creation_index, destroy! : Nil destroy!, enabled? enabled?, get_component(index : Int32)
get_component(index : Entitas::Component::Index) : Entitas::IComponent
get_component
, get_component_indices : Enumerable(Int32) get_component_indices, get_components : Enumerable(Entitas::IComponent) get_components, has_any_component?(indices : Enumerable(Int32)) : Bool has_any_component?, has_component?(index : Int32) : Bool
has_component?(index : Entitas::Component::Index) : Bool
has_component?
, has_components?(indices : Enumerable(Int32)) : Bool has_components?, internal_destroy! internal_destroy!, on_component_added(&block : Entitas::Events::OnComponentAdded -> Nil) on_component_added, on_component_added_event_hooks : Array(Proc(Entitas::Events::OnComponentAdded, Nil)) on_component_added_event_hooks, on_component_removed(&block : Entitas::Events::OnComponentRemoved -> Nil) on_component_removed, on_component_removed_event_hooks : Array(Proc(Entitas::Events::OnComponentRemoved, Nil)) on_component_removed_event_hooks, on_component_replaced(&block : Entitas::Events::OnComponentReplaced -> Nil) on_component_replaced, on_component_replaced_event_hooks : Array(Proc(Entitas::Events::OnComponentReplaced, Nil)) on_component_replaced_event_hooks, on_destroy_entity(&block : Entitas::Events::OnDestroyEntity -> Nil) on_destroy_entity, on_destroy_entity_event_hooks : Array(Proc(Entitas::Events::OnDestroyEntity, Nil)) on_destroy_entity_event_hooks, on_entity_created(&block : Entitas::Events::OnEntityCreated -> Nil) on_entity_created, on_entity_created_event_hooks : Array(Proc(Entitas::Events::OnEntityCreated, Nil)) on_entity_created_event_hooks, on_entity_destroyed(&block : Entitas::Events::OnEntityDestroyed -> Nil) on_entity_destroyed, on_entity_destroyed_event_hooks : Array(Proc(Entitas::Events::OnEntityDestroyed, Nil)) on_entity_destroyed_event_hooks, on_entity_released(&block : Entitas::Events::OnEntityReleased -> Nil) on_entity_released, on_entity_released_event_hooks : Array(Proc(Entitas::Events::OnEntityReleased, Nil)) on_entity_released_event_hooks, on_entity_will_be_destroyed(&block : Entitas::Events::OnEntityWillBeDestroyed -> Nil) on_entity_will_be_destroyed, on_entity_will_be_destroyed_event_hooks : Array(Proc(Entitas::Events::OnEntityWillBeDestroyed, Nil)) on_entity_will_be_destroyed_event_hooks, on_group_created(&block : Entitas::Events::OnGroupCreated -> Nil) on_group_created, on_group_created_event_hooks : Array(Proc(Entitas::Events::OnGroupCreated, Nil)) on_group_created_event_hooks, reactivate(creation_index : Int32, context_info : Entitas::Context::Info)
reactivate(creation_index : Int32)
reactivate
, receive_on_component_added_event(event : Entitas::Events::OnComponentAdded) receive_on_component_added_event, receive_on_component_removed_event(event : Entitas::Events::OnComponentRemoved) receive_on_component_removed_event, receive_on_component_replaced_event(event : Entitas::Events::OnComponentReplaced) receive_on_component_replaced_event, receive_on_destroy_entity_event(event : Entitas::Events::OnDestroyEntity) receive_on_destroy_entity_event, receive_on_entity_created_event(event : Entitas::Events::OnEntityCreated) receive_on_entity_created_event, receive_on_entity_destroyed_event(event : Entitas::Events::OnEntityDestroyed) receive_on_entity_destroyed_event, receive_on_entity_released_event(event : Entitas::Events::OnEntityReleased) receive_on_entity_released_event, receive_on_entity_will_be_destroyed_event(event : Entitas::Events::OnEntityWillBeDestroyed) receive_on_entity_will_be_destroyed_event, receive_on_group_created_event(event : Entitas::Events::OnGroupCreated) receive_on_group_created_event, release(owner) release, remove_all_components! : Nil remove_all_components!, remove_all_on_entity_released_handlers remove_all_on_entity_released_handlers, remove_component(index : Int32)
remove_component(index : Entitas::Component::Index) : Nil
remove_component
, remove_on_component_added_hook(hook : Proc(Entitas::Events::OnComponentAdded, Nil)) remove_on_component_added_hook, remove_on_component_removed_hook(hook : Proc(Entitas::Events::OnComponentRemoved, Nil)) remove_on_component_removed_hook, remove_on_component_replaced_hook(hook : Proc(Entitas::Events::OnComponentReplaced, Nil)) remove_on_component_replaced_hook, remove_on_destroy_entity_hook(hook : Proc(Entitas::Events::OnDestroyEntity, Nil)) remove_on_destroy_entity_hook, remove_on_entity_created_hook(hook : Proc(Entitas::Events::OnEntityCreated, Nil)) remove_on_entity_created_hook, remove_on_entity_destroyed_hook(hook : Proc(Entitas::Events::OnEntityDestroyed, Nil)) remove_on_entity_destroyed_hook, remove_on_entity_released_hook(hook : Proc(Entitas::Events::OnEntityReleased, Nil)) remove_on_entity_released_hook, remove_on_entity_will_be_destroyed_hook(hook : Proc(Entitas::Events::OnEntityWillBeDestroyed, Nil)) remove_on_entity_will_be_destroyed_hook, remove_on_group_created_hook(hook : Proc(Entitas::Events::OnGroupCreated, Nil)) remove_on_group_created_hook, replace_component(index : Int32, component : Entitas::IComponent | Nil)
replace_component(index : Entitas::Component::Index, component : Entitas::IComponent | Nil)
replace_component(component : Entitas::IComponent | Nil)
replace_component
, retain_count : Int32 retain_count, retained_by?(owner) retained_by?, total_components : Int32 total_components

Instance methods inherited from module Entitas::Helper::ComponentPools

clear_component_pool(index : Int32)
clear_component_pool(index : Entitas::Component::ComponentTypes)
clear_component_pool
, clear_component_pools clear_component_pools, component_index_value(index) : Int32 component_index_value, component_pool(index : Int32) : ComponentPool
component_pool(index : Entitas::Component::ComponentTypes) : ComponentPool
component_pool(index : Entitas::Component::Index) : ComponentPool
component_pool
, component_pools : Array(Entitas::ComponentPool) component_pools

Constructor Detail

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

[View source]

Instance Method Detail

def 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.


[View source]
def aerc : SafeAERC #

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.


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


[View source]
def create_component(index : Entitas::Component::Index, **args) #

[View source]
def destroy : Nil #

Dispatches OnDestroyEntity which will start the destroy process.


[View source]
def destroy! : Nil #

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


[View source]
def get_component_indices : Enumerable(Int32) #

Returns all indices of added components.


[View source]
def get_components : Enumerable(Entitas::IComponent) #

Returns all added components.


[View source]
def has_any_component?(indices : Enumerable(Int32)) : Bool #

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


[View source]
def has_any_component?(indices : Enumerable(Entitas::Component::Index)) : Bool #

[View source]
def has_component?(index : Int32) : Bool #

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


[View source]
def has_components?(indices : Enumerable(Int32)) : Bool #

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


[View source]
def has_components?(indices : Enumerable(Entitas::Component::Index)) : Bool #

[View source]
def init(creation_index ct_index : Int32 = 0, context_info ctx_info : Entitas::Context::Info | Nil = nil, aerc _aerc : SafeAERC | Nil = nil) #

[View source]
def internal_destroy! #

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


[View source]
def reactivate(creation_index : Int32, context_info : Entitas::Context::Info) : Entity #

Re-enable the entity and set its creation index


[View source]
def reactivate(creation_index : Int32) : Entity #

Re-enable the entity and set its creation index


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


[View source]
def remove_all_components! : Nil #

Removes all components.


[View source]
def remove_all_on_entity_released_handlers #

[View source]
def remove_component(index : Int32) : Nil #

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


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


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


[View source]
def retain_count : Int32 #

Returns the number of objects that retain this entity.


[View source]
def retained_by?(owner) #

Returns Bool if the owner retains this instance


[View source]
def to_json(json : JSON::Builder) #

[View source]
def to_s(io) #

[View source]