class Crash::ComponentMatchingFamily
- Crash::ComponentMatchingFamily
- Crash::Family
- Reference
- Object
Overview
The default class for managing a NodeList. This class creates the NodeList and adds and removes nodes to/from the list as the entities and the components in the engine change.
It uses the basic entity matching pattern of an entity system - entities are added to the list if they contain components matching all the public properties of the node class.
Defined in:
crash/component_matching_family.crConstructors
-
.new(engine : Crash::Engine, *components : Crash::Component.class)
The constructor.
Instance Method Summary
-
#clean_up
Removes all entities from the entity list.
-
#component_added_to_entity(entity : Crash::Entity, component_class : Crash::Component.class)
Called by the engine when a component has been added to an entity.
-
#component_removed_from_entity(entity : Crash::Entity, component_class : Crash::Component.class)
Called by the engine when a component has been removed from an entity.
-
#entity_list : Array(Crash::Entity)
The entity list managed by this family.
-
#new_entity(entity : Crash::Entity)
Called by the engine when an entity has been added to it.
-
#remove_entity(entity : Crash::Entity)
Called by the engine when an entity has been rmoved from it.
Instance methods inherited from class Crash::Family
clean_up
clean_up,
component_added_to_entity(entity : Crash::Entity, component_class : Crash::Component.class)
component_added_to_entity,
component_removed_from_entity(entity : Crash::Entity, component_class : Crash::Component.class)
component_removed_from_entity,
entity_list : Array(Crash::Entity)
entity_list,
new_entity(entity : Crash::Entity)
new_entity,
remove_entity(entity : Crash::Entity)
remove_entity
Constructor Detail
The constructor. Creates a ComponentMatchingFamily to provide a NodeList for the given node class.
@param nodeClass The type of node to create and manage a NodeList for. @param engine The engine that this family is managing teh NodeList for.
Instance Method Detail
Called by the engine when a component has been added to an entity. We check if the entity is not in this family's entity list and should be, and add it if appropriate.
Called by the engine when a component has been removed from an entity. We check if the removed component is required by this family's entity list and if so, we check if the entity is in this this entity list and remove it if so.
The entity list managed by this family. This is a reference that remains valid always since it is retained and reused by Systems that use the list. i.e. we never recreate the list, we always modify it in place.
Called by the engine when an entity has been added to it. We check if the entity should be in this family's entity list and add it if appropriate.
Called by the engine when an entity has been rmoved from it. We check if the entity is in this family's entity list and remove it if so.