mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-12 13:37:01 +03:00
Add GetState/SetState, meshswap/visibility funcs, correctly use SetAnim
This commit is contained in:
parent
953504be44
commit
cbe4fe3ec3
3 changed files with 139 additions and 53 deletions
|
@ -49,11 +49,17 @@ static constexpr char ScriptReserved_GetFrameNumber[] = "GetFrame";
|
||||||
static constexpr char ScriptReserved_SetFrameNumber[] = "SetFrame";
|
static constexpr char ScriptReserved_SetFrameNumber[] = "SetFrame";
|
||||||
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_SetStateNumber[] = "SetState";
|
||||||
static constexpr char ScriptReserved_GetOCB[] = "GetOCB";
|
static constexpr char ScriptReserved_GetOCB[] = "GetOCB";
|
||||||
static constexpr char ScriptReserved_SetOCB[] = "SetOCB";
|
static constexpr char ScriptReserved_SetOCB[] = "SetOCB";
|
||||||
static constexpr char ScriptReserved_GetStatus[] = "GetStatus";
|
static constexpr char ScriptReserved_GetStatus[] = "GetStatus";
|
||||||
static constexpr char ScriptReserved_GetAIBits[] = "GetAIBits";
|
static constexpr char ScriptReserved_GetAIBits[] = "GetAIBits";
|
||||||
static constexpr char ScriptReserved_SetAIBits[] = "SetAIBits";
|
static constexpr char ScriptReserved_SetAIBits[] = "SetAIBits";
|
||||||
|
static constexpr char ScriptReserved_GetMeshVisibility[] = "GetMeshVisibility";
|
||||||
|
static constexpr char ScriptReserved_SetMeshVisibility[] = "SetMeshVisibility";
|
||||||
|
static constexpr char ScriptReserved_GetMeshSwap[] = "GetMeshSwap";
|
||||||
|
static constexpr char ScriptReserved_SetMeshSwap[] = "SetMeshSwap";
|
||||||
static constexpr char ScriptReserved_GetHitStatus[] = "GetHitStatus";
|
static constexpr char ScriptReserved_GetHitStatus[] = "GetHitStatus";
|
||||||
static constexpr char ScriptReserved_GetActive[] = "GetActive";
|
static constexpr char ScriptReserved_GetActive[] = "GetActive";
|
||||||
static constexpr char ScriptReserved_GetRoom[] = "GetRoom";
|
static constexpr char ScriptReserved_GetRoom[] = "GetRoom";
|
||||||
|
|
|
@ -220,15 +220,28 @@ void Moveable::Register(sol::table & parent)
|
||||||
// shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
|
// shiva:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
|
||||||
ScriptReserved_SetObjectID, &Moveable::SetObjectID,
|
ScriptReserved_SetObjectID, &Moveable::SetObjectID,
|
||||||
|
|
||||||
|
/// Retrieve the index of the current animation.
|
||||||
|
// This corresponds to the number shown in the item's state ID field in WadTool.
|
||||||
|
// @function Moveable:GetState
|
||||||
|
// @treturn int the index of the active state
|
||||||
|
ScriptReserved_GetStateNumber, &Moveable::GetStateNumber,
|
||||||
|
|
||||||
|
/// Set the object's state to the one specified by the given index.
|
||||||
|
// Performs no bounds checking. *Ensure the number given is correct, else
|
||||||
|
// object may end up in corrupted animation state.*
|
||||||
|
// @function Moveable:SetState
|
||||||
|
// @tparam int index the index of the desired state
|
||||||
|
ScriptReserved_SetStateNumber, &Moveable::SetStateNumber,
|
||||||
|
|
||||||
/// Retrieve the index of the current animation.
|
/// Retrieve the index of the current animation.
|
||||||
// This corresponds to the number shown in the item's animation list in WadTool.
|
// This corresponds to the number shown in the item's animation list in WadTool.
|
||||||
// @function Moveable:GetAnim
|
// @function Moveable:GetAnim
|
||||||
// @treturn int the index of the active animation
|
// @treturn int the index of the active animation
|
||||||
ScriptReserved_GetAnimNumber, &Moveable::GetAnimNumber,
|
ScriptReserved_GetAnimNumber, &Moveable::GetAnimNumber,
|
||||||
|
|
||||||
/// Set the opject'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
|
||||||
// the program is likely to crash with an unhelpful error message.*
|
// 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
|
||||||
ScriptReserved_SetAnimNumber, &Moveable::SetAnimNumber,
|
ScriptReserved_SetAnimNumber, &Moveable::SetAnimNumber,
|
||||||
|
@ -293,6 +306,36 @@ void Moveable::Register(sol::table & parent)
|
||||||
// sas:SetAIBits({1, 0, 0, 0, 0, 0})
|
// sas:SetAIBits({1, 0, 0, 0, 0, 0})
|
||||||
ScriptReserved_SetAIBits, &Moveable::SetAIBits,
|
ScriptReserved_SetAIBits, &Moveable::SetAIBits,
|
||||||
|
|
||||||
|
/// Get state of specified mesh visibility of object
|
||||||
|
// Returns true if specified mesh is visible on an object, and false
|
||||||
|
// if it is not visible.
|
||||||
|
// @function Moveable:GetMeshVisibility
|
||||||
|
// @tparam int index of a mesh
|
||||||
|
// @treturn bool visibility status
|
||||||
|
ScriptReserved_GetMeshVisibility, &Moveable::GetMeshVisibility,
|
||||||
|
|
||||||
|
/// Set state of specified mesh visibility of object
|
||||||
|
// Use this to show or hide specified mesh of an object.
|
||||||
|
// @function Moveable:SetMeshVisibility
|
||||||
|
// @tparam int index of a mesh
|
||||||
|
// @tparam bool status, visible or invisible
|
||||||
|
ScriptReserved_SetMeshVisibility, &Moveable::SetMeshVisibility,
|
||||||
|
|
||||||
|
/// Get state of specified mesh swap of object
|
||||||
|
// Returns true if specified mesh is swapped on an object, and false
|
||||||
|
// if it is not swapped.
|
||||||
|
// @function Moveable:GetMeshSwap
|
||||||
|
// @tparam int index of a mesh
|
||||||
|
// @treturn bool mesh swap status
|
||||||
|
ScriptReserved_GetMeshSwap, &Moveable::GetMeshSwap,
|
||||||
|
|
||||||
|
/// Set state of specified mesh swap of object
|
||||||
|
// Use this to swap specified mesh of an object.
|
||||||
|
// @function Moveable:SetMeshSwap
|
||||||
|
// @tparam int index of a mesh
|
||||||
|
// @tparam bool status, swapped or not
|
||||||
|
ScriptReserved_SetMeshSwap, &Moveable::SetMeshSwap,
|
||||||
|
|
||||||
/// Get the hit status of the object
|
/// Get the hit status of the object
|
||||||
// @function Moveable:GetHitStatus
|
// @function Moveable:GetHitStatus
|
||||||
// @treturn bool true if the moveable was hit by something in the last gameplay frame, false otherwise
|
// @treturn bool true if the moveable was hit by something in the last gameplay frame, false otherwise
|
||||||
|
@ -576,6 +619,16 @@ void Moveable::SetAIBits(aiBitsType const & bits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Moveable::GetStateNumber() const
|
||||||
|
{
|
||||||
|
return m_item->Animation.ActiveState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moveable::SetStateNumber(int stateNumber)
|
||||||
|
{
|
||||||
|
m_item->Animation.TargetState = stateNumber;
|
||||||
|
}
|
||||||
|
|
||||||
int Moveable::GetAnimNumber() const
|
int Moveable::GetAnimNumber() const
|
||||||
{
|
{
|
||||||
return m_item->Animation.AnimNumber - Objects[m_item->ObjectNumber].animIndex;
|
return m_item->Animation.AnimNumber - Objects[m_item->ObjectNumber].animIndex;
|
||||||
|
@ -583,8 +636,7 @@ int Moveable::GetAnimNumber() const
|
||||||
|
|
||||||
void Moveable::SetAnimNumber(int animNumber)
|
void Moveable::SetAnimNumber(int animNumber)
|
||||||
{
|
{
|
||||||
//TODO fixme: we need bounds checking with an error message once it's in the level file format
|
SetAnimation(m_item, animNumber);
|
||||||
m_item->Animation.AnimNumber = animNumber + Objects[m_item->ObjectNumber].animIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Moveable::GetFrameNumber() const
|
int Moveable::GetFrameNumber() const
|
||||||
|
@ -592,7 +644,6 @@ int Moveable::GetFrameNumber() const
|
||||||
return m_item->Animation.FrameNumber - g_Level.Anims[m_item->Animation.AnimNumber].frameBase;
|
return m_item->Animation.FrameNumber - g_Level.Anims[m_item->Animation.AnimNumber].frameBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Moveable::SetFrameNumber(int frameNumber)
|
void Moveable::SetFrameNumber(int frameNumber)
|
||||||
{
|
{
|
||||||
auto const fBase = g_Level.Anims[m_item->Animation.AnimNumber].frameBase;
|
auto const fBase = g_Level.Anims[m_item->Animation.AnimNumber].frameBase;
|
||||||
|
@ -651,6 +702,32 @@ short Moveable::GetStatus() const
|
||||||
return m_item->Status;
|
return m_item->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Moveable::GetMeshVisibility(int meshId) const
|
||||||
|
{
|
||||||
|
return m_item->TestBits(JointBitType::Mesh, meshId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moveable::SetMeshVisibility(int meshId, bool visible)
|
||||||
|
{
|
||||||
|
if (visible)
|
||||||
|
m_item->SetBits(JointBitType::Mesh, meshId);
|
||||||
|
else
|
||||||
|
m_item->ClearBits(JointBitType::Mesh, meshId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Moveable::GetMeshSwap(int meshId) const
|
||||||
|
{
|
||||||
|
return m_item->TestBits(JointBitType::MeshSwap, meshId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moveable::SetMeshSwap(int meshId, bool swapped)
|
||||||
|
{
|
||||||
|
if (swapped)
|
||||||
|
m_item->SetBits(JointBitType::MeshSwap, meshId);
|
||||||
|
else
|
||||||
|
m_item->ClearBits(JointBitType::MeshSwap, meshId);
|
||||||
|
}
|
||||||
|
|
||||||
void Moveable::EnableItem()
|
void Moveable::EnableItem()
|
||||||
{
|
{
|
||||||
if (!m_item->Active)
|
if (!m_item->Active)
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
[[nodiscard]] Rotation GetRot() const;
|
[[nodiscard]] Rotation GetRot() const;
|
||||||
void SetRot(Rotation const& rot);
|
void SetRot(Rotation const& rot);
|
||||||
|
|
||||||
|
[[nodiscard]] int GetStateNumber() const;
|
||||||
|
void SetStateNumber(int stateNumber);
|
||||||
|
|
||||||
[[nodiscard]] int GetAnimNumber() const;
|
[[nodiscard]] int GetAnimNumber() const;
|
||||||
void SetAnimNumber(int animNumber);
|
void SetAnimNumber(int animNumber);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue