Skip to content
ConcordConcordConcord

Entity

An object in a World that holds Components processed by Systems.

If the concord folder is in the root directory of your game, you can import this module like so:

concord.entity = require('concord.entity')

Components are stored as fields named after the component (entity.position after :give("position", ...)). Prefer :give, :get, and :has so unregistered names error instead of silently failing. Entity(...) is equivalent to Entity.new(...).

Name Type Description
SERIALIZE_BY_DEFAULT boolean When true, Entity.new auto-:give("serializable") (see built-in Serializable)
Name Type Description
__world? World
Method Description
Entity.new Creates a new Entity. Optionally queues it to be added to a World.
Entity:give Gives an Entity a Component.
Entity:ensure Ensures an Entity has a Component.
Entity:remove Removes a Component from an Entity.
Entity:assemble Assembles an Entity by calling assemblage(self, ...) and returning self.
Entity:destroy Destroys the Entity.
Entity:has Returns true if the Entity has a Component.
Entity:get Gets a Component from the Entity.
Entity:getComponents Returns a shallow copy of the Entity’s fields, excluding __world and __isEntity.
Entity:inWorld Returns true if the Entity has been assigned a World.
Entity:getWorld Returns the World the Entity is in, or nil when not in a world.
Entity:serialize Serializes the Entity’s Components.
Entity:deserialize Deserializes Components onto the Entity from the array portion of serialized data.