Class Entity
An object that exists in a world.
An entity contains components which are processed by systems.
Methods
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:has (componentClass) | Returns true if the Entity has a Component. |
Entity:get (componentClass) | Gets a Component from the Entity. |
Entity:getComponents (output) | 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. |
Methods
- Entity:new ([world])
-
Creates a new Entity. Optionally adds it to a World.
Parameters:
- world World World to add the entity to (optional)
Returns:
-
Entity
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 Component ComponentClass to add an instance of
- ... additional arguments to pass to the Component's populate function
Returns:
-
Entity
self
- Entity:ensure (componentClass, ...)
-
Ensures an Entity to have a Component.
If the Component already exists, no action is taken
Parameters:
- componentClass Component ComponentClass to add an instance of
- ... additional arguments to pass to the Component's populate function
Returns:
-
Entity
self
- Entity:remove (componentClass)
-
Removes a Component from an Entity.
Parameters:
- componentClass Component ComponentClass of the Component to remove
Returns:
-
Entity
self
- Entity:assemble (assemblage, ...)
-
Assembles an Entity.
Parameters:
- assemblage function Function that will assemble an entity
- ... additional arguments to pass to the assemblage function.
Returns:
-
Entity
self
- Entity:destroy ()
-
Destroys the Entity.
Removes the Entity from its World if it's in one.
Returns:
-
self
- Entity:has (componentClass)
-
Returns true if the Entity has a Component.
Parameters:
- componentClass Component ComponentClass of the Component to check
Returns:
-
boolean
- Entity:get (componentClass)
-
Gets a Component from the Entity.
Parameters:
- componentClass Component ComponentClass of the Component to get
Returns:
- Entity:getComponents (output)
-
Returns a table of all Components the Entity has.
Warning: Do not modify this table.
Use Entity:give/ensure/remove instead
Parameters:
- output
Returns:
-
table
Table of all Components the Entity has
- Entity:inWorld ()
-
Returns true if the Entity is in a World.
Returns:
-
boolean
- Entity:getWorld ()
-
Returns the World the Entity is in.
Returns: