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

ecs: add callbackFiltered and emitFiltered

This commit is contained in:
Étienne Fildadut 2022-10-13 00:24:47 +09:00
parent bd28610ff4
commit aa332a0adf
20 changed files with 697 additions and 568 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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -323,10 +323,18 @@ 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>
@ -1799,6 +1807,48 @@ 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>
@ -1849,6 +1899,44 @@ 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>
@ -1876,7 +1964,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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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#Entity.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#Tile.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#Entity.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#Tile.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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </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-11 19:12:05 </i> <i style="float:right;">Last updated 2022-10-13 00:23:58 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1,33 +0,0 @@
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

@ -0,0 +1,33 @@
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

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

View file

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

@ -1,23 +0,0 @@
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