Class World

A collection of Systems and Entities.

A world emits to let Systems iterate. A World contains any amount of Systems. A World contains any amount of Entities.

Methods

World:new () Creates a new World.
World:addEntity (e) Adds an Entity to the World.
World:removeEntity (e) Removes an Entity from the World.
World:addSystem (systemClass) Adds a System to the World.
World:addSystems (...) Adds multiple Systems to the World.
World:hasSystem (systemClass) Returns if the World has a System.
World:getSystem (systemClass) Gets a System from the World.
World:emit (functionName, ...) Emits a callback in the World.
World:clear () Removes all entities from the World
World:hasName () Returns true if the World has a name.
World:getName () Returns the name of the World.
World:onEntityAdded (e) Callback for when an Entity is added to the World.
World:onEntityRemoved (e) Callback for when an Entity is removed from the World.


Methods

World:new ()
Creates a new World.

Returns:

    World The new World
World:addEntity (e)
Adds an Entity to the World.

Parameters:

Returns:

    World self
World:removeEntity (e)
Removes an Entity from the World.

Parameters:

Returns:

    World self
World:addSystem (systemClass)
Adds a System to the World. Callbacks are registered automatically Entities added before are added to the System retroactively

Parameters:

  • systemClass System SystemClass of System to add

Returns:

    World self

See also:

World:addSystems (...)
Adds multiple Systems to the World. Callbacks are registered automatically

Parameters:

  • ... SystemClasses of Systems to add

Returns:

    World self

See also:

World:hasSystem (systemClass)
Returns if the World has a System.

Parameters:

  • systemClass System SystemClass of System to check for

Returns:

    boolean
World:getSystem (systemClass)
Gets a System from the World.

Parameters:

  • systemClass System SystemClass of System to get

Returns:

    System System to get
World:emit (functionName, ...)
Emits a callback in the World. Calls all functions with the functionName of added Systems

Parameters:

  • functionName string Name of functions to call.
  • ... Parameters passed to System's functions

Returns:

    World self
World:clear ()
Removes all entities from the World

Returns:

    World self
World:hasName ()
Returns true if the World has a name.

Returns:

    boolean
World:getName ()
Returns the name of the World.

Returns:

    string
World:onEntityAdded (e)
Callback for when an Entity is added to the World.

Parameters:

  • e Entity The Entity that was added
World:onEntityRemoved (e)
Callback for when an Entity is removed from the World.

Parameters:

  • e Entity The Entity that was removed
generated by LDoc 1.4.6 Last updated 2020-08-18 15:20:32