abstract class Entitas::Entity
- Entitas::Entity
- Reference
- Object
Included Modules
Defined in:
entitas.crentitas/entity.cr
entitas/entity/components.cr
Constructors
Instance Method Summary
-
#add_component(index : Int32, component : Entitas::IComponent) : Entitas::IComponent
Will add the
Entitas::Component
at the provided index. -
#aerc : SafeAERC
Automatic Entity Reference Counting (AERC) is used internally to prevent pooling retained entities.
-
#context_info : Entitas::Context::Info
The
#context_info
is set by the context which created the entity and contains information about the context. - #create_component(index : Entitas::Component::Index, **args)
-
#destroy : Nil
Dispatches
OnDestroyEntity
which will start the destroy process. - #destroy! : Nil
-
#get_component(index : Int32) : Entitas::IComponent
Will return the
Entitas::Component
at the provided index. -
#get_component_indices : Enumerable(Int32)
Returns all indices of added components.
-
#get_components : Enumerable(Entitas::IComponent)
Returns all added components.
-
#has_any_component?(indices : Enumerable(Int32)) : Bool
Determines whether this entity has a component at any of the specified indices.
- #has_any_component?(indices : Enumerable(Entitas::Component::Index)) : Bool
-
#has_component?(index : Int32) : Bool
Determines whether this entity has a component at the specified index.
-
#has_components?(indices : Enumerable(Int32)) : Bool
Determines whether this entity has components at all the specified indices.
- #has_components?(indices : Enumerable(Entitas::Component::Index)) : Bool
- #init(creation_index ct_index : Int32 = 0, context_info ctx_info : Entitas::Context::Info | Nil = nil, aerc _aerc : SafeAERC | Nil = nil)
-
#internal_destroy!
This method is used internally.
-
#reactivate(creation_index : Int32, context_info : Entitas::Context::Info) : Entity
Re-enable the entity and set its creation index
-
#reactivate(creation_index : Int32) : Entity
Re-enable the entity and set its creation index
-
#release(owner)
Releases the entity.
-
#remove_all_components! : Nil
Removes all components.
- #remove_all_on_entity_released_handlers
-
#remove_component(index : Int32) : Nil
Removes a component at the specified index.
-
#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.
-
#retain(owner)
Retains the entity.
-
#retain_count : Int32
Returns the number of objects that retain this entity.
-
#retained_by?(owner)
Returns
Bool
if theowner
retains this instance - #to_json(json : JSON::Builder)
- #to_s(io)
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
Instance Method Detail
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.
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.
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.
Will return the Entitas::Component
at the provided index.
You can only get a component at an index if it exists.
Determines whether this entity has a component at any of the specified indices.
Determines whether this entity has a component at the specified index.
Determines whether this entity has components at all the specified indices.
Re-enable the entity and set its creation index
Re-enable the entity and set its creation index
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.
Removes a component at the specified index. You can only remove a component at an index if it exists.
Replaces an existing component at the specified index or adds it if it doesn't exist yet.
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.