class Crash::Engine

Included Modules

Defined in:

crash/engine.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def add_entity(entity : Entity) #

Add an entity to the engine.


[View source]
def add_system(system : System, priority : Int32) #

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.


[View source]
def add_system(system : System) #

[View source]
def entities : Array(Crash::Entity) #

[View source]
def get_entity_by_name(name : String) : Entity | Nil #

Get an entity based on its name.


[View source]
def get_node_list(node_class : Node.class) : Array(Node) #

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.


[View source]
def get_system(type : System.class) : System | Nil #

Get the system instance of a particular type from within the engine.


[View source]
def release_node_list(node_class : Node.class) #

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.


[View source]
def remove_all_entities #

Remove all entities from the engine.


[View source]
def remove_all_systems #

Remove all systems from the engine.


[View source]
def remove_entity(entity : Entity) #

Remove an entity from the engine.


[View source]
def remove_system(system : System) #

Remove a system from the engine.


[View source]
def systems : Array(Crash::System) #

[View source]
def update(time : Float64) #

Update the engine. This causes the engine update loop to run, calling update on all the systems in the engine.

The package net.richardlord.ash.tick contains classes that can be used to provide a steady or variable tick that calls this update method.


[View source]
def updating : Bool #

Indicates if the engine is currently in its update loop.


[View source]