mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Start restructuring script Moveable class
This commit is contained in:
parent
98b01ff64a
commit
d8c646fabd
19 changed files with 1632 additions and 1733 deletions
File diff suppressed because it is too large
Load diff
|
@ -136,13 +136,13 @@
|
||||||
|
|
||||||
<p>Table of Objects.MoveableStatus constants. </p>
|
<p>Table of Objects.MoveableStatus constants. </p>
|
||||||
|
|
||||||
<p>To be used with <a href="../2 classes/Objects.Moveable.html#Moveable:GetStatus">Objects.Moveable.GetStatus</a> and <a href="../2 classes/Objects.Moveable.html#Moveable:SetStatus">Objects.Moveable.SetStatus</a> functions.</p>
|
<p> To be used with <a href="../2 classes/Objects.Moveable.html#Moveable:GetStatus">Objects.Moveable.GetStatus</a> and <a href="../2 classes/Objects.Moveable.html#Moveable:SetStatus">Objects.Moveable.SetStatus</a> functions.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>INACTIVE</code> - object was never activated.</li>
|
<li><code>INACTIVE</code> - moveable is inactive (was never activated).</li>
|
||||||
<li><code>ACTIVE</code> - object is active.</li>
|
<li><code>ACTIVE</code> - moveable is active.</li>
|
||||||
<li><code>DEACTIVATED</code> - object was active before and was deactivated.</li>
|
<li><code>DEACTIVATED</code> - moveable is deactivated (was previously active and later deactivated).</li>
|
||||||
<li><code>INVISIBLE</code> - object is invisible.</li>
|
<li><code>INVISIBLE</code> - moveable is invisible.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ local door = GetMoveableByName("door_type4_14")
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" ><a href="2 classes/Objects.Moveable.html">Objects.Moveable</a></td>
|
<td class="name" ><a href="2 classes/Objects.Moveable.html">Objects.Moveable</a></td>
|
||||||
<td class="summary">Represents a mopveable object in the game world.</td>
|
<td class="summary">Represents a moveable object in the game world.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" ><a href="2 classes/Objects.Room.html">Objects.Room</a></td>
|
<td class="name" ><a href="2 classes/Objects.Room.html">Objects.Room</a></td>
|
||||||
|
|
|
@ -9,6 +9,7 @@ struct AI_OBJECT;
|
||||||
struct ROOM_INFO;
|
struct ROOM_INFO;
|
||||||
|
|
||||||
using VarMapVal = std::variant<
|
using VarMapVal = std::variant<
|
||||||
|
int,
|
||||||
short,
|
short,
|
||||||
std::reference_wrapper<MESH_INFO>,
|
std::reference_wrapper<MESH_INFO>,
|
||||||
std::reference_wrapper<LevelCameraInfo>,
|
std::reference_wrapper<LevelCameraInfo>,
|
||||||
|
|
|
@ -323,7 +323,7 @@ Possible event type values:
|
||||||
*/
|
*/
|
||||||
void LogicHandler::HandleEvent(const std::string& name, EventType type, sol::optional<Moveable&> activator)
|
void LogicHandler::HandleEvent(const std::string& name, EventType type, sol::optional<Moveable&> activator)
|
||||||
{
|
{
|
||||||
TEN::Control::Volumes::HandleEvent(name, type, activator.has_value() ? (Activator)activator.value().GetIndex() : (Activator)short(LaraItem->Index));
|
TEN::Control::Volumes::HandleEvent(name, type, activator.has_value() ? (Activator)(short)activator->GetIndex() : (Activator)(short)LaraItem->Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Attempt to find an event set and enable specified event in it.
|
/*** Attempt to find an event set and enable specified event in it.
|
||||||
|
|
|
@ -132,17 +132,15 @@ std::string AIObject::GetName() const
|
||||||
return m_aiObject.Name;
|
return m_aiObject.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIObject::SetName(std::string const & id)
|
void AIObject::SetName(const std::string& id)
|
||||||
{
|
{
|
||||||
if (!ScriptAssert(!id.empty(), "Name cannot be blank. Not setting name."))
|
if (!ScriptAssert(!id.empty(), "Name cannot be blank. Not setting name."))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (s_callbackSetName(id, m_aiObject))
|
if (_callbackSetName(id, m_aiObject))
|
||||||
{
|
{
|
||||||
// remove the old name if we have one
|
// Remove old name if it exists.
|
||||||
s_callbackRemoveName(m_aiObject.Name);
|
_callbackRemoveName(m_aiObject.Name);
|
||||||
m_aiObject.Name = id;
|
m_aiObject.Name = id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
void SetRoomNumber(short Room);
|
void SetRoomNumber(short Room);
|
||||||
|
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
void SetName(std::string const &);
|
void SetName(const std::string&);
|
||||||
|
|
||||||
GAME_OBJECT_ID GetObjectID() const;
|
GAME_OBJECT_ID GetObjectID() const;
|
||||||
void SetObjectID(GAME_OBJECT_ID);
|
void SetObjectID(GAME_OBJECT_ID);
|
||||||
|
|
|
@ -90,14 +90,12 @@ std::string CameraObject::GetName() const
|
||||||
void CameraObject::SetName(std::string const & id)
|
void CameraObject::SetName(std::string const & id)
|
||||||
{
|
{
|
||||||
if (!ScriptAssert(!id.empty(), "Name cannot be blank. Not setting name."))
|
if (!ScriptAssert(!id.empty(), "Name cannot be blank. Not setting name."))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (s_callbackSetName(id, m_camera))
|
if (_callbackSetName(id, m_camera))
|
||||||
{
|
{
|
||||||
// remove the old name if we have one
|
// Remove old name if it exists.
|
||||||
s_callbackRemoveName(m_camera.Name);
|
_callbackRemoveName(m_camera.Name);
|
||||||
m_camera.Name = id;
|
m_camera.Name = id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -32,7 +32,7 @@ using namespace TEN::Entities::Generic;
|
||||||
// Lara:SetPoison(10)
|
// Lara:SetPoison(10)
|
||||||
void LaraObject::SetPoison(sol::optional<int> potency)
|
void LaraObject::SetPoison(sol::optional<int> potency)
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (potency.has_value())
|
if (potency.has_value())
|
||||||
lara->Status.Poison = std::clamp(potency.value(), 0, (int)LARA_POISON_MAX);
|
lara->Status.Poison = std::clamp(potency.value(), 0, (int)LARA_POISON_MAX);
|
||||||
|
@ -47,7 +47,7 @@ void LaraObject::SetPoison(sol::optional<int> potency)
|
||||||
// local poisonPotency = Lara:GetPoison()
|
// local poisonPotency = Lara:GetPoison()
|
||||||
int LaraObject::GetPoison() const
|
int LaraObject::GetPoison() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return lara->Status.Poison;
|
return lara->Status.Poison;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ int LaraObject::GetPoison() const
|
||||||
// Lara:SetAir(100)
|
// Lara:SetAir(100)
|
||||||
void LaraObject::SetAir(sol::optional<int> air)
|
void LaraObject::SetAir(sol::optional<int> air)
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (air.has_value())
|
if (air.has_value())
|
||||||
lara->Status.Air = std::clamp(air.value(), 0, (int)LARA_AIR_MAX);
|
lara->Status.Air = std::clamp(air.value(), 0, (int)LARA_AIR_MAX);
|
||||||
|
@ -73,7 +73,7 @@ void LaraObject::SetAir(sol::optional<int> air)
|
||||||
// local currentAir = Lara:GetAir()
|
// local currentAir = Lara:GetAir()
|
||||||
int LaraObject::GetAir() const
|
int LaraObject::GetAir() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return lara->Status.Air;
|
return lara->Status.Air;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int LaraObject::GetAir() const
|
||||||
// Lara:SetWet(100)
|
// Lara:SetWet(100)
|
||||||
void LaraObject::SetWet(sol::optional<int> wetness)
|
void LaraObject::SetWet(sol::optional<int> wetness)
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
float value = wetness.has_value() ? (float)wetness.value() : PLAYER_DRIP_NODE_MAX;
|
float value = wetness.has_value() ? (float)wetness.value() : PLAYER_DRIP_NODE_MAX;
|
||||||
for (float& i : lara->Effect.DripNodes)
|
for (float& i : lara->Effect.DripNodes)
|
||||||
|
@ -98,7 +98,7 @@ void LaraObject::SetWet(sol::optional<int> wetness)
|
||||||
// local dripAmount = Lara:GetWet()
|
// local dripAmount = Lara:GetWet()
|
||||||
int LaraObject::GetWet() const
|
int LaraObject::GetWet() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return lara->Effect.DripNodes[0];
|
return lara->Effect.DripNodes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ int LaraObject::GetWet() const
|
||||||
// Lara:SetStamina(120)
|
// Lara:SetStamina(120)
|
||||||
void LaraObject::SetStamina(sol::optional<int> value)
|
void LaraObject::SetStamina(sol::optional<int> value)
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (value.has_value())
|
if (value.has_value())
|
||||||
lara->Status.Stamina = std::clamp(value.value(), 0, (int)LARA_STAMINA_MAX);
|
lara->Status.Stamina = std::clamp(value.value(), 0, (int)LARA_STAMINA_MAX);
|
||||||
|
@ -124,7 +124,7 @@ void LaraObject::SetStamina(sol::optional<int> value)
|
||||||
// local sprintEnergy = Lara:GetStamina()
|
// local sprintEnergy = Lara:GetStamina()
|
||||||
int LaraObject::GetStamina() const
|
int LaraObject::GetStamina() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return lara->Status.Stamina;
|
return lara->Status.Stamina;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ int LaraObject::GetStamina() const
|
||||||
// @treturn (bool) true if Lara state must react to aerial forces.
|
// @treturn (bool) true if Lara state must react to aerial forces.
|
||||||
bool LaraObject::GetAirborne() const
|
bool LaraObject::GetAirborne() const
|
||||||
{
|
{
|
||||||
return m_item->Animation.IsAirborne;
|
return _moveable->Animation.IsAirborne;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the moveable's airborne status
|
/// Set the moveable's airborne status
|
||||||
|
@ -141,7 +141,7 @@ bool LaraObject::GetAirborne() const
|
||||||
// @tparam (bool) New airborn status for Lara.
|
// @tparam (bool) New airborn status for Lara.
|
||||||
void LaraObject::SetAirborne(bool newAirborne)
|
void LaraObject::SetAirborne(bool newAirborne)
|
||||||
{
|
{
|
||||||
m_item->Animation.IsAirborne = newAirborne;
|
_moveable->Animation.IsAirborne = newAirborne;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lara will undraw her weapon if it is drawn and throw away a flare if she is currently holding one.
|
/// Lara will undraw her weapon if it is drawn and throw away a flare if she is currently holding one.
|
||||||
|
@ -150,7 +150,7 @@ void LaraObject::SetAirborne(bool newAirborne)
|
||||||
// Lara:UndrawWeapon()
|
// Lara:UndrawWeapon()
|
||||||
void LaraObject::UndrawWeapon()
|
void LaraObject::UndrawWeapon()
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (lara->Control.HandStatus != HandStatus::Free ||
|
if (lara->Control.HandStatus != HandStatus::Free ||
|
||||||
lara->Control.Weapon.GunType == LaraWeaponType::Flare)
|
lara->Control.Weapon.GunType == LaraWeaponType::Flare)
|
||||||
|
@ -165,7 +165,7 @@ void LaraObject::UndrawWeapon()
|
||||||
// Lara:ThrowAwayTorch()
|
// Lara:ThrowAwayTorch()
|
||||||
void LaraObject::ThrowAwayTorch()
|
void LaraObject::ThrowAwayTorch()
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (lara->Control.Weapon.GunType == LaraWeaponType::Torch)
|
if (lara->Control.Weapon.GunType == LaraWeaponType::Torch)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +182,7 @@ void LaraObject::ThrowAwayTorch()
|
||||||
// @treturn int hand status 0=HandsFree, 1=Busy(climbing,etc), 2=WeaponDraw, 3=WeaponUndraw, 4=WeaponInHand.
|
// @treturn int hand status 0=HandsFree, 1=Busy(climbing,etc), 2=WeaponDraw, 3=WeaponUndraw, 4=WeaponInHand.
|
||||||
HandStatus LaraObject::GetHandStatus() const
|
HandStatus LaraObject::GetHandStatus() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return HandStatus{ lara->Control.HandStatus };
|
return HandStatus{ lara->Control.HandStatus };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ HandStatus LaraObject::GetHandStatus() const
|
||||||
// @treturn Flow.WeaponType current weapon type.
|
// @treturn Flow.WeaponType current weapon type.
|
||||||
LaraWeaponType LaraObject::GetWeaponType() const
|
LaraWeaponType LaraObject::GetWeaponType() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return LaraWeaponType{ lara->Control.Weapon.GunType };
|
return LaraWeaponType{ lara->Control.Weapon.GunType };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ LaraWeaponType LaraObject::GetWeaponType() const
|
||||||
// @tparam bool activate if `true`, also draw the weapons or set torch lit. If `false`, keep weapons holstered or leave torch unlit.
|
// @tparam bool activate if `true`, also draw the weapons or set torch lit. If `false`, keep weapons holstered or leave torch unlit.
|
||||||
void LaraObject::SetWeaponType(LaraWeaponType weaponType, bool activate)
|
void LaraObject::SetWeaponType(LaraWeaponType weaponType, bool activate)
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
switch (weaponType)
|
switch (weaponType)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ void LaraObject::SetWeaponType(LaraWeaponType weaponType, bool activate)
|
||||||
// local CurrentAmmoType = Lara:GetAmmoType()
|
// local CurrentAmmoType = Lara:GetAmmoType()
|
||||||
int LaraObject::GetAmmoType() const
|
int LaraObject::GetAmmoType() const
|
||||||
{
|
{
|
||||||
const auto& player = GetLaraInfo(*m_item);
|
const auto& player = GetLaraInfo(*_moveable);
|
||||||
|
|
||||||
auto ammoType = std::optional<PlayerAmmoType>(std::nullopt);
|
auto ammoType = std::optional<PlayerAmmoType>(std::nullopt);
|
||||||
switch (player.Control.Weapon.GunType)
|
switch (player.Control.Weapon.GunType)
|
||||||
|
@ -328,7 +328,7 @@ int LaraObject::GetAmmoType() const
|
||||||
// local equippedWeaponAmmoLeft = Lara:GetAmmoCount()
|
// local equippedWeaponAmmoLeft = Lara:GetAmmoCount()
|
||||||
int LaraObject::GetAmmoCount() const
|
int LaraObject::GetAmmoCount() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
auto& ammo = GetAmmo(Lara, Lara.Control.Weapon.GunType);
|
auto& ammo = GetAmmo(Lara, Lara.Control.Weapon.GunType);
|
||||||
return (ammo.HasInfinite()) ? -1 : (int)ammo.GetCount();
|
return (ammo.HasInfinite()) ? -1 : (int)ammo.GetCount();
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ int LaraObject::GetAmmoCount() const
|
||||||
// local vehicle = Lara:GetVehicle()
|
// local vehicle = Lara:GetVehicle()
|
||||||
std::unique_ptr<Moveable> LaraObject::GetVehicle() const
|
std::unique_ptr<Moveable> LaraObject::GetVehicle() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
|
|
||||||
if (lara->Context.Vehicle == NO_VALUE)
|
if (lara->Context.Vehicle == NO_VALUE)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -355,7 +355,7 @@ std::unique_ptr<Moveable> LaraObject::GetVehicle() const
|
||||||
// local target = Lara:GetTarget()
|
// local target = Lara:GetTarget()
|
||||||
std::unique_ptr<Moveable> LaraObject::GetTarget() const
|
std::unique_ptr<Moveable> LaraObject::GetTarget() const
|
||||||
{
|
{
|
||||||
const auto& player = GetLaraInfo(*m_item);
|
const auto& player = GetLaraInfo(*_moveable);
|
||||||
|
|
||||||
if (player.TargetEntity == nullptr)
|
if (player.TargetEntity == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -370,7 +370,7 @@ std::unique_ptr<Moveable> LaraObject::GetTarget() const
|
||||||
// local interactedMoveable = Lara:GetInteractedMoveable()
|
// local interactedMoveable = Lara:GetInteractedMoveable()
|
||||||
std::unique_ptr<Moveable> LaraObject::GetPlayerInteractedMoveable() const
|
std::unique_ptr<Moveable> LaraObject::GetPlayerInteractedMoveable() const
|
||||||
{
|
{
|
||||||
const auto& player = GetLaraInfo(*m_item);
|
const auto& player = GetLaraInfo(*_moveable);
|
||||||
|
|
||||||
if (player.Context.InteractedItem == NO_VALUE)
|
if (player.Context.InteractedItem == NO_VALUE)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -385,7 +385,7 @@ std::unique_ptr<Moveable> LaraObject::GetPlayerInteractedMoveable() const
|
||||||
// local torchIsLit = Lara:TorchIsLit()
|
// local torchIsLit = Lara:TorchIsLit()
|
||||||
bool LaraObject::TorchIsLit() const
|
bool LaraObject::TorchIsLit() const
|
||||||
{
|
{
|
||||||
auto* lara = GetLaraInfo(m_item);
|
auto* lara = GetLaraInfo(_moveable);
|
||||||
return lara->Torch.IsLit;
|
return lara->Torch.IsLit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,17 +4,13 @@
|
||||||
#include "Scripting/Internal/TEN/Objects/NamedBase.h"
|
#include "Scripting/Internal/TEN/Objects/NamedBase.h"
|
||||||
#include "Scripting/Internal/TEN/Objects/Room/RoomObject.h"
|
#include "Scripting/Internal/TEN/Objects/Room/RoomObject.h"
|
||||||
|
|
||||||
class LevelFunc;
|
namespace sol { class state; }
|
||||||
|
namespace sol { template <typename T> struct as_table_t; }
|
||||||
|
|
||||||
namespace sol
|
|
||||||
{
|
|
||||||
class state;
|
|
||||||
template <typename T> struct as_table_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ItemStatus;
|
|
||||||
enum GAME_OBJECT_ID : short;
|
enum GAME_OBJECT_ID : short;
|
||||||
|
enum ItemStatus;
|
||||||
enum class EffectType;
|
enum class EffectType;
|
||||||
|
class LevelFunc;
|
||||||
class ScriptColor;
|
class ScriptColor;
|
||||||
class Vec3;
|
class Vec3;
|
||||||
struct ItemInfo;
|
struct ItemInfo;
|
||||||
|
@ -25,128 +21,117 @@ using namespace TEN::Scripting;
|
||||||
using aiBitsArray = std::array<int, 6>;
|
using aiBitsArray = std::array<int, 6>;
|
||||||
using aiBitsType = sol::as_table_t<aiBitsArray>;
|
using aiBitsType = sol::as_table_t<aiBitsArray>;
|
||||||
|
|
||||||
class Moveable : public NamedBase<Moveable, short>
|
class Moveable : public NamedBase<Moveable, int>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using IdentifierType = short;
|
|
||||||
|
|
||||||
static void Register(sol::state& state, sol::table& parent);
|
static void Register(sol::state& state, sol::table& parent);
|
||||||
|
|
||||||
Moveable(short num, bool alreadyInitialized = true);
|
protected:
|
||||||
|
ItemInfo* _moveable = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _moveableID = 0;
|
||||||
|
bool _initialized = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using IdentifierType = int;
|
||||||
|
|
||||||
|
// Constructors, destructors
|
||||||
|
|
||||||
|
Moveable(int movID, bool alreadyInitialized = true);
|
||||||
|
Moveable(const Moveable& mov) = delete;
|
||||||
|
Moveable(Moveable&& mov) noexcept;
|
||||||
~Moveable();
|
~Moveable();
|
||||||
Moveable& operator =(const Moveable& other) = delete;
|
|
||||||
Moveable(const Moveable& other) = delete;
|
|
||||||
Moveable(Moveable&& other) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] GAME_OBJECT_ID GetObjectID() const;
|
// Getters
|
||||||
void SetObjectID(GAME_OBJECT_ID id);
|
|
||||||
|
|
||||||
[[nodiscard]] std::string GetName() const;
|
int GetIndex() const;
|
||||||
bool SetName(const std::string&);
|
GAME_OBJECT_ID GetObjectID() const;
|
||||||
|
std::string GetName() const;
|
||||||
[[nodiscard]] bool GetValid() const;
|
bool GetValid() const;
|
||||||
void Invalidate();
|
Vec3 GetPosition() const;
|
||||||
|
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
Vec3 GetPos() const;
|
|
||||||
Vec3 GetJointPos(int jointID, sol::optional<Vec3> offset) const;
|
Vec3 GetJointPos(int jointID, sol::optional<Vec3> offset) const;
|
||||||
void SetPos(const Vec3& pos, sol::optional<bool> updateRoom);
|
Rotation GetJointRot(int index) const;
|
||||||
|
Rotation GetRotation() const;
|
||||||
|
int GetStateNumber() const;
|
||||||
|
int GetTargetStateNumber() const;
|
||||||
|
int GetAnimNumber() const;
|
||||||
|
int GetAnimSlot() const;
|
||||||
|
int GetFrameNumber() const;
|
||||||
|
int GetEndFrame() const;
|
||||||
|
Vec3 GetVelocity() const;
|
||||||
|
ScriptColor GetColor() const;
|
||||||
|
short GetHP() const;
|
||||||
|
short GetSlotHP() const;
|
||||||
|
short GetOcb() const;
|
||||||
|
EffectType GetEffect() const;
|
||||||
|
aiBitsType GetAIBits() const;
|
||||||
|
short GetItemFlags(int index = 0) const;
|
||||||
|
short GetLocationAI() const;
|
||||||
|
short GetMeshCount() const;
|
||||||
|
bool GetMeshVisible(int meshId) const;
|
||||||
|
bool GetMeshSwapped(int meshId) const;
|
||||||
|
bool GetHitStatus() const;
|
||||||
|
bool GetActive() const;
|
||||||
|
short GetStatus() const;
|
||||||
|
|
||||||
[[nodiscard]] Rotation GetJointRot(int index) const;
|
// Setters
|
||||||
[[nodiscard]] Rotation GetRot() const;
|
|
||||||
void SetRot(const Rotation& rot);
|
|
||||||
|
|
||||||
[[nodiscard]] int GetStateNumber() const;
|
void SetObjectID(GAME_OBJECT_ID id);
|
||||||
[[nodiscard]] int GetTargetStateNumber() const;
|
bool SetName(const std::string&);
|
||||||
|
void SetPosition(const Vec3& pos, sol::optional<bool> updateRoom);
|
||||||
|
std::unique_ptr<Room> GetRoom() const;
|
||||||
|
int GetRoomNumber() const;
|
||||||
|
void SetRotation(const Rotation& rot);
|
||||||
void SetStateNumber(int stateNumber);
|
void SetStateNumber(int stateNumber);
|
||||||
|
|
||||||
[[nodiscard]] int GetAnimNumber() const;
|
|
||||||
[[nodiscard]] int GetAnimSlot() const;
|
|
||||||
void SetAnimNumber(int animNumber, sol::optional<int> slotIndex);
|
void SetAnimNumber(int animNumber, sol::optional<int> slotIndex);
|
||||||
|
|
||||||
[[nodiscard]] int GetFrameNumber() const;
|
|
||||||
[[nodiscard]] int GetEndFrame() const;
|
|
||||||
void SetFrameNumber(int frameNumber);
|
void SetFrameNumber(int frameNumber);
|
||||||
|
|
||||||
[[nodiscard]] Vec3 GetVelocity() const;
|
|
||||||
void SetVelocity(Vec3 velocity);
|
void SetVelocity(Vec3 velocity);
|
||||||
|
|
||||||
[[nodiscard]] ScriptColor GetColor() const;
|
|
||||||
void SetColor(const ScriptColor& color);
|
void SetColor(const ScriptColor& color);
|
||||||
|
|
||||||
[[nodiscard]] short GetHP() const;
|
|
||||||
void SetHP(short hp);
|
void SetHP(short hp);
|
||||||
|
void SetOcb(short ocb);
|
||||||
[[nodiscard]] short GetSlotHP() const;
|
|
||||||
|
|
||||||
[[nodiscard]] short GetOCB() const;
|
|
||||||
void SetOCB(short ocb);
|
|
||||||
|
|
||||||
[[nodiscard]] EffectType GetEffect() const;
|
|
||||||
void SetEffect(EffectType effectType, sol::optional<float> timeout);
|
void SetEffect(EffectType effectType, sol::optional<float> timeout);
|
||||||
void SetCustomEffect(const ScriptColor& col1, const ScriptColor& col2, sol::optional<float> timeout);
|
void SetCustomEffect(const ScriptColor& col1, const ScriptColor& col2, sol::optional<float> timeout);
|
||||||
|
void SetAIBits(aiBitsType const& bits);
|
||||||
[[nodiscard]] aiBitsType GetAIBits() const;
|
|
||||||
void SetAIBits(aiBitsType const & bits);
|
|
||||||
|
|
||||||
[[nodiscard]] short GetItemFlags(int index = 0) const;
|
|
||||||
void SetItemFlags(short value, int index = 0);
|
void SetItemFlags(short value, int index = 0);
|
||||||
|
|
||||||
[[nodiscard]] short GetLocationAI() const;
|
|
||||||
void SetLocationAI(short value);
|
void SetLocationAI(short value);
|
||||||
|
|
||||||
[[nodiscard]] short GetMeshCount() const;
|
|
||||||
[[nodiscard]] bool GetMeshVisible(int meshId) const;
|
|
||||||
void SetMeshVisible(int meshId, bool isVisible);
|
void SetMeshVisible(int meshId, bool isVisible);
|
||||||
void ShatterMesh(int meshId);
|
|
||||||
|
|
||||||
[[nodiscard]] bool GetMeshSwapped(int meshId) const;
|
|
||||||
void SwapMesh(int meshId, int swapSlotId, sol::optional<int> swapMeshIndex);
|
|
||||||
void UnswapMesh(int meshId);
|
|
||||||
|
|
||||||
[[nodiscard]] bool GetHitStatus() const;
|
|
||||||
|
|
||||||
[[nodiscard]] bool GetActive() const;
|
|
||||||
void SetActive(bool isActive);
|
void SetActive(bool isActive);
|
||||||
|
|
||||||
std::unique_ptr<Room> GetRoom() const;
|
|
||||||
[[nodiscard]] int GetRoomNumber() const;
|
|
||||||
void SetRoomNumber(int roomNumber);
|
void SetRoomNumber(int roomNumber);
|
||||||
|
void SetStatus(ItemStatus value);
|
||||||
void AttachObjCamera(short camMeshId, Moveable& mov, short targetMeshId);
|
|
||||||
void AnimFromObject(GAME_OBJECT_ID object, int animNumber, int stateID);
|
|
||||||
|
|
||||||
void EnableItem(sol::optional<float> timer);
|
|
||||||
void DisableItem();
|
|
||||||
void MakeInvisible();
|
|
||||||
void SetVisible(bool isVisible);
|
|
||||||
[[nodiscard]] bool GetCollidable();
|
|
||||||
void SetCollidable(bool isCollidable);
|
|
||||||
void Explode();
|
|
||||||
void Shatter();
|
|
||||||
|
|
||||||
void SetOnHit(const TypeOrNil<LevelFunc>& cb);
|
void SetOnHit(const TypeOrNil<LevelFunc>& cb);
|
||||||
void SetOnKilled(const TypeOrNil<LevelFunc>& cb);
|
void SetOnKilled(const TypeOrNil<LevelFunc>& cb);
|
||||||
void SetOnCollidedWithObject(const TypeOrNil<LevelFunc>& cb);
|
void SetOnCollidedWithObject(const TypeOrNil<LevelFunc>& cb);
|
||||||
void SetOnCollidedWithRoom(const TypeOrNil<LevelFunc>& cb);
|
void SetOnCollidedWithRoom(const TypeOrNil<LevelFunc>& cb);
|
||||||
|
|
||||||
[[nodiscard]] short GetStatus() const;
|
|
||||||
void SetStatus(ItemStatus value);
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
|
|
||||||
friend bool operator ==(const Moveable&, const Moveable&);
|
|
||||||
friend void SetLevelFuncCallback(const TypeOrNil<LevelFunc>& cb, const std::string& callerName, Moveable& mov, std::string& toModify);
|
friend void SetLevelFuncCallback(const TypeOrNil<LevelFunc>& cb, const std::string& callerName, Moveable& mov, std::string& toModify);
|
||||||
|
|
||||||
short GetIndex() const;
|
// Utilities
|
||||||
|
|
||||||
protected:
|
void Initialize();
|
||||||
ItemInfo* m_item;
|
void Invalidate();
|
||||||
|
void Destroy();
|
||||||
|
void ShatterMesh(int meshId);
|
||||||
|
void SwapMesh(int meshId, int swapSlotId, sol::optional<int> swapMeshIndex);
|
||||||
|
void UnswapMesh(int meshId);
|
||||||
|
void AttachObjCamera(short camMeshId, Moveable& mov, short targetMeshId);
|
||||||
|
void AnimFromObject(GAME_OBJECT_ID object, int animNumber, int stateID);
|
||||||
|
void EnableItem(sol::optional<float> timer);
|
||||||
|
void DisableItem();
|
||||||
|
void MakeInvisible();
|
||||||
|
void SetVisible(bool isVisible);
|
||||||
|
bool GetCollidable();
|
||||||
|
void SetCollidable(bool isCollidable);
|
||||||
|
void Explode();
|
||||||
|
void Shatter();
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
|
||||||
|
Moveable& operator =(const Moveable& mov) = delete;
|
||||||
|
friend bool operator ==(const Moveable&, const Moveable&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
short m_num;
|
// Helpers
|
||||||
bool m_initialized;
|
|
||||||
|
|
||||||
bool MeshExists(int number) const;
|
bool MeshExists(int number) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "Game/items.h"
|
#include "Game/items.h"
|
||||||
|
|
||||||
/***
|
/// Constants for moveable statuses.
|
||||||
Constants for moveable statuses.
|
// @enum Objects.MoveableStatus
|
||||||
@enum Objects.MoveableStatus
|
// @pragma nostrip
|
||||||
@pragma nostrip
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*** Table of Objects.MoveableStatus constants.
|
/// Table of Objects.MoveableStatus constants.
|
||||||
|
//
|
||||||
To be used with @{Objects.Moveable.GetStatus} and @{Objects.Moveable.SetStatus} functions.
|
// To be used with @{Objects.Moveable.GetStatus} and @{Objects.Moveable.SetStatus} functions.
|
||||||
|
//
|
||||||
- `INACTIVE` - object was never activated.
|
// - `INACTIVE` - moveable is inactive (was never activated).
|
||||||
- `ACTIVE` - object is active.
|
// - `ACTIVE` - moveable is active.
|
||||||
- `DEACTIVATED` - object was active before and was deactivated.
|
// - `DEACTIVATED` - moveable is deactivated (was previously active and later deactivated).
|
||||||
- `INVISIBLE` - object is invisible.
|
// - `INVISIBLE` - moveable is invisible.
|
||||||
|
//
|
||||||
@table Objects.MoveableStatus
|
// @table Objects.MoveableStatus
|
||||||
*/
|
|
||||||
|
|
||||||
static const std::unordered_map<std::string, ItemStatus> MOVEABLE_STATUSES
|
static const std::unordered_map<std::string, ItemStatus> MOVEABLE_STATUSES
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "Scripting/Internal/ScriptAssert.h"
|
#include "Scripting/Internal/ScriptAssert.h"
|
||||||
|
|
||||||
template <typename S> using callbackSetName = std::function<bool(std::string const&, S identifier)>;
|
template <typename S> using callbackSetName = std::function<bool(const std::string&, S identifier)>;
|
||||||
using callbackRemoveName = std::function<bool(std::string const&)>;
|
using callbackRemoveName = std::function<bool(const std::string&)>;
|
||||||
|
|
||||||
// Use the "curiously recurring template pattern" to allow classes to inherit static members and functions.
|
// Use the "curiously recurring template pattern" to allow classes to inherit static members and functions.
|
||||||
// T is the class that will both derive and instantiate this base class. S is the type used inside GameScriptWhateverInfo
|
// T is the class that will both derive and instantiate this base class. S is the type used inside GameScriptWhateverInfo
|
||||||
|
@ -15,27 +13,27 @@ template <typename T, class S> class NamedBase
|
||||||
public:
|
public:
|
||||||
static void SetNameCallbacks(callbackSetName<S> cbs, callbackRemoveName cbr)
|
static void SetNameCallbacks(callbackSetName<S> cbs, callbackRemoveName cbr)
|
||||||
{
|
{
|
||||||
s_callbackSetName = cbs;
|
_callbackSetName = cbs;
|
||||||
s_callbackRemoveName = cbr;
|
_callbackRemoveName = cbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static callbackSetName<S> s_callbackSetName;
|
static callbackSetName<S> _callbackSetName;
|
||||||
static callbackRemoveName s_callbackRemoveName;
|
static callbackRemoveName _callbackRemoveName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Default callbacks.
|
||||||
|
template <typename T, typename S> callbackSetName<S> NamedBase<T, S>::_callbackSetName = [](const std::string& name, S identifier)
|
||||||
|
{
|
||||||
|
auto err = std::string("\"Set Name\" callback is not set.");
|
||||||
|
throw TENScriptException(err);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
// default callbacks
|
// This could potentially be called by the GameScriptItemInfo destructor, and thus cannot throw.
|
||||||
template <typename T, typename S> callbackSetName<S> NamedBase<T, S>::s_callbackSetName = [](std::string const& n, S identifier) {
|
template <typename T, typename S> callbackRemoveName NamedBase<T, S>::_callbackRemoveName = [](const std::string& name)
|
||||||
std::string err = "\"Set Name\" callback is not set.";
|
{
|
||||||
throw TENScriptException(err);
|
TENLog("\"Remove Name\" callback is not set.", LogLevel::Error);
|
||||||
return false;
|
std::terminate();
|
||||||
};
|
return false;
|
||||||
|
};
|
||||||
// this could potentially be called by the GameScriptItemInfo destructor, and thus cannot throw
|
|
||||||
template <typename T, typename S> callbackRemoveName NamedBase<T, S>::s_callbackRemoveName = [](std::string const& n) {
|
|
||||||
TENLog("\"Remove Name\" callback is not set.", LogLevel::Error);
|
|
||||||
std::terminate();
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ private:
|
||||||
if (key.empty())
|
if (key.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto p = std::pair< const std::string&, VarMapVal>{ key, val };
|
auto p = std::pair<const std::string&, VarMapVal>(key, val);
|
||||||
return m_nameMap.insert(p).second;
|
return m_nameMap.insert(p).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove previous name if it already exists.
|
// Remove previous name if it already exists.
|
||||||
if (s_callbackSetName(name, _room))
|
if (_callbackSetName(name, _room))
|
||||||
{
|
{
|
||||||
s_callbackRemoveName(_room.Name);
|
_callbackRemoveName(_room.Name);
|
||||||
_room.Name = name;
|
_room.Name = name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -83,10 +83,10 @@ void Sink::SetName(const std::string& id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_callbackSetName(id, m_sink))
|
if (_callbackSetName(id, m_sink))
|
||||||
{
|
{
|
||||||
// remove the old name if we have one
|
// remove the old name if we have one
|
||||||
s_callbackRemoveName(m_sink.Name);
|
_callbackRemoveName(m_sink.Name);
|
||||||
m_sink.Name = id;
|
m_sink.Name = id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -82,10 +82,10 @@ void SoundSource::SetName(std::string const& id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_callbackSetName(id, m_soundSource))
|
if (_callbackSetName(id, m_soundSource))
|
||||||
{
|
{
|
||||||
// remove the old name if we have one
|
// remove the old name if we have one
|
||||||
s_callbackRemoveName(m_soundSource.Name);
|
_callbackRemoveName(m_soundSource.Name);
|
||||||
m_soundSource.Name = id;
|
m_soundSource.Name = id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -228,10 +228,10 @@ void Static::SetName(std::string const & name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_callbackSetName(name, m_mesh))
|
if (_callbackSetName(name, m_mesh))
|
||||||
{
|
{
|
||||||
// remove the old name if we have one
|
// remove the old name if we have one
|
||||||
s_callbackRemoveName(m_mesh.Name);
|
_callbackRemoveName(m_mesh.Name);
|
||||||
m_mesh.Name = name;
|
m_mesh.Name = name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -90,9 +90,9 @@ void Volume::SetName(const std::string& name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove previous name if it exists.
|
// Remove previous name if it exists.
|
||||||
if (s_callbackSetName(name, _volume))
|
if (_callbackSetName(name, _volume))
|
||||||
{
|
{
|
||||||
s_callbackRemoveName(_volume.Name);
|
_callbackRemoveName(_volume.Name);
|
||||||
_volume.Name = name;
|
_volume.Name = name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue