Tidy up Lua doc for Static class

This commit is contained in:
Sezz 2025-02-06 02:35:16 +11:00
parent 437ce7c139
commit 2b41ae743a
19 changed files with 694 additions and 677 deletions

View file

@ -140,7 +140,7 @@
<td class="summary">Emit blood.</td>
</tr>
<tr>
<td class="name" ><a href="#EmitAirBubble">EmitAirBubble(pos[, size][, amplitude])</a></td>
<td class="name" ><a href="#EmitAirBubble">EmitAirBubble(pos[, size][, amp])</a></td>
<td class="summary">Emit air bubble in a water room.</td>
</tr>
<tr>
@ -251,51 +251,51 @@
</li>
<li><span class="parameter">gravity</span>
<span class="types"><span class="type">float</span></span>
(default 0) Specifies if the particle will fall over time. Positive values ascend, negative values descend. Recommended range: [-1000 and 1000].
Specifies if the particle will fall over time. Positive values ascend, negative values descend. Recommended range: [-1000 and 1000]. <strong>Default: 0</strong>
</li>
<li><span class="parameter">rotVel</span>
<span class="types"><span class="type">float</span></span>
(default 0) Rotational velocity in degrees.
Rotational velocity in degrees. <strong>Default: 0</strong>
</li>
<li><span class="parameter">startColor</span>
<span class="types"><a class="type" href="../3 primitive classes/Color.html#">Color</a></span>
(default Color(255, 255, 255)) Color at start of life.
Color at start of life. <strong>Default: Color(255, 255, 255)</strong>
</li>
<li><span class="parameter">endColor</span>
<span class="types"><a class="type" href="../3 primitive classes/Color.html#">Color</a></span>
(default Color(255, 255, 255)) Color to fade toward. This will finish long before the end of the particle's life due to internal math.
Color to fade toward. This will finish long before the end of the particle's life due to internal math. <strong>Default: Color(255, 255, 255)</strong>
</li>
<li><span class="parameter">blendMode</span>
<span class="types"><a class="type" href="../4 enums/Effects.BlendID.html#">BlendID</a></span>
(default TEN.Effects.BlendID.ALPHABLEND) Render blend mode.
Render blend mode. <strong>TEN.Effects.BlendID.ALPHABLEND</strong>
</li>
<li><span class="parameter">startSize</span>
<span class="types"><span class="type">float</span></span>
(default 10) Size at start of life.
Size at start of life. <strong>Default: 10</strong>
</li>
<li><span class="parameter">endSize</span>
<span class="types"><span class="type">float</span></span>
(default 0) Size at end of life. The particle will linearly shrink or grow toward this size over its lifespan.
Size at end of life. The particle will linearly shrink or grow toward this size over its lifespan. <strong>Default: 0</strong>
</li>
<li><span class="parameter">life</span>
<span class="types"><span class="type">float</span></span>
(default 2) Lifespan in seconds.
Lifespan in seconds. <strong>Default: 2</strong>
</li>
<li><span class="parameter">applyDamage</span>
<span class="types"><span class="type">bool</span></span>
(default false) Specifies if the particle will harm the player on collision.
Specify if the particle will harm the player on collision. <strong>Default: false</strong>
</li>
<li><span class="parameter">applyPoison</span>
<span class="types"><span class="type">bool</span></span>
(default false) Specifies if the particle will poison the player on collision.
Specify if the particle will poison the player on collision. <strong>Default: false</strong>
</li>
<li><span class="parameter">spriteSeqID</span>
<span class="types"><a class="type" href="../4 enums/Objects.ObjID.html#">ObjID</a></span>
(default Objects.ObjID.DEFAULT_SPRITES) ID of the sprite sequence object.
ID of the sprite sequence object. <strong>Default: Objects.ObjID.DEFAULT_SPRITES</strong>
</li>
<li><span class="parameter">startRot</span>
<span class="types"><span class="type">float</span></span>
(default random) Rotation at start of life.
Rotation at start of life. <strong>Default: random</strong>
</li>
</ul>
@ -504,7 +504,7 @@
</dd>
<dt>
<a name = "EmitAirBubble"></a>
<strong>EmitAirBubble(pos[, size][, amplitude])</strong>
<strong>EmitAirBubble(pos[, size][, amp])</strong>
</dt>
<dd>
Emit air bubble in a water room.
@ -515,16 +515,16 @@
<ul>
<li><span class="parameter">pos</span>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
The position where the air bubble will be spawned. Needs to be in a water room.
World position where the effect will be spawned. Must be in a water room.
</li>
<li><span class="parameter">size</span>
<span class="types"><span class="type">float</span></span>
The size of the air bubble.
Sprite size. <strong>Default: 32</strong>
(<em>optional</em>)
</li>
<li><span class="parameter">amplitude</span>
<li><span class="parameter">amp</span>
<span class="types"><span class="type">float</span></span>
The oscillation amplitude of the air bubble.
Oscillation amplitude. <strong>Default: 32</strong>
(<em>optional</em>)
</li>
</ul>

View file

@ -107,7 +107,7 @@
<div id="content">
<h1>Table <code>Objects</code></h1>
<p>Moveables, statics, cameras, and so on.</p>
<p>Objects including moveables, statics, cameras, and others.</p>
<p>
</p>

View file

@ -108,7 +108,7 @@
<h1>Class <code>Objects.Moveable</code></h1>
<p>Represents a moveable object in the game world.</p>
<p> Examples include traps, enemies, doors, pickups, and the player. See also <a href="../2 classes/Objects.LaraObject.html#">Objects.LaraObject</a> for player-specific features.</p>
<p> Examples include the player, traps, enemies, doors, and pickups. See also <a href="../2 classes/Objects.LaraObject.html#">Objects.LaraObject</a> for player-specific features.</p>
<p> pragma nostrip</p>
@ -436,7 +436,7 @@ most can just be ignored (see usage).
</li>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
Lua name of the item
Lua name.
</li>
<li><span class="parameter">position</span>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
@ -460,11 +460,11 @@ most can just be ignored (see usage).
</li>
<li><span class="parameter">hp</span>
<span class="types"><span class="type">int</span></span>
HP of item
Hit points.
</li>
<li><span class="parameter">OCB</span>
<span class="types"><span class="type">int</span></span>
ocb of item
Object code bits.
</li>
<li><span class="parameter">AIBits</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.6">table</a></span>

View file

@ -107,7 +107,7 @@
<div id="content">
<h1>Class <code>Objects.Static</code></h1>
<p>Statics</p>
<p>Represents a static object in the game world.</p>
<p>
</p>
@ -115,88 +115,85 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#Static:Enable">Static:Enable()</a></td>
<td class="summary">Enable the static, for cases when it was shattered or manually disabled before.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:Disable">Static:Disable()</a></td>
<td class="summary">Disable the static</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetActive">Static:GetActive()</a></td>
<td class="summary">Get static mesh visibility</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetSolid">Static:GetSolid()</a></td>
<td class="summary">Get static mesh solid collision state</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetSolid">Static:SetSolid(solidState)</a></td>
<td class="summary">Set static mesh solid collision state</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetPosition">Static:GetPosition()</a></td>
<td class="summary">Get the static's position</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetPosition">Static:SetPosition(position)</a></td>
<td class="summary">Set the static's position</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetRotation">Static:GetRotation()</a></td>
<td class="summary">Get the static's rotation</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetRotation">Static:SetRotation(rotation)</a></td>
<td class="summary">Set the static's rotation</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetScale">Static:GetScale()</a></td>
<td class="summary">Get the static's scale</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetScale">Static:SetScale(scale)</a></td>
<td class="summary">Set the static's scale</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetHP">Static:GetHP()</a></td>
<td class="summary">Get current HP (hit points/health points)
Used only with shatterable static meshes.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetHP">Static:SetHP(HP)</a></td>
<td class="summary">Set current HP (hit points/health points)
Used only with shatterable static meshes.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetName">Static:GetName()</a></td>
<td class="summary">Get the static's unique string identifier</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetName">Static:SetName(name)</a></td>
<td class="summary">Set the static's name (its unique string identifier)
e.g.</td>
<td class="summary">Get this static's unique string identifier.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetSlot">Static:GetSlot()</a></td>
<td class="summary">Get the static's slot number (as listed in Tomb Editor and WadTool)</td>
<td class="summary">Get this static's slot ID.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetSlot">Static:SetSlot(slot)</a></td>
<td class="summary">Set the static's slot number (as listed in Tomb Editor and WadTool)</td>
<td class="name" ><a href="#Static:GetPosition">Static:GetPosition()</a></td>
<td class="summary">Get this static's world position.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetRotation">Static:GetRotation()</a></td>
<td class="summary">Get this static's world rotation.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetScale">Static:GetScale()</a></td>
<td class="summary">Get this static's world scale.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetColor">Static:GetColor()</a></td>
<td class="summary">Get the static's color</td>
<td class="summary">Get this static's color.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetHP">Static:GetHP()</a></td>
<td class="summary">Get this static's hit points.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetActive">Static:GetActive()</a></td>
<td class="summary">Get this static's visibility state.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:GetSolid">Static:GetSolid()</a></td>
<td class="summary">Get this static's solid collision state.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetName">Static:SetName(name)</a></td>
<td class="summary">Set this static's unique identifier string.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetSlot">Static:SetSlot(New)</a></td>
<td class="summary">Set this static's slot ID.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetPosition">Static:SetPosition(New)</a></td>
<td class="summary">Set this static's world position.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetRotation">Static:SetRotation(New)</a></td>
<td class="summary">Set this static's rotation.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetScale">Static:SetScale(New)</a></td>
<td class="summary">Set this static's world scale.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetColor">Static:SetColor(color)</a></td>
<td class="summary">Set the static's color</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetHP">Static:SetHP(New)</a></td>
<td class="summary">Set this static's hit points.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:SetSolid">Static:SetSolid(Solid)</a></td>
<td class="summary">Set this static's solid collision state.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:Enable">Static:Enable()</a></td>
<td class="summary">Enable this static.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:Disable">Static:Disable()</a></td>
<td class="summary">Disable this static.</td>
</tr>
<tr>
<td class="name" ><a href="#Static:Shatter">Static:Shatter()</a></td>
<td class="summary">Shatter static mesh</td>
<td class="summary">Shatter this static.</td>
</tr>
</table>
@ -208,30 +205,147 @@
<dl class="function">
<dt>
<a name = "Static:Enable"></a>
<strong>Static:Enable()</strong>
<a name = "Static:GetName"></a>
<strong>Static:GetName()</strong>
</dt>
<dd>
Enable the static, for cases when it was shattered or manually disabled before.
Get this static's unique string identifier.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
Name string.
</ol>
</dd>
<dt>
<a name = "Static:Disable"></a>
<strong>Static:Disable()</strong>
<a name = "Static:GetSlot"></a>
<strong>Static:GetSlot()</strong>
</dt>
<dd>
Disable the static
Get this static's slot ID.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
Slot ID.
</ol>
</dd>
<dt>
<a name = "Static:GetPosition"></a>
<strong>Static:GetPosition()</strong>
</dt>
<dd>
Get this static's world position.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
World position.
</ol>
</dd>
<dt>
<a name = "Static:GetRotation"></a>
<strong>Static:GetRotation()</strong>
</dt>
<dd>
Get this static's world rotation.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Rotation.html#">Rotation</a></span>
World rotation.
</ol>
</dd>
<dt>
<a name = "Static:GetScale"></a>
<strong>Static:GetScale()</strong>
</dt>
<dd>
Get this static's world scale.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">float</span></span>
World scale.
</ol>
</dd>
<dt>
<a name = "Static:GetColor"></a>
<strong>Static:GetColor()</strong>
</dt>
<dd>
Get this static's color.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Color.html#">Color</a></span>
Color.
</ol>
</dd>
<dt>
<a name = "Static:GetHP"></a>
<strong>Static:GetHP()</strong>
</dt>
<dd>
Get this static's hit points. Used only with shatterable statics.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
Hit points.
</ol>
@ -242,7 +356,7 @@
<strong>Static:GetActive()</strong>
</dt>
<dd>
Get static mesh visibility
Get this static's visibility state.
@ -251,7 +365,7 @@
<ol>
<span class="types"><span class="type">bool</span></span>
visibility state
Visibility state.
</ol>
@ -263,7 +377,7 @@
<strong>Static:GetSolid()</strong>
</dt>
<dd>
Get static mesh solid collision state
Get this static's solid collision state.
@ -272,224 +386,7 @@
<ol>
<span class="types"><span class="type">bool</span></span>
solid collision state (true if solid, false if soft)
</ol>
</dd>
<dt>
<a name = "Static:SetSolid"></a>
<strong>Static:SetSolid(solidState)</strong>
</dt>
<dd>
Set static mesh solid collision state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">solidState</span>
<span class="types"><span class="type">bool</span></span>
if set, collision will be solid, if not, will be soft
</li>
</ul>
</dd>
<dt>
<a name = "Static:GetPosition"></a>
<strong>Static:GetPosition()</strong>
</dt>
<dd>
Get the static's position
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
a copy of the static's position
</ol>
</dd>
<dt>
<a name = "Static:SetPosition"></a>
<strong>Static:SetPosition(position)</strong>
</dt>
<dd>
Set the static's position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">position</span>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
the new position of the static
</li>
</ul>
</dd>
<dt>
<a name = "Static:GetRotation"></a>
<strong>Static:GetRotation()</strong>
</dt>
<dd>
Get the static's rotation
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Rotation.html#">Rotation</a></span>
a copy of the static's rotation
</ol>
</dd>
<dt>
<a name = "Static:SetRotation"></a>
<strong>Static:SetRotation(rotation)</strong>
</dt>
<dd>
Set the static's rotation
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rotation</span>
<span class="types"><a class="type" href="../3 primitive classes/Rotation.html#">Rotation</a></span>
the static's new rotation
</li>
</ul>
</dd>
<dt>
<a name = "Static:GetScale"></a>
<strong>Static:GetScale()</strong>
</dt>
<dd>
Get the static's scale
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">float</span></span>
current static scale
</ol>
</dd>
<dt>
<a name = "Static:SetScale"></a>
<strong>Static:SetScale(scale)</strong>
</dt>
<dd>
Set the static's scale
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">Scale</span></span>
the static's new scale
</li>
</ul>
</dd>
<dt>
<a name = "Static:GetHP"></a>
<strong>Static:GetHP()</strong>
</dt>
<dd>
Get current HP (hit points/health points)
Used only with shatterable static meshes.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
the amount of HP the static currently has
</ol>
</dd>
<dt>
<a name = "Static:SetHP"></a>
<strong>Static:SetHP(HP)</strong>
</dt>
<dd>
Set current HP (hit points/health points)
Used only with shatterable static meshes.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">HP</span>
<span class="types"><span class="type">int</span></span>
the amount of HP to give the static
</li>
</ul>
</dd>
<dt>
<a name = "Static:GetName"></a>
<strong>Static:GetName()</strong>
</dt>
<dd>
Get the static's unique string identifier
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
the static's name
Solid collision state. <strong>True: solid</strong>, <strong>False: soft</strong>
</ol>
@ -501,8 +398,7 @@
<strong>Static:SetName(name)</strong>
</dt>
<dd>
Set the static's name (its unique string identifier)
e.g. "my_vase" or "oldrubble"
Set this static's unique identifier string.
@ -510,7 +406,7 @@
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
The static's new name
New name.
</li>
</ul>
@ -518,42 +414,21 @@
</dd>
<dt>
<a name = "Static:GetSlot"></a>
<strong>Static:GetSlot()</strong>
</dt>
<dd>
Get the static's slot number (as listed in Tomb Editor and WadTool)
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
the static's slot number
</ol>
</dd>
<dt>
<a name = "Static:SetSlot"></a>
<strong>Static:SetSlot(slot)</strong>
<strong>Static:SetSlot(New)</strong>
</dt>
<dd>
Set the static's slot number (as listed in Tomb Editor and WadTool)
Set this static's slot ID.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">slot</span>
<li><span class="parameter">New</span>
<span class="types"><span class="type">int</span></span>
The static's slot number
slot ID.
</li>
</ul>
@ -563,21 +438,66 @@
</dd>
<dt>
<a name = "Static:GetColor"></a>
<strong>Static:GetColor()</strong>
<a name = "Static:SetPosition"></a>
<strong>Static:SetPosition(New)</strong>
</dt>
<dd>
Get the static's color
Set this static's world position.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">New</span>
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
world position.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../3 primitive classes/Color.html#">Color</a></span>
a copy of the static's color
</ol>
</dd>
<dt>
<a name = "Static:SetRotation"></a>
<strong>Static:SetRotation(New)</strong>
</dt>
<dd>
Set this static's rotation.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">New</span>
<span class="types"><a class="type" href="../3 primitive classes/Rotation.html#">Rotation</a></span>
rotation.
</li>
</ul>
</dd>
<dt>
<a name = "Static:SetScale"></a>
<strong>Static:SetScale(New)</strong>
</dt>
<dd>
Set this static's world scale.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">New</span>
<span class="types"><span class="type">Scale</span></span>
world scale.
</li>
</ul>
@ -604,13 +524,87 @@
</dd>
<dt>
<a name = "Static:SetHP"></a>
<strong>Static:SetHP(New)</strong>
</dt>
<dd>
Set this static's hit points. Used only with shatterable statics.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">New</span>
<span class="types"><span class="type">int</span></span>
hit points.
</li>
</ul>
</dd>
<dt>
<a name = "Static:SetSolid"></a>
<strong>Static:SetSolid(Solid)</strong>
</dt>
<dd>
Set this static's solid collision state.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">Solid</span>
<span class="types"><span class="type">bool</span></span>
collision state. <strong>True: solid</strong>, <strong>False: soft</strong>
</li>
</ul>
</dd>
<dt>
<a name = "Static:Enable"></a>
<strong>Static:Enable()</strong>
</dt>
<dd>
Enable this static. Used when previously shattered disabled manually.
</dd>
<dt>
<a name = "Static:Disable"></a>
<strong>Static:Disable()</strong>
</dt>
<dd>
Disable this static.
</dd>
<dt>
<a name = "Static:Shatter"></a>
<strong>Static:Shatter()</strong>
</dt>
<dd>
Shatter static mesh
Shatter this static.

View file

@ -153,7 +153,7 @@ local door = GetMoveableByName("door_type4_14")
</tr>
<tr>
<td class="name" ><a href="1 modules/Objects.html">Objects</a></td>
<td class="summary">Moveables, statics, cameras, and so on.</td>
<td class="summary">Objects including moveables, statics, cameras, and others.</td>
</tr>
<tr>
<td class="name" ><a href="1 modules/Sound.html">Sound</a></td>
@ -216,7 +216,7 @@ local door = GetMoveableByName("door_type4_14")
</tr>
<tr>
<td class="name" ><a href="2 classes/Objects.Static.html">Objects.Static</a></td>
<td class="summary">Statics</td>
<td class="summary">Represents a static object in the game world.</td>
</tr>
<tr>
<td class="name" ><a href="2 classes/Objects.Volume.html">Objects.Volume</a></td>

View file

@ -16,7 +16,6 @@ static constexpr char ScriptReserved_Util[] = "Util";
static constexpr char ScriptReserved_Effects[] = "Effects";
// Classes
static constexpr char ScriptReserved_Static[] = "Static";
static constexpr char ScriptReserved_Camera[] = "Camera";
static constexpr char ScriptReserved_Sink[] = "Sink";
static constexpr char ScriptReserved_SoundSource[] = "SoundSource";
@ -401,6 +400,10 @@ static constexpr char ScriptReserved_LogLevelError[] = "ERROR";
// Internal
static constexpr char ScriptReserved_LaraObject[] = "LaraObject";
// =======
// OBJECTS
// =======
// Room
constexpr char ScriptReserved_Room[] = "Room";
@ -415,6 +418,39 @@ constexpr char ScriptReserved_RoomSetFlag[] = "SetFlag";
constexpr char ScriptReserved_RoomSetName[] = "SetName";
constexpr char ScriptReserved_RoomSetReverbType[] = "SetReverbType";
// Static
constexpr char ScriptReserved_Static[] = "Static";
constexpr char ScriptReserved_StaticDisable[] = "Disable";
constexpr char ScriptReserved_StaticEnable[] = "Enable";
constexpr char ScriptReserved_StaticGetActive[] = "GetActive";
constexpr char ScriptReserved_StaticGetColor[] = "GetColor";
constexpr char ScriptReserved_StaticGetHP[] = "GetHP";
constexpr char ScriptReserved_StaticGetName[] = "GetName";
constexpr char ScriptReserved_StaticGetPosition[] = "GetPosition";
constexpr char ScriptReserved_StaticGetRotation[] = "GetRotation";
constexpr char ScriptReserved_StaticGetScale[] = "GetScale";
constexpr char ScriptReserved_StaticGetSlot[] = "GetSlot";
constexpr char ScriptReserved_StaticGetSolid[] = "GetSolid";
constexpr char ScriptReserved_StaticSetColor[] = "SetColor";
constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHP";
constexpr char ScriptReserved_StaticSetName[] = "SetName";
constexpr char ScriptReserved_StaticSetPosition[] = "SetPosition";
constexpr char ScriptReserved_StaticSetRotation[] = "SetRotation";
constexpr char ScriptReserved_StaticSetScale[] = "SetScale";
constexpr char ScriptReserved_StaticSetSlot[] = "SetSlot";
constexpr char ScriptReserved_StaticSetSolid[] = "SetSolid";
constexpr char ScriptReserved_StaticShatter[] = "Shatter";
// =====
// TYPES
// =====
// Rotation
constexpr char ScriptReserved_Rotation[] = "Rotation";
constexpr char ScriptReserved_RotationDirection[] = "Direction";
// Vec2
constexpr char ScriptReserved_Vec2[] = "Vec2";
@ -439,8 +475,3 @@ constexpr char ScriptReserved_Vec3Lerp[] = "Lerp";
constexpr char ScriptReserved_Vec3Normalize[] = "Normalize";
constexpr char ScriptReserved_Vec3Rotate[] = "Rotate";
constexpr char ScriptReserved_Vec3Translate[] = "Translate";
// Rotation object
constexpr char ScriptReserved_Rotation[] = "Rotation";
constexpr char ScriptReserved_RotationDirection[] = "Direction";

View file

@ -1,7 +1,6 @@
#pragma once
#include <optional>
#include <spdlog/fmt/fmt.h>
#include <string>
enum class ErrorMode
{
@ -16,7 +15,8 @@ ErrorMode GetScriptErrorMode();
void ScriptWarn(const std::string& msg);
bool ScriptAssert(bool cond, const std::string& msg, std::optional<ErrorMode> forceMode = std::nullopt);
template <typename ... Ts> bool ScriptAssertF(bool cond, std::string_view str, Ts...args)
template <typename ... Ts>
bool ScriptAssertF(bool cond, std::string_view str, Ts...args)
{
if (!cond)
{
@ -36,7 +36,8 @@ template <typename ... Ts> bool ScriptAssertF(bool cond, std::string_view str, T
return cond;
}
template <typename ... Ts> bool ScriptAssertTerminateF(bool cond, std::string_view str, Ts...args)
template <typename ... Ts>
bool ScriptAssertTerminateF(bool cond, std::string_view str, Ts...args)
{
if (!cond)
{

View file

@ -2,21 +2,20 @@
#include "Scripting/Internal/ScriptAssert.h"
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE& item, sol::object key) \
#define IndexErrorMaker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE& item, sol::object key) \
{ \
std::string err = "Attempted to read missing variable \"" + key.as<std::string>() + "\" from " + LUA_CLASS_NAME; \
ScriptAssert(false, err);\
}
#define newindex_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE& item, sol::object key) \
#define NewIndexErrorMaker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE& item, sol::object key) \
{ \
std::string err = "Attempted to set missing variable \"" + key.as<std::string>() + "\" of " + LUA_CLASS_NAME; \
ScriptAssert(false, err);\
}
// Helper type to allow us to more easily specify "give a value of type X or just give nil" parameters.
// Sol doesn't (at the time of writing) have any mechanisms to do this kind of optional argument without
// drawbacks, or at least no mechanisms that I could find.
// Helper type to allow specification of optional parameters.
// Sol doesn't (at the time of writing) have any mechanisms to do this kind of optional argument without drawbacks.
//
// sol::optional doesn't distinguish between nil values and values of the wrong type
// (so we can't provide the user with an error message to tell them they messed up).

View file

@ -48,7 +48,7 @@ namespace TEN::Scripting
parent.new_usertype<Settings>(ScriptReserved_Settings,
sol::constructors<Settings()>(),
sol::meta_function::new_index, newindex_error_maker(Settings, ScriptReserved_Settings),
sol::meta_function::new_index, NewIndexErrorMaker(Settings, ScriptReserved_Settings),
ScriptReserved_AnimSettings, &Settings::Animations,
ScriptReserved_FlareSettings, &Settings::Flare,
ScriptReserved_CameraSettings, &Settings::Camera,
@ -68,7 +68,7 @@ namespace TEN::Scripting
parent.create().new_usertype<AnimSettings>(
ScriptReserved_AnimSettings, sol::constructors<AnimSettings()>(),
sol::call_constructor, sol::constructors<AnimSettings()>(),
sol::meta_function::new_index, newindex_error_maker(AnimSettings, ScriptReserved_AnimSettings),
sol::meta_function::new_index, NewIndexErrorMaker(AnimSettings, ScriptReserved_AnimSettings),
/// Extended crawl moveset.
// @tfield bool crawlExtended when enabled, player will be able to traverse across one-click steps in crawlspaces.
@ -111,7 +111,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<CameraSettings>(ScriptReserved_CameraSettings, sol::constructors<CameraSettings()>(),
sol::call_constructor, sol::constructors<CameraSettings()>(),
sol::meta_function::new_index, newindex_error_maker(CameraSettings, ScriptReserved_CameraSettings),
sol::meta_function::new_index, NewIndexErrorMaker(CameraSettings, ScriptReserved_CameraSettings),
/// Determines highlight color in binocular mode.
// @tfield Color binocularLightColor color of highlight, when player presses action. Zero color means there will be no highlight.
@ -134,7 +134,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<FlareSettings>(ScriptReserved_FlareSettings, sol::constructors<FlareSettings()>(),
sol::call_constructor, sol::constructors<FlareSettings()>(),
sol::meta_function::new_index, newindex_error_maker(FlareSettings, ScriptReserved_FlareSettings),
sol::meta_function::new_index, NewIndexErrorMaker(FlareSettings, ScriptReserved_FlareSettings),
/// Flare color.
// @tfield Color color flare color. Used for sparks and lensflare coloring as well.
@ -183,7 +183,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<HairSettings>(ScriptReserved_HairSettings, sol::constructors<HairSettings()>(),
sol::call_constructor, sol::constructors<HairSettings()>(),
sol::meta_function::new_index, newindex_error_maker(HairSettings, ScriptReserved_HairSettings),
sol::meta_function::new_index, NewIndexErrorMaker(HairSettings, ScriptReserved_HairSettings),
/// Root mesh to which hair object will attach to.
// @tfield int mesh index of a root mesh to which hair will attach. Root mesh may be different for each hair object.
@ -206,7 +206,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<HudSettings>(ScriptReserved_HudSettings, sol::constructors<HudSettings()>(),
sol::call_constructor, sol::constructors<HudSettings()>(),
sol::meta_function::new_index, newindex_error_maker(HudSettings, ScriptReserved_HudSettings),
sol::meta_function::new_index, NewIndexErrorMaker(HudSettings, ScriptReserved_HudSettings),
/// Toggle in-game status bars visibility.
// @tfield bool statusBars if disabled, all status bars (health, air, stamina) will be hidden.
@ -233,7 +233,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<PhysicsSettings>(ScriptReserved_PhysicsSettings, sol::constructors<PhysicsSettings()>(),
sol::call_constructor, sol::constructors<PhysicsSettings()>(),
sol::meta_function::new_index, newindex_error_maker(PhysicsSettings, ScriptReserved_PhysicsSettings),
sol::meta_function::new_index, NewIndexErrorMaker(PhysicsSettings, ScriptReserved_PhysicsSettings),
/// Global world gravity.
// @tfield float gravity specifies global gravity. Mostly affects Lara and several other objects.
@ -253,7 +253,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<WeaponSettings>(ScriptReserved_WeaponSettings, sol::constructors<WeaponSettings()>(),
sol::call_constructor, sol::constructors<WeaponSettings()>(),
sol::meta_function::new_index, newindex_error_maker(WeaponSettings, ScriptReserved_WeaponSettings),
sol::meta_function::new_index, NewIndexErrorMaker(WeaponSettings, ScriptReserved_WeaponSettings),
/// Shooting accuracy.
// @tfield float accuracy determines accuracy range in angles (smaller angles mean higher accuracy). Applicable only for firearms.
@ -320,7 +320,7 @@ namespace TEN::Scripting
{
parent.create().new_usertype<SystemSettings>(ScriptReserved_SystemSettings, sol::constructors<SystemSettings()>(),
sol::call_constructor, sol::constructors<SystemSettings()>(),
sol::meta_function::new_index, newindex_error_maker(SystemSettings, ScriptReserved_SystemSettings),
sol::meta_function::new_index, NewIndexErrorMaker(SystemSettings, ScriptReserved_SystemSettings),
/// How should the application respond to script errors?
// @tfield Flow.ErrorMode errorMode error mode to use. */

View file

@ -18,7 +18,7 @@ namespace TEN::Scripting
parent.new_usertype<Statistics>(
ScriptReserved_Statistics, sol::constructors<Statistics()>(),
sol::call_constructor, sol::constructors<Statistics()>(),
sol::meta_function::new_index, newindex_error_maker(Statistics, ScriptReserved_Statistics),
sol::meta_function::new_index, NewIndexErrorMaker(Statistics, ScriptReserved_Statistics),
/*** Ammo hits.
@tfield int ammoHits amount of successful enemy hits.

View file

@ -14,8 +14,8 @@ AI object
@pragma nostrip
*/
static auto IndexError = index_error_maker(AIObject, ScriptReserved_AIObject);
static auto NewIndexError = newindex_error_maker(AIObject, ScriptReserved_AIObject);
static auto IndexError = IndexErrorMaker(AIObject, ScriptReserved_AIObject);
static auto NewIndexError = NewIndexErrorMaker(AIObject, ScriptReserved_AIObject);
AIObject::AIObject(AI_OBJECT & ref) : m_aiObject{ref}
{};

View file

@ -16,8 +16,8 @@ Basic cameras that can point at Lara or at a CAMERA_TARGET.
@pragma nostrip
*/
static auto IndexError = index_error_maker(CameraObject, ScriptReserved_Camera);
static auto NewIndexError = newindex_error_maker(CameraObject, ScriptReserved_Camera);
static auto IndexError = IndexErrorMaker(CameraObject, ScriptReserved_Camera);
static auto NewIndexError = NewIndexErrorMaker(CameraObject, ScriptReserved_Camera);
CameraObject::CameraObject(LevelCameraInfo & ref) : m_camera{ref}
{};

View file

@ -31,8 +31,8 @@ using namespace TEN::Math;
// @tenclass Objects.Moveable
// pragma nostrip
static auto IndexError = index_error_maker(Moveable, ScriptReserved_Moveable);
static auto NewIndexError = newindex_error_maker(Moveable, ScriptReserved_Moveable);
static auto IndexError = IndexErrorMaker(Moveable, ScriptReserved_Moveable);
static auto NewIndexError = NewIndexErrorMaker(Moveable, ScriptReserved_Moveable);
/*** Used to generate a new moveable dynamically at runtime.
For more information on each parameter, see the

View file

@ -19,8 +19,8 @@
//namespace TEN::Scripting
//{
static auto IndexError = index_error_maker(Room, ScriptReserved_Volume);
static auto NewIndexError = newindex_error_maker(Room, ScriptReserved_Volume);
static auto IndexError = IndexErrorMaker(Room, ScriptReserved_Volume);
static auto NewIndexError = NewIndexErrorMaker(Room, ScriptReserved_Volume);
Room::Room(ROOM_INFO& room) :
_room(room)

View file

@ -14,8 +14,8 @@ Sink
@pragma nostrip
*/
static auto IndexError = index_error_maker(Sink, ScriptReserved_Sink);
static auto NewIndexError = newindex_error_maker(Sink, ScriptReserved_Sink);
static auto IndexError = IndexErrorMaker(Sink, ScriptReserved_Sink);
static auto NewIndexError = NewIndexErrorMaker(Sink, ScriptReserved_Sink);
Sink::Sink(SinkInfo& ref) : m_sink{ref}
{};

View file

@ -14,8 +14,8 @@ Sound source
@pragma nostrip
*/
static auto IndexError = index_error_maker(SoundSource, ScriptReserved_SoundSource);
static auto NewIndexError = newindex_error_maker(SoundSource, ScriptReserved_SoundSource);
static auto IndexError = IndexErrorMaker(SoundSource, ScriptReserved_SoundSource);
static auto NewIndexError = NewIndexErrorMaker(SoundSource, ScriptReserved_SoundSource);
SoundSource::SoundSource(SoundSourceInfo& ref) : m_soundSource{ref}
{};

View file

@ -1,269 +1,240 @@
#include "framework.h"
#include "Game/effects/debris.h"
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/TEN/Objects/Static/StaticObject.h"
#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
#include "Scripting/Internal/TEN/Types/Color/Color.h"
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
using namespace TEN::Scripting;
/// Represents a static object in the game world.
//
// @tenclass Objects.Static
// @pragma nostrip
/***
Statics
@tenclass Objects.Static
@pragma nostrip
*/
static auto IndexError = index_error_maker(Static, ScriptReserved_Static);
static auto NewIndexError = newindex_error_maker(Static, ScriptReserved_Static);
Static::Static(MESH_INFO & ref) : m_mesh{ref}
{};
void Static::Register(sol::table & parent)
namespace TEN::Scripting
{
parent.new_usertype<Static>(
ScriptReserved_Static, sol::no_constructor, // Ability to spawn new ones could be added later.
sol::meta_function::index, IndexError,
sol::meta_function::new_index, NewIndexError,
static auto IndexError = IndexErrorMaker(Static, ScriptReserved_Static);
static auto NewIndexError = NewIndexErrorMaker(Static, ScriptReserved_Static);
/// Enable the static, for cases when it was shattered or manually disabled before.
// @function Static:Enable
ScriptReserved_Enable, &Static::Enable,
/// Disable the static
// @function Static:Disable
ScriptReserved_Disable, &Static::Disable,
/// Get static mesh visibility
// @function Static:GetActive
// @treturn bool visibility state
ScriptReserved_GetActive, &Static::GetActive,
/// Get static mesh solid collision state
// @function Static:GetSolid
// @treturn bool solid collision state (true if solid, false if soft)
ScriptReserved_GetSolid, &Static::GetSolid,
/// Set static mesh solid collision state
// @function Static:SetSolid
// @tparam bool solidState if set, collision will be solid, if not, will be soft
ScriptReserved_SetSolid, &Static::SetSolid,
/// Get the static's position
// @function Static:GetPosition
// @treturn Vec3 a copy of the static's position
ScriptReserved_GetPosition, &Static::GetPos,
/// Set the static's position
// @function Static:SetPosition
// @tparam Vec3 position the new position of the static
ScriptReserved_SetPosition, &Static::SetPos,
/// Get the static's rotation
// @function Static:GetRotation
// @treturn Rotation a copy of the static's rotation
ScriptReserved_GetRotation, &Static::GetRot,
/// Set the static's rotation
// @function Static:SetRotation
// @tparam Rotation rotation the static's new rotation
ScriptReserved_SetRotation, &Static::SetRot,
/// Get the static's scale
// @function Static:GetScale
// @treturn float current static scale
ScriptReserved_GetScale, &Static::GetScale,
/// Set the static's scale
// @function Static:SetScale
// @tparam Scale scale the static's new scale
ScriptReserved_SetScale, &Static::SetScale,
/// Get current HP (hit points/health points)
// Used only with shatterable static meshes.
// @function Static:GetHP
// @treturn int the amount of HP the static currently has
ScriptReserved_GetHP, &Static::GetHP,
/// Set current HP (hit points/health points)
// Used only with shatterable static meshes.
// @function Static:SetHP
// @tparam int HP the amount of HP to give the static
ScriptReserved_SetHP, &Static::SetHP,
/// Get the static's unique string identifier
// @function Static:GetName
// @treturn string the static's name
ScriptReserved_GetName, &Static::GetName,
/// Set the static's name (its unique string identifier)
// e.g. "my\_vase" or "oldrubble"
// @function Static:SetName
// @tparam string name The static's new name
ScriptReserved_SetName, &Static::SetName,
/// Get the static's slot number (as listed in Tomb Editor and WadTool)
// @function Static:GetSlot
// @treturn string the static's slot number
ScriptReserved_GetSlot, &Static::GetSlot,
/// Set the static's slot number (as listed in Tomb Editor and WadTool)
// @function Static:SetSlot
// @tparam int slot The static's slot number
ScriptReserved_SetSlot, &Static::SetSlot,
/// Get the static's color
// @function Static:GetColor
// @treturn Color a copy of the static's color
ScriptReserved_GetColor, &Static::GetColor,
/// Set the static's color
// @function Static:SetColor
// @tparam Color color the new color of the static
ScriptReserved_SetColor, &Static::SetColor,
/// Shatter static mesh
// @function Static:Shatter
ScriptReserved_Shatter, &Static::Shatter);
}
void Static::Enable()
{
m_mesh.flags |= StaticMeshFlags::SM_VISIBLE;
}
void Static::Disable()
{
m_mesh.flags &= ~StaticMeshFlags::SM_VISIBLE;
}
bool Static::GetActive()
{
return (m_mesh.flags & StaticMeshFlags::SM_VISIBLE) != 0;
}
bool Static::GetSolid()
{
return (m_mesh.flags & StaticMeshFlags::SM_SOLID) != 0;
}
void Static::SetSolid(bool yes)
{
if (yes)
m_mesh.flags |= StaticMeshFlags::SM_SOLID;
else
m_mesh.flags &= ~StaticMeshFlags::SM_SOLID;
}
Vec3 Static::GetPos() const
{
return Vec3(m_mesh.pos.Position.x, m_mesh.pos.Position.y, m_mesh.pos.Position.z);
}
void Static::SetPos(Vec3 const& pos)
{
m_mesh.pos.Position.x = pos.x;
m_mesh.pos.Position.y = pos.y;
m_mesh.pos.Position.z = pos.z;
m_mesh.Dirty = true;
}
float Static::GetScale() const
{
return m_mesh.scale;
}
void Static::SetScale(float const& scale)
{
m_mesh.scale = scale;
m_mesh.Dirty = true;
}
int Static::GetHP() const
{
return m_mesh.HitPoints;
}
void Static::SetHP(short hitPoints)
{
m_mesh.HitPoints = hitPoints;
}
// This does not guarantee that the returned value will be identical
// to a value written in via SetRot - only that the angle measures
// will be mathematically equal
// (e.g. 90 degrees = -270 degrees = 450 degrees)
Rotation Static::GetRot() const
{
return
void Static::Register(sol::table& parent)
{
// Register type.
parent.new_usertype<Static>(
ScriptReserved_Static,
sol::no_constructor, // TODO: Add feature to spawn statics.
sol::meta_function::index, IndexError,
sol::meta_function::new_index, NewIndexError,
ScriptReserved_StaticGetName, &Static::GetName,
ScriptReserved_StaticGetSlot, &Static::GetSlot,
ScriptReserved_StaticGetPosition, &Static::GetPosition,
ScriptReserved_StaticGetRotation, &Static::GetRotation,
ScriptReserved_StaticGetScale, &Static::GetScale, // TODO: Deprecate. Should return Vec3 converted from static.Pose.Scale.
ScriptReserved_StaticGetColor, &Static::GetColor,
ScriptReserved_StaticGetHP, &Static::GetHitPoints, // TODO: Deprecate.
ScriptReserved_StaticGetActive, &Static::GetActiveStatus, // TODO: Deprecate. Rename Lua func to GetActiveStatus.
ScriptReserved_StaticGetSolid, &Static::GetSolidStatus, // TODO: Deprecate. Rename Lua func to GetSolidStatus.
ScriptReserved_StaticSetName, &Static::SetName,
ScriptReserved_StaticSetSlot, &Static::SetSlot,
ScriptReserved_StaticSetPosition, &Static::SetPosition,
ScriptReserved_StaticSetRotation, &Static::SetRotation,
ScriptReserved_StaticSetScale, &Static::SetScale,
ScriptReserved_StaticSetColor, &Static::SetColor,
ScriptReserved_StaticSetHitPoints, &Static::SetHitPoints, // TODO: Deprecate. Rename Lua func to SetHitPoints.
ScriptReserved_StaticSetSolid, &Static::SetSolidStatus, // TODO: Deprecate. Rename Lua func to SetSolidStatus.
ScriptReserved_StaticEnable, &Static::Enable,
ScriptReserved_StaticDisable, &Static::Disable,
ScriptReserved_StaticShatter, &Static::Shatter);
}
Static::Static(MESH_INFO& staticObj) :
_static(staticObj)
{
TO_DEGREES(m_mesh.pos.Orientation.x),
TO_DEGREES(m_mesh.pos.Orientation.y),
TO_DEGREES(m_mesh.pos.Orientation.z)
};
}
void Static::SetRot(Rotation const& rot)
{
m_mesh.pos.Orientation.x = ANGLE(rot.x);
m_mesh.pos.Orientation.y = ANGLE(rot.y);
m_mesh.pos.Orientation.z = ANGLE(rot.z);
m_mesh.Dirty = true;
}
std::string Static::GetName() const
{
return m_mesh.Name;
}
void Static::SetName(std::string const & name)
{
if (!ScriptAssert(!name.empty(), "Name cannot be blank. Not setting name."))
/// Get this static's unique string identifier.
// @function Static:GetName
// @treturn string Name string.
std::string Static::GetName() const
{
return;
return _static.Name;
}
if (_callbackSetName(name, m_mesh))
/// Get this static's slot ID.
// @function Static:GetSlot
// @treturn int Slot ID.
int Static::GetSlot() const
{
// remove the old name if we have one
_callbackRemoveName(m_mesh.Name);
m_mesh.Name = name;
return _static.staticNumber;
}
else
/// Get this static's world position.
// @function Static:GetPosition
// @treturn Vec3 World position.
Vec3 Static::GetPosition() const
{
ScriptAssertF(false, "Could not add name {} - does an object with this name already exist?", name);
TENLog("Name will not be set", LogLevel::Warning, LogConfig::All);
return Vec3(_static.pos.Position);
}
/// Get this static's world rotation.
// @function Static:GetRotation
// @treturn Rotation World rotation.
Rotation Static::GetRotation() const
{
return Rotation(_static.pos.Orientation);
}
/// Get this static's world scale.
// @function Static:GetScale
// @treturn float World scale.
float Static::GetScale() const
{
return _static.scale;
}
/// Get this static's color.
// @function Static:GetColor
// @treturn Color Color.
ScriptColor Static::GetColor() const
{
return ScriptColor(_static.color);
}
/// Get this static's hit points. Used only with shatterable statics.
// @function Static:GetHP
// @treturn int Hit points.
int Static::GetHitPoints() const
{
return _static.HitPoints;
}
/// Get this static's visibility state.
// @function Static:GetActive
// @treturn bool Visibility state.
bool Static::GetActiveStatus()
{
return ((_static.flags & StaticMeshFlags::SM_VISIBLE) != 0);
}
/// Get this static's solid collision state.
// @function Static:GetSolid
// @treturn bool Solid collision state. __True: solid__, __False: soft__
bool Static::GetSolidStatus()
{
return ((_static.flags & StaticMeshFlags::SM_SOLID) != 0);
}
/// Set this static's unique identifier string.
// @function Static:SetName
// @tparam string name New name.
void Static::SetName(const std::string& name)
{
if (!ScriptAssert(!name.empty(), "Name cannot be blank. Not setting name."))
return;
if (_callbackSetName(name, _static))
{
_callbackRemoveName(_static.Name);
_static.Name = name;
}
else
{
ScriptAssertF(false, "Could not add name {} - an object with this name may already exist.", name);
TENLog("Name will not be set.", LogLevel::Warning, LogConfig::All);
}
}
/// Set this static's slot ID.
// @function Static:SetSlot
// @tparam int New slot ID.
void Static::SetSlot(int slotID)
{
_static.staticNumber = slotID;
_static.Dirty = true;
}
/// Set this static's world position.
// @function Static:SetPosition
// @tparam Vec3 New world position.
void Static::SetPosition(const Vec3& pos)
{
_static.pos.Position = pos.ToVector3i();
_static.Dirty = true;
}
/// Set this static's rotation.
// @function Static:SetRotation
// @tparam Rotation New rotation.
void Static::SetRotation(const Rotation& rot)
{
_static.pos.Orientation = rot.ToEulerAngles();
_static.Dirty = true;
}
/// Set this static's world scale.
// @function Static:SetScale
// @tparam Scale New world scale.
void Static::SetScale(float scale)
{
_static.scale = scale;
_static.Dirty = true;
}
/// Set the static's color
// @function Static:SetColor
// @tparam Color color the new color of the static
void Static::SetColor(ScriptColor const& col)
{
_static.color = col;
_static.Dirty = true;
}
/// Set this static's hit points. Used only with shatterable statics.
// @function Static:SetHP
// @tparam int New hit points.
void Static::SetHitPoints(int hitPoints)
{
_static.HitPoints = hitPoints;
}
/// Set this static's solid collision state.
// @function Static:SetSolid
// @tparam bool Solid collision state. __True: solid__, __False: soft__
void Static::SetSolidStatus(bool status)
{
if (status)
{
_static.flags |= StaticMeshFlags::SM_SOLID;
}
else
{
_static.flags &= ~StaticMeshFlags::SM_SOLID;
}
}
/// Enable this static. Used when previously shattered disabled manually.
// @function Static:Enable
void Static::Enable()
{
_static.flags |= StaticMeshFlags::SM_VISIBLE;
}
/// Disable this static.
// @function Static:Disable
void Static::Disable()
{
_static.flags &= ~StaticMeshFlags::SM_VISIBLE;
}
/// Shatter this static.
// @function Static:Shatter
void Static::Shatter()
{
ShatterObject(nullptr, &_static, -128, _static.roomNumber, 0);
}
}
int Static::GetSlot() const
{
return m_mesh.staticNumber;
}
void Static::SetSlot(int slot)
{
m_mesh.staticNumber = slot;
m_mesh.Dirty = true;
}
ScriptColor Static::GetColor() const
{
return ScriptColor{ m_mesh.color };
}
void Static::SetColor(ScriptColor const& col)
{
m_mesh.color = col;
m_mesh.Dirty = true;
}
void Static::Shatter()
{
ShatterObject(nullptr, &m_mesh, -128, m_mesh.roomNumber, 0);
}

View file

@ -3,46 +3,67 @@
#include "Game/room.h"
#include "Scripting/Internal/TEN/Objects/NamedBase.h"
namespace sol { class state; }
class ScriptColor;
class Vec3;
namespace sol { class state; }
namespace TEN::Scripting { class Rotation; }
using namespace TEN::Scripting;
class Static : public NamedBase<Static, MESH_INFO&>
namespace TEN::Scripting
{
public:
using IdentifierType = std::reference_wrapper<MESH_INFO>;
Static(MESH_INFO& id);
~Static() = default;
class Rotation;
Static& operator=(Static const& other) = delete;
Static(Static const& other) = delete;
class Static : public NamedBase<Static, MESH_INFO&>
{
public:
static void Register(sol::table& parent);
static void Register(sol::table & parent);
private:
// Fields
void Enable();
void Disable();
bool GetActive();
bool GetSolid();
void SetSolid(bool yes);
Rotation GetRot() const;
void SetRot(Rotation const& rot);
Vec3 GetPos() const;
void SetPos(Vec3 const& pos);
float GetScale() const;
void SetScale(float const& scale);
int GetHP() const;
void SetHP(short hitPoints);
std::string GetName() const;
void SetName(std::string const& name);
int GetSlot() const;
void SetSlot(int slot);
ScriptColor GetColor() const;
void SetColor(ScriptColor const& col);
void Shatter();
MESH_INFO& _static;
private:
MESH_INFO& m_mesh;
};
public:
// Aliases
using IdentifierType = std::reference_wrapper<MESH_INFO>;
// Constructors, destructors
Static(MESH_INFO& staticObj);
Static(const Static& staticObj) = delete;
~Static() = default;
// Getters
std::string GetName() const;
int GetSlot() const;
Vec3 GetPosition() const;
Rotation GetRotation() const;
float GetScale() const;
ScriptColor GetColor() const;
int GetHitPoints() const;
bool GetActiveStatus();
bool GetSolidStatus();
// Setters
void SetName(const std::string& name);
void SetSlot(int slotID);
void SetPosition(const Vec3& pos);
void SetRotation(const Rotation& rot);
void SetScale(float scale);
void SetColor(const ScriptColor& color);
void SetHitPoints(int hitPoints);
void SetSolidStatus(bool status);
// Utilities
void Enable();
void Disable();
void Shatter();
// Operators
Static& operator =(const Static& staticObj) = delete;
};
}

View file

@ -16,8 +16,8 @@ Activator volume.
@pragma nostrip
*/
static auto IndexError = index_error_maker(Volume, ScriptReserved_Volume);
static auto NewIndexError = newindex_error_maker(Volume, ScriptReserved_Volume);
static auto IndexError = IndexErrorMaker(Volume, ScriptReserved_Volume);
static auto NewIndexError = NewIndexErrorMaker(Volume, ScriptReserved_Volume);
Volume::Volume(TriggerVolume& volume) :
_volume(volume)