1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 17:19:31 +00:00

Compare commits

..

No commits in common. "8ca439591c491242759bf5ad61f924fd833d82aa" and "bd28610ff4e860276a069cf2be679fb691009812" have entirely different histories.

24 changed files with 589 additions and 717 deletions

View file

@ -113,7 +113,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -337,7 +337,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -323,18 +323,10 @@ end
<td class="summary">Trigger a custom callback on a single entity.</td> <td class="summary">Trigger a custom callback on a single entity.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#System:callbackFiltered">System:callbackFiltered (filter, name, e, ...)</a></td>
<td class="summary">Same as <a href="../modules/ecs.html#System:callback">callback</a>, but will check every system against a filter before calling the callback.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#System:emit">System:emit (name, ...)</a></td> <td class="name" nowrap><a href="#System:emit">System:emit (name, ...)</a></td>
<td class="summary">Emit an event on the system.</td> <td class="summary">Emit an event on the system.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#System:emitFiltered">System:emitFiltered (filter, name, ...)</a></td>
<td class="summary">Same as <a href="../modules/ecs.html#System:emit">emit</a>, but will check every system against a filter before calling the event.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#System:destroy">System:destroy ()</a></td> <td class="name" nowrap><a href="#System:destroy">System:destroy ()</a></td>
<td class="summary">Remove all the entities and subsystems in this system.</td> <td class="summary">Remove all the entities and subsystems in this system.</td>
</tr> </tr>
@ -1807,48 +1799,6 @@ avoid repeating your filters or allow controlling several system from a single p
</dd>
<dt>
<a name = "System:callbackFiltered"></a>
<strong>System:callbackFiltered (filter, name, e, ...)</strong>
</dt>
<dd>
Same as <a href="../modules/ecs.html#System:callback">callback</a>, but will check every system against a filter before calling the callback. </p>
<p> <a href="../modules/ecs.html#System:filter">filter</a> is a function that receive the arguments <code>filter(system, name, e, &hellip;)</code>, and returns a boolean.
It will be called on each system before emitting the callback on it; if the filter returns false, the callback will not
be called on this system and its subsystems.</p>
<p> Complexity: O(1) per system
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">filter</span>
<span class="types"><span class="type">function</span></span>
filter function
</li>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
name of the callback
</li>
<li><span class="parameter">e</span>
<span class="types"><a class="type" href="../modules/ecs.html#Entity_objects">Entity</a></span>
the entity to perform the callback on
</li>
<li><span class="parameter">...</span>
other arguments to pass to the callback
</li>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "System:emit"></a> <a name = "System:emit"></a>
@ -1899,44 +1849,6 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
</dd>
<dt>
<a name = "System:emitFiltered"></a>
<strong>System:emitFiltered (filter, name, ...)</strong>
</dt>
<dd>
Same as <a href="../modules/ecs.html#System:emit">emit</a>, but will check every system against a filter before calling the event. </p>
<p> <a href="../modules/ecs.html#System:filter">filter</a> is a function that receive the arguments <code>filter(system, name, &hellip;)</code>, and returns a boolean.
It will be called on each system before emitting the event on it; if the filter returns false, the event will not
be emitted to this system and its subsystems.</p>
<p> Complexity: O(1) per system
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">filter</span>
<span class="types"><span class="type">function</span></span>
filter function
</li>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
name of the callback
</li>
<li><span class="parameter">...</span>
other arguments to pass to the callback
</li>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "System:destroy"></a> <a name = "System:destroy"></a>
@ -1964,7 +1876,7 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1723,7 +1723,7 @@ player.fire.event:bind(<span class="string">"pressed"</span>, <span class="keywo
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -2066,7 +2066,7 @@ end
Level background. </p> Level background. </p>
<p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code> <p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code>
where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Tile.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a> are the top-left position, where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a> are the top-left position,
and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors. and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors.
</ul> </ul>
@ -2142,7 +2142,7 @@ end
<li>Enum are converted into a Lua string giving the currently selected enum value.</li> <li>Enum are converted into a Lua string giving the currently selected enum value.</li>
<li>Filepath are converted into a Lua string giving the file path.</li> <li>Filepath are converted into a Lua string giving the file path.</li>
<li>Arrays are converted into a Lua table with the elements in it as a list.</li> <li>Arrays are converted into a Lua table with the elements in it as a list.</li>
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Tile.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a>, in pixels: <code>{ x=number, y=number }</code>.</li> <li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a>, in pixels: <code>{ x=number, y=number }</code>.</li>
<li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li> <li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li>
<li>Tiles are converted into a Lua table { tileset = associated tileset object, quad = associated quad } where <a href="../modules/ldtk.html#Tile.quad">quad</a> is a LÖVE Quad if LÖVE is available, otherwise a table <code>{ x, y, width, height }</code>.</li> <li>Tiles are converted into a Lua table { tileset = associated tileset object, quad = associated quad } where <a href="../modules/ldtk.html#Tile.quad">quad</a> is a LÖVE Quad if LÖVE is available, otherwise a table <code>{ x, y, width, height }</code>.</li>
<li>EntityRef are converted into a Lua table { level = level, layerIid = layer IID, entityIid = entity IID, entity = see explanation }. If the entity being refernced belongs to another level and this level is not loaded, <code>entity</code> will be nil; otherwise (same level or the other level is also loaded), it will contain the entity.</li> <li>EntityRef are converted into a Lua table { level = level, layerIid = layer IID, entityIid = entity IID, entity = see explanation }. If the entity being refernced belongs to another level and this level is not loaded, <code>entity</code> will be nil; otherwise (same level or the other level is also loaded), it will contain the entity.</li>
@ -2170,7 +2170,7 @@ end
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -703,7 +703,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -788,7 +788,7 @@ signal.event:bind(&quot;keypressed&quot;, function(key, scancode) print(&quot;pr
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1154,7 +1154,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -394,7 +394,7 @@ the repository to save you a few seconds.</p>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -785,7 +785,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -65,7 +65,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -87,7 +87,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-10-13 00:23:58 </i> <i style="float:right;">Last updated 2022-10-11 19:12:05 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

33
ecs/children.lua Normal file
View file

@ -0,0 +1,33 @@
return { -- ./ecs/children.can:12
["name"] = "children", -- ./ecs/children.can:13
["filter"] = true, -- ./ecs/children.can:14
["onAdd"] = function(self, e) -- ./ecs/children.can:15
if not e["children"] then -- ./ecs/children.can:16
e["children"] = {} -- ./ecs/children.can:16
end -- ./ecs/children.can:16
if e["parent"] then -- ./ecs/children.can:17
local parentchildren -- ./ecs/children.can:18
parentchildren = e["parent"]["children"] -- ./ecs/children.can:18
table["insert"](parentchildren, e) -- ./ecs/children.can:19
end -- ./ecs/children.can:19
for _, o in ipairs(e["children"]) do -- ./ecs/children.can:21
o["parent"] = e -- ./ecs/children.can:22
self["world"]:add(o) -- ./ecs/children.can:23
end -- ./ecs/children.can:23
end, -- ./ecs/children.can:23
["onRemove"] = function(self, e) -- ./ecs/children.can:26
for i = # e["children"], 1, - 1 do -- ./ecs/children.can:27
self["world"]:remove(e["children"][i]) -- ./ecs/children.can:28
end -- ./ecs/children.can:28
if e["parent"] then -- ./ecs/children.can:30
local parentchildren -- ./ecs/children.can:31
parentchildren = e["parent"]["children"] -- ./ecs/children.can:31
for i = # parentchildren, 1, - 1 do -- ./ecs/children.can:32
if parentchildren[i] == e then -- ./ecs/children.can:33
table["remove"](parentchildren, i) -- ./ecs/children.can:34
break -- ./ecs/children.can:35
end -- ./ecs/children.can:35
end -- ./ecs/children.can:35
end -- ./ecs/children.can:35
end -- ./ecs/children.can:35
} -- ./ecs/children.can:35

View file

@ -1,33 +0,0 @@
return { -- ./ecs/commonsystems/children.can:12
["name"] = "children", -- ./ecs/commonsystems/children.can:13
["filter"] = true, -- ./ecs/commonsystems/children.can:14
["onAdd"] = function(self, e) -- ./ecs/commonsystems/children.can:15
if not e["children"] then -- ./ecs/commonsystems/children.can:16
e["children"] = {} -- ./ecs/commonsystems/children.can:16
end -- ./ecs/commonsystems/children.can:16
if e["parent"] then -- ./ecs/commonsystems/children.can:17
local parentchildren -- ./ecs/commonsystems/children.can:18
parentchildren = e["parent"]["children"] -- ./ecs/commonsystems/children.can:18
table["insert"](parentchildren, e) -- ./ecs/commonsystems/children.can:19
end -- ./ecs/commonsystems/children.can:19
for _, o in ipairs(e["children"]) do -- ./ecs/commonsystems/children.can:21
o["parent"] = e -- ./ecs/commonsystems/children.can:22
self["world"]:add(o) -- ./ecs/commonsystems/children.can:23
end -- ./ecs/commonsystems/children.can:23
end, -- ./ecs/commonsystems/children.can:23
["onRemove"] = function(self, e) -- ./ecs/commonsystems/children.can:26
for i = # e["children"], 1, - 1 do -- ./ecs/commonsystems/children.can:27
self["world"]:remove(e["children"][i]) -- ./ecs/commonsystems/children.can:28
end -- ./ecs/commonsystems/children.can:28
if e["parent"] then -- ./ecs/commonsystems/children.can:30
local parentchildren -- ./ecs/commonsystems/children.can:31
parentchildren = e["parent"]["children"] -- ./ecs/commonsystems/children.can:31
for i = # parentchildren, 1, - 1 do -- ./ecs/commonsystems/children.can:32
if parentchildren[i] == e then -- ./ecs/commonsystems/children.can:33
table["remove"](parentchildren, i) -- ./ecs/commonsystems/children.can:34
break -- ./ecs/commonsystems/children.can:35
end -- ./ecs/commonsystems/children.can:35
end -- ./ecs/commonsystems/children.can:35
end -- ./ecs/commonsystems/children.can:35
end -- ./ecs/commonsystems/children.can:35
} -- ./ecs/commonsystems/children.can:35

View file

@ -1,23 +0,0 @@
local timer -- ./ecs/commonsystems/timer.can:4
timer = require((...):match("^(.-)ecs%.timer") .. "scene") -- ./ecs/commonsystems/timer.can:4
return { -- ./ecs/commonsystems/timer.can:6
["name"] = "timer", -- ./ecs/commonsystems/timer.can:7
["filter"] = "timer", -- ./ecs/commonsystems/timer.can:8
["default"] = {}, -- ./ecs/commonsystems/timer.can:9
["process"] = function(self, e, t, dt) -- ./ecs/commonsystems/timer.can:12
t:update(dt) -- ./ecs/commonsystems/timer.can:13
if t:dead() then -- ./ecs/commonsystems/timer.can:14
self["world"]:remove(t["entity"]) -- ./ecs/commonsystems/timer.can:15
end -- ./ecs/commonsystems/timer.can:15
end, -- ./ecs/commonsystems/timer.can:15
["run"] = function(self, func) -- ./ecs/commonsystems/timer.can:20
local t = timer["run"](func) -- ./ecs/commonsystems/timer.can:21
self["world"]:add({ ["timer"] = t }) -- ./ecs/commonsystems/timer.can:23
return t -- ./ecs/commonsystems/timer.can:25
end, -- ./ecs/commonsystems/timer.can:25
["tween"] = function(self, duration, tbl, to, method) -- ./ecs/commonsystems/timer.can:28
local t = timer["tween"](duration, tbl, to, method) -- ./ecs/commonsystems/timer.can:29
self["world"]:add({ ["timer"] = t }) -- ./ecs/commonsystems/timer.can:31
return t -- ./ecs/commonsystems/timer.can:33
end -- ./ecs/commonsystems/timer.can:33
} -- ./ecs/commonsystems/timer.can:33

View file

@ -144,10 +144,6 @@ let copy = (a, b, cache={})
end end
end end
--- Self descriptive
let alwaysTrue = () return true end
let alwaysFalse = () return false end
--- Skip list implementation --- --- Skip list implementation ---
-- Well technically it's a conbination of a skip list (for ordering) and a hash map (for that sweet O(1) search). Takes more memory but oh so efficient. -- Well technically it's a conbination of a skip list (for ordering) and a hash map (for that sweet O(1) search). Takes more memory but oh so efficient.
@ -763,21 +759,6 @@ let system_mt = {
-- @tparam Entity e the entity to perform the callback on -- @tparam Entity e the entity to perform the callback on
-- @param ... other arguments to pass to the callback -- @param ... other arguments to pass to the callback
callback = :(name, e, ...) callback = :(name, e, ...)
return @callbackFiltered(alwaysTrue, name, e, ...)
end,
--- Same as `callback`, but will check every system against a filter before calling the callback.
--
-- `filter` is a function that receive the arguments `filter(system, name, e, ...)`, and returns a boolean.
-- It will be called on each system before emitting the callback on it; if the filter returns false, the callback will not
-- be called on this system and its subsystems.
--
-- Complexity: O(1) per system
-- @tparam function filter filter function
-- @tparam string name name of the callback
-- @tparam Entity e the entity to perform the callback on
-- @param ... other arguments to pass to the callback
callbackFiltered = :(filter, name, e, ...)
if filter(@, name, e, ...) then
-- call callback -- call callback
if @_has[e] and @[name] then if @_has[e] and @[name] then
@[name](@, e, e[@component], ...) @[name](@, e, e[@component], ...)
@ -785,8 +766,7 @@ let system_mt = {
-- callback on subsystems (if it wasn't removed during the callback) -- callback on subsystems (if it wasn't removed during the callback)
if @_has[e] then if @_has[e] then
for _, ss in ipairs(@systems) do for _, ss in ipairs(@systems) do
ss:callbackFiltered(filter, name, e, ...) ss:callback(name, e, ...)
end
end end
end end
end, end,
@ -813,20 +793,6 @@ let system_mt = {
-- @tparam string name name of the callback -- @tparam string name name of the callback
-- @param ... other arguments to pass to the callback -- @param ... other arguments to pass to the callback
emit = :(name, ...) emit = :(name, ...)
return @emitFiltered(alwaysTrue, name, ...)
end,
--- Same as `emit`, but will check every system against a filter before calling the event.
--
-- `filter` is a function that receive the arguments `filter(system, name, ...)`, and returns a boolean.
-- It will be called on each system before emitting the event on it; if the filter returns false, the event will not
-- be emitted to this system and its subsystems.
--
-- Complexity: O(1) per system
-- @tparam function filter filter function
-- @tparam string name name of the callback
-- @param ... other arguments to pass to the callback
emitFiltered = :(filter, name, ...)
if filter(@, name, ...) then
-- call event -- call event
let status let status
if @[name] then if @[name] then
@ -835,12 +801,11 @@ let system_mt = {
-- call event on subsystems (if it wasn't stopped or captured) -- call event on subsystems (if it wasn't stopped or captured)
if status ~= "stop" and status ~= "capture" then if status ~= "stop" and status ~= "capture" then
for _, s in ipairs(@systems) do for _, s in ipairs(@systems) do
status = s:emitFiltered(filter, name, ...) status = s:emit(name, ...)
if status == "capture" then break end if status == "capture" then break end
end end
end end
return status return status
end
end, end,
--- Remove all the entities and subsystems in this system. --- Remove all the entities and subsystems in this system.
-- Complexity: O(entityCount) per system -- Complexity: O(entityCount) per system
@ -850,6 +815,10 @@ let system_mt = {
end, end,
} }
--- Self descriptive
let alwaysTrue = () return true end
let alwaysFalse = () return false end
--- Recursively instanciate a list of systems for a world: --- Recursively instanciate a list of systems for a world:
-- * create their self table with instance fields set -- * create their self table with instance fields set
-- * create a field with their name in world.s (if name defined) -- * create a field with their name in world.s (if name defined)

View file

@ -49,504 +49,494 @@ b[k] = v -- ./ecs/ecs.can:142
end -- ./ecs/ecs.can:142 end -- ./ecs/ecs.can:142
end -- ./ecs/ecs.can:142 end -- ./ecs/ecs.can:142
end -- ./ecs/ecs.can:142 end -- ./ecs/ecs.can:142
local alwaysTrue -- ./ecs/ecs.can:148 local head -- ./ecs/ecs.can:151
alwaysTrue = function() -- ./ecs/ecs.can:148 head = {} -- ./ecs/ecs.can:151
return true -- ./ecs/ecs.can:148 local skipNew -- ./ecs/ecs.can:154
end -- ./ecs/ecs.can:148 skipNew = function() -- ./ecs/ecs.can:154
local alwaysFalse -- ./ecs/ecs.can:149 local s -- ./ecs/ecs.can:155
alwaysFalse = function() -- ./ecs/ecs.can:149 s = { -- ./ecs/ecs.can:155
return false -- ./ecs/ecs.can:149 ["first"] = { -- ./ecs/ecs.can:158
end -- ./ecs/ecs.can:149 head, -- ./ecs/ecs.can:158
local head -- ./ecs/ecs.can:155 nil -- ./ecs/ecs.can:158
head = {} -- ./ecs/ecs.can:155 }, -- ./ecs/ecs.can:158
local skipNew -- ./ecs/ecs.can:158 ["firstBase"] = nil, -- ./ecs/ecs.can:160
skipNew = function() -- ./ecs/ecs.can:158 ["previous"] = { {} }, -- ./ecs/ecs.can:164
local s -- ./ecs/ecs.can:159 ["nLayers"] = 1, -- ./ecs/ecs.can:166
s = { -- ./ecs/ecs.can:159 ["n"] = 0 -- ./ecs/ecs.can:168
["first"] = { -- ./ecs/ecs.can:162 } -- ./ecs/ecs.can:168
head, -- ./ecs/ecs.can:162 s["firstBase"] = s["first"] -- ./ecs/ecs.can:170
nil -- ./ecs/ecs.can:162 return s -- ./ecs/ecs.can:171
}, -- ./ecs/ecs.can:162 end -- ./ecs/ecs.can:171
["firstBase"] = nil, -- ./ecs/ecs.can:164 local nextEntity -- ./ecs/ecs.can:175
["previous"] = { {} }, -- ./ecs/ecs.can:168 nextEntity = function(s) -- ./ecs/ecs.can:175
["nLayers"] = 1, -- ./ecs/ecs.can:170 if s[1] then -- ./ecs/ecs.can:176
["n"] = 0 -- ./ecs/ecs.can:172 local var -- ./ecs/ecs.can:177
} -- ./ecs/ecs.can:172 var = s[1][1] -- ./ecs/ecs.can:177
s["firstBase"] = s["first"] -- ./ecs/ecs.can:174 s[1] = s[1][2] -- ./ecs/ecs.can:178
return s -- ./ecs/ecs.can:175 return var -- ./ecs/ecs.can:179
end -- ./ecs/ecs.can:175 else -- ./ecs/ecs.can:179
local nextEntity -- ./ecs/ecs.can:179 return nil -- ./ecs/ecs.can:181
nextEntity = function(s) -- ./ecs/ecs.can:179 end -- ./ecs/ecs.can:181
if s[1] then -- ./ecs/ecs.can:180 end -- ./ecs/ecs.can:181
local var -- ./ecs/ecs.can:181 local skipIter -- ./ecs/ecs.can:186
var = s[1][1] -- ./ecs/ecs.can:181 skipIter = function(self) -- ./ecs/ecs.can:186
s[1] = s[1][2] -- ./ecs/ecs.can:182 return nextEntity, { self["firstBase"][2] } -- ./ecs/ecs.can:187
return var -- ./ecs/ecs.can:183 end -- ./ecs/ecs.can:187
else -- ./ecs/ecs.can:183 local skipAddLayers -- ./ecs/ecs.can:193
return nil -- ./ecs/ecs.can:185 skipAddLayers = function(self) -- ./ecs/ecs.can:193
end -- ./ecs/ecs.can:185 while self["n"] > 2 ^ self["nLayers"] do -- ./ecs/ecs.can:194
end -- ./ecs/ecs.can:185 self["first"] = { -- ./ecs/ecs.can:195
local skipIter -- ./ecs/ecs.can:190 head, -- ./ecs/ecs.can:195
skipIter = function(self) -- ./ecs/ecs.can:190 nil, -- ./ecs/ecs.can:195
return nextEntity, { self["firstBase"][2] } -- ./ecs/ecs.can:191 self["first"] -- ./ecs/ecs.can:195
end -- ./ecs/ecs.can:191 } -- ./ecs/ecs.can:195
local skipAddLayers -- ./ecs/ecs.can:197 table["insert"](self["previous"], {}) -- ./ecs/ecs.can:196
skipAddLayers = function(self) -- ./ecs/ecs.can:197 self["nLayers"] = self["nLayers"] + (1) -- ./ecs/ecs.can:197
while self["n"] > 2 ^ self["nLayers"] do -- ./ecs/ecs.can:198 end -- ./ecs/ecs.can:197
self["first"] = { -- ./ecs/ecs.can:199 end -- ./ecs/ecs.can:197
head, -- ./ecs/ecs.can:199 local coinFlip -- ./ecs/ecs.can:202
nil, -- ./ecs/ecs.can:199 coinFlip = function() -- ./ecs/ecs.can:202
self["first"] -- ./ecs/ecs.can:199 return math["random"](0, 1) == 1 -- ./ecs/ecs.can:203
} -- ./ecs/ecs.can:199 end -- ./ecs/ecs.can:203
table["insert"](self["previous"], {}) -- ./ecs/ecs.can:200 local skipInsert -- ./ecs/ecs.can:208
self["nLayers"] = self["nLayers"] + (1) -- ./ecs/ecs.can:201 skipInsert = function(self, system, e) -- ./ecs/ecs.can:208
end -- ./ecs/ecs.can:201 local prevLayer -- ./ecs/ecs.can:210
end -- ./ecs/ecs.can:201 prevLayer = {} -- ./ecs/ecs.can:210
local coinFlip -- ./ecs/ecs.can:206 local prev -- ./ecs/ecs.can:211
coinFlip = function() -- ./ecs/ecs.can:206 prev = self["first"] -- ./ecs/ecs.can:211
return math["random"](0, 1) == 1 -- ./ecs/ecs.can:207 for i = self["nLayers"], 1, - 1 do -- ./ecs/ecs.can:212
end -- ./ecs/ecs.can:207 while true do -- ./ecs/ecs.can:213
local skipInsert -- ./ecs/ecs.can:212 if prev[2] == nil or system:compare(e, prev[2][1]) then -- ./ecs/ecs.can:215
skipInsert = function(self, system, e) -- ./ecs/ecs.can:212 prevLayer[i] = prev -- ./ecs/ecs.can:216
local prevLayer -- ./ecs/ecs.can:214 if prev[3] then -- ./ecs/ecs.can:218
prevLayer = {} -- ./ecs/ecs.can:214 prev = prev[3] -- ./ecs/ecs.can:219
local prev -- ./ecs/ecs.can:215 break -- ./ecs/ecs.can:220
prev = self["first"] -- ./ecs/ecs.can:215 end -- ./ecs/ecs.can:220
for i = self["nLayers"], 1, - 1 do -- ./ecs/ecs.can:216 break -- ./ecs/ecs.can:222
while true do -- ./ecs/ecs.can:217 else -- ./ecs/ecs.can:222
if prev[2] == nil or system:compare(e, prev[2][1]) then -- ./ecs/ecs.can:219 prev = prev[2] -- ./ecs/ecs.can:225
prevLayer[i] = prev -- ./ecs/ecs.can:220 end -- ./ecs/ecs.can:225
if prev[3] then -- ./ecs/ecs.can:222 end -- ./ecs/ecs.can:225
prev = prev[3] -- ./ecs/ecs.can:223 end -- ./ecs/ecs.can:225
break -- ./ecs/ecs.can:224 local inLowerLayer -- ./ecs/ecs.can:230
end -- ./ecs/ecs.can:224 for i = 1, self["nLayers"] do -- ./ecs/ecs.can:231
break -- ./ecs/ecs.can:226 prev = prevLayer[i] -- ./ecs/ecs.can:232
else -- ./ecs/ecs.can:226 if i == 1 or coinFlip() then -- ./ecs/ecs.can:233
prev = prev[2] -- ./ecs/ecs.can:229 local nxt -- ./ecs/ecs.can:234
end -- ./ecs/ecs.can:229 nxt = prev[2] -- ./ecs/ecs.can:234
end -- ./ecs/ecs.can:229 prev[2] = { -- ./ecs/ecs.can:235
end -- ./ecs/ecs.can:229 e, -- ./ecs/ecs.can:235
local inLowerLayer -- ./ecs/ecs.can:234 nxt, -- ./ecs/ecs.can:235
for i = 1, self["nLayers"] do -- ./ecs/ecs.can:235 inLowerLayer -- ./ecs/ecs.can:235
prev = prevLayer[i] -- ./ecs/ecs.can:236 } -- ./ecs/ecs.can:235
if i == 1 or coinFlip() then -- ./ecs/ecs.can:237 self["previous"][i][e] = prev -- ./ecs/ecs.can:236
local nxt -- ./ecs/ecs.can:238 if nxt then -- ./ecs/ecs.can:237
nxt = prev[2] -- ./ecs/ecs.can:238 self["previous"][i][nxt[1]] = prev[2] -- ./ecs/ecs.can:238
prev[2] = { -- ./ecs/ecs.can:239 end -- ./ecs/ecs.can:238
e, -- ./ecs/ecs.can:239 inLowerLayer = prev[2] -- ./ecs/ecs.can:240
nxt, -- ./ecs/ecs.can:239 else -- ./ecs/ecs.can:240
inLowerLayer -- ./ecs/ecs.can:239 break -- ./ecs/ecs.can:242
} -- ./ecs/ecs.can:239
self["previous"][i][e] = prev -- ./ecs/ecs.can:240
if nxt then -- ./ecs/ecs.can:241
self["previous"][i][nxt[1]] = prev[2] -- ./ecs/ecs.can:242
end -- ./ecs/ecs.can:242 end -- ./ecs/ecs.can:242
inLowerLayer = prev[2] -- ./ecs/ecs.can:244 end -- ./ecs/ecs.can:242
else -- ./ecs/ecs.can:244 self["n"] = self["n"] + (1) -- ./ecs/ecs.can:245
break -- ./ecs/ecs.can:246 end -- ./ecs/ecs.can:245
end -- ./ecs/ecs.can:246 local skipDelete -- ./ecs/ecs.can:251
end -- ./ecs/ecs.can:246 skipDelete = function(self, e) -- ./ecs/ecs.can:251
self["n"] = self["n"] + (1) -- ./ecs/ecs.can:249 for i = 1, self["nLayers"] do -- ./ecs/ecs.can:253
end -- ./ecs/ecs.can:249 local previous -- ./ecs/ecs.can:254
local skipDelete -- ./ecs/ecs.can:255 previous = self["previous"][i] -- ./ecs/ecs.can:254
skipDelete = function(self, e) -- ./ecs/ecs.can:255 if previous[e] then -- ./ecs/ecs.can:255
for i = 1, self["nLayers"] do -- ./ecs/ecs.can:257 local prev -- ./ecs/ecs.can:256
local previous -- ./ecs/ecs.can:258 prev = previous[e] -- ./ecs/ecs.can:256
previous = self["previous"][i] -- ./ecs/ecs.can:258 prev[2] = prev[2][2] -- ./ecs/ecs.can:257
if previous[e] then -- ./ecs/ecs.can:259 previous[e] = nil -- ./ecs/ecs.can:258
local prev -- ./ecs/ecs.can:260 if prev[2] then -- ./ecs/ecs.can:259
prev = previous[e] -- ./ecs/ecs.can:260 previous[prev[2][1]] = prev -- ./ecs/ecs.can:260
prev[2] = prev[2][2] -- ./ecs/ecs.can:261 end -- ./ecs/ecs.can:260
previous[e] = nil -- ./ecs/ecs.can:262 else -- ./ecs/ecs.can:260
if prev[2] then -- ./ecs/ecs.can:263 break -- ./ecs/ecs.can:263
previous[prev[2][1]] = prev -- ./ecs/ecs.can:264 end -- ./ecs/ecs.can:263
end -- ./ecs/ecs.can:264 end -- ./ecs/ecs.can:263
else -- ./ecs/ecs.can:264 self["n"] = self["n"] - (1) -- ./ecs/ecs.can:266
break -- ./ecs/ecs.can:267 end -- ./ecs/ecs.can:266
end -- ./ecs/ecs.can:267 local skipReorder -- ./ecs/ecs.can:272
end -- ./ecs/ecs.can:267 skipReorder = function(self, system, e) -- ./ecs/ecs.can:272
self["n"] = self["n"] - (1) -- ./ecs/ecs.can:270 skipDelete(self, e) -- ./ecs/ecs.can:273
end -- ./ecs/ecs.can:270 skipInsert(self, system, e) -- ./ecs/ecs.can:274
local skipReorder -- ./ecs/ecs.can:276 end -- ./ecs/ecs.can:274
skipReorder = function(self, system, e) -- ./ecs/ecs.can:276 local skipIndex -- ./ecs/ecs.can:279
skipDelete(self, e) -- ./ecs/ecs.can:277 skipIndex = function(self, i) -- ./ecs/ecs.can:279
skipInsert(self, system, e) -- ./ecs/ecs.can:278 local n = 1 -- ./ecs/ecs.can:280
end -- ./ecs/ecs.can:278 for e in skipIter(self) do -- ./ecs/ecs.can:281
local skipIndex -- ./ecs/ecs.can:283 if n == i then -- ./ecs/ecs.can:282
skipIndex = function(self, i) -- ./ecs/ecs.can:283 return e -- ./ecs/ecs.can:283
local n = 1 -- ./ecs/ecs.can:284 end -- ./ecs/ecs.can:283
for e in skipIter(self) do -- ./ecs/ecs.can:285 n = n + (1) -- ./ecs/ecs.can:285
if n == i then -- ./ecs/ecs.can:286 end -- ./ecs/ecs.can:285
return e -- ./ecs/ecs.can:287 return nil -- ./ecs/ecs.can:287
end -- ./ecs/ecs.can:287 end -- ./ecs/ecs.can:287
n = n + (1) -- ./ecs/ecs.can:289 local system_mt -- ./ecs/ecs.can:351
end -- ./ecs/ecs.can:289 system_mt = { -- ./ecs/ecs.can:351
return nil -- ./ecs/ecs.can:291 ["name"] = nil, -- ./ecs/ecs.can:365
end -- ./ecs/ecs.can:291 ["systems"] = nil, -- ./ecs/ecs.can:373
local system_mt -- ./ecs/ecs.can:355 ["interval"] = false, -- ./ecs/ecs.can:379
system_mt = { -- ./ecs/ecs.can:355 ["active"] = true, -- ./ecs/ecs.can:383
["name"] = nil, -- ./ecs/ecs.can:369 ["visible"] = true, -- ./ecs/ecs.can:387
["systems"] = nil, -- ./ecs/ecs.can:377 ["component"] = nil, -- ./ecs/ecs.can:394
["interval"] = false, -- ./ecs/ecs.can:383 ["default"] = nil, -- ./ecs/ecs.can:404
["active"] = true, -- ./ecs/ecs.can:387 ["filter"] = function(self, e) -- ./ecs/ecs.can:425
["visible"] = true, -- ./ecs/ecs.can:391 return false -- ./ecs/ecs.can:425
["component"] = nil, -- ./ecs/ecs.can:398 end, -- ./ecs/ecs.can:425
["default"] = nil, -- ./ecs/ecs.can:408 ["compare"] = function(self, e1, e2) -- ./ecs/ecs.can:437
["filter"] = function(self, e) -- ./ecs/ecs.can:429 return true -- ./ecs/ecs.can:437
return false -- ./ecs/ecs.can:429 end, -- ./ecs/ecs.can:437
end, -- ./ecs/ecs.can:429 ["onAdd"] = function(self, e, c) -- ./ecs/ecs.can:443
["compare"] = function(self, e1, e2) -- ./ecs/ecs.can:441 -- ./ecs/ecs.can:443
return true -- ./ecs/ecs.can:441 end, -- ./ecs/ecs.can:443
end, -- ./ecs/ecs.can:441 ["onRemove"] = function(self, e, c) -- ./ecs/ecs.can:448
["onAdd"] = function(self, e, c) -- ./ecs/ecs.can:447 -- ./ecs/ecs.can:448
-- ./ecs/ecs.can:447 end, -- ./ecs/ecs.can:448
end, -- ./ecs/ecs.can:447 ["onInstance"] = function(self) -- ./ecs/ecs.can:451
["onRemove"] = function(self, e, c) -- ./ecs/ecs.can:452 -- ./ecs/ecs.can:451
-- ./ecs/ecs.can:452 end, -- ./ecs/ecs.can:451
end, -- ./ecs/ecs.can:452 ["onAddToWorld"] = function(self, world) -- ./ecs/ecs.can:455
["onInstance"] = function(self) -- ./ecs/ecs.can:455
-- ./ecs/ecs.can:455 -- ./ecs/ecs.can:455
end, -- ./ecs/ecs.can:455 end, -- ./ecs/ecs.can:455
["onAddToWorld"] = function(self, world) -- ./ecs/ecs.can:459 ["onRemoveFromWorld"] = function(self, world) -- ./ecs/ecs.can:459
-- ./ecs/ecs.can:459 -- ./ecs/ecs.can:459
end, -- ./ecs/ecs.can:459 end, -- ./ecs/ecs.can:459
["onRemoveFromWorld"] = function(self, world) -- ./ecs/ecs.can:463 ["onDestroy"] = function(self) -- ./ecs/ecs.can:462
-- ./ecs/ecs.can:463 -- ./ecs/ecs.can:462
end, -- ./ecs/ecs.can:463 end, -- ./ecs/ecs.can:462
["onDestroy"] = function(self) -- ./ecs/ecs.can:466 ["onUpdate"] = function(self, dt) -- ./ecs/ecs.can:467
-- ./ecs/ecs.can:466 -- ./ecs/ecs.can:467
end, -- ./ecs/ecs.can:466 end, -- ./ecs/ecs.can:467
["onUpdate"] = function(self, dt) -- ./ecs/ecs.can:471 ["onDraw"] = function(self) -- ./ecs/ecs.can:471
-- ./ecs/ecs.can:471 -- ./ecs/ecs.can:471
end, -- ./ecs/ecs.can:471 end, -- ./ecs/ecs.can:471
["onDraw"] = function(self) -- ./ecs/ecs.can:475 ["process"] = function(self, e, c, dt) -- ./ecs/ecs.can:478
-- ./ecs/ecs.can:475 -- ./ecs/ecs.can:478
end, -- ./ecs/ecs.can:475 end, -- ./ecs/ecs.can:478
["process"] = function(self, e, c, dt) -- ./ecs/ecs.can:482 ["render"] = function(self, e, c) -- ./ecs/ecs.can:484
-- ./ecs/ecs.can:482 -- ./ecs/ecs.can:484
end, -- ./ecs/ecs.can:482 end, -- ./ecs/ecs.can:484
["render"] = function(self, e, c) -- ./ecs/ecs.can:488 ["onUpdateEnd"] = function(self, dt) -- ./ecs/ecs.can:489
-- ./ecs/ecs.can:488 -- ./ecs/ecs.can:489
end, -- ./ecs/ecs.can:488 end, -- ./ecs/ecs.can:489
["onUpdateEnd"] = function(self, dt) -- ./ecs/ecs.can:493 ["onDrawEnd"] = function(self) -- ./ecs/ecs.can:493
-- ./ecs/ecs.can:493 -- ./ecs/ecs.can:493
end, -- ./ecs/ecs.can:493 end, -- ./ecs/ecs.can:493
["onDrawEnd"] = function(self) -- ./ecs/ecs.can:497 ["world"] = nil, -- ./ecs/ecs.can:503
-- ./ecs/ecs.can:497 ["w"] = nil, -- ./ecs/ecs.can:507
end, -- ./ecs/ecs.can:497 ["entityCount"] = 0, -- ./ecs/ecs.can:511
["world"] = nil, -- ./ecs/ecs.can:507 ["s"] = nil, -- ./ecs/ecs.can:515
["w"] = nil, -- ./ecs/ecs.can:511 ["_has"] = nil, -- ./ecs/ecs.can:523
["entityCount"] = 0, -- ./ecs/ecs.can:515 ["_waited"] = 0, -- ./ecs/ecs.can:527
["s"] = nil, -- ./ecs/ecs.can:519 ["add"] = function(self, e, ...) -- ./ecs/ecs.can:548
["_has"] = nil, -- ./ecs/ecs.can:527 if e ~= nil and not self["_has"][e] and self:filter(e) then -- ./ecs/ecs.can:549
["_waited"] = 0, -- ./ecs/ecs.can:531 if self["component"] and self["default"] then -- ./ecs/ecs.can:551
["add"] = function(self, e, ...) -- ./ecs/ecs.can:552 copy({ [self["component"]] = self["default"] }, e) -- ./ecs/ecs.can:552
if e ~= nil and not self["_has"][e] and self:filter(e) then -- ./ecs/ecs.can:553 end -- ./ecs/ecs.can:552
if self["component"] and self["default"] then -- ./ecs/ecs.can:555 if self["compare"] ~= system_mt["compare"] then -- ./ecs/ecs.can:555
copy({ [self["component"]] = self["default"] }, e) -- ./ecs/ecs.can:556 skipAddLayers(self["_skiplist"]) -- ./ecs/ecs.can:556
end -- ./ecs/ecs.can:556 end -- ./ecs/ecs.can:556
if self["compare"] ~= system_mt["compare"] then -- ./ecs/ecs.can:559 skipInsert(self["_skiplist"], self, e) -- ./ecs/ecs.can:559
skipAddLayers(self["_skiplist"]) -- ./ecs/ecs.can:560 self["entityCount"] = self["entityCount"] + (1) -- ./ecs/ecs.can:561
end -- ./ecs/ecs.can:560 self:onAdd(e, e[self["component"]]) -- ./ecs/ecs.can:562
skipInsert(self["_skiplist"], self, e) -- ./ecs/ecs.can:563 if self["_has"][e] then -- ./ecs/ecs.can:564
self["entityCount"] = self["entityCount"] + (1) -- ./ecs/ecs.can:565 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:565
self:onAdd(e, e[self["component"]]) -- ./ecs/ecs.can:566 s:add(e) -- ./ecs/ecs.can:566
if self["_has"][e] then -- ./ecs/ecs.can:568 end -- ./ecs/ecs.can:566
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:569 end -- ./ecs/ecs.can:566
s:add(e) -- ./ecs/ecs.can:570 end -- ./ecs/ecs.can:566
end -- ./ecs/ecs.can:570 if ... then -- ./ecs/ecs.can:570
end -- ./ecs/ecs.can:570 return e, self:add(...) -- ./ecs/ecs.can:571
end -- ./ecs/ecs.can:570 else -- ./ecs/ecs.can:571
if ... then -- ./ecs/ecs.can:574 return e -- ./ecs/ecs.can:573
return e, self:add(...) -- ./ecs/ecs.can:575 end -- ./ecs/ecs.can:573
else -- ./ecs/ecs.can:575 end, -- ./ecs/ecs.can:573
return e -- ./ecs/ecs.can:577 ["remove"] = function(self, e, ...) -- ./ecs/ecs.can:588
end -- ./ecs/ecs.can:577 if e ~= nil then -- ./ecs/ecs.can:589
end, -- ./ecs/ecs.can:577 if self["_has"][e] then -- ./ecs/ecs.can:590
["remove"] = function(self, e, ...) -- ./ecs/ecs.can:592 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:592
if e ~= nil then -- ./ecs/ecs.can:593 s:remove(e) -- ./ecs/ecs.can:593
if self["_has"][e] then -- ./ecs/ecs.can:594 end -- ./ecs/ecs.can:593
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:596 end -- ./ecs/ecs.can:593
s:remove(e) -- ./ecs/ecs.can:597 if self["_has"][e] then -- ./ecs/ecs.can:596
end -- ./ecs/ecs.can:597 skipDelete(self["_skiplist"], e) -- ./ecs/ecs.can:597
end -- ./ecs/ecs.can:597 self["entityCount"] = self["entityCount"] - (1) -- ./ecs/ecs.can:599
if self["_has"][e] then -- ./ecs/ecs.can:600 self:onRemove(e, e[self["component"]]) -- ./ecs/ecs.can:600
skipDelete(self["_skiplist"], e) -- ./ecs/ecs.can:601 end -- ./ecs/ecs.can:600
self["entityCount"] = self["entityCount"] - (1) -- ./ecs/ecs.can:603 end -- ./ecs/ecs.can:600
self:onRemove(e, e[self["component"]]) -- ./ecs/ecs.can:604 if ... then -- ./ecs/ecs.can:603
end -- ./ecs/ecs.can:604 return e, self:remove(...) -- ./ecs/ecs.can:604
end -- ./ecs/ecs.can:604 else -- ./ecs/ecs.can:604
if ... then -- ./ecs/ecs.can:607 return e -- ./ecs/ecs.can:606
return e, self:remove(...) -- ./ecs/ecs.can:608 end -- ./ecs/ecs.can:606
else -- ./ecs/ecs.can:608 end, -- ./ecs/ecs.can:606
return e -- ./ecs/ecs.can:610 ["refresh"] = function(self, e, ...) -- ./ecs/ecs.can:618
end -- ./ecs/ecs.can:610 if e ~= nil then -- ./ecs/ecs.can:619
end, -- ./ecs/ecs.can:610 if not self["_has"][e] then -- ./ecs/ecs.can:620
["refresh"] = function(self, e, ...) -- ./ecs/ecs.can:622 self:add(e) -- ./ecs/ecs.can:621
if e ~= nil then -- ./ecs/ecs.can:623 else -- ./ecs/ecs.can:621
if not self["_has"][e] then -- ./ecs/ecs.can:624 if not self:filter(e) then -- ./ecs/ecs.can:623
self:add(e) -- ./ecs/ecs.can:625 self:remove(e) -- ./ecs/ecs.can:624
else -- ./ecs/ecs.can:625 else -- ./ecs/ecs.can:624
if not self:filter(e) then -- ./ecs/ecs.can:627 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:626
self:remove(e) -- ./ecs/ecs.can:628 s:refresh(e) -- ./ecs/ecs.can:627
else -- ./ecs/ecs.can:628 end -- ./ecs/ecs.can:627
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:630 end -- ./ecs/ecs.can:627
s:refresh(e) -- ./ecs/ecs.can:631 end -- ./ecs/ecs.can:627
end -- ./ecs/ecs.can:631 end -- ./ecs/ecs.can:627
end -- ./ecs/ecs.can:631 if ... then -- ./ecs/ecs.can:632
end -- ./ecs/ecs.can:631 return e, self:refresh(...) -- ./ecs/ecs.can:633
end -- ./ecs/ecs.can:631 else -- ./ecs/ecs.can:633
if ... then -- ./ecs/ecs.can:636 return e -- ./ecs/ecs.can:635
return e, self:refresh(...) -- ./ecs/ecs.can:637 end -- ./ecs/ecs.can:635
else -- ./ecs/ecs.can:637 end, -- ./ecs/ecs.can:635
return e -- ./ecs/ecs.can:639 ["reorder"] = function(self, e, ...) -- ./ecs/ecs.can:647
end -- ./ecs/ecs.can:639 if e ~= nil and self["_has"][e] then -- ./ecs/ecs.can:648
end, -- ./ecs/ecs.can:639 skipReorder(self["_skiplist"], self, e) -- ./ecs/ecs.can:649
["reorder"] = function(self, e, ...) -- ./ecs/ecs.can:651 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:651
if e ~= nil and self["_has"][e] then -- ./ecs/ecs.can:652 s:reorder(e) -- ./ecs/ecs.can:652
skipReorder(self["_skiplist"], self, e) -- ./ecs/ecs.can:653 end -- ./ecs/ecs.can:652
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:655 end -- ./ecs/ecs.can:652
s:reorder(e) -- ./ecs/ecs.can:656 if ... then -- ./ecs/ecs.can:655
end -- ./ecs/ecs.can:656 return e, self:reorder(...) -- ./ecs/ecs.can:656
end -- ./ecs/ecs.can:656 else -- ./ecs/ecs.can:656
if ... then -- ./ecs/ecs.can:659 return e -- ./ecs/ecs.can:658
return e, self:reorder(...) -- ./ecs/ecs.can:660 end -- ./ecs/ecs.can:658
else -- ./ecs/ecs.can:660 end, -- ./ecs/ecs.can:658
return e -- ./ecs/ecs.can:662 ["has"] = function(self, e, ...) -- ./ecs/ecs.can:667
end -- ./ecs/ecs.can:662 local has -- ./ecs/ecs.can:668
end, -- ./ecs/ecs.can:662 has = e == nil or not not self["_has"][e] -- ./ecs/ecs.can:668
["has"] = function(self, e, ...) -- ./ecs/ecs.can:671 if ... then -- ./ecs/ecs.can:669
local has -- ./ecs/ecs.can:672 return has and self:has(...) -- ./ecs/ecs.can:670
has = e == nil or not not self["_has"][e] -- ./ecs/ecs.can:672 else -- ./ecs/ecs.can:670
if ... then -- ./ecs/ecs.can:673 return has -- ./ecs/ecs.can:672
return has and self:has(...) -- ./ecs/ecs.can:674 end -- ./ecs/ecs.can:672
else -- ./ecs/ecs.can:674 end, -- ./ecs/ecs.can:672
return has -- ./ecs/ecs.can:676 ["iter"] = function(self) -- ./ecs/ecs.can:679
end -- ./ecs/ecs.can:676 return skipIter(self["_skiplist"]) -- ./ecs/ecs.can:680
end, -- ./ecs/ecs.can:676 end, -- ./ecs/ecs.can:680
["iter"] = function(self) -- ./ecs/ecs.can:683 ["get"] = function(self, i) -- ./ecs/ecs.can:687
return skipIter(self["_skiplist"]) -- ./ecs/ecs.can:684 return skipIndex(self["_skiplist"], i) -- ./ecs/ecs.can:688
end, -- ./ecs/ecs.can:684 end, -- ./ecs/ecs.can:688
["get"] = function(self, i) -- ./ecs/ecs.can:691 ["clear"] = function(self) -- ./ecs/ecs.can:693
return skipIndex(self["_skiplist"], i) -- ./ecs/ecs.can:692 for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:694
end, -- ./ecs/ecs.can:692 self:remove(e) -- ./ecs/ecs.can:695
["clear"] = function(self) -- ./ecs/ecs.can:697 end -- ./ecs/ecs.can:695
for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:698 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:697
self:remove(e) -- ./ecs/ecs.can:699 s:clear() -- ./ecs/ecs.can:698
end -- ./ecs/ecs.can:699 end -- ./ecs/ecs.can:698
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:701 end, -- ./ecs/ecs.can:698
s:clear() -- ./ecs/ecs.can:702 ["update"] = function(self, dt) -- ./ecs/ecs.can:707
end -- ./ecs/ecs.can:702 if self["active"] then -- ./ecs/ecs.can:708
end, -- ./ecs/ecs.can:702 if self["interval"] then -- ./ecs/ecs.can:709
["update"] = function(self, dt) -- ./ecs/ecs.can:711 self["_waited"] = self["_waited"] + (dt) -- ./ecs/ecs.can:710
if self["active"] then -- ./ecs/ecs.can:712 if self["_waited"] < self["interval"] then -- ./ecs/ecs.can:711
if self["interval"] then -- ./ecs/ecs.can:713 return -- ./ecs/ecs.can:712
self["_waited"] = self["_waited"] + (dt) -- ./ecs/ecs.can:714 end -- ./ecs/ecs.can:712
if self["_waited"] < self["interval"] then -- ./ecs/ecs.can:715 end -- ./ecs/ecs.can:712
return -- ./ecs/ecs.can:716 self:onUpdate(dt) -- ./ecs/ecs.can:715
end -- ./ecs/ecs.can:716 if self["process"] ~= system_mt["process"] then -- ./ecs/ecs.can:716
end -- ./ecs/ecs.can:716 for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:717
self:onUpdate(dt) -- ./ecs/ecs.can:719 self:process(e, e[self["component"]], dt) -- ./ecs/ecs.can:718
if self["process"] ~= system_mt["process"] then -- ./ecs/ecs.can:720 end -- ./ecs/ecs.can:718
for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:721 end -- ./ecs/ecs.can:718
self:process(e, e[self["component"]], dt) -- ./ecs/ecs.can:722 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:721
s:update(dt) -- ./ecs/ecs.can:722
end -- ./ecs/ecs.can:722 end -- ./ecs/ecs.can:722
end -- ./ecs/ecs.can:722 self:onUpdateEnd(dt) -- ./ecs/ecs.can:724
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:725 if self["interval"] then -- ./ecs/ecs.can:725
s:update(dt) -- ./ecs/ecs.can:726 self["_waited"] = self["_waited"] - (self["interval"]) -- ./ecs/ecs.can:726
end -- ./ecs/ecs.can:726 end -- ./ecs/ecs.can:726
self:onUpdateEnd(dt) -- ./ecs/ecs.can:728 end -- ./ecs/ecs.can:726
if self["interval"] then -- ./ecs/ecs.can:729 end, -- ./ecs/ecs.can:726
self["_waited"] = self["_waited"] - (self["interval"]) -- ./ecs/ecs.can:730 ["draw"] = function(self) -- ./ecs/ecs.can:735
end -- ./ecs/ecs.can:730 if self["visible"] then -- ./ecs/ecs.can:736
end -- ./ecs/ecs.can:730 self:onDraw() -- ./ecs/ecs.can:737
end, -- ./ecs/ecs.can:730 if self["render"] ~= system_mt["render"] then -- ./ecs/ecs.can:738
["draw"] = function(self) -- ./ecs/ecs.can:739 for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:739
if self["visible"] then -- ./ecs/ecs.can:740 self:render(e, e[self["component"]]) -- ./ecs/ecs.can:740
self:onDraw() -- ./ecs/ecs.can:741 end -- ./ecs/ecs.can:740
if self["render"] ~= system_mt["render"] then -- ./ecs/ecs.can:742 end -- ./ecs/ecs.can:740
for e in skipIter(self["_skiplist"]) do -- ./ecs/ecs.can:743 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:743
self:render(e, e[self["component"]]) -- ./ecs/ecs.can:744 s:draw() -- ./ecs/ecs.can:744
end -- ./ecs/ecs.can:744 end -- ./ecs/ecs.can:744
end -- ./ecs/ecs.can:744 self:onDrawEnd() -- ./ecs/ecs.can:746
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:747 end -- ./ecs/ecs.can:746
s:draw() -- ./ecs/ecs.can:748 end, -- ./ecs/ecs.can:746
end -- ./ecs/ecs.can:748 ["callback"] = function(self, name, e, ...) -- ./ecs/ecs.can:761
self:onDrawEnd() -- ./ecs/ecs.can:750 if self["_has"][e] and self[name] then -- ./ecs/ecs.can:763
end -- ./ecs/ecs.can:750 self[name](self, e, e[self["component"]], ...) -- ./ecs/ecs.can:764
end, -- ./ecs/ecs.can:750 end -- ./ecs/ecs.can:764
["callback"] = function(self, name, e, ...) -- ./ecs/ecs.can:765 if self["_has"][e] then -- ./ecs/ecs.can:767
return self:callbackFiltered(alwaysTrue, name, e, ...) -- ./ecs/ecs.can:766 for _, ss in ipairs(self["systems"]) do -- ./ecs/ecs.can:768
end, -- ./ecs/ecs.can:766 ss:callback(name, e, ...) -- ./ecs/ecs.can:769
["callbackFiltered"] = function(self, filter, name, e, ...) -- ./ecs/ecs.can:779 end -- ./ecs/ecs.can:769
if filter(self, name, e, ...) then -- ./ecs/ecs.can:780 end -- ./ecs/ecs.can:769
if self["_has"][e] and self[name] then -- ./ecs/ecs.can:782 end, -- ./ecs/ecs.can:769
self[name](self, e, e[self["component"]], ...) -- ./ecs/ecs.can:783 ["emit"] = function(self, name, ...) -- ./ecs/ecs.can:795
end -- ./ecs/ecs.can:783 local status -- ./ecs/ecs.can:797
if self["_has"][e] then -- ./ecs/ecs.can:786 if self[name] then -- ./ecs/ecs.can:798
for _, ss in ipairs(self["systems"]) do -- ./ecs/ecs.can:787 status = self[name](self, ...) -- ./ecs/ecs.can:799
ss:callbackFiltered(filter, name, e, ...) -- ./ecs/ecs.can:788 end -- ./ecs/ecs.can:799
end -- ./ecs/ecs.can:788 if status ~= "stop" and status ~= "capture" then -- ./ecs/ecs.can:802
end -- ./ecs/ecs.can:788 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:803
end -- ./ecs/ecs.can:788 status = s:emit(name, ...) -- ./ecs/ecs.can:804
end, -- ./ecs/ecs.can:788 if status == "capture" then -- ./ecs/ecs.can:805
["emit"] = function(self, name, ...) -- ./ecs/ecs.can:815 break -- ./ecs/ecs.can:805
return self:emitFiltered(alwaysTrue, name, ...) -- ./ecs/ecs.can:816 end -- ./ecs/ecs.can:805
end, -- ./ecs/ecs.can:816 end -- ./ecs/ecs.can:805
["emitFiltered"] = function(self, filter, name, ...) -- ./ecs/ecs.can:828 end -- ./ecs/ecs.can:805
if filter(self, name, ...) then -- ./ecs/ecs.can:829 return status -- ./ecs/ecs.can:808
local status -- ./ecs/ecs.can:831 end, -- ./ecs/ecs.can:808
if self[name] then -- ./ecs/ecs.can:832 ["destroy"] = function(self) -- ./ecs/ecs.can:812
status = self[name](self, ...) -- ./ecs/ecs.can:833 recCallOnRemoveFromWorld(self["world"], { self }) -- ./ecs/ecs.can:813
end -- ./ecs/ecs.can:833 recDestroySystems({ ["systems"] = { self } }) -- ./ecs/ecs.can:814
if status ~= "stop" and status ~= "capture" then -- ./ecs/ecs.can:836 end -- ./ecs/ecs.can:814
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:837 } -- ./ecs/ecs.can:814
status = s:emitFiltered(filter, name, ...) -- ./ecs/ecs.can:838 local alwaysTrue -- ./ecs/ecs.can:819
if status == "capture" then -- ./ecs/ecs.can:839 alwaysTrue = function() -- ./ecs/ecs.can:819
break -- ./ecs/ecs.can:839 return true -- ./ecs/ecs.can:819
end -- ./ecs/ecs.can:839 end -- ./ecs/ecs.can:819
end -- ./ecs/ecs.can:839 local alwaysFalse -- ./ecs/ecs.can:820
end -- ./ecs/ecs.can:839 alwaysFalse = function() -- ./ecs/ecs.can:820
return status -- ./ecs/ecs.can:842 return false -- ./ecs/ecs.can:820
end -- ./ecs/ecs.can:842 end -- ./ecs/ecs.can:820
end, -- ./ecs/ecs.can:842 local recInstanciateSystems -- ./ecs/ecs.can:825
["destroy"] = function(self) -- ./ecs/ecs.can:847 recInstanciateSystems = function(world, systems) -- ./ecs/ecs.can:825
recCallOnRemoveFromWorld(self["world"], { self }) -- ./ecs/ecs.can:848 local t -- ./ecs/ecs.can:826
recDestroySystems({ ["systems"] = { self } }) -- ./ecs/ecs.can:849 t = {} -- ./ecs/ecs.can:826
end -- ./ecs/ecs.can:849 for _, s in ipairs(systems) do -- ./ecs/ecs.can:827
} -- ./ecs/ecs.can:849 local system -- ./ecs/ecs.can:828
local recInstanciateSystems -- ./ecs/ecs.can:856 system = setmetatable({ -- ./ecs/ecs.can:830
recInstanciateSystems = function(world, systems) -- ./ecs/ecs.can:856 ["systems"] = recInstanciateSystems(world, s["systems"] or {}), -- ./ecs/ecs.can:831
local t -- ./ecs/ecs.can:857 ["world"] = world, -- ./ecs/ecs.can:832
t = {} -- ./ecs/ecs.can:857 ["w"] = world, -- ./ecs/ecs.can:833
for _, s in ipairs(systems) do -- ./ecs/ecs.can:858 ["s"] = world["s"], -- ./ecs/ecs.can:834
local system -- ./ecs/ecs.can:859 ["_skiplist"] = skipNew() -- ./ecs/ecs.can:835
system = setmetatable({ -- ./ecs/ecs.can:861 }, { ["__index"] = function(self, k) -- ./ecs/ecs.can:837
["systems"] = recInstanciateSystems(world, s["systems"] or {}), -- ./ecs/ecs.can:862 if s[k] ~= nil then -- ./ecs/ecs.can:838
["world"] = world, -- ./ecs/ecs.can:863 return s[k] -- ./ecs/ecs.can:839
["w"] = world, -- ./ecs/ecs.can:864 else -- ./ecs/ecs.can:839
["s"] = world["s"], -- ./ecs/ecs.can:865 return system_mt[k] -- ./ecs/ecs.can:841
["_skiplist"] = skipNew() -- ./ecs/ecs.can:866 end -- ./ecs/ecs.can:841
}, { ["__index"] = function(self, k) -- ./ecs/ecs.can:868 end }) -- ./ecs/ecs.can:841
if s[k] ~= nil then -- ./ecs/ecs.can:869 system["_has"] = system["_skiplist"]["previous"][1] -- ./ecs/ecs.can:845
return s[k] -- ./ecs/ecs.can:870 if type(s["filter"]) == "string" then -- ./ecs/ecs.can:847
else -- ./ecs/ecs.can:870 system["filter"] = function(_, e) -- ./ecs/ecs.can:848
return system_mt[k] -- ./ecs/ecs.can:872 return e[s["filter"]] ~= nil -- ./ecs/ecs.can:848
end -- ./ecs/ecs.can:872 end -- ./ecs/ecs.can:848
end }) -- ./ecs/ecs.can:872 elseif type(s["filter"]) == "table" then -- ./ecs/ecs.can:849
system["_has"] = system["_skiplist"]["previous"][1] -- ./ecs/ecs.can:876 system["filter"] = ecs["all"](unpack(s["filter"])) -- ./ecs/ecs.can:850
if type(s["filter"]) == "string" then -- ./ecs/ecs.can:878 elseif type(s["filter"]) == "boolean" then -- ./ecs/ecs.can:851
system["filter"] = function(_, e) -- ./ecs/ecs.can:879 if s["filter"] then -- ./ecs/ecs.can:852
return e[s["filter"]] ~= nil -- ./ecs/ecs.can:879 system["filter"] = alwaysTrue -- ./ecs/ecs.can:853
end -- ./ecs/ecs.can:879 else -- ./ecs/ecs.can:853
elseif type(s["filter"]) == "table" then -- ./ecs/ecs.can:880 system["filter"] = alwaysFalse -- ./ecs/ecs.can:855
system["filter"] = ecs["all"](unpack(s["filter"])) -- ./ecs/ecs.can:881 end -- ./ecs/ecs.can:855
elseif type(s["filter"]) == "boolean" then -- ./ecs/ecs.can:882 end -- ./ecs/ecs.can:855
if s["filter"] then -- ./ecs/ecs.can:883 if not s["component"] and s["name"] then -- ./ecs/ecs.can:859
system["filter"] = alwaysTrue -- ./ecs/ecs.can:884 s["component"] = s["name"] -- ./ecs/ecs.can:860
else -- ./ecs/ecs.can:884 end -- ./ecs/ecs.can:860
system["filter"] = alwaysFalse -- ./ecs/ecs.can:886 table["insert"](t, system) -- ./ecs/ecs.can:863
end -- ./ecs/ecs.can:886 if s["name"] then -- ./ecs/ecs.can:864
end -- ./ecs/ecs.can:886 world["s"][s["name"]] = system -- ./ecs/ecs.can:865
if not s["component"] and s["name"] then -- ./ecs/ecs.can:890 end -- ./ecs/ecs.can:865
s["component"] = s["name"] -- ./ecs/ecs.can:891 system:onInstance() -- ./ecs/ecs.can:867
end -- ./ecs/ecs.can:891 end -- ./ecs/ecs.can:867
table["insert"](t, system) -- ./ecs/ecs.can:894 return t -- ./ecs/ecs.can:869
if s["name"] then -- ./ecs/ecs.can:895 end -- ./ecs/ecs.can:869
world["s"][s["name"]] = system -- ./ecs/ecs.can:896 local recCallOnAddToWorld -- ./ecs/ecs.can:872
end -- ./ecs/ecs.can:896 recCallOnAddToWorld = function(world, systems) -- ./ecs/ecs.can:872
system:onInstance() -- ./ecs/ecs.can:898 for _, s in ipairs(systems) do -- ./ecs/ecs.can:873
end -- ./ecs/ecs.can:898 recCallOnAddToWorld(world, s["systems"]) -- ./ecs/ecs.can:874
return t -- ./ecs/ecs.can:900 s:onAddToWorld(world) -- ./ecs/ecs.can:875
end -- ./ecs/ecs.can:900 end -- ./ecs/ecs.can:875
local recCallOnAddToWorld -- ./ecs/ecs.can:903 end -- ./ecs/ecs.can:875
recCallOnAddToWorld = function(world, systems) -- ./ecs/ecs.can:903 ecs = { -- ./ecs/ecs.can:881
for _, s in ipairs(systems) do -- ./ecs/ecs.can:904 ["world"] = function(...) -- ./ecs/ecs.can:886
recCallOnAddToWorld(world, s["systems"]) -- ./ecs/ecs.can:905 local world -- ./ecs/ecs.can:887
s:onAddToWorld(world) -- ./ecs/ecs.can:906 world = setmetatable({ -- ./ecs/ecs.can:887
end -- ./ecs/ecs.can:906 ["filter"] = ecs["all"](), -- ./ecs/ecs.can:888
end -- ./ecs/ecs.can:906 ["s"] = {}, -- ./ecs/ecs.can:889
ecs = { -- ./ecs/ecs.can:912 ["_skiplist"] = skipNew() -- ./ecs/ecs.can:890
["world"] = function(...) -- ./ecs/ecs.can:917 }, { ["__index"] = system_mt }) -- ./ecs/ecs.can:891
local world -- ./ecs/ecs.can:918 world["_has"] = world["_skiplist"]["previous"][1] -- ./ecs/ecs.can:892
world = setmetatable({ -- ./ecs/ecs.can:918 world["world"] = world -- ./ecs/ecs.can:893
["filter"] = ecs["all"](), -- ./ecs/ecs.can:919 world["w"] = world -- ./ecs/ecs.can:894
["s"] = {}, -- ./ecs/ecs.can:920 world["systems"] = recInstanciateSystems(world, { ... }) -- ./ecs/ecs.can:895
["_skiplist"] = skipNew() -- ./ecs/ecs.can:921 recCallOnAddToWorld(world, world["systems"]) -- ./ecs/ecs.can:896
}, { ["__index"] = system_mt }) -- ./ecs/ecs.can:922 return world -- ./ecs/ecs.can:897
world["_has"] = world["_skiplist"]["previous"][1] -- ./ecs/ecs.can:923 end, -- ./ecs/ecs.can:897
world["world"] = world -- ./ecs/ecs.can:924 ["all"] = function(...) -- ./ecs/ecs.can:903
world["w"] = world -- ./ecs/ecs.can:925 if ... then -- ./ecs/ecs.can:904
world["systems"] = recInstanciateSystems(world, { ... }) -- ./ecs/ecs.can:926 local l -- ./ecs/ecs.can:905
recCallOnAddToWorld(world, world["systems"]) -- ./ecs/ecs.can:927 l = { ... } -- ./ecs/ecs.can:905
return world -- ./ecs/ecs.can:928 return function(s, e) -- ./ecs/ecs.can:906
end, -- ./ecs/ecs.can:928 for _, k in ipairs(l) do -- ./ecs/ecs.can:907
["all"] = function(...) -- ./ecs/ecs.can:934 if e[k] == nil then -- ./ecs/ecs.can:908
if ... then -- ./ecs/ecs.can:935 return false -- ./ecs/ecs.can:909
local l -- ./ecs/ecs.can:936 end -- ./ecs/ecs.can:909
l = { ... } -- ./ecs/ecs.can:936 end -- ./ecs/ecs.can:909
return function(s, e) -- ./ecs/ecs.can:937 return true -- ./ecs/ecs.can:912
for _, k in ipairs(l) do -- ./ecs/ecs.can:938 end -- ./ecs/ecs.can:912
if e[k] == nil then -- ./ecs/ecs.can:939 else -- ./ecs/ecs.can:912
return false -- ./ecs/ecs.can:940 return alwaysTrue -- ./ecs/ecs.can:915
end -- ./ecs/ecs.can:940 end -- ./ecs/ecs.can:915
end -- ./ecs/ecs.can:940 end, -- ./ecs/ecs.can:915
return true -- ./ecs/ecs.can:943 ["any"] = function(...) -- ./ecs/ecs.can:922
end -- ./ecs/ecs.can:943 if ... then -- ./ecs/ecs.can:923
else -- ./ecs/ecs.can:943 local l -- ./ecs/ecs.can:924
return alwaysTrue -- ./ecs/ecs.can:946 l = { ... } -- ./ecs/ecs.can:924
end -- ./ecs/ecs.can:946 return function(s, e) -- ./ecs/ecs.can:925
end, -- ./ecs/ecs.can:946 for _, k in ipairs(l) do -- ./ecs/ecs.can:926
["any"] = function(...) -- ./ecs/ecs.can:953 if e[k] ~= nil then -- ./ecs/ecs.can:927
if ... then -- ./ecs/ecs.can:954 return true -- ./ecs/ecs.can:928
local l -- ./ecs/ecs.can:955 end -- ./ecs/ecs.can:928
l = { ... } -- ./ecs/ecs.can:955 end -- ./ecs/ecs.can:928
return function(s, e) -- ./ecs/ecs.can:956 return false -- ./ecs/ecs.can:931
for _, k in ipairs(l) do -- ./ecs/ecs.can:957 end -- ./ecs/ecs.can:931
if e[k] ~= nil then -- ./ecs/ecs.can:958 else -- ./ecs/ecs.can:931
return true -- ./ecs/ecs.can:959 return alwaysFalse -- ./ecs/ecs.can:934
end -- ./ecs/ecs.can:934
end, -- ./ecs/ecs.can:934
["scene"] = function(name, systems, entities) -- ./ecs/ecs.can:952
if systems == nil then systems = {} end -- ./ecs/ecs.can:952
if entities == nil then entities = {} end -- ./ecs/ecs.can:952
assert(scene, "ubiquitousse.scene unavailable") -- ./ecs/ecs.can:953
local s -- ./ecs/ecs.can:954
s = scene["new"](name) -- ./ecs/ecs.can:954
local w -- ./ecs/ecs.can:955
s["enter"] = function(self) -- ./ecs/ecs.can:957
local sys, ent = systems, entities -- ./ecs/ecs.can:958
if type(systems) == "function" then -- ./ecs/ecs.can:959
sys = { systems() } -- ./ecs/ecs.can:959
end -- ./ecs/ecs.can:959 end -- ./ecs/ecs.can:959
end -- ./ecs/ecs.can:959 if type(entities) == "function" then -- ./ecs/ecs.can:960
return false -- ./ecs/ecs.can:962 ent = { entities() } -- ./ecs/ecs.can:960
end -- ./ecs/ecs.can:960
w = ecs["world"](unpack(sys)) -- ./ecs/ecs.can:961
w:add(unpack(ent)) -- ./ecs/ecs.can:962
end -- ./ecs/ecs.can:962 end -- ./ecs/ecs.can:962
else -- ./ecs/ecs.can:962 s["exit"] = function(self) -- ./ecs/ecs.can:964
return alwaysFalse -- ./ecs/ecs.can:965 w:destroy() -- ./ecs/ecs.can:965
end -- ./ecs/ecs.can:965 end -- ./ecs/ecs.can:965
end, -- ./ecs/ecs.can:965 s["suspend"] = function(self) -- ./ecs/ecs.can:967
["scene"] = function(name, systems, entities) -- ./ecs/ecs.can:983 w:emit("onSuspend") -- ./ecs/ecs.can:968
if systems == nil then systems = {} end -- ./ecs/ecs.can:983 end -- ./ecs/ecs.can:968
if entities == nil then entities = {} end -- ./ecs/ecs.can:983 s["resume"] = function(self) -- ./ecs/ecs.can:970
assert(scene, "ubiquitousse.scene unavailable") -- ./ecs/ecs.can:984 w:emit("onResume") -- ./ecs/ecs.can:971
local s -- ./ecs/ecs.can:985 end -- ./ecs/ecs.can:971
s = scene["new"](name) -- ./ecs/ecs.can:985 s["update"] = function(self, dt) -- ./ecs/ecs.can:973
local w -- ./ecs/ecs.can:986 w:update(dt) -- ./ecs/ecs.can:974
s["enter"] = function(self) -- ./ecs/ecs.can:988 end -- ./ecs/ecs.can:974
local sys, ent = systems, entities -- ./ecs/ecs.can:989 s["draw"] = function(self) -- ./ecs/ecs.can:976
if type(systems) == "function" then -- ./ecs/ecs.can:990 w:draw() -- ./ecs/ecs.can:977
sys = { systems() } -- ./ecs/ecs.can:990 end -- ./ecs/ecs.can:977
end -- ./ecs/ecs.can:990 return s -- ./ecs/ecs.can:980
if type(entities) == "function" then -- ./ecs/ecs.can:991 end -- ./ecs/ecs.can:980
ent = { entities() } -- ./ecs/ecs.can:991 } -- ./ecs/ecs.can:980
end -- ./ecs/ecs.can:991 return ecs -- ./ecs/ecs.can:984
w = ecs["world"](unpack(sys)) -- ./ecs/ecs.can:992
w:add(unpack(ent)) -- ./ecs/ecs.can:993
end -- ./ecs/ecs.can:993
s["exit"] = function(self) -- ./ecs/ecs.can:995
w:destroy() -- ./ecs/ecs.can:996
end -- ./ecs/ecs.can:996
s["suspend"] = function(self) -- ./ecs/ecs.can:998
w:emit("onSuspend") -- ./ecs/ecs.can:999
end -- ./ecs/ecs.can:999
s["resume"] = function(self) -- ./ecs/ecs.can:1001
w:emit("onResume") -- ./ecs/ecs.can:1002
end -- ./ecs/ecs.can:1002
s["update"] = function(self, dt) -- ./ecs/ecs.can:1004
w:update(dt) -- ./ecs/ecs.can:1005
end -- ./ecs/ecs.can:1005
s["draw"] = function(self) -- ./ecs/ecs.can:1007
w:draw() -- ./ecs/ecs.can:1008
end -- ./ecs/ecs.can:1008
return s -- ./ecs/ecs.can:1011
end -- ./ecs/ecs.can:1011
} -- ./ecs/ecs.can:1011
return ecs -- ./ecs/ecs.can:1015

View file

@ -9,7 +9,7 @@ return {
default = { default = {
-- timer object -- timer object
}, },
process = :(e, t, dt) process = :(t, dt)
t:update(dt) t:update(dt)
if t:dead() then if t:dead() then
@world:remove(t.entity) @world:remove(t.entity)

23
ecs/timer.lua Normal file
View file

@ -0,0 +1,23 @@
local timer -- ./ecs/timer.can:4
timer = require((...):match("^(.-)ecs%.timer") .. "scene") -- ./ecs/timer.can:4
return { -- ./ecs/timer.can:6
["name"] = "timer", -- ./ecs/timer.can:7
["filter"] = "timer", -- ./ecs/timer.can:8
["default"] = {}, -- ./ecs/timer.can:9
["process"] = function(self, t, dt) -- ./ecs/timer.can:12
t:update(dt) -- ./ecs/timer.can:13
if t:dead() then -- ./ecs/timer.can:14
self["world"]:remove(t["entity"]) -- ./ecs/timer.can:15
end -- ./ecs/timer.can:15
end, -- ./ecs/timer.can:15
["run"] = function(self, func) -- ./ecs/timer.can:20
local t = timer["run"](func) -- ./ecs/timer.can:21
self["world"]:add({ ["timer"] = t }) -- ./ecs/timer.can:23
return t -- ./ecs/timer.can:25
end, -- ./ecs/timer.can:25
["tween"] = function(self, duration, tbl, to, method) -- ./ecs/timer.can:28
local t = timer["tween"](duration, tbl, to, method) -- ./ecs/timer.can:29
self["world"]:add({ ["timer"] = t }) -- ./ecs/timer.can:31
return t -- ./ecs/timer.can:33
end -- ./ecs/timer.can:33
} -- ./ecs/timer.can:33

View file

@ -306,9 +306,9 @@ input_mt = {
-- -- The deadzone for analog inputs (e.g. joystick axes): if the input absolute value is strictly below this, it will be considered as 0. 0.05 by default. -- -- The deadzone for analog inputs (e.g. joystick axes): if the input absolute value is strictly below this, it will be considered as 0. 0.05 by default.
-- -- This is applied automatically after the evaluation of input expressions. -- -- This is applied automatically after the evaluation of input expressions.
-- deadzone = 0.05, -- deadzone = 0.05,
-- -- The pressed threshold: an input is considered down if above or equal to this value. 0.1 by default. -- -- The pressed threshold: an input is considered down if above or equal to this value. 0.05 by default.
-- -- This is considered when determining if the input is pressed, down and released. -- -- This is considered when determining if the input is pressed, odwn and released.
-- threshold = 0.1, -- threshold = 0.05,
-- -- Dimension of the input (i.e. the number of values returned by this input). 1 by default. -- -- Dimension of the input (i.e. the number of values returned by this input). 1 by default.
-- dimension = 1 -- dimension = 1
-- } -- }
@ -371,7 +371,7 @@ input_mt = {
-- Cache computed directly from the input config. Recomputed by :reload(). -- Cache computed directly from the input config. Recomputed by :reload().
_dimension = 1, -- Dimension of the input. _dimension = 1, -- Dimension of the input.
_deadzone = 0.05, -- Deadzone of the input. _deadzone = 0.05, -- Deadzone of the input.
_threshold = 0.1, -- Threshold of the input. _threshold = 0.05, -- Threshold of the input.
--- Update the input and its children. --- Update the input and its children.
-- Should be called every frame, typically _after_ you've done all your input handling -- Should be called every frame, typically _after_ you've done all your input handling
@ -425,7 +425,7 @@ input_mt = {
-- get main options -- get main options
self._dimension = self.config.dimension or 1 self._dimension = self.config.dimension or 1
self._deadzone = self.config.deadzone or 0.05 self._deadzone = self.config.deadzone or 0.05
self._threshold = self.config.threshold or 0.1 self._threshold = self.config.threshold or 0.05
-- resize dimensions -- resize dimensions
if #self._value > self._dimension then if #self._value > self._dimension then
for i=self._dimension+1, #self._value do for i=self._dimension+1, #self._value do
@ -602,10 +602,8 @@ input_mt = {
new = filter(self, new, ...) new = filter(self, new, ...)
if not new then return end -- filtered out if not new then return end -- filtered out
end end
if s.parentCache[s.lastKey] ~= new then -- filter out no-op events
s.parentCache[s.lastKey] = new s.parentCache[s.lastKey] = new
self._afterFilterEvent:emit(sname, new) self._afterFilterEvent:emit(sname, new)
end
end) end)
end end
self._boundSourceEvents[sname] = true self._boundSourceEvents[sname] = true

View file

@ -534,7 +534,7 @@ let level_mt = {
-- @number[opt=0] y offset Y position to draw the level at -- @number[opt=0] y offset Y position to draw the level at
-- @require love -- @require love
draw = :(x=0, y=0) draw = :(x=0, y=0)
assert(@loaded == true, ("level %q not loaded"):format(@identifier)) assert(@loaded == true, "level not loaded")
lg.push() lg.push()
lg.translate(x + @x, y + @y) lg.translate(x + @x, y + @y)
@drawBackground() @drawBackground()
@ -554,7 +554,7 @@ let level_mt = {
-- @number[opt=0] y offset Y position to draw the backgroud at -- @number[opt=0] y offset Y position to draw the backgroud at
-- @require love -- @require love
drawBackground = :(x=0, y=0) drawBackground = :(x=0, y=0)
assert(@loaded == true, ("level %q not loaded"):format(@identifier)) assert(@loaded == true, "level not loaded")
-- background color -- background color
lg.setColor(@background.color) lg.setColor(@background.color)
lg.rectangle("fill", x, y, @width, @height) lg.rectangle("fill", x, y, @width, @height)
@ -581,7 +581,7 @@ let level_mt = {
-- --
-- @tparam[opt] table callbacks -- @tparam[opt] table callbacks
load = :(callbacks={}) load = :(callbacks={})
assert(@loaded == false, ("level %q already loaded"):format(@identifier)) assert(@loaded == false, "level already loaded")
if @_json.bgRelPath then if @_json.bgRelPath then
let pos = @_json.__bgPos let pos = @_json.__bgPos
let cropRect = pos.cropRect let cropRect = pos.cropRect
@ -623,7 +623,7 @@ let level_mt = {
-- --
-- @tparam[opt] table callbacks -- @tparam[opt] table callbacks
unload = :(callbacks={}) unload = :(callbacks={})
assert(@loaded == true, ("level %q not loaded"):format(@identifier)) assert(@loaded == true, "level not loaded")
let onRemoveLayer = callbacks.onRemoveLayer let onRemoveLayer = callbacks.onRemoveLayer
for _, l in ipairs(@layers) do for _, l in ipairs(@layers) do
l:_unloadCallbacks(callbacks) l:_unloadCallbacks(callbacks)

View file

@ -353,7 +353,7 @@ level_mt = { -- ./ldtk/ldtk.can:525
["draw"] = function(self, x, y) -- ./ldtk/ldtk.can:536 ["draw"] = function(self, x, y) -- ./ldtk/ldtk.can:536
if x == nil then x = 0 end -- ./ldtk/ldtk.can:536 if x == nil then x = 0 end -- ./ldtk/ldtk.can:536
if y == nil then y = 0 end -- ./ldtk/ldtk.can:536 if y == nil then y = 0 end -- ./ldtk/ldtk.can:536
assert(self["loaded"] == true, ("level %q not loaded"):format(self["identifier"])) -- ./ldtk/ldtk.can:537 assert(self["loaded"] == true, "level not loaded") -- ./ldtk/ldtk.can:537
lg["push"]() -- ./ldtk/ldtk.can:538 lg["push"]() -- ./ldtk/ldtk.can:538
lg["translate"](x + self["x"], y + self["y"]) -- ./ldtk/ldtk.can:539 lg["translate"](x + self["x"], y + self["y"]) -- ./ldtk/ldtk.can:539
self:drawBackground() -- ./ldtk/ldtk.can:540 self:drawBackground() -- ./ldtk/ldtk.can:540
@ -365,7 +365,7 @@ end, -- ./ldtk/ldtk.can:545
["drawBackground"] = function(self, x, y) -- ./ldtk/ldtk.can:556 ["drawBackground"] = function(self, x, y) -- ./ldtk/ldtk.can:556
if x == nil then x = 0 end -- ./ldtk/ldtk.can:556 if x == nil then x = 0 end -- ./ldtk/ldtk.can:556
if y == nil then y = 0 end -- ./ldtk/ldtk.can:556 if y == nil then y = 0 end -- ./ldtk/ldtk.can:556
assert(self["loaded"] == true, ("level %q not loaded"):format(self["identifier"])) -- ./ldtk/ldtk.can:557 assert(self["loaded"] == true, "level not loaded") -- ./ldtk/ldtk.can:557
lg["setColor"](self["background"]["color"]) -- ./ldtk/ldtk.can:559 lg["setColor"](self["background"]["color"]) -- ./ldtk/ldtk.can:559
lg["rectangle"]("fill", x, y, self["width"], self["height"]) -- ./ldtk/ldtk.can:560 lg["rectangle"]("fill", x, y, self["width"], self["height"]) -- ./ldtk/ldtk.can:560
lg["setColor"](white) -- ./ldtk/ldtk.can:562 lg["setColor"](white) -- ./ldtk/ldtk.can:562
@ -377,7 +377,7 @@ end -- ./ldtk/ldtk.can:565
end, -- ./ldtk/ldtk.can:565 end, -- ./ldtk/ldtk.can:565
["load"] = function(self, callbacks) -- ./ldtk/ldtk.can:583 ["load"] = function(self, callbacks) -- ./ldtk/ldtk.can:583
if callbacks == nil then callbacks = {} end -- ./ldtk/ldtk.can:583 if callbacks == nil then callbacks = {} end -- ./ldtk/ldtk.can:583
assert(self["loaded"] == false, ("level %q already loaded"):format(self["identifier"])) -- ./ldtk/ldtk.can:584 assert(self["loaded"] == false, "level already loaded") -- ./ldtk/ldtk.can:584
if self["_json"]["bgRelPath"] then -- ./ldtk/ldtk.can:585 if self["_json"]["bgRelPath"] then -- ./ldtk/ldtk.can:585
local pos -- ./ldtk/ldtk.can:586 local pos -- ./ldtk/ldtk.can:586
pos = self["_json"]["__bgPos"] -- ./ldtk/ldtk.can:586 pos = self["_json"]["__bgPos"] -- ./ldtk/ldtk.can:586
@ -415,7 +415,7 @@ self["loaded"] = true -- ./ldtk/ldtk.can:612
end, -- ./ldtk/ldtk.can:612 end, -- ./ldtk/ldtk.can:612
["unload"] = function(self, callbacks) -- ./ldtk/ldtk.can:625 ["unload"] = function(self, callbacks) -- ./ldtk/ldtk.can:625
if callbacks == nil then callbacks = {} end -- ./ldtk/ldtk.can:625 if callbacks == nil then callbacks = {} end -- ./ldtk/ldtk.can:625
assert(self["loaded"] == true, ("level %q not loaded"):format(self["identifier"])) -- ./ldtk/ldtk.can:626 assert(self["loaded"] == true, "level not loaded") -- ./ldtk/ldtk.can:626
local onRemoveLayer -- ./ldtk/ldtk.can:627 local onRemoveLayer -- ./ldtk/ldtk.can:627
onRemoveLayer = callbacks["onRemoveLayer"] -- ./ldtk/ldtk.can:627 onRemoveLayer = callbacks["onRemoveLayer"] -- ./ldtk/ldtk.can:627
for _, l in ipairs(self["layers"]) do -- ./ldtk/ldtk.can:628 for _, l in ipairs(self["layers"]) do -- ./ldtk/ldtk.can:628

View file

@ -189,11 +189,14 @@ util = {
-- @treturn table the copied table -- @treturn table the copied table
copy = function(t, cache) copy = function(t, cache)
if cache == nil then cache = {} end if cache == nil then cache = {} end
if cache[t] then return cache[t] end
local r = {} local r = {}
cache[t] = r cache[t] = r
for k, v in pairs(t) do for k, v in pairs(t) do
r[k] = type(v) == "table" and util.copy(v, cache) or v if type(v) == "table" then
r[k] = cache[v] or util.copy(v, cache)
else
r[k] = v
end
end end
return setmetatable(r, getmetatable(t)) return setmetatable(r, getmetatable(t))
end, end,