mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-27 09:09:30 +00:00
ecs: add System:onUpdateEnd, System:onDrawEnd
This commit is contained in:
parent
f78499e891
commit
ce7e54fb69
12 changed files with 154 additions and 34 deletions
|
|
@ -108,7 +108,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -224,6 +224,14 @@ end
|
|||
<td class="name" nowrap><a href="#System:render">System:render (e, c) <sup><em>[callback]</em></sup></a></td>
|
||||
<td class="summary">Called when drawing the system, for every entity the system contains.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#System:onUpdateEnd">System:onUpdateEnd (dt) <sup><em>[callback]</em></sup></a></td>
|
||||
<td class="summary">Called after updating the system.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#System:onDrawEnd">System:onDrawEnd () <sup><em>[callback]</em></sup></a></td>
|
||||
<td class="summary">Called after drawing the system.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 class="doc-title"><a href="#System.ro">Read-only fields.</a></h3>
|
||||
<table class="function_list">
|
||||
|
|
@ -1002,6 +1010,7 @@ avoid repeating your filters or allow controlling several system from a single p
|
|||
</dt>
|
||||
<dd>
|
||||
Called when updating the system.
|
||||
Called before any call to <a href="../modules/ecs.html#System:process">System:process</a> or call to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
@ -1027,6 +1036,7 @@ avoid repeating your filters or allow controlling several system from a single p
|
|||
</dt>
|
||||
<dd>
|
||||
Called when drawing the system.
|
||||
Called before any call to <a href="../modules/ecs.html#System:draw">System:draw</a> or call to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
@ -1044,7 +1054,8 @@ avoid repeating your filters or allow controlling several system from a single p
|
|||
<strong>System:process (e, c, dt) <sup><em>[callback]</em></sup></strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Called when updating the system, for every entity the system contains. Called after <a href="../modules/ecs.html#System:onUpdate">System:onUpdate</a> was called on the system.
|
||||
Called when updating the system, for every entity the system contains.
|
||||
Called after <a href="../modules/ecs.html#System:onUpdate">System:onUpdate</a> was called on the system, and before any call to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
@ -1077,7 +1088,8 @@ avoid repeating your filters or allow controlling several system from a single p
|
|||
<strong>System:render (e, c) <sup><em>[callback]</em></sup></strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Called when drawing the system, for every entity the system contains. Called after <a href="../modules/ecs.html#System:onDraw">System:onDraw</a> was called on the system.
|
||||
Called when drawing the system, for every entity the system contains.
|
||||
Called after <a href="../modules/ecs.html#System:onDraw">System:onDraw</a> was called on the system, and before any call to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
@ -1100,6 +1112,51 @@ avoid repeating your filters or allow controlling several system from a single p
|
|||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "System:onUpdateEnd"></a>
|
||||
<strong>System:onUpdateEnd (dt) <sup><em>[callback]</em></sup></strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Called after updating the system.
|
||||
Called after <a href="../modules/ecs.html#System:onDraw">System:onDraw</a>, <a href="../modules/ecs.html#System:process">System:process</a> and calls to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">dt</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
delta-time since last update
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "System:onDrawEnd"></a>
|
||||
<strong>System:onDrawEnd () <sup><em>[callback]</em></sup></strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Called after drawing the system.
|
||||
Called after <a href="../modules/ecs.html#System:onUpdate">System:onUpdate</a>, <a href="../modules/ecs.html#System:render">System:render</a> and calls to subsystems.
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h3 class="doc-title"><a name = "System.ro"></a>Read-only fields.</h3>
|
||||
|
|
@ -1626,7 +1683,7 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ end
|
|||
<h2><a href="#Layer_objects">Layer objects </a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Layer:draw">Layer:draw ()</a></td>
|
||||
<td class="name" nowrap><a href="#Layer:draw">Layer:draw ([, x=0[, y=0]])</a></td>
|
||||
<td class="summary">Draw the current layer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -311,11 +311,11 @@ end
|
|||
<h2><a href="#Level_objects">Level objects </a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Level:draw">Level:draw ()</a></td>
|
||||
<td class="summary">Draw this level (background and layers).</td>
|
||||
<td class="name" nowrap><a href="#Level:draw">Level:draw ([, x=0[, y=0]])</a></td>
|
||||
<td class="summary">Draw this level.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Level:drawBackground">Level:drawBackground ()</a></td>
|
||||
<td class="name" nowrap><a href="#Level:drawBackground">Level:drawBackground ([, x=0[, y=0]])</a></td>
|
||||
<td class="summary">Draw this level background.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -712,7 +712,8 @@ end
|
|||
<dd>
|
||||
Called for the entity when drawing the associated entity layer (you will likely want to redefine it). </p>
|
||||
|
||||
<p> By default, this draws the tile associated with the entity if there is one, or a rectangle around the entity position otherwise.
|
||||
<p> By default, this draws the tile associated with the entity if there is one, or a rectangle around the entity position otherwise,
|
||||
assuming we are currently in layer coordinates (i.e. layer top-left is at 0,0).
|
||||
|
||||
<h3>Requires:</h3>
|
||||
<ul>
|
||||
|
|
@ -766,11 +767,13 @@ end
|
|||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "Layer:draw"></a>
|
||||
<strong>Layer:draw ()</strong>
|
||||
<strong>Layer:draw ([, x=0[, y=0]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Draw the current layer.
|
||||
Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
Draw the current layer. </p>
|
||||
|
||||
<p> Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
You can specify an offset if your level top-left coordinate is not at 0,0 (or to produce other effects).
|
||||
|
||||
<h3>Requires:</h3>
|
||||
<ul>
|
||||
|
|
@ -780,6 +783,19 @@ end
|
|||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset X position to draw the layer at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset Y position to draw the layer at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1459,13 +1475,16 @@ end
|
|||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "Level:draw"></a>
|
||||
<strong>Level:draw ()</strong>
|
||||
<strong>Level:draw ([, x=0[, y=0]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Draw this level (background and layers).
|
||||
Assumes we are currently in world coordinates (i.e. world top-left is at 0,0).
|
||||
The level must be loaded.
|
||||
Will draw the eventual backgrounds and all the layers in the level.
|
||||
Draw this level.
|
||||
Will draw the eventual backgrounds and all the layers in the level.</p>
|
||||
|
||||
<p> Assumes we are currently in world coordinates (i.e. world top-left is at 0,0).
|
||||
You can specify an offset if your world top-left coordinate is not at 0,0 (or to produce other effects).</p>
|
||||
|
||||
<p> The level must be loaded.
|
||||
|
||||
<h3>Requires:</h3>
|
||||
<ul>
|
||||
|
|
@ -1475,6 +1494,19 @@ end
|
|||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset X position to draw the level at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset Y position to draw the level at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1483,12 +1515,15 @@ end
|
|||
</dd>
|
||||
<dt>
|
||||
<a name = "Level:drawBackground"></a>
|
||||
<strong>Level:drawBackground ()</strong>
|
||||
<strong>Level:drawBackground ([, x=0[, y=0]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Draw this level background.
|
||||
Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
The level must be loaded.
|
||||
Draw this level background. </p>
|
||||
|
||||
<p> Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
You can specify an offset if your level top-left coordinate is not at 0,0 (or to produce other effects).</p>
|
||||
|
||||
<p> The level must be loaded.
|
||||
|
||||
<h3>Requires:</h3>
|
||||
<ul>
|
||||
|
|
@ -1498,6 +1533,19 @@ end
|
|||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset X position to draw the background at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
offset Y position to draw the backgroud at
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1781,7 +1829,7 @@ end
|
|||
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>
|
||||
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#Entity.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#Layer.x">x</a> and <a href="../modules/ldtk.html#Level.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.
|
||||
|
||||
</ul>
|
||||
|
|
@ -1856,7 +1904,7 @@ end
|
|||
<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>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#Entity.y">y</a>: <code>{ x=number, y=number }</code>.</li>
|
||||
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Layer.x">x</a> and <a href="../modules/ldtk.html#Level.y">y</a>: <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>
|
||||
</ul>
|
||||
|
||||
|
|
@ -1882,7 +1930,7 @@ end
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -702,7 +702,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 14:09:51 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
19
ecs/ecs.can
19
ecs/ecs.can
|
|
@ -327,23 +327,36 @@ let system_mt = {
|
|||
-- @callback
|
||||
onDestroy = :() end,
|
||||
--- Called when updating the system.
|
||||
-- Called before any call to `System:process` or call to subsystems.
|
||||
-- @callback
|
||||
-- @number dt delta-time since last update
|
||||
onUpdate = :(dt) end,
|
||||
--- Called when drawing the system.
|
||||
-- Called before any call to `System:draw` or call to subsystems.
|
||||
-- @callback
|
||||
onDraw = :() end,
|
||||
--- Called when updating the system, for every entity the system contains. Called after `System:onUpdate` was called on the system.
|
||||
--- Called when updating the system, for every entity the system contains.
|
||||
-- Called after `System:onUpdate` was called on the system, and before any call to subsystems.
|
||||
-- @callback
|
||||
-- @tparam Entity e the entity table
|
||||
-- @tparam Component c the entity's system component, if any
|
||||
-- @number dt delta-time since last update
|
||||
process = :(e, c, dt) end,
|
||||
--- Called when drawing the system, for every entity the system contains. Called after `System:onDraw` was called on the system.
|
||||
--- Called when drawing the system, for every entity the system contains.
|
||||
-- Called after `System:onDraw` was called on the system, and before any call to subsystems.
|
||||
-- @callback
|
||||
-- @tparam Entity e the entity table
|
||||
-- @tparam Component c the entity's system component, if any
|
||||
render = :(e, c) end,
|
||||
--- Called after updating the system.
|
||||
-- Called after `System:onDraw`, `System:process` and calls to subsystems.
|
||||
-- @callback
|
||||
-- @number dt delta-time since last update
|
||||
onUpdateEnd = :(dt) end,
|
||||
--- Called after drawing the system.
|
||||
-- Called after `System:onUpdate`, `System:render` and calls to subsystems.
|
||||
-- @callback
|
||||
onDrawEnd = :() end,
|
||||
|
||||
--- Read-only fields.
|
||||
--
|
||||
|
|
@ -626,6 +639,7 @@ let system_mt = {
|
|||
for _, s in ipairs(@systems) do
|
||||
s:update(dt)
|
||||
end
|
||||
@onUpdateEnd(dt)
|
||||
if @interval then
|
||||
@_waited -= @interval
|
||||
end
|
||||
|
|
@ -645,6 +659,7 @@ let system_mt = {
|
|||
for _, s in ipairs(@systems) do
|
||||
s:draw()
|
||||
end
|
||||
@onDrawEnd()
|
||||
end
|
||||
end,
|
||||
--- Trigger a custom callback on a single entity.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue