class Engine
package ash.core
The Engine class is the central point for creating and managing your game state. Add entities and systems to the engine, and fetch families of nodes from the engine.
Constructor
Variables
familyClass:Class<IFamily<Dynamic>> = ComponentMatchingFamily
The class used to manage node lists. In most cases the default class is sufficient but it is exposed here so advanced developers can choose to create and use a different implementation.
The class must implement the IFamily interface.
read onlyupdateComplete:Signal0
Dispatched when the update loop ends. If you want to add and remove systems from the engine it is required to listen for this signal and make the change when the signal is dispatched.
Methods
addSystem (system:System, priority:Int):Void
Add a system to the engine, and set its priority for the order in which the systems are updated by the engine update loop.
The priority dictates the order in which the systems are updated by the engine update loop. Lower numbers for priority are updated first. i.e. a priority of 1 is updated before a priority of 2.
Parameters:
system | The system to add to the engine. |
---|---|
priority | The priority for updating the systems during the engine loop. A lower number means the system is updated sooner. |
inline getEntityByName (name:String):Entity
Get an entity based n its name.
Parameters:
name | The name of the entity |
---|
Returns:
The entity, or null if no entity with that name exists on the engine
getNodeList<TNode> (nodeClass:Class<TNode>):NodeList<TNode>
Get a collection of nodes from the engine, based on the type of the node required.
The engine will create the appropriate NodeList if it doesn't already exist and will keep its contents up to date as entities are added to and removed from the engine.
If a NodeList is no longer required, release it with the releaseNodeList method.
Parameters:
nodeClass | The type of node required. |
---|
Returns:
A linked list of all nodes of this type from all entities in the engine.
getSystem<TSystem> (type:Class<TSystem>):TSystem
Get the system instance of a particular type from within the engine.
Parameters:
type | The type of system |
---|
Returns:
The instance of the system type that is in the engine, or null if no systems of this type are in the engine.
releaseNodeList<TNode> (nodeClass:Class<TNode>):Void
If a NodeList is no longer required, this method will stop the engine updating the list and will release all references to the list within the framework classes, enabling it to be garbage collected.
It is not essential to release a list, but releasing it will free up memory and processor resources.
Parameters:
nodeClass | The type of the node class if the list to be released. |
---|
removeEntity (entity:Entity):Void
Remove an entity from the engine.
Parameters:
entity | The entity to remove. |
---|
removeSystem (system:System):Void
Remove a system from the engine.
Parameters:
system | The system to remove from the engine. |
---|