Module tiny-ecs

Info:

  • Author: Calvin Rose

Fields

tiny._VERSION Tiny-ecs Version, a period-separated three number string like "1.2.3" with no leading zeros.

Filter functions

tiny.requireAll (...) Makes a Filter that filters Entities with specified Components.
tiny.requireOne (...) Makes a Filter that filters Entities with specified Components.

System functions

tiny.processingSystem (filter, entityCallback, onAdd, onRemove) Creates a System that processes Entities every update.
tiny.system (callback, filter, entityCallback, onAdd, onRemove) Creates a System.

World functions

tiny.add (world, ...) Adds Entities and Systems to the World.
tiny.clearEntities (world) Removes all Entities from the World.
tiny.clearSystems (world) Removes all Systems from the World.
tiny.manageEntities (world) Adds and removes Entities that have been marked.
tiny.manageSystems (world) Adds and removes Systems that have been marked from the World.
tiny.remove (world, ...) Removes Entities and Systems from the World.
tiny.setSystemActive (world, system, active) Sets if a System is active in a world.
tiny.update (world, dt) Updates the World.
tiny.updateSystem (world, system, dt) Updates a System.
tiny.world (...) Creates a new World.


Fields

tiny._VERSION
Tiny-ecs Version, a period-separated three number string like "1.2.3" with no leading zeros.

Filter functions

A Filter is a function that selects which Entities apply to a System.
tiny.requireAll (...)
Makes a Filter that filters Entities with specified Components. An Entity must have all Components to match the filter.

Parameters:

  • ... List of Components
tiny.requireOne (...)
Makes a Filter that filters Entities with specified Components. An Entity must have at least one specified Component to match the filter.

Parameters:

  • ... List of Components

System functions

A System a wrapper around function callbacks for manipulating Entities.
tiny.processingSystem (filter, entityCallback, onAdd, onRemove)
Creates a System that processes Entities every update. Also provides optional callbacks for when Entities are added or removed from the System.

Parameters:

  • filter Function of one argument, an Entity, that returns a boolean
  • entityCallback Function of two arguments, an Entity and delta time
  • onAdd Optional callback for when Entities are added to the System that takes one argument, an Entity
  • onRemove Similar to onAdd, but is instead called when an Entity is removed from the System
tiny.system (callback, filter, entityCallback, onAdd, onRemove)
Creates a System.

Parameters:

  • callback Function of one argument, delta time, that is called once per world update
  • filter Function of one argument, an Entity, that returns a boolean
  • entityCallback Function of two arguments, an Entity and delta time
  • onAdd Optional callback for when Enities are added to the System that takes one argument, an Entity
  • onRemove Similar to onAdd, but is instead called when an Entity is removed from the System

World functions

A World is a container that manages Entities and Systems. The tiny-ecs module is set to be the __index of all World tables, so the often clearer syntax of World:method can be used for any function in the library. For example, tiny.add(world, e1, e2, e3) is the same as world:add(e1, e2, e3).
tiny.add (world, ...)
Adds Entities and Systems to the World. New objects will enter the World the next time World:update(dt) is called. Also call this method when an Entity has had its Components changed, such that it matches different Filters.

Parameters:

  • world
  • ... Systems and Entities
tiny.clearEntities (world)
Removes all Entities from the World. When World:update(dt) is next called, all Entities will be removed.

Parameters:

  • world
tiny.clearSystems (world)
Removes all Systems from the World. When World:update(dt) is next called, all Systems will be removed.

Parameters:

  • world
tiny.manageEntities (world)
Adds and removes Entities that have been marked. The user of this library should seldom if ever call this.

Parameters:

  • world
tiny.manageSystems (world)
Adds and removes Systems that have been marked from the World. The user of this library should seldom if ever call this.

Parameters:

  • world
tiny.remove (world, ...)
Removes Entities and Systems from the World. Objects will exit the World the next time World:update(dt) is called.

Parameters:

  • world
  • ... Systems and Entities
tiny.setSystemActive (world, system, active)
Sets if a System is active in a world. If the system is active, it will update automatically when World:update(dt) is called. Otherwise, the user must call World:updateSystem(system, dt) to update the unactivated system.

Parameters:

  • world
  • system A System in the World activate/deactivate
  • active Boolean new state of the System
tiny.update (world, dt)
Updates the World. Frees Entities that have been marked for freeing, adds entities that have been marked for adding, etc.

Parameters:

  • world
  • dt Delta time
tiny.updateSystem (world, system, dt)
Updates a System.

Parameters:

  • world
  • system A System in the World to update
  • dt Delta time
tiny.world (...)
Creates a new World. Can optionally add default Systems and Entities.

Parameters:

  • ... Systems and Entities to add to the World

Returns:

    A new World
generated by LDoc 1.4.3 Last updated 2015-03-29 20:36:32