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(node_class : Node.class, engine : Engine)
The constructor.
Instance Method Summary
-
#clean_up
Removes all nodes from the NodeList.
-
#component_added_to_entity(entity : Entity, component_class : Component.class)
Called by the engine when a component has been added to an entity.
-
#component_removed_from_entity(entity : Entity, component_class : Component.class)
Called by the engine when a component has been removed from an entity.
-
#new_entity(entity : Entity)
Called by the engine when an entity has been added to it.
-
#node_list : Array(Node)
The nodelist managed by this family.
-
#remove_entity(entity : 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 : Entity, component_class : Component.class)
component_added_to_entity,
component_removed_from_entity(entity : Entity, component_class : Component.class)
component_removed_from_entity,
new_entity(entity : Entity)
new_entity,
node_list : Array(Node)
node_list,
remove_entity(entity : 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 NodeList 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 NodeList and if so, we check if the entity is in this this NodeList and remove it if so.
Called by the engine when an entity has been added to it. We check if the entity should be in this family's NodeList and add it if appropriate.
The nodelist 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 rmoved from it. We check if the entity is in this family's NodeList and remove it if so.