Module world

World A World is 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

Functions

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:__dirtyEntity (e) Internal: Marks an Entity as dirty.
World:__flush () Internal: Flushes all changes to Entities.
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: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.


Functions

World.new ()
Creates a new World.

Returns:

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

Parameters:

  • e Entity to add

Returns:

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

Parameters:

  • e Entity to remove

Returns:

    self
World:__dirtyEntity (e)
Internal: Marks an Entity as dirty.

Parameters:

  • e Entity to mark as dirty
World:__flush ()
Internal: Flushes all changes to Entities. This processes all entities. Adding and removing entities, as well as reevaluating dirty entities.

Returns:

    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 SystemClass of System to add

Returns:

    self

See also:

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

Parameters:

  • ... SystemClasses of Systems to add

Returns:

    self

See also:

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

Parameters:

  • systemClass SystemClass of System to check for

Returns:

    True if World has System, false otherwise
World:getSystem (systemClass)
Gets a System from the World.

Parameters:

  • systemClass SystemClass of System to get

Returns:

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

Parameters:

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

Returns:

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

Returns:

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

Parameters:

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

Parameters:

  • e The Entity that was removed
generated by LDoc 1.4.6 Last updated 2020-01-04 00:43:06