mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Expose different animation slots to scripting API
This commit is contained in:
parent
d75bba698f
commit
0ae3888456
5 changed files with 57 additions and 8 deletions
|
@ -58,6 +58,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
|
||||||
* Added optional cast shadow and name parameters for Effects.EmitLight() function.
|
* Added optional cast shadow and name parameters for Effects.EmitLight() function.
|
||||||
* Added Effects.GetWind() function to get current wind speed vector.
|
* Added Effects.GetWind() function to get current wind speed vector.
|
||||||
* Added Moveable:GetCollidable() and Moveable:SetCollidable() functions.
|
* Added Moveable:GetCollidable() and Moveable:SetCollidable() functions.
|
||||||
|
* Added Moveable:GetAnimSlot() and optional second argument for Moveable:SetAnim() to access different animation slots.
|
||||||
* Added Rotation:Direction() method to get directional vector.
|
* Added Rotation:Direction() method to get directional vector.
|
||||||
* Added support for transparency value in Strings.DisplayString class.
|
* Added support for transparency value in Strings.DisplayString class.
|
||||||
* Added extra argument for Sound.SetAmbientTrack() function to specify if new ambient track should play from the beginning.
|
* Added extra argument for Sound.SetAmbientTrack() function to specify if new ambient track should play from the beginning.
|
||||||
|
@ -69,6 +70,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
|
||||||
* Fixed Strings.DisplayString class not supporting some Unicode characters and empty lines in multiline strings.
|
* Fixed Strings.DisplayString class not supporting some Unicode characters and empty lines in multiline strings.
|
||||||
* Fixed Strings.DisplayString not being deallocated after showing.
|
* Fixed Strings.DisplayString not being deallocated after showing.
|
||||||
* Fixed GameVars not transferring between levels in hub mode.
|
* Fixed GameVars not transferring between levels in hub mode.
|
||||||
|
* Fixed incorrect return value of Moveable:GetAnim() function, if animation from another slot is currently playing.
|
||||||
* Fixed incorrect behaviour of Moveable:GetJointRotation() function.
|
* Fixed incorrect behaviour of Moveable:GetJointRotation() function.
|
||||||
* Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions.
|
* Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions.
|
||||||
* Fixed Util.HasLineOfSight() not taking static meshes into consideration.
|
* Fixed Util.HasLineOfSight() not taking static meshes into consideration.
|
||||||
|
|
|
@ -171,7 +171,11 @@ pickups, and Lara herself (see also <a href="../2 classes/Objects.LaraObject.htm
|
||||||
<td class="summary">Retrieve the index of the current animation.</td>
|
<td class="summary">Retrieve the index of the current animation.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" ><a href="#Moveable:SetAnim">Moveable:SetAnim(index)</a></td>
|
<td class="name" ><a href="#Moveable:GetAnimSlot">Moveable:GetAnimSlot()</a></td>
|
||||||
|
<td class="summary">Retrieve the slot ID of the animation.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" ><a href="#Moveable:SetAnim">Moveable:SetAnim(index[, slot])</a></td>
|
||||||
<td class="summary">Set the object's animation to the one specified by the given index.</td>
|
<td class="summary">Set the object's animation to the one specified by the given index.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -774,10 +778,33 @@ shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Moveable:GetAnimSlot"></a>
|
||||||
|
<strong>Moveable:GetAnimSlot()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Retrieve the slot ID of the animation.
|
||||||
|
In certain cases, moveable may play animations from another object slot. Use this
|
||||||
|
function when you need to identify such cases.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">int</span></span>
|
||||||
|
animation slot ID
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
<a name = "Moveable:SetAnim"></a>
|
<a name = "Moveable:SetAnim"></a>
|
||||||
<strong>Moveable:SetAnim(index)</strong>
|
<strong>Moveable:SetAnim(index[, slot])</strong>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Set the object's animation to the one specified by the given index.
|
Set the object's animation to the one specified by the given index.
|
||||||
|
@ -792,6 +819,11 @@ shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)</pre>
|
||||||
<span class="types"><span class="type">int</span></span>
|
<span class="types"><span class="type">int</span></span>
|
||||||
the index of the desired anim
|
the index of the desired anim
|
||||||
</li>
|
</li>
|
||||||
|
<li><span class="parameter">slot</span>
|
||||||
|
<span class="types"><span class="type">int</span></span>
|
||||||
|
slot ID of the desired anim (if omitted, moveable's own slot ID is used)
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ static constexpr char ScriptReserved_SetVelocity[] = "SetVelocity";
|
||||||
static constexpr char ScriptReserved_GetFrameNumber[] = "GetFrame";
|
static constexpr char ScriptReserved_GetFrameNumber[] = "GetFrame";
|
||||||
static constexpr char ScriptReserved_GetEndFrame[] = "GetEndFrame";
|
static constexpr char ScriptReserved_GetEndFrame[] = "GetEndFrame";
|
||||||
static constexpr char ScriptReserved_SetFrameNumber[] = "SetFrame";
|
static constexpr char ScriptReserved_SetFrameNumber[] = "SetFrame";
|
||||||
|
static constexpr char ScriptReserved_GetAnimSlot[] = "GetAnimSlot";
|
||||||
static constexpr char ScriptReserved_GetAnimNumber[] = "GetAnim";
|
static constexpr char ScriptReserved_GetAnimNumber[] = "GetAnim";
|
||||||
static constexpr char ScriptReserved_SetAnimNumber[] = "SetAnim";
|
static constexpr char ScriptReserved_SetAnimNumber[] = "SetAnim";
|
||||||
static constexpr char ScriptReserved_GetStateNumber[] = "GetState";
|
static constexpr char ScriptReserved_GetStateNumber[] = "GetState";
|
||||||
|
|
|
@ -130,7 +130,7 @@ static std::unique_ptr<Moveable> Create(
|
||||||
|
|
||||||
if (std::holds_alternative<int>(animNumber))
|
if (std::holds_alternative<int>(animNumber))
|
||||||
{
|
{
|
||||||
ptr->SetAnimNumber(std::get<int>(animNumber));
|
ptr->SetAnimNumber(std::get<int>(animNumber), objID);
|
||||||
ptr->SetFrameNumber(USE_IF_HAVE(int, frameNumber, 0));
|
ptr->SetFrameNumber(USE_IF_HAVE(int, frameNumber, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,11 +245,19 @@ void Moveable::Register(sol::state& state, sol::table& parent)
|
||||||
// @treturn int the index of the active animation
|
// @treturn int the index of the active animation
|
||||||
ScriptReserved_GetAnimNumber, &Moveable::GetAnimNumber,
|
ScriptReserved_GetAnimNumber, &Moveable::GetAnimNumber,
|
||||||
|
|
||||||
|
/// Retrieve the slot ID of the animation.
|
||||||
|
// In certain cases, moveable may play animations from another object slot. Use this
|
||||||
|
// function when you need to identify such cases.
|
||||||
|
// @function Moveable:GetAnimSlot
|
||||||
|
// @treturn int animation slot ID
|
||||||
|
ScriptReserved_GetAnimSlot, &Moveable::GetAnimSlot,
|
||||||
|
|
||||||
/// Set the object's animation to the one specified by the given index.
|
/// Set the object's animation to the one specified by the given index.
|
||||||
// Performs no bounds checking. *Ensure the number given is correct, else
|
// Performs no bounds checking. *Ensure the number given is correct, else
|
||||||
// object may end up in corrupted animation state.*
|
// object may end up in corrupted animation state.*
|
||||||
// @function Moveable:SetAnim
|
// @function Moveable:SetAnim
|
||||||
// @tparam int index the index of the desired anim
|
// @tparam int index the index of the desired anim
|
||||||
|
// @tparam[opt] int slot slot ID of the desired anim (if omitted, moveable's own slot ID is used)
|
||||||
ScriptReserved_SetAnimNumber, &Moveable::SetAnimNumber,
|
ScriptReserved_SetAnimNumber, &Moveable::SetAnimNumber,
|
||||||
|
|
||||||
/// Retrieve frame number.
|
/// Retrieve frame number.
|
||||||
|
@ -878,14 +886,19 @@ void Moveable::SetStateNumber(int stateNumber)
|
||||||
m_item->Animation.TargetState = stateNumber;
|
m_item->Animation.TargetState = stateNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Moveable::GetAnimNumber() const
|
int Moveable::GetAnimSlot() const
|
||||||
{
|
{
|
||||||
return m_item->Animation.AnimNumber - Objects[m_item->ObjectNumber].animIndex;
|
return m_item->Animation.AnimObjectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Moveable::SetAnimNumber(int animNumber)
|
int Moveable::GetAnimNumber() const
|
||||||
{
|
{
|
||||||
SetAnimation(m_item, animNumber);
|
return m_item->Animation.AnimNumber - Objects[m_item->Animation.AnimObjectID].animIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moveable::SetAnimNumber(int animNumber, sol::optional<int> slotIndex)
|
||||||
|
{
|
||||||
|
SetAnimation(*m_item, (GAME_OBJECT_ID)slotIndex.value_or(m_item->ObjectNumber), animNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Moveable::GetFrameNumber() const
|
int Moveable::GetFrameNumber() const
|
||||||
|
|
|
@ -62,7 +62,8 @@ public:
|
||||||
void SetStateNumber(int stateNumber);
|
void SetStateNumber(int stateNumber);
|
||||||
|
|
||||||
[[nodiscard]] int GetAnimNumber() const;
|
[[nodiscard]] int GetAnimNumber() const;
|
||||||
void SetAnimNumber(int animNumber);
|
[[nodiscard]] int GetAnimSlot() const;
|
||||||
|
void SetAnimNumber(int animNumber, sol::optional<int> slotIndex);
|
||||||
|
|
||||||
[[nodiscard]] int GetFrameNumber() const;
|
[[nodiscard]] int GetFrameNumber() const;
|
||||||
[[nodiscard]] int GetEndFrame() const;
|
[[nodiscard]] int GetEndFrame() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue