diff --git a/doc/index.html b/doc/index.html index 97dabe2..be48c6a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -3,8 +3,8 @@ - Reference - + tiny-ecs API + @@ -45,10 +45,14 @@

Module tiny-ecs

-

-

+

+

+

+

Info:

@@ -57,33 +61,35 @@ - + - +
tiny.requireAll (...)Makes a Filter that filters Entities with specified Components.Makes a Filter that selects Entities with all specified Components and + Filters.
tiny.requireOne (...)Makes a Filter that filters Entities with specified Components.Makes a Filter that selects Entities with at least one of the specified + Components and Filters.

System functions

+ + + + - - + +
tiny.system (table)Creates a System.
tiny.processingSystem (table) Creates a Processing System.
tiny.system (table)Creates a System.tiny.sortedSystem (table)Creates a Sorted Processing System.

World functions

- - - - - - + + @@ -94,6 +100,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -102,10 +128,6 @@ - - - - @@ -115,43 +137,11 @@ - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - +
tiny.activate (world, ...)Activates Systems in the World.
tiny.add (world, ...)Shortcut for adding multiple Entities and Systems to the World.tiny.world (...)Creates a new World.
tiny.addEntity (world, entity)Adds a System to the world.
tiny.add (world, ...)Shortcut for adding multiple Entities and Systems to the World.
tiny.removeEntity (world, entity)Removes an Entity to the World.
tiny.removeSystem (world, system)Removes a System from the world.
tiny.remove (world, ...)Shortcut for removing multiple Entities and Systems from the World.
tiny.update (world, dt)Updates the World.
tiny.clearEntities (world) Removes all Entities from the World.
Removes all Systems from the World.
tiny.deactivate (world, ...)Deactivates Systems in the World.
tiny.getEntityCount (world) Gets count of Entities in World.
tiny.getSystemIndex (world, system)Gets the index of a System in 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, ...)Shortcut for removing multiple Entities and Systems from the World.
tiny.removeEntity (world, entity)Removes an Entity to the World.
tiny.removeSystem (world, system)Removes a System from the world.Gets the index of a System in the World.
tiny.setSystemIndex (world, system, index)Sets the index of a System in the world.
tiny.update (world, dt)Updates the World.
tiny.updateSystem (world, system, dt)Updates a System.
tiny.world (...)Creates a new World.Sets the index of a System in the World.
@@ -161,22 +151,51 @@

Filter functions

+

A Filter is a function that selects which Entities apply to a System. + Filters take two parameters, the System and the Entity, and return a boolean + value indicating if the Entity should be processed by the System.

+ +

Filters must be added to Systems by setting the filter field of the System. + Filter’s returned by tiny.requireAll and tiny.requireOne are immutable + and can be used by multiple Systems.

+ +
local f1 = tiny.requireAll("position", "velocity", "size")
+local f2 = tiny.requireOne("position", "velocity", "size")
+
+local e1 = {
+    position = {2, 3},
+    velocity = {3, 3},
+    size = {4, 4}
+}
+
+local entity2 = {
+    position = {4, 5},
+    size = {4, 4}
+}
+
+local e3 = {
+    position = {2, 3},
+    velocity = {3, 3}
+}
+
+print(f1(nil, e1), f1(nil, e2), f1(nil, e3)) -- prints true, false, false
+print(f2(nil, e1), f2(nil, e2), f2(nil, e3)) -- prints true, true, true
+
- 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. + Makes a Filter that selects Entities with all specified Components and + Filters.

Parameters:

  • ... - List of Components + List of required Components and other Filters.
@@ -190,14 +209,14 @@ tiny.requireOne (...)
- Makes a Filter that filters Entities with specified Components. - An Entity must have at least one specified Component to match the filter. + Makes a Filter that selects Entities with at least one of the specified + Components and Filters.

Parameters:

  • ... - List of Components + List of required Components and other Filters.
@@ -209,56 +228,45 @@

System functions

- - A System is a wrapper around function callbacks for manipulating Entities. + A System is a wrapper around function callbacks for manipulating Entities.
-
- - tiny.processingSystem (table) -
-
- Creates a Processing System. A Processing System iterates through its - Entities in no particluar order, and updates them individually. It has two - important fields, function system:process(entity, dt), and function - system:filter(entity). entities is an unordered table of Entities with - Entities as KEYS, and dt is the delta time. There are also a few other - optional callbacks: - function system:preProcess(entities, dt) - returns nil, - function system:postProcess(entities, dt) - returns nil, - function system:onAdd(entity) - returns nil, - function system:onRemove(entity) - returns nil. - For Filters, it is conveient to use tiny.requireAll or tiny.requireOne, - but one can write their own filters as well. - - -

Parameters:

-
    -
  • table - A table to be used as a System, or nil to create a new - Processing System. -
  • -
- - - - - -
tiny.system (table)
- Creates a System. Systems are tables that contain at least one field; - an update function that takes parameters like so: - function system:update(entities, dt). entities is an unordered table of - Entities with Entities as KEYS, and dt is the delta time. There are also a - few other optional callbacks: - function system:filter(entity) - returns a boolean, - function system:onAdd(entity) - returns nil, - function system:onRemove(entity) - returns nil. - For Filters, it is conveient to use tiny.requireAll or tiny.requireOne, - but one can write their own filters as well. +

Creates a System. Systems are tables that contain at least one method; + an update function that takes parameters like so:

+ +
    +
  • function system:update(dt).
  • +
+ + +

There are also a few other optional callbacks:

+ +
    +
  • function system:filter(entity)
  • +
  • function system:onAdd(entity)
  • +
  • function system:onRemove(entity)
  • +
  • function system:onModify(dt)
  • +
+ + +

For Filters, it is conveient to use tiny.requireAll or tiny.requireOne, + but one can write their own filters as well. Set the Filter of your System + like so:

+ +
system.filter = tiny.requireAll("a", "b", "c")
+
+ +

or

+ +
function system:filter(entity)
+    return entity.myRequiredComponentName ~= nil
+end
+
+

Parameters:

@@ -272,447 +280,99 @@ +
+
+ + tiny.processingSystem (table) +
+
+ Creates a Processing System.

+ +

A Processing System iterates through its Entities in no particluar order, and + updates them individually. It has two important fields:

+ +
    +
  • function system:process(entity, dt)
  • +
  • function system:filter(entity)
  • +
+ + +

There are also a few other optional callbacks, including the optional + callbacks in tiny.system:

+ +
    +
  • function system:preProcess(entities, dt)
  • +
  • function system:postProcess(entities, dt)
  • +
+ + +

Processing System. + + +

Parameters:

+
    +
  • table + A table to be used as a System, or nil to create a new +
  • +
+ + + +

See also:

+ + + +
+
+ + tiny.sortedSystem (table) +
+
+ Creates a Sorted Processing System. A Sorted System iterates through its + Entities in a specific order, and updates them individually. It has three + important methods:

+ +
    +
  • function system:process(entity, dt)
  • +
  • function system:compare(entity1, entity2)
  • +
  • function system:filter(entity)
  • +
+ + +

Sorted Systems have the same optitonal callbacks as ProcessingSystems. + Sorted System. + + +

Parameters:

+
    +
  • table + A table to be used as a System, or nil to create a new +
  • +
+ + + +

See also:

+ + +

World functions

+ A World is a container that manages Entities and Systems. Typically, a + program uses one World at a time.

- 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). +

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.activate (world, ...) -
-
- Activates Systems in the World. - Activated Systems will be update whenever tiny.update(world, dt) is called. - - -

Parameters:

-
    -
  • world - -
  • -
  • ... - Systems to activate. The Systems must already be added to the - World. -
  • -
- - - - - -
-
- - tiny.add (world, ...) -
-
- Shortcut for adding multiple 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.addEntity (world, entity) -
-
- Adds an Entity to the world. - The new Entity will enter the world next time World:update is called. - Also call this on Entities that have changed Components such that it - matches different systems. - - -

Parameters:

-
    -
  • world - -
  • -
  • entity - -
  • -
- - - - - -
-
- - tiny.addSystem (world, system) -
-
- Adds a System to the world. - The new System will enter the world next time World:update is called. - - -

Parameters:

-
    -
  • world - -
  • -
  • system - -
  • -
- - - - - -
-
- - 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.deactivate (world, ...) -
-
- Deactivates Systems in the World. - Deactivated Systems must be update manually, and will not update when the - rest of World updates. They will, however, process new Entities added while - the System is deactivated. - - -

Parameters:

-
    -
  • world - -
  • -
  • ... - Systems to deactivate. The Systems must already be added to the - World. -
  • -
- - - - - -
-
- - tiny.getEntityCount (world) -
-
- Gets count of Entities in World. - - -

Parameters:

-
    -
  • world - -
  • -
- - - - - -
-
- - tiny.getSystemCount (world) -
-
- Gets count of Systems in World. - - -

Parameters:

-
    -
  • world - -
  • -
- - - - - -
-
- - tiny.getSystemIndex (world, system) -
-
- Gets the index of a System in the world. Lower indexed Systems are processed - before higher indexed systems. - - -

Parameters:

-
    -
  • world - -
  • -
  • system - -
  • -
- - - - - -
-
- - 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, ...) -
-
- Shortcut for removing multiple 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.removeEntity (world, entity) -
-
- Removes an Entity to the World. - The Entity will exit the World next time World:update is called. - Also call this on Entities that have changed Components such that it - matches different systems. - - -

Parameters:

-
    -
  • world - -
  • -
  • entity - -
  • -
- - - - - -
-
- - tiny.removeSystem (world, system) -
-
- Removes a System from the world. - The System will exit the World next time World:update is called. - - -

Parameters:

-
    -
  • world - -
  • -
  • system - -
  • -
- - - - - -
-
- - tiny.setSystemIndex (world, system, index) -
-
- Sets the index of a System in the world. Changes the order in - which they Systems processed, because lower indexed Systems are processed - first. - - -

Parameters:

-
    -
  • world - -
  • -
  • system - -
  • -
  • index - -
  • -
- - - - - -
-
- - 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 (...) @@ -738,6 +398,332 @@ + +
+ + tiny.addEntity (world, entity) +
+
+ Adds an Entity to the world. + Also call this on Entities that have changed Components such that they + match different Filters. + + +

Parameters:

+
    +
  • world + + +
  • +
  • entity + + +
  • +
+ + + + + +
+
+ + tiny.addSystem (world, system) +
+
+ Adds a System to the world. + + +

Parameters:

+
    +
  • world + + +
  • +
  • system + + +
  • +
+ + + + + +
+
+ + tiny.add (world, ...) +
+
+ Shortcut for adding multiple Entities and Systems to the World. + + +

Parameters:

+
    +
  • world + + +
  • +
  • ... + Systems and Entities +
  • +
+ + + +

See also:

+ + + +
+
+ + tiny.removeEntity (world, entity) +
+
+ Removes an Entity to the World. + + +

Parameters:

+
    +
  • world + + +
  • +
  • entity + + +
  • +
+ + + + + +
+
+ + tiny.removeSystem (world, system) +
+
+ Removes a System from the world. + + +

Parameters:

+
    +
  • world + + +
  • +
  • system + + +
  • +
+ + + + + +
+
+ + tiny.remove (world, ...) +
+
+ Shortcut for removing multiple Entities and Systems from the World. + + +

Parameters:

+
    +
  • world + + +
  • +
  • ... + Systems and Entities +
  • +
+ + + +

See also:

+ + + +
+
+ + tiny.update (world, dt) +
+
+ Updates the World. + Put this in your main loop. + + +

Parameters:

+
    +
  • world + + +
  • +
  • dt + Delta time +
  • +
+ + + + + +
+
+ + tiny.clearEntities (world) +
+
+ Removes all Entities from the World. + + +

Parameters:

+
    +
  • world + + +
  • +
+ + + + + +
+
+ + tiny.clearSystems (world) +
+
+ Removes all Systems from the World. + + +

Parameters:

+
    +
  • world + + +
  • +
+ + + + + +
+
+ + tiny.getEntityCount (world) +
+
+ Gets count of Entities in World. + + +

Parameters:

+
    +
  • world + + +
  • +
+ + + + + +
+
+ + tiny.getSystemCount (world) +
+
+ Gets count of Systems in World. + + +

Parameters:

+
    +
  • world + + +
  • +
+ + + + + +
+
+ + tiny.getSystemIndex (world, system) +
+
+ Gets the index of a System in the World. Lower indexed Systems are processed + before higher indexed systems. + + +

Parameters:

+
    +
  • world + + +
  • +
  • system + + +
  • +
+ + + + + +
+
+ + tiny.setSystemIndex (world, system, index) +
+
+ Sets the index of a System in the World. Changes the order in + which they Systems processed, because lower indexed Systems are processed + first. + + +

Parameters:

+
    +
  • world + + +
  • +
  • system + + +
  • +
  • index + + +
  • +
+ + + + +
@@ -746,7 +732,7 @@
generated by LDoc 1.4.3 -Last updated 2015-04-22 17:58:12 +Last updated 2015-05-04 20:16:58
diff --git a/doc/ldoc.css b/doc/ldoc_fixed.css similarity index 89% rename from doc/ldoc.css rename to doc/ldoc_fixed.css index 7d74ca2..45b5689 100644 --- a/doc/ldoc.css +++ b/doc/ldoc_fixed.css @@ -28,7 +28,7 @@ del,ins { text-decoration: none; } li { - list-style: disc; + list-style: bullet; margin-left: 20px; } caption,th { @@ -124,8 +124,8 @@ pre.example { } pre { - background-color: rgb(245, 245, 245); - border: 1px solid silver; + background-color: rgb(245,245,255); // rgb(245, 245, 245); + border: 1px solid #cccccc; //silver; padding: 10px; margin: 10px 0 10px 0; overflow: auto; @@ -139,7 +139,7 @@ table.index td { text-align: left; vertical-align: top; } #container { margin-left: 1em; margin-right: 1em; - background-color: #f0f0f0; + background-color: #ffffff; } #product { @@ -153,25 +153,31 @@ table.index td { text-align: left; vertical-align: top; } } #main { - background-color: #f0f0f0; - border-left: 2px solid #cccccc; + background-color:#FFFFFF; // #f0f0f0; + border-left: 1px solid #cccccc; } #navigation { + position: fixed; + top: 0; + left: 0; float: left; width: 14em; vertical-align: top; - background-color: #f0f0f0; + background-color:#FFFFFF; // #f0f0f0; + border-right: 2px solid #cccccc; overflow: visible; + overflow-y: scroll; + height: 100%; + padding-left: 1em; } #navigation h2 { - background-color:#e7e7e7; + background-color:#FFFFFF;//:#e7e7e7; font-size:1.1em; color:#000000; text-align: left; padding:0.2em; - border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; } @@ -195,16 +201,19 @@ table.index td { text-align: left; vertical-align: top; } #content { margin-left: 14em; padding: 1em; + padding-left: 2em; width: 700px; border-left: 2px solid #cccccc; - border-right: 2px solid #cccccc; + // border-right: 2px solid #cccccc; background-color: #ffffff; } #about { clear: both; - padding: 5px; + padding-left: 1em; + margin-left: 14em; // avoid the damn sidebar! border-top: 2px solid #cccccc; + border-left: 2px solid #cccccc; background-color: #ffffff; } @@ -252,10 +261,9 @@ table.module_list td { border-style: solid; border-color: #cccccc; } -table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; } table.module_list td.summary { width: 100%; } - table.function_list { border-width: 1px; border-style: solid; @@ -268,18 +276,18 @@ table.function_list td { border-style: solid; border-color: #cccccc; } -table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; } table.function_list td.summary { width: 100%; } -ul.nowrap { - overflow:auto; - white-space:nowrap; -} - dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} dl.table h3, dl.function h3 {font-size: .95em;} +ul.nowrap { + overflow:auto; + whitespace:nowrap; +} + /* stop sublists from having initial vertical space */ ul ul { margin-top: 0px; } ol ul { margin-top: 0px; }