Entitas::Context(TEntity)
Inherits Entitas::Helper::ComponentPools / Enumerable / Entitas::Helper::Entities / Entitas::IContext / Reference / Object
A context manages the lifecycle of entities and groups. You can create and destroy entities and get groups of entities. The prefered way to create a context is to use the generated methods from the code generator, e.g. var context = new GameContext();
Constants
Constructors
Instance methods
Destroys all entities in the context. Throws an exception if there are still retained entities.
Returns a group for the specified matcher. Calling context.GetGroup(matcher) with the same matcher will always return the same instance of the group.
The contextInfo contains information about the context. It's used to provide better error messages.
Triggers update_groups_component_added_or_removed for the provided Entitas::Events::OnComponentAdded
Triggers update_groups_component_added_or_removed for the provided Entitas::Events::OnComponentRemoved
Triggers update_groups_component_added_or_removed for the provided Entitas::Events::OnComponentReplaced
Will destroy the entity provided in the Entitas::Events::OnDestroyEntity event. It will
delete it from the entities set, emit Entitas::Events::OnEntityWillBeDestroyed before destroying it,
as well as emit Entitas::Events::OnEntityDestroyed after distruction.
Method to process event: Entitas::Events::OnEntityCreated when emited. Will raise Entitas::Error::MethodNotImplemented
when not implimented if an Entitas::Events::OnEntityCreated is emitted.
def on_entity_created(event : Entitas::Events::OnEntityCreated) : Nil
# do something with event
end
Method to process event: Entitas::Events::OnEntityDestroyed when emited. Will raise Entitas::Error::MethodNotImplemented
when not implimented if an Entitas::Events::OnEntityDestroyed is emitted.
def on_entity_destroyed(event : Entitas::Events::OnEntityDestroyed) : Nil
# do something with event
end
Will clean the entity provided in the Entitas::Events::OnEntityReleased event. It will
remove all release handlers and append it to the reusable_entities cache
Method to process event: Entitas::Events::OnEntityWillBeDestroyed when emited. Will raise Entitas::Error::MethodNotImplemented
when not implimented if an Entitas::Events::OnEntityWillBeDestroyed is emitted.
def on_entity_will_be_destroyed(event : Entitas::Events::OnEntityWillBeDestroyed) : Nil
# do something with event
end
Method to process event: Entitas::Events::OnGroupCreated when emited. Will raise Entitas::Error::MethodNotImplemented
when not implimented if an Entitas::Events::OnGroupCreated is emitted.
def on_group_created(event : Entitas::Events::OnGroupCreated) : Nil
# do something with event
end
Removes all event handlers OnEntityCreated, OnEntityWillBeDestroyed, OnEntityDestroyed and OnGroupCreated