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.

Constructor

new (nodeClass:Class<TNode>, engine:Engine)

The constructor. Creates a ComponentMatchingFamily to provide a NodeList for the given node class.

Parameters:

nodeClass

The type of node to create and manage a NodeList for.

engine

The engine that this family is managing teh NodeList for.

Variables

read onlynodeList:NodeList<TNode>

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.

Methods

cleanUp ():Void

Removes all nodes from the NodeList.

componentAddedToEntity (entity:Entity, componentClass:Class<Dynamic>):Void

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.

componentRemovedFromEntity (entity:Entity, componentClass:Class<Dynamic>):Void

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.

newEntity (entity:Entity):Void

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.

removeEntity (entity:Entity):Void

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.