From a65f88dd5ed1f5741b10b9e12674cf06b93df4b2 Mon Sep 17 00:00:00 2001 From: Andrew Minnich Date: Sat, 4 Jan 2020 10:31:05 -0500 Subject: [PATCH] make the docs a little nicer main changes: - add parameter and return types where applicable - use @module and @classmod tags at the top of files - remove some redundant descriptions of return values, especially for functions that return a boolean recommended next steps: - more consistent grammar - add links to classes and functions in descriptions where appropriate - be consistent about naming Systems vs. SystemClasses and Components vs. ComponentClasses --- concord/assemblage.lua | 19 +- concord/assemblages.lua | 22 +- concord/component.lua | 21 +- concord/components.lua | 22 +- concord/entity.lua | 52 ++-- concord/init.lua | 3 +- concord/list.lua | 18 +- concord/pool.lua | 28 +- concord/system.lua | 49 ++-- concord/systems.lua | 16 +- concord/type.lua | 14 +- concord/world.lua | 54 ++-- concord/worlds.lua | 10 +- config.ld | 3 +- docs/classes/Assemblage.html | 204 +++++++++++++ docs/classes/Component.html | 170 +++++++++++ .../entity.html => classes/Entity.html} | 114 ++++---- docs/{modules/list.html => classes/List.html} | 227 ++++++++------- docs/{modules/pool.html => classes/Pool.html} | 177 +++++------- .../system.html => classes/System.html} | 270 +++++++++--------- .../world.html => classes/World.html} | 174 ++++++----- docs/index.html | 117 ++++---- docs/modules/{init.html => Concord.html} | 55 ++-- docs/modules/assemblage.html | 147 ---------- docs/modules/assemblages.html | 102 +++++-- docs/modules/component.html | 166 ----------- docs/modules/components.html | 102 +++++-- docs/modules/systems.html | 101 +++++-- docs/modules/type.html | 48 ++-- docs/modules/utils.html | 27 +- docs/modules/worlds.html | 89 +++++- 31 files changed, 1474 insertions(+), 1147 deletions(-) create mode 100644 docs/classes/Assemblage.html create mode 100644 docs/classes/Component.html rename docs/{modules/entity.html => classes/Entity.html} (67%) rename docs/{modules/list.html => classes/List.html} (68%) rename docs/{modules/pool.html => classes/Pool.html} (61%) rename docs/{modules/system.html => classes/System.html} (55%) rename docs/{modules/world.html => classes/World.html} (65%) rename docs/modules/{init.html => Concord.html} (67%) delete mode 100644 docs/modules/assemblage.html delete mode 100644 docs/modules/component.html diff --git a/concord/assemblage.lua b/concord/assemblage.lua index e6125b7..b90fb36 100644 --- a/concord/assemblage.lua +++ b/concord/assemblage.lua @@ -1,6 +1,5 @@ ---- Assemblage --- An Assemblage is a function that 'makes' an entity something. --- It does this by :give'ing or :ensure'ing Components, or by :assemble'ing the Entity. +--- Gives an entity a set of components. +-- @classmod Assemblage local Assemblage = {} Assemblage.__mt = { @@ -8,8 +7,8 @@ Assemblage.__mt = { } --- Creates a new Assemblage. --- @param assemble Function that assembles an Entity --- @return A new Assemblage +-- @tparam function assemble Function that assembles an Entity +-- @treturn Assemblage A new assemblage function Assemblage.new(assemble) local assemblage = setmetatable({ __assemble = assemble, @@ -22,9 +21,9 @@ function Assemblage.new(assemble) end --- Assembles an Entity. --- @param e Entity to assemble --- @param ... Varargs to pass to the assemble function --- @ return self +-- @tparam Entity e Entity to assemble +-- @param ... additional arguments to pass to the assemble function +-- @treturn Assemblage self function Assemblage:assemble(e, ...) self.__assemble(e, ...) @@ -32,13 +31,13 @@ function Assemblage:assemble(e, ...) end --- Returns true if the Assemblage has a name. --- @return True if the Assemblage has a name, false otherwise +-- @treturn boolean function Assemblage:hasName() return self.__name and true or false end --- Returns the name of the Assemblage. --- @return Name of the Assemblage +-- @treturn string function Assemblage:getName() return self.__name end diff --git a/concord/assemblages.lua b/concord/assemblages.lua index 2e5b6ad..58731a8 100644 --- a/concord/assemblages.lua +++ b/concord/assemblages.lua @@ -1,5 +1,5 @@ ---- Assemblages --- Container for registered Assemblages +--- A container for registered @{Assemblage}s +-- @module Assemblages local PATH = (...):gsub('%.[^%.]+$', '') @@ -8,8 +8,8 @@ local Type = require(PATH..".type") local Assemblages = {} --- Registers an Assemblage. --- @param name Name to register under --- @param assemblage Assemblage to register +-- @string name Name to register under +-- @tparam Assemblage assemblage Assemblage to register function Assemblages.register(name, assemblage) if (type(name) ~= "string") then error("bad argument #1 to 'Assemblages.register' (string expected, got "..type(name)..")", 3) @@ -27,16 +27,16 @@ function Assemblages.register(name, assemblage) assemblage.__name = name end ---- Returns true if the containter has the Assemblage with the name --- @param name Name of the Assemblage to check --- @return True if the containter has the Assemblage with the name, false otherwise +--- Returns true if the containter has an Assemblage with the specified name +-- @string name Name of the Assemblage to check +-- @treturn boolean function Assemblages.has(name) return Assemblages[name] and true or false end ---- Returns the Assemblage with the name --- @param name Name of the Assemblage to get --- @return Assemblage with the name +--- Returns the Assemblage with the specified name +-- @string name Name of the Assemblage to get +-- @treturn Assemblage function Assemblages.get(name) return Assemblages[name] end @@ -46,4 +46,4 @@ return setmetatable(Assemblages, { __index = function(_, name) error("Attempt to index assemblage '"..tostring(name).."' that does not exist / was not registered", 2) end -}) \ No newline at end of file +}) diff --git a/concord/component.lua b/concord/component.lua index 202e873..1b391ee 100644 --- a/concord/component.lua +++ b/concord/component.lua @@ -1,6 +1,5 @@ ---- Component --- A Component is a pure data container. --- A Component is contained by a single entity. +--- A pure data container that is contained by a single entity. +-- @classmod Component local Component = {} Component.__mt = { @@ -8,8 +7,8 @@ Component.__mt = { } --- Creates a new ComponentClass. --- @param populate Function that populates a Component with values --- @return A new ComponentClass +-- @tparam function populate Function that populates a Component with values +-- @treturn Component A new ComponentClass function Component.new(populate) if (type(populate) ~= "function" and type(populate) ~= "nil") then error("bad argument #1 to 'Component.new' (function/nil expected, got "..type(populate)..")", 2) @@ -29,7 +28,7 @@ function Component.new(populate) return componentClass end ---- Internal: Populates a Component with values +-- Internal: Populates a Component with values function Component:__populate() -- luacheck: ignore end @@ -39,7 +38,7 @@ end function Component:deserialize(data) -- luacheck: ignore end ---- Internal: Creates a new Component. +-- Internal: Creates a new Component. -- @return A new Component function Component:__new() local component = setmetatable({ @@ -52,7 +51,7 @@ function Component:__new() return component end ---- Internal: Creates and populates a new Component. +-- Internal: Creates and populates a new Component. -- @param ... Varargs passed to the populate function -- @return A new populated Component function Component:__initialize(...) @@ -64,13 +63,13 @@ function Component:__initialize(...) end --- Returns true if the Component has a name. --- @return True if the Component has a name, false otherwise +-- @treturn boolean function Component:hasName() return self.__name and true or false end --- Returns the name of the Component. --- @return Name of the Component +-- @treturn string function Component:getName() return self.__name end @@ -79,4 +78,4 @@ return setmetatable(Component, { __call = function(_, ...) return Component.new(...) end, -}) \ No newline at end of file +}) diff --git a/concord/components.lua b/concord/components.lua index e67ec23..d7063da 100644 --- a/concord/components.lua +++ b/concord/components.lua @@ -1,5 +1,5 @@ ---- Components --- Container for registered ComponentClasss +--- Container for registered ComponentClasses +-- @module Components local PATH = (...):gsub('%.[^%.]+$', '') @@ -8,8 +8,8 @@ local Type = require(PATH..".type") local Components = {} --- Registers a ComponentClass. --- @param name Name to register under --- @param componentClass ComponentClass to register +-- @string name Name to register under +-- @tparam Component componentClass ComponentClass to register function Components.register(name, componentClass) if (type(name) ~= "string") then error("bad argument #1 to 'Components.register' (string expected, got "..type(name)..")", 3) @@ -27,16 +27,16 @@ function Components.register(name, componentClass) componentClass.__name = name end ---- Returns true if the containter has the ComponentClass with the name --- @param name Name of the ComponentClass to check --- @return True if the containter has the ComponentClass with the name, false otherwise +--- Returns true if the containter has the ComponentClass with the specified name +-- @string name Name of the ComponentClass to check +-- @treturn boolean function Components.has(name) return Components[name] and true or false end ---- Returns the ComponentClass with the name --- @param name Name of the ComponentClass to get --- @return ComponentClass with the name +--- Returns the ComponentClass with the specified name +-- @string name Name of the ComponentClass to get +-- @treturn Component function Components.get(name) return Components[name] end @@ -45,4 +45,4 @@ return setmetatable(Components, { __index = function(_, name) error("Attempt to index ComponentClass '"..tostring(name).."' that does not exist / was not registered", 2) end -}) \ No newline at end of file +}) diff --git a/concord/entity.lua b/concord/entity.lua index 8359fd8..da446e5 100644 --- a/concord/entity.lua +++ b/concord/entity.lua @@ -1,7 +1,6 @@ ---- 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. +--- An object that exists in a world. An entity +-- contains components which are processed by systems. +-- @classmod Entity local PATH = (...):gsub('%.[^%.]+$', '') @@ -14,8 +13,8 @@ Entity.__mt = { } --- Creates a new Entity. Optionally adds it to a World. --- @param world Optional World to add the entity to --- @return A new Entity +-- @tparam[opt] World world World to add the entity to +-- @treturn Entity A new Entity function Entity.new(world) if (world ~= nil and not Type.isWorld(world)) then error("bad argument #1 to 'Entity.new' (world/nil expected, got "..type(world)..")", 2) @@ -53,9 +52,9 @@ end --- Gives an Entity a Component. -- If the Component already exists, it's overridden by this new Component --- @param componentClass ComponentClass to add an instance of --- @param ... varargs passed to the Component's populate function --- @return self +-- @tparam Component componentClass ComponentClass to add an instance of +-- @param ... additional arguments to pass to the Component's populate function +-- @treturn Entity self function Entity:give(componentClass, ...) if not Type.isComponentClass(componentClass) then error("bad argument #1 to 'Entity:give' (ComponentClass expected, got "..type(componentClass)..")", 2) @@ -68,9 +67,9 @@ end --- Ensures an Entity to have a Component. -- If the Component already exists, no action is taken --- @param componentClass ComponentClass to add an instance of --- @param ... varargs passed to the Component's populate function --- @return self +-- @tparam Component componentClass ComponentClass to add an instance of +-- @param ... additional arguments to pass to the Component's populate function +-- @treturn Entity self function Entity:ensure(componentClass, ...) if not Type.isComponentClass(componentClass) then error("bad argument #1 to 'Entity:ensure' (ComponentClass expected, got "..type(componentClass)..")", 2) @@ -86,8 +85,8 @@ function Entity:ensure(componentClass, ...) end --- Removes a Component from an Entity. --- @param componentClass ComponentClass of the Component to remove --- @return self +-- @tparam Component componentClass ComponentClass of the Component to remove +-- @treturn Entity self function Entity:remove(componentClass) if not Type.isComponentClass(componentClass) then error("bad argument #1 to 'Entity:remove' (ComponentClass expected, got "..type(componentClass)..")") @@ -99,8 +98,9 @@ function Entity:remove(componentClass) end --- Assembles an Entity. --- @param assemblage Assemblage to assemble with --- @param ... Varargs to pass to the Assemblage's assemble function. +-- @tparam Assemblage assemblage Assemblage to assemble with +-- @param ... additional arguments to pass to the Assemblage's assemble function. +-- @treturn Entity self function Entity:assemble(assemblage, ...) if not Type.isAssemblage(assemblage) then error("bad argument #1 to 'Entity:assemble' (Assemblage expected, got "..type(assemblage)..")") @@ -112,7 +112,7 @@ function Entity:assemble(assemblage, ...) end --- Destroys the Entity. --- Removes the Entity from it's World if it's in one. +-- Removes the Entity from its World if it's in one. -- @return self function Entity:destroy() if self.__world then @@ -122,7 +122,7 @@ function Entity:destroy() return self end ---- Internal: Tells the World it's in that this Entity is dirty. +-- Internal: Tells the World it's in that this Entity is dirty. -- @return self function Entity:__dirty() if self.__world then @@ -133,8 +133,8 @@ function Entity:__dirty() end --- Returns true if the Entity has a Component. --- @param componentClass ComponentClass of the Component to check --- @return True if the Entity has the Component, false otherwise +-- @tparam Component componentClass ComponentClass of the Component to check +-- @treturn boolean function Entity:has(componentClass) if not Type.isComponentClass(componentClass) then error("bad argument #1 to 'Entity:has' (ComponentClass expected, got "..type(componentClass)..")") @@ -144,8 +144,8 @@ function Entity:has(componentClass) end --- Gets a Component from the Entity. --- @param componentClass ComponentClass of the Component to get --- @return The Component +-- @tparam Component componentClass ComponentClass of the Component to get +-- @treturn table function Entity:get(componentClass) if not Type.isComponentClass(componentClass) then error("bad argument #1 to 'Entity:get' (ComponentClass expected, got "..type(componentClass)..")") @@ -157,19 +157,19 @@ end --- Returns a table of all Components the Entity has. -- Warning: Do not modify this table. -- Use Entity:give/ensure/remove instead --- @return Table of all Components the Entity has +-- @treturn table Table of all Components the Entity has function Entity:getComponents() return self.__components end --- Returns true if the Entity is in a World. --- @return True if the Entity is in a World, false otherwise +-- @treturn boolean function Entity:inWorld() return self.__world and true or false end --- Returns the World the Entity is in. --- @return The World the Entity is in. +-- @treturn World function Entity:getWorld() return self.__world end @@ -213,4 +213,4 @@ return setmetatable(Entity, { __call = function(_, ...) return Entity.new(...) end, -}) \ No newline at end of file +}) diff --git a/concord/init.lua b/concord/init.lua index 1f65695..7ff46d3 100644 --- a/concord/init.lua +++ b/concord/init.lua @@ -1,4 +1,5 @@ ---- init +--- +-- @module Concord local PATH = (...):gsub('%.init$', '') diff --git a/concord/list.lua b/concord/list.lua index 38ff949..215d1bb 100644 --- a/concord/list.lua +++ b/concord/list.lua @@ -1,5 +1,5 @@ ---- List --- Data structure that allows for fast removal at the cost of containing order. +--- Data structure that allows for fast removal at the cost of containing order. +-- @classmod List local List = {} List.__mt = { @@ -7,7 +7,7 @@ List.__mt = { } --- Creates a new List. --- @return A new List +-- @treturn List A new List function List.new() return setmetatable({ size = 0, @@ -18,7 +18,7 @@ end -- Object must be of reference type -- Object may not be the string 'size' -- @param obj Object to add --- @return self +-- @treturn List self function List:__add(obj) local size = self.size + 1 @@ -31,7 +31,7 @@ end --- Removes an object from the List. -- @param obj Object to remove --- @return self +-- @treturn List self function List:__remove(obj) local index = self[obj] if not index then return end @@ -55,7 +55,7 @@ function List:__remove(obj) end --- Clears the List completely. --- @return self +-- @treturn List self function List:__clear() for i = 1, self.size do local o = self[i] @@ -71,13 +71,13 @@ end --- Returns true if the List has the object. -- @param obj Object to check for --- @return True if the List has the object, false otherwise +-- @treturn boolean function List:has(obj) return self[obj] and true or false end --- Returns the object at an index. --- @param i Index to get from +-- @number i Index to get from -- @return Object at the index function List:get(i) return self[i] @@ -85,7 +85,7 @@ end --- Returns the index of an object in the List. -- @param obj Object to get index of --- @return index of object in the List. +-- @treturn number index of object in the List. function List:indexOf(obj) if (not self[obj]) then error("bad argument #1 to 'List:indexOf' (Object was not in List)", 2) diff --git a/concord/pool.lua b/concord/pool.lua index 4cde567..ef22aed 100644 --- a/concord/pool.lua +++ b/concord/pool.lua @@ -1,6 +1,6 @@ ---- Pool --- A Pool is used to iterate over Entities with a specific Components +--- Used to iterate over Entities with a specific Components -- A Pool contain a any amount of Entities. +-- @classmod Pool local PATH = (...):gsub('%.[^%.]+$', '') @@ -12,9 +12,9 @@ Pool.__mt = { } --- Creates a new Pool --- @param name Name for the Pool. --- @param filter Table containing the required BaseComponents --- @return The new Pool +-- @string name Name for the Pool. +-- @tparam table filter Table containing the required BaseComponents +-- @treturn Pool The new Pool function Pool.new(name, filter) local pool = setmetatable(List(), Pool.__mt) @@ -27,8 +27,8 @@ function Pool.new(name, filter) end --- Checks if an Entity is eligible for the Pool. --- @param e Entity to check --- @return True if the entity is eligible, false otherwise +-- @tparam Entity e Entity to check +-- @treturn boolean function Pool:__eligible(e) for _, component in ipairs(self.__filter) do if not e[component] then @@ -39,9 +39,9 @@ function Pool:__eligible(e) return true end ---- Internal: Adds an Entity to the Pool. +-- Internal: Adds an Entity to the Pool. -- @param e Entity to add --- @return self +-- @treturn Pool self function Pool:__add(e) List.__add(self, e) self:onEntityAdded(e) @@ -49,9 +49,9 @@ function Pool:__add(e) return self end ---- Internal: Removed an Entity from the Pool. +-- Internal: Removed an Entity from the Pool. -- @param e Entity to remove --- @return self +-- @treturn Pool self function Pool:__remove(e) List.__remove(self, e) self:onEntityRemoved(e) @@ -60,7 +60,7 @@ function Pool:__remove(e) end --- Gets the name of the Pool --- @return Name of the Pool. +-- @treturn string function Pool:getName() return self.__name end @@ -73,12 +73,12 @@ function Pool:getFilter() end --- Callback for when an Entity is added to the Pool. --- @param e Entity that was added. +-- @tparam Entity e Entity that was added. function Pool:onEntityAdded(e) -- luacheck: ignore end -- Callback for when an Entity is removed from the Pool. --- @param e Entity that was removed. +-- @tparam Entity e Entity that was removed. function Pool:onEntityRemoved(e) -- luacheck: ignore end diff --git a/concord/system.lua b/concord/system.lua index 8eeb12d..6ff374e 100644 --- a/concord/system.lua +++ b/concord/system.lua @@ -1,7 +1,7 @@ ---- System --- A System iterates over Entities. From these Entities its get Components and modify them. +--- Iterates over Entities. From these Entities its get Components and modify them. -- A System contains 1 or more Pools. -- A System is contained by 1 World. +-- @classmod System local PATH = (...):gsub('%.[^%.]+$', '') @@ -50,7 +50,7 @@ System.mt = { --- Creates a new SystemClass. -- @param ... Variable amounts of filters --- @return A new SystemClass +-- @treturn System A new SystemClass function System.new(...) local systemClass = setmetatable({ __filter = {...}, @@ -70,7 +70,7 @@ function System.new(...) return systemClass end ---- Internal: Builds a Pool for the System. +-- Internal: Builds a Pool for the System. -- @param baseFilter The 'raw' Filter -- @return A new Pool function System.__buildPool(baseFilter) @@ -88,9 +88,9 @@ function System.__buildPool(baseFilter) return Pool(name, filter) end ---- Internal: Evaluates an Entity for all the System's Pools. +-- Internal: Evaluates an Entity for all the System's Pools. -- @param e The Entity to check --- @return self +-- @treturn System self function System:__evaluate(e) for _, pool in ipairs(self.__pools) do local has = pool:has(e) @@ -106,9 +106,9 @@ function System:__evaluate(e) return self end ---- Internal: Removes an Entity from the System. +-- Internal: Removes an Entity from the System. -- @param e The Entity to remove --- @return self +-- @treturn System self function System:__remove(e) for _, pool in ipairs(self.__pools) do if pool:has(e) then @@ -119,8 +119,8 @@ function System:__remove(e) return self end ---- Internal: Clears all Entities from the System. --- @return self +-- Internal: Clears all Entities from the System. +-- @treturn System self function System:__clear() for i = 1, #self.__pools do self.__pools[i]:__clear() @@ -130,7 +130,7 @@ function System:__clear() end --- Enables the System. --- @return self +-- @treturn System self function System:enable() self:setEnabled(true) @@ -138,7 +138,7 @@ function System:enable() end --- Disables the System. --- @return self +-- @treturn System self function System:disable() self:setEnabled(false) @@ -146,7 +146,7 @@ function System:disable() end --- Toggles if the System is enabled. --- @return self +-- @treturn System self function System:toggleEnabled() self:setEnabled(not self.__enabled) @@ -154,8 +154,8 @@ function System:toggleEnabled() end --- Sets if the System is enabled --- @param enable Enable --- @return self +-- @tparam boolean enable +-- @treturn System self function System:setEnabled(enable) if (not self.__enabled and enable) then self.__enabled = true @@ -169,39 +169,42 @@ function System:setEnabled(enable) end --- Returns is the System is enabled --- @return True if the System is enabled, false otherwise +-- @treturn boolean function System:isEnabled() return self.__enabled end --- Returns the World the System is in. --- @return The World the System is in +-- @treturn World function System:getWorld() return self.__world end --- Returns true if the System has a name. --- @return True if the System has a name, false otherwise +-- @treturn boolean function System:hasName() return self.__name and true or false end --- Returns the name of the System. --- @return Name of the System +-- @treturn string function System:getName() return self.__name end +--- Callbacks +-- @section Callbacks + --- Callback for system initialization. --- @param world The World the System was added to +-- @tparam World world The World the System was added to function System:init(world) -- luacheck: ignore end --- Callback for when a System is enabled. +--- Callback for when a System is enabled. function System:onEnabled() -- luacheck: ignore end --- Callback for when a System is disabled. +--- Callback for when a System is disabled. function System:onDisabled() -- luacheck: ignore end @@ -209,4 +212,4 @@ return setmetatable(System, { __call = function(_, ...) return System.new(...) end, -}) \ No newline at end of file +}) diff --git a/concord/systems.lua b/concord/systems.lua index 4781f1d..f29550d 100644 --- a/concord/systems.lua +++ b/concord/systems.lua @@ -1,5 +1,5 @@ ---- Systems --- Container for registered SystemClasses +--- Container for registered SystemClasses +-- @module Systems local PATH = (...):gsub('%.[^%.]+$', '') @@ -8,8 +8,8 @@ local Type = require(PATH..".type") local Systems = {} --- Registers a SystemClass. --- @param name Name to register under --- @param systemClass SystemClass to register +-- @tparam string name Name to register under +-- @tparam System systemClass SystemClass to register function Systems.register(name, systemClass) if (type(name) ~= "string") then error("bad argument #1 to 'Systems.register' (string expected, got "..type(name)..")", 3) @@ -28,14 +28,14 @@ function Systems.register(name, systemClass) end --- Returns true if the containter has the SystemClass with the name --- @param name Name of the SystemClass to check --- @return True if the containter has the SystemClass with the name, false otherwise +-- @tparam string name Name of the SystemClass to check +-- @treturn boolean function Systems.has(name) return Systems[name] and true or false end --- Returns the SystemClass with the name --- @param name Name of the SystemClass to get +-- @tparam string name Name of the SystemClass to get -- @return SystemClass with the name function Systems.get(name) return Systems[name] @@ -45,4 +45,4 @@ return setmetatable(Systems, { __index = function(_, name) error("Attempt to index system '"..tostring(name).."' that does not exist / was not registered", 2) end -}) \ No newline at end of file +}) diff --git a/concord/type.lua b/concord/type.lua index 9a882a8..62ef0f9 100644 --- a/concord/type.lua +++ b/concord/type.lua @@ -5,49 +5,49 @@ local Type = {} --- Returns if object is an Entity. -- @param t Object to check --- @return True if object is an Entity, false otherwise +-- @treturn boolean function Type.isEntity(t) return type(t) == "table" and t.__isEntity or false end --- Returns if object is a ComponentClass. -- @param t Object to check --- @return True if object is an ComponentClass, false otherwise +-- @treturn boolean function Type.isComponentClass(t) return type(t) == "table" and t.__isComponentClass or false end --- Returns if object is a Component. -- @param t Object to check --- @return True if object is an Component, false otherwise +-- @treturn boolean function Type.isComponent(t) return type(t) == "table" and t.__isComponent or false end --- Returns if object is a SystemClass. -- @param t Object to check --- @return True if object is an SystemClass, false otherwise +-- @treturn boolean function Type.isSystemClass(t) return type(t) == "table" and t.__isSystemClass or false end --- Returns if object is a System. -- @param t Object to check --- @return True if object is an System, false otherwise +-- @treturn boolean function Type.isSystem(t) return type(t) == "table" and t.__isSystem or false end --- Returns if object is a World. -- @param t Object to check --- @return True if object is an World, false otherwise +-- @treturn boolean function Type.isWorld(t) return type(t) == "table" and t.__isWorld or false end --- Returns if object is an Assemblage. -- @param t Object to check --- @return True if object is an Assemblage, false otherwise +-- @treturn boolean function Type.isAssemblage(t) return type(t) == "table" and t.__isAssemblage or false end diff --git a/concord/world.lua b/concord/world.lua index 4461da0..e196300 100644 --- a/concord/world.lua +++ b/concord/world.lua @@ -1,8 +1,8 @@ ---- 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 +--- 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. +-- @classmod World local PATH = (...):gsub('%.[^%.]+$', '') @@ -19,7 +19,7 @@ World.__mt = { } --- Creates a new World. --- @return The new World +-- @treturn World The new World function World.new() local world = setmetatable({ __entities = List(), @@ -48,8 +48,8 @@ function World.new() end --- Adds an Entity to the World. --- @param e Entity to add --- @return self +-- @tparam Entity e Entity to add +-- @treturn World self function World:addEntity(e) if not Type.isEntity(e) then error("bad argument #1 to 'World:addEntity' (Entity expected, got "..type(e)..")", 2) @@ -66,8 +66,8 @@ function World:addEntity(e) end --- Removes an Entity from the World. --- @param e Entity to remove --- @return self +-- @tparam Entity e Entity to remove +-- @treturn World self function World:removeEntity(e) if not Type.isEntity(e) then error("bad argument #1 to 'World:removeEntity' (Entity expected, got "..type(e)..")", 2) @@ -78,7 +78,7 @@ function World:removeEntity(e) return self end ---- Internal: Marks an Entity as dirty. +-- Internal: Marks an Entity as dirty. -- @param e Entity to mark as dirty function World:__dirtyEntity(e) if not self.__dirty:has(e) then @@ -86,9 +86,9 @@ function World:__dirtyEntity(e) end end ---- Internal: Flushes all changes to Entities. +-- Internal: Flushes all changes to Entities. -- This processes all entities. Adding and removing entities, as well as reevaluating dirty entities. --- @return self +-- @treturn World self function World:__flush() -- Early out if (self.__added.size == 0 and self.__removed.size == 0 and self.__dirty.size == 0) then @@ -155,8 +155,8 @@ local blacklistedSystemFunctions = { -- Callbacks are registered automatically -- Entities added before are added to the System retroactively -- @see World:emit --- @param systemClass SystemClass of System to add --- @return self +-- @tparam System systemClass SystemClass of System to add +-- @treturn World self function World:addSystem(systemClass) if (not Type.isSystemClass(systemClass)) then error("bad argument #1 to 'World:addSystems' (SystemClass expected, got "..type(systemClass)..")", 2) @@ -202,7 +202,7 @@ end -- @see World:addSystem -- @see World:emit -- @param ... SystemClasses of Systems to add --- @return self +-- @treturn World self function World:addSystems(...) for i = 1, select("#", ...) do local systemClass = select(i, ...) @@ -214,8 +214,8 @@ function World:addSystems(...) end --- Returns if the World has a System. --- @param systemClass SystemClass of System to check for --- @return True if World has System, false otherwise +-- @tparam System systemClass SystemClass of System to check for +-- @treturn boolean function World:hasSystem(systemClass) if not Type.isSystemClass(systemClass) then error("bad argument #1 to 'World:getSystem' (systemClass expected, got "..type(systemClass)..")", 2) @@ -225,8 +225,8 @@ function World:hasSystem(systemClass) end --- Gets a System from the World. --- @param systemClass SystemClass of System to get --- @return System to get +-- @tparam System systemClass SystemClass of System to get +-- @treturn System System to get function World:getSystem(systemClass) if not Type.isSystemClass(systemClass) then error("bad argument #1 to 'World:getSystem' (systemClass expected, got "..type(systemClass)..")", 2) @@ -237,9 +237,9 @@ end --- Emits a callback in the World. -- Calls all functions with the functionName of added Systems --- @param functionName Name of functions to call. +-- @string functionName Name of functions to call. -- @param ... Parameters passed to System's functions --- @return self +-- @treturn World self function World:emit(functionName, ...) if not functionName or type(functionName) ~= "string" then error("bad argument #1 to 'World:emit' (String expected, got "..type(functionName)..")") @@ -263,7 +263,7 @@ function World:emit(functionName, ...) end --- Removes all entities from the World --- @return self +-- @treturn World self function World:clear() for i = 1, self.__entities.size do self:removeEntity(self.__entities[i]) @@ -318,24 +318,24 @@ function World:deserialize(data, append) end --- Returns true if the World has a name. --- @return True if the World has a name, false otherwise +-- @treturn boolean function World:hasName() return self.__name and true or false end --- Returns the name of the World. --- @return Name of the World +-- @treturn string function World:getName() return self.__name end --- Callback for when an Entity is added to the World. --- @param e The Entity that was added +-- @tparam Entity e The Entity that was added function World:onEntityAdded(e) -- luacheck: ignore end --- Callback for when an Entity is removed from the World. --- @param e The Entity that was removed +-- @tparam Entity e The Entity that was removed function World:onEntityRemoved(e) -- luacheck: ignore end diff --git a/concord/worlds.lua b/concord/worlds.lua index 9ac18ef..6feba44 100644 --- a/concord/worlds.lua +++ b/concord/worlds.lua @@ -8,7 +8,7 @@ local Type = require(PATH..".type") local Worlds = {} --- Registers a World. --- @param name Name to register under +-- @tparam string name Name to register under -- @param world World to register function Worlds.register(name, world) if (type(name) ~= "string") then @@ -28,14 +28,14 @@ function Worlds.register(name, world) end --- Returns true if the containter has the World with the name --- @param name Name of the World to check --- @return True if the containter has the World with the name, false otherwise +-- @tparam string name Name of the World to check +-- @treturn boolean function Worlds.has(name) return Worlds[name] and true or false end --- Returns the World with the name --- @param name Name of the World to get +-- @tparam string name Name of the World to get -- @return World with the name function Worlds.get(name) return Worlds[name] @@ -45,4 +45,4 @@ return setmetatable(Worlds, { __index = function(_, name) error("Attempt to index world '"..tostring(name).."' that does not exist / was not registered", 2) end -}) \ No newline at end of file +}) diff --git a/config.ld b/config.ld index fed6e35..9b7ea55 100644 --- a/config.ld +++ b/config.ld @@ -1,3 +1,4 @@ project = 'Concord' description = 'A feature-complete ECS library' -file = {'concord', exclude = {}} \ No newline at end of file +file = {'concord', exclude = {}} +dir = 'docs' diff --git a/docs/classes/Assemblage.html b/docs/classes/Assemblage.html new file mode 100644 index 0000000..c61009b --- /dev/null +++ b/docs/classes/Assemblage.html @@ -0,0 +1,204 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class Assemblage

+

Gives an entity a set of components.

+

+ + +

Methods

+ + + + + + + + + + + + + + + + + +
Assemblage:new (assemble)Creates a new Assemblage.
Assemblage:assemble (e, ...)Assembles an Entity.
Assemblage:hasName ()Returns true if the Assemblage has a name.
Assemblage:getName ()Returns the name of the Assemblage.
+ +
+
+ + +

Methods

+ +
+
+ + Assemblage:new (assemble) +
+
+ Creates a new Assemblage. + + +

Parameters:

+
    +
  • assemble + function + Function that assembles an Entity +
  • +
+ +

Returns:

+
    + + Assemblage + A new assemblage +
+ + + + +
+
+ + Assemblage:assemble (e, ...) +
+
+ Assembles an Entity. + + +

Parameters:

+
    +
  • e + Entity + Entity to assemble +
  • +
  • ... + additional arguments to pass to the assemble function +
  • +
+ +

Returns:

+
    + + Assemblage + self +
+ + + + +
+
+ + Assemblage:hasName () +
+
+ Returns true if the Assemblage has a name. + + + +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + Assemblage:getName () +
+
+ Returns the name of the Assemblage. + + + +

Returns:

+
    + + string + +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-01-04 10:27:07 +
+
+ + diff --git a/docs/classes/Component.html b/docs/classes/Component.html new file mode 100644 index 0000000..ad4f3e2 --- /dev/null +++ b/docs/classes/Component.html @@ -0,0 +1,170 @@ + + + + + Reference + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class Component

+

A pure data container that is contained by a single entity.

+

+ + +

Methods

+ + + + + + + + + + + + + +
Component:new (populate)Creates a new ComponentClass.
Component:hasName ()Returns true if the Component has a name.
Component:getName ()Returns the name of the Component.
+ +
+
+ + +

Methods

+ +
+
+ + Component:new (populate) +
+
+ Creates a new ComponentClass. + + +

Parameters:

+
    +
  • populate + function + Function that populates a Component with values +
  • +
+ +

Returns:

+
    + + Component + A new ComponentClass +
+ + + + +
+
+ + Component:hasName () +
+
+ Returns true if the Component has a name. + + + +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + Component:getName () +
+
+ Returns the name of the Component. + + + +

Returns:

+
    + + string + +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-01-04 10:27:07 +
+
+ + diff --git a/docs/modules/entity.html b/docs/classes/Entity.html similarity index 67% rename from docs/modules/entity.html rename to docs/classes/Entity.html index 4350a6f..5ecd569 100644 --- a/docs/modules/entity.html +++ b/docs/classes/Entity.html @@ -32,25 +32,28 @@

Contents

+

Classes

+

Modules

@@ -58,18 +61,17 @@
-

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.

+

Class Entity

+

An object that exists in a world.

+

An entity + contains components which are processed by systems. +

-

Functions

+

Methods

- + @@ -93,10 +95,6 @@ - - - - @@ -122,12 +120,12 @@
-

Functions

+

Methods

- - Entity.new (world) + + Entity:new ([world])
Creates a new Entity. Optionally adds it to a World. @@ -136,13 +134,16 @@

Parameters:

  • world - Optional World to add the entity to + World + World to add the entity to + (optional)

Returns:

    + Entity A new Entity
@@ -162,16 +163,18 @@

Parameters:

  • componentClass + Component ComponentClass to add an instance of
  • ... - varargs passed to the Component's populate function + additional arguments to pass to the Component's populate function

Returns:

    + Entity self
@@ -191,16 +194,18 @@

Parameters:

  • componentClass + Component ComponentClass to add an instance of
  • ... - varargs passed to the Component's populate function + additional arguments to pass to the Component's populate function

Returns:

    + Entity self
@@ -219,6 +224,7 @@

Parameters:

  • componentClass + Component ComponentClass of the Component to remove
@@ -226,6 +232,7 @@

Returns:

    + Entity self
@@ -244,13 +251,20 @@

Parameters:

  • assemblage + Assemblage Assemblage to assemble with
  • ... - Varargs to pass to the Assemblage's assemble function. + additional arguments to pass to the Assemblage's assemble function.
+

Returns:

+
    + + Entity + self +
@@ -262,26 +276,7 @@
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. + Removes the Entity from its World if it's in one. @@ -306,6 +301,7 @@

Parameters:

  • componentClass + Component ComponentClass of the Component to check
@@ -313,7 +309,8 @@

Returns:

    - True if the Entity has the Component, false otherwise + boolean +
@@ -331,6 +328,7 @@

Parameters:

  • componentClass + Component ComponentClass of the Component to get
@@ -338,7 +336,8 @@

Returns:

    - The Component + table +
@@ -359,6 +358,7 @@

Returns:

    + table Table of all Components the Entity has
@@ -378,7 +378,8 @@

Returns:

    - True if the Entity is in a World, false otherwise + boolean +
@@ -397,7 +398,8 @@

Returns:

    - The World the Entity is in. + World +
@@ -411,7 +413,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/list.html b/docs/classes/List.html similarity index 68% rename from docs/modules/list.html rename to docs/classes/List.html index 757c1d3..b6becb6 100644 --- a/docs/modules/list.html +++ b/docs/classes/List.html @@ -32,25 +32,29 @@

Contents

+

Classes

+

Modules

@@ -58,31 +62,18 @@
-

Module list

-

List - Data structure that allows for fast removal at the cost of containing order.

+

Class List

+

Data structure that allows for fast removal at the cost of containing order.

-

Functions

+

Methods

Entity.new (world)Entity:new ([world]) Creates a new Entity.
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.
- + - - - - - - - - - - - - @@ -95,17 +86,32 @@
List.new ()List:new () Creates a new List.
List:__add (obj)Adds an object to the List.
List:__remove (obj)Removes an object from the List.
List:__clear ()Clears the List completely.
List:has (obj) Returns true if the List has the object.
Returns the index of an object in the List.
+

Metamethods

+ + + + + + + + + + + + + +
List:__add (obj)Adds an object to the List.
List:__remove (obj)Removes an object from the List.
List:__clear ()Clears the List completely.


-

Functions

+

Methods

- - List.new () + + List:new ()
Creates a new List. @@ -115,83 +121,13 @@

Returns:

    + List A new List
-
-
- - List:__add (obj) -
-
- Adds an object to the List. - Object must be of reference type - Object may not be the string 'size' - - -

Parameters:

-
    -
  • obj - Object to add -
  • -
- -

Returns:

-
    - - self -
- - - - -
-
- - List:__remove (obj) -
-
- Removes an object from the List. - - -

Parameters:

-
    -
  • obj - Object to remove -
  • -
- -

Returns:

-
    - - self -
- - - - -
-
- - List:__clear () -
-
- Clears the List completely. - - - -

Returns:

-
    - - self -
- - - -
@@ -211,7 +147,8 @@

Returns:

    - True if the List has the object, false otherwise + boolean +
@@ -229,6 +166,7 @@

Parameters:

  • i + number Index to get from
@@ -261,12 +199,91 @@

Returns:

    + number index of object in the List.
+ +
+

Metamethods

+ +
+
+ + List:__add (obj) +
+
+ Adds an object to the List. + Object must be of reference type + Object may not be the string 'size' + + +

Parameters:

+
    +
  • obj + Object to add +
  • +
+ +

Returns:

+
    + + List + self +
+ + + + +
+
+ + List:__remove (obj) +
+
+ Removes an object from the List. + + +

Parameters:

+
    +
  • obj + Object to remove +
  • +
+ +

Returns:

+
    + + List + self +
+ + + + +
+
+ + List:__clear () +
+
+ Clears the List completely. + + + +

Returns:

+
    + + List + self +
+ + + +
@@ -275,7 +292,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/pool.html b/docs/classes/Pool.html similarity index 61% rename from docs/modules/pool.html rename to docs/classes/Pool.html index ed53743..184ad8c 100644 --- a/docs/modules/pool.html +++ b/docs/classes/Pool.html @@ -32,25 +32,29 @@

Contents

+

Classes

+

Modules

@@ -58,32 +62,19 @@
-

Module pool

-

Pool - A Pool is used to iterate over Entities with a specific Components +

Class Pool

+

Used to iterate over Entities with a specific Components A Pool contain a any amount of Entities.

-

Functions

+

Methods

- + - - - - - - - - - - - - @@ -96,17 +87,24 @@
Pool.new (name, filter)Pool:new (name, filter) Creates a new Pool
Pool:__eligible (e)Checks if an Entity is eligible for the Pool.
Pool:__add (e)Internal: Adds an Entity to the Pool.
Pool:__remove (e)Internal: Removed an Entity from the Pool.
Pool:getName () Gets the name of the Pool
Callback for when an Entity is added to the Pool.
+

Metamethods

+ + + + + +
Pool:__eligible (e)Checks if an Entity is eligible for the Pool.


-

Functions

+

Methods

- - Pool.new (name, filter) + + Pool:new (name, filter)
Creates a new Pool @@ -115,9 +113,11 @@

Parameters:

  • name + string Name for the Pool.
  • filter + table Table containing the required BaseComponents
@@ -125,87 +125,13 @@

Returns:

    + Pool The new Pool
-
-
- - Pool:__eligible (e) -
-
- Checks if an Entity is eligible for the Pool. - - -

Parameters:

-
    -
  • e - Entity to check -
  • -
- -

Returns:

-
    - - True if the entity is eligible, false otherwise -
- - - - -
-
- - Pool:__add (e) -
-
- Internal: Adds an Entity to the Pool. - - -

Parameters:

-
    -
  • e - Entity to add -
  • -
- -

Returns:

-
    - - self -
- - - - -
-
- - Pool:__remove (e) -
-
- Internal: Removed an Entity from the Pool. - - -

Parameters:

-
    -
  • e - Entity to remove -
  • -
- -

Returns:

-
    - - self -
- - - -
@@ -219,7 +145,8 @@

Returns:

    - Name of the Pool. + string +
@@ -257,6 +184,7 @@

Parameters:

  • e + Entity Entity that was added.
@@ -265,6 +193,37 @@ + +
+

Metamethods

+ +
+
+ + Pool:__eligible (e) +
+
+ Checks if an Entity is eligible for the Pool. + + +

Parameters:

+
    +
  • e + Entity + Entity to check +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + +
@@ -273,7 +232,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/system.html b/docs/classes/System.html similarity index 55% rename from docs/modules/system.html rename to docs/classes/System.html index 8011319..914bd9b 100644 --- a/docs/modules/system.html +++ b/docs/classes/System.html @@ -32,25 +32,29 @@

Contents

+

Classes

+

Modules

@@ -58,37 +62,21 @@
-

Module system

-

System - A System iterates over Entities.

+

Class System

+

Iterates over Entities.

From these Entities its get Components and modify them. A System contains 1 or more Pools. - A System is contained by 1 World.

+ A System is contained by 1 World. +

-

Functions

+

Methods

- + - - - - - - - - - - - - - - - - @@ -97,7 +85,7 @@ - + @@ -112,22 +100,41 @@ + + + + + + + + +
System.new (...)System:new (...) Creates a new SystemClass.
System.__buildPool (baseFilter)Internal: Builds a Pool for the System.
System:__evaluate (e)Internal: Evaluates an Entity for all the System's Pools.
System:__remove (e)Internal: Removes an Entity from the System.
System:clear ()Internal: Clears all Entities from the System.
System:enable () Enables the System.
Disables the System.
System:toggleEnable ()System:toggleEnabled () Toggles if the System is enabled.
System:getWorld () Returns the World the System is in.
System:hasName ()Returns true if the System has a name.
System:getName ()Returns the name of the System.
+

Callbacks

+ + + + + + + + +
System:init (world) Callback for system initialization.
System:onEnabled ()Callback for when a System is enabled.
System:onDisabled ()Callback for when a System is disabled.


-

Functions

+

Methods

- - System.new (...) + + System:new (...)
Creates a new SystemClass. @@ -143,106 +150,13 @@

Returns:

    + System A new SystemClass
-
-
- - System.__buildPool (baseFilter) -
-
- Internal: Builds a Pool for the System. - - -

Parameters:

-
    -
  • baseFilter - The 'raw' Filter -
  • -
- -

Returns:

-
    - - A new Pool -
- - - - -
-
- - System:__evaluate (e) -
-
- Internal: Evaluates an Entity for all the System's Pools. - - -

Parameters:

-
    -
  • e - The Entity to check -
  • -
- -

Returns:

-
    - - self -
- - - - -
-
- - System:__remove (e) -
-
- Internal: Removes an Entity from the System. - - -

Parameters:

-
    -
  • e - The Entity to remove -
  • -
- -

Returns:

-
    - - self -
- - - - -
-
- - System:clear () -
-
- Internal: Clears all Entities from the System. - - - -

Returns:

-
    - - self -
- - - -
@@ -256,6 +170,7 @@

Returns:

    + System self
@@ -275,6 +190,7 @@

Returns:

    + System self
@@ -283,8 +199,8 @@
- - System:toggleEnable () + + System:toggleEnabled ()
Toggles if the System is enabled. @@ -294,6 +210,7 @@

Returns:

    + System self
@@ -312,13 +229,15 @@

Parameters:

  • enable - Enable + boolean +

Returns:

    + System self
@@ -338,7 +257,8 @@

Returns:

    - True if the System is enabled, false otherwise + boolean +
@@ -357,13 +277,58 @@

Returns:

    - The World the System is in + World +
+
+ + System:hasName () +
+
+ Returns true if the System has a name. + + + +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + System:getName () +
+
+ Returns the name of the System. + + + +

Returns:

+
    + + string + +
+ + + + +
+
+

Callbacks

+ +
System:init (world) @@ -375,6 +340,7 @@

Parameters:

  • world + World The World the System was added to
@@ -383,6 +349,34 @@ + +
+ + System:onEnabled () +
+
+ Callback for when a System is enabled. + + + + + + + +
+
+ + System:onDisabled () +
+
+ Callback for when a System is disabled. + + + + + + +
@@ -391,7 +385,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/world.html b/docs/classes/World.html similarity index 65% rename from docs/modules/world.html rename to docs/classes/World.html index 8338c23..ce29521 100644 --- a/docs/modules/world.html +++ b/docs/classes/World.html @@ -32,25 +32,28 @@

Contents

+

Classes

+

Modules

@@ -58,19 +61,19 @@
-

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

-

+

Class World

+

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

+

Methods

- + @@ -82,14 +85,6 @@ - - - - - - - - @@ -114,6 +109,14 @@ + + + + + + + + @@ -127,12 +130,12 @@
-

Functions

+

Methods

- - World.new () + + World:new ()
Creates a new World. @@ -142,6 +145,7 @@

Returns:

    + World The new World
@@ -160,6 +164,7 @@

Parameters:

@@ -167,6 +172,7 @@

Returns:

    + World self
@@ -185,6 +191,7 @@

Parameters:

@@ -192,46 +199,7 @@

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:

-
    - + World self
@@ -252,6 +220,7 @@

Parameters:

  • systemClass + System SystemClass of System to add
@@ -259,13 +228,14 @@

Returns:

    + World self

See also:

@@ -289,14 +259,15 @@

Returns:

    + World self

See also:

@@ -312,6 +283,7 @@

Parameters:

  • systemClass + System SystemClass of System to check for
@@ -319,7 +291,8 @@

Returns:

    - True if World has System, false otherwise + boolean +
@@ -337,6 +310,7 @@

Parameters:

  • systemClass + System SystemClass of System to get
@@ -344,6 +318,7 @@

Returns:

    + System System to get
@@ -363,6 +338,7 @@

Parameters:

  • functionName + string Name of functions to call.
  • ... @@ -373,6 +349,7 @@

    Returns:

      + World self
    @@ -392,12 +369,53 @@

    Returns:

      + World self
    +
+
+ + World:hasName () +
+
+ Returns true if the World has a name. + + + +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + World:getName () +
+
+ Returns the name of the World. + + + +

Returns:

+
    + + string + +
+ + + +
@@ -410,6 +428,7 @@

Parameters:

  • e + Entity The Entity that was added
@@ -430,6 +449,7 @@

Parameters:

  • e + Entity The Entity that was removed
@@ -446,7 +466,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/index.html b/docs/index.html index c46ade3..427d6b7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,21 +31,24 @@

Modules

+

Classes

+ @@ -57,54 +60,20 @@

Modules

World.new ()World:new () Creates a new World.
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.
Removes all entities from the World
World:hasName ()Returns true if the World has a name.
World:getName ()Returns the name of the World.
World:onEntityAdded (e) Callback for when an Entity is added to the World.
- - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -115,14 +84,6 @@ - - - - @@ -130,12 +91,44 @@ Container for registered Worlds
assemblageAssemblage - An Assemblage is a function that 'makes' an entity something.AssemblagesA container for registered Assemblages
assemblagesAssemblages - Container for registered AssemblagesComponentsContainer for registered ComponentClasses
componentComponent - A Component is a pure data container.Concord
componentsComponents - Container for registered ComponentClasss
entityEntity - Entities are the concrete objects that exist in your project.
initinit
listList - Data structure that allows for fast removal at the cost of containing order.
poolPool - A Pool is used to iterate over Entities with a specific Components - A Pool contain a any amount of Entities.
systemSystem - A System iterates over Entities.
systemsSystems - Container for registered SystemClassesSystemsContainer for registered SystemClasses
typeutils Utils Helper module for misc operations
worldWorld - 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
worlds
+

Classes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AssemblageGives an entity a set of components.
ComponentA pure data container that is contained by a single entity.
EntityAn object that exists in a world.
ListData structure that allows for fast removal at the cost of containing order.
PoolUsed to iterate over Entities with a specific Components + A Pool contain a any amount of Entities.
SystemIterates over Entities.
WorldA collection of Systems and Entities.
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/init.html b/docs/modules/Concord.html similarity index 67% rename from docs/modules/init.html rename to docs/modules/Concord.html index b3b246d..b50ef54 100644 --- a/docs/modules/init.html +++ b/docs/modules/Concord.html @@ -38,47 +38,50 @@

Modules

+

Classes

+
-

Module init

-

init

+

Module Concord

+

Functions

- + - + - + - +
Concord.loadComponents (pathOrFiles)loadComponents (pathOrFiles) Loads ComponentClasses and puts them in the Components container.
Concord.loadSystems (pathOrFiles)loadSystems (pathOrFiles) Loads SystemClasses and puts them in the Systems container.
Concord.loadWorlds (pathOrFiles)loadWorlds (pathOrFiles) Loads Worlds and puts them in the Worlds container.
Concord.loadAssemblages (pathOrFiles)loadAssemblages (pathOrFiles) Loads Assemblages and puts them in the Assemblages container.
@@ -91,8 +94,8 @@
- - Concord.loadComponents (pathOrFiles) + + loadComponents (pathOrFiles)
Loads ComponentClasses and puts them in the Components container. @@ -113,8 +116,8 @@
- - Concord.loadSystems (pathOrFiles) + + loadSystems (pathOrFiles)
Loads SystemClasses and puts them in the Systems container. @@ -135,8 +138,8 @@
- - Concord.loadWorlds (pathOrFiles) + + loadWorlds (pathOrFiles)
Loads Worlds and puts them in the Worlds container. @@ -157,8 +160,8 @@
- - Concord.loadAssemblages (pathOrFiles) + + loadAssemblages (pathOrFiles)
Loads Assemblages and puts them in the Assemblages container. @@ -185,7 +188,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/assemblage.html b/docs/modules/assemblage.html deleted file mode 100644 index bfb4d07..0000000 --- a/docs/modules/assemblage.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Reference - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module assemblage

-

Assemblage - An Assemblage is a function that 'makes' an entity something.

-

- It does this by :give'ing or :ensure'ing Components, or by :assemble'ing the Entity.

- - -

Functions

- - - - - - - - - -
Assemblage.new (assemble)Creates a new Assemblage.
Assemblage:assemble (e, ...)Assembles an Entity.
- -
-
- - -

Functions

- -
-
- - Assemblage.new (assemble) -
-
- Creates a new Assemblage. - - -

Parameters:

-
    -
  • assemble - Function that assembles an Entity -
  • -
- -

Returns:

-
    - - A new Assemblage -
- - - - -
-
- - Assemblage:assemble (e, ...) -
-
- Assembles an Entity. - - -

Parameters:

-
    -
  • e - Entity to assemble -
  • -
  • ... - Varargs to pass to the assemble function - @ return self -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 -
-
- - diff --git a/docs/modules/assemblages.html b/docs/modules/assemblages.html index 4aeed9c..8b4d725 100644 --- a/docs/modules/assemblages.html +++ b/docs/modules/assemblages.html @@ -38,38 +38,48 @@

Modules

+

Classes

+
-

Module assemblages

-

Assemblages - Container for registered Assemblages

+

Module Assemblages

+

A container for registered Assemblages

Functions

- + + + + + + + + +
Assemblages.register (name, assemblage)register (name, assemblage) Registers an Assemblage.
has (name)Returns true if the containter has an Assemblage with the specified name
get (name)Returns the Assemblage with the specified name

@@ -80,8 +90,8 @@
- - Assemblages.register (name, assemblage) + + register (name, assemblage)
Registers an Assemblage. @@ -90,9 +100,11 @@

Parameters:

  • name + string Name to register under
  • assemblage + Assemblage Assemblage to register
@@ -101,6 +113,60 @@ +
+
+ + has (name) +
+
+ Returns true if the containter has an Assemblage with the specified name + + +

Parameters:

+
    +
  • name + string + Name of the Assemblage to check +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + get (name) +
+
+ Returns the Assemblage with the specified name + + +

Parameters:

+
    +
  • name + string + Name of the Assemblage to get +
  • +
+ +

Returns:

+
    + + Assemblage + +
+ + + +
@@ -109,7 +175,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/component.html b/docs/modules/component.html deleted file mode 100644 index a5ce1fb..0000000 --- a/docs/modules/component.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - Reference - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module component

-

Component - A Component is a pure data container.

-

- A Component is contained by a single entity.

- - -

Functions

- - - - - - - - - - - - - -
Component.new (populate)Creates a new ComponentClass.
Component:__populate ()Internal: Populates a Component with values
Component:__initialize (...)Internal: Creates and populates a new Component.
- -
-
- - -

Functions

- -
-
- - Component.new (populate) -
-
- Creates a new ComponentClass. - - -

Parameters:

-
    -
  • populate - Function that populates a Component with values -
  • -
- -

Returns:

-
    - - A new ComponentClass -
- - - - -
-
- - Component:__populate () -
-
- Internal: Populates a Component with values - - - - - - - -
-
- - Component:__initialize (...) -
-
- Internal: Creates and populates a new Component. - - -

Parameters:

-
    -
  • ... - Varargs passed to the populate function -
  • -
- -

Returns:

-
    - - A new populated Component -
- - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 -
-
- - diff --git a/docs/modules/components.html b/docs/modules/components.html index c9e4dd7..f97534d 100644 --- a/docs/modules/components.html +++ b/docs/modules/components.html @@ -38,38 +38,48 @@

Modules

+

Classes

+
-

Module components

-

Components - Container for registered ComponentClasss

+

Module Components

+

Container for registered ComponentClasses

Functions

- + + + + + + + + +
Components.register (name, componentClass)register (name, componentClass) Registers a ComponentClass.
has (name)Returns true if the containter has the ComponentClass with the specified name
get (name)Returns the ComponentClass with the specified name

@@ -80,8 +90,8 @@
- - Components.register (name, componentClass) + + register (name, componentClass)
Registers a ComponentClass. @@ -90,9 +100,11 @@

Parameters:

  • name + string Name to register under
  • componentClass + Component ComponentClass to register
@@ -101,6 +113,60 @@ +
+
+ + has (name) +
+
+ Returns true if the containter has the ComponentClass with the specified name + + +

Parameters:

+
    +
  • name + string + Name of the ComponentClass to check +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + get (name) +
+
+ Returns the ComponentClass with the specified name + + +

Parameters:

+
    +
  • name + string + Name of the ComponentClass to get +
  • +
+ +

Returns:

+
    + + Component + +
+ + + +
@@ -109,7 +175,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/systems.html b/docs/modules/systems.html index d6bf949..c1e22b0 100644 --- a/docs/modules/systems.html +++ b/docs/modules/systems.html @@ -38,38 +38,48 @@

Modules

+

Classes

+
-

Module systems

-

Systems - Container for registered SystemClasses

+

Module Systems

+

Container for registered SystemClasses

Functions

- + + + + + + + + +
Systems.register (name, systemClass)register (name, systemClass) Registers a SystemClass.
has (name)Returns true if the containter has the SystemClass with the name
get (name)Returns the SystemClass with the name

@@ -80,8 +90,8 @@
- - Systems.register (name, systemClass) + + register (name, systemClass)
Registers a SystemClass. @@ -90,9 +100,11 @@

Parameters:

  • name + string Name to register under
  • systemClass + System SystemClass to register
@@ -101,6 +113,59 @@ +
+
+ + has (name) +
+
+ Returns true if the containter has the SystemClass with the name + + +

Parameters:

+
    +
  • name + string + Name of the SystemClass to check +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + get (name) +
+
+ Returns the SystemClass with the name + + +

Parameters:

+
    +
  • name + string + Name of the SystemClass to get +
  • +
+ +

Returns:

+
    + + SystemClass with the name +
+ + + +
@@ -109,7 +174,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/type.html b/docs/modules/type.html index 377c972..923c547 100644 --- a/docs/modules/type.html +++ b/docs/modules/type.html @@ -38,21 +38,24 @@

Modules

+

Classes

+ @@ -121,7 +124,8 @@

Returns:

    - True if object is an Entity, false otherwise + boolean +
@@ -146,7 +150,8 @@

Returns:

    - True if object is an ComponentClass, false otherwise + boolean +
@@ -171,7 +176,8 @@

Returns:

    - True if object is an Component, false otherwise + boolean +
@@ -196,7 +202,8 @@

Returns:

    - True if object is an SystemClass, false otherwise + boolean +
@@ -221,7 +228,8 @@

Returns:

    - True if object is an System, false otherwise + boolean +
@@ -246,7 +254,8 @@

Returns:

    - True if object is an World, false otherwise + boolean +
@@ -271,7 +280,8 @@

Returns:

    - True if object is an Assemblage, false otherwise + boolean +
@@ -285,7 +295,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/utils.html b/docs/modules/utils.html index 925eb00..30d8e2a 100644 --- a/docs/modules/utils.html +++ b/docs/modules/utils.html @@ -38,21 +38,24 @@

Modules

+

Classes

+ @@ -109,7 +112,7 @@
generated by LDoc 1.4.6 -Last updated 2020-01-04 00:43:06 +Last updated 2020-01-04 10:27:07
diff --git a/docs/modules/worlds.html b/docs/modules/worlds.html index 74bf7c3..88489f7 100644 --- a/docs/modules/worlds.html +++ b/docs/modules/worlds.html @@ -38,21 +38,24 @@

Modules

+

Classes

+ @@ -70,6 +73,14 @@ Worlds.register (name, world) Registers a World. + + Worlds.has (name) + Returns true if the containter has the World with the name + + + Worlds.get (name) + Returns the World with the name +
@@ -90,6 +101,7 @@

Parameters: