Module entity

Entity Entities are the concrete objects that exist in your project.

An Entity have Components and are processed by Systems. An Entity is contained by a maximum of 1 World.

Functions

Entity.new (world) Creates a new Entity.
Entity:give (componentClass, ...) Gives an Entity a Component.
Entity:ensure (componentClass, ...) Ensures an Entity to have a Component.
Entity:remove (componentClass) Removes a Component from an Entity.
Entity:assemble (assemblage, ...) Assembles an Entity.
Entity:destroy () Destroys the Entity.
Entity:__dirty () Internal: Tells the World it's in that this Entity is dirty.
Entity:has (componentClass) Returns true if the Entity has a Component.
Entity:get (componentClass) Gets a Component from the Entity.
Entity:getComponents () Returns a table of all Components the Entity has.
Entity:inWorld () Returns true if the Entity is in a World.
Entity:getWorld () Returns the World the Entity is in.


Functions

Entity.new (world)
Creates a new Entity. Optionally adds it to a World.

Parameters:

  • world Optional World to add the entity to

Returns:

    A new Entity
Entity:give (componentClass, ...)
Gives an Entity a Component. If the Component already exists, it's overridden by this new Component

Parameters:

  • componentClass ComponentClass to add an instance of
  • ... varargs passed to the Component's populate function

Returns:

    self
Entity:ensure (componentClass, ...)
Ensures an Entity to have a Component. If the Component already exists, no action is taken

Parameters:

  • componentClass ComponentClass to add an instance of
  • ... varargs passed to the Component's populate function

Returns:

    self
Entity:remove (componentClass)
Removes a Component from an Entity.

Parameters:

  • componentClass ComponentClass of the Component to remove

Returns:

    self
Entity:assemble (assemblage, ...)
Assembles an Entity.

Parameters:

  • assemblage Assemblage to assemble with
  • ... Varargs to pass to the Assemblage's assemble function.
Entity:destroy ()
Destroys the Entity. Removes the Entity from it's World if it's in one.

Returns:

    self
Entity:__dirty ()
Internal: Tells the World it's in that this Entity is dirty.

Returns:

    self
Entity:has (componentClass)
Returns true if the Entity has a Component.

Parameters:

  • componentClass ComponentClass of the Component to check

Returns:

    True if the Entity has the Component, false otherwise
Entity:get (componentClass)
Gets a Component from the Entity.

Parameters:

  • componentClass ComponentClass of the Component to get

Returns:

    The Component
Entity:getComponents ()
Returns a table of all Components the Entity has. Warning: Do not modify this table. Use Entity:give/ensure/remove instead

Returns:

    Table of all Components the Entity has
Entity:inWorld ()
Returns true if the Entity is in a World.

Returns:

    True if the Entity is in a World, false otherwise
Entity:getWorld ()
Returns the World the Entity is in.

Returns:

    The World the Entity is in.
generated by LDoc 1.4.6 Last updated 2020-01-04 00:43:06