class

Crash::ComponentMatchingFamily

Inherits Crash::Family < Reference < Object

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.

Constructors

new(engine : Crash::Engine, *components : Crash::Component.class)

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.

Source

Instance methods

clean_up

Removes all entities from the entity list.

Source
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. We check if the entity is not in this family's entity list and should be, and add it if appropriate.

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

Source
entity_list

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.

Source
new_entity(entity : Crash::Entity)

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.

Source
remove_entity(entity : Crash::Entity)

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.

Source