mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-03 02:07:59 +03:00
Add concept of 'temporary' ItemInfo instances. These instances will kill the ITEM_INFO they reference when they are destroyed. This was previously the default behaviour. However, now that we're using things like GetItemByName, it makes more sense for ItemInfos to be non-owning by default.
Move LDoc from GameScriptItemInfo.h to GameScriptItemInfo.cpp. This might seem counter-intuitive, but LDoc is concerned with the Lua interfaces rather than the actual C++ functions; since the Lua interfaces are defined in GameScriptItemInfo::Register, it makes more sense for the comments to be nearby.
This commit is contained in:
parent
075a8cf7dd
commit
24b7d549f6
2 changed files with 202 additions and 182 deletions
|
@ -10,11 +10,20 @@
|
||||||
#include "trmath.h"
|
#include "trmath.h"
|
||||||
#include "lara.h"
|
#include "lara.h"
|
||||||
|
|
||||||
|
/***
|
||||||
|
Represents any object inside the game world.
|
||||||
|
Examples include statics, enemies, doors,
|
||||||
|
pickups, and Lara herself.
|
||||||
|
|
||||||
|
@classmod ItemInfo
|
||||||
|
@pragma nostrip
|
||||||
|
*/
|
||||||
|
|
||||||
extern bool const WarningsAsErrors;
|
extern bool const WarningsAsErrors;
|
||||||
|
|
||||||
constexpr auto LUA_CLASS_NAME{ "ItemInfo" };
|
constexpr auto LUA_CLASS_NAME{ "ItemInfo" };
|
||||||
|
|
||||||
GameScriptItemInfo::GameScriptItemInfo(short num) : m_item{ &g_Level.Items[num]}, m_num { num }
|
GameScriptItemInfo::GameScriptItemInfo(short num, bool temp) : m_item{ &g_Level.Items[num] }, m_num{ num }, m_initialised{ false }, m_temporary{ temp }
|
||||||
{};
|
{};
|
||||||
|
|
||||||
GameScriptItemInfo::GameScriptItemInfo(GameScriptItemInfo&& other) noexcept :
|
GameScriptItemInfo::GameScriptItemInfo(GameScriptItemInfo&& other) noexcept :
|
||||||
|
@ -26,7 +35,7 @@ GameScriptItemInfo::GameScriptItemInfo(GameScriptItemInfo&& other) noexcept :
|
||||||
// todo.. how to check if item is killed outside of script?
|
// todo.. how to check if item is killed outside of script?
|
||||||
GameScriptItemInfo::~GameScriptItemInfo() {
|
GameScriptItemInfo::~GameScriptItemInfo() {
|
||||||
// todo.. see if there's a better default state than -1
|
// todo.. see if there's a better default state than -1
|
||||||
if (m_num > NO_ITEM)
|
if (m_temporary && (m_num > NO_ITEM))
|
||||||
{
|
{
|
||||||
s_callbackRemoveName(m_item->luaName);
|
s_callbackRemoveName(m_item->luaName);
|
||||||
KillItem(m_num);
|
KillItem(m_num);
|
||||||
|
@ -66,48 +75,79 @@ void GameScriptItemInfo::SetNameCallbacks(callbackSetName cbs, callbackRemoveNam
|
||||||
s_callbackRemoveName = cbr;
|
s_callbackRemoveName = cbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** If you create items with this you NEED to give a position, room,
|
||||||
|
and object number, and then call InitialiseItem before it will work.
|
||||||
|
@function ItemInfo.newItem
|
||||||
|
*/
|
||||||
|
|
||||||
void GameScriptItemInfo::Register(sol::state* state)
|
/*** Like above, but the returned variable controls the
|
||||||
{
|
lifetime of the object (it will be destroyed when the variable goes
|
||||||
state->new_usertype<GameScriptItemInfo>(LUA_CLASS_NAME,
|
out of scope).
|
||||||
"new", sol::overload(&GameScriptItemInfo::Create, &GameScriptItemInfo::CreateEmpty),
|
@function ItemInfo.newItemTemporary
|
||||||
sol::meta_function::index, &index_error,
|
*/
|
||||||
"Init", &GameScriptItemInfo::Init,
|
template <bool temp> std::unique_ptr<GameScriptItemInfo> CreateEmpty()
|
||||||
"GetLara", &GameScriptItemInfo::GetLara,
|
|
||||||
"objectID", sol::property(&GameScriptItemInfo::GetObjectID, &GameScriptItemInfo::SetObjectID),
|
|
||||||
"currentAnimState", sol::property(&GameScriptItemInfo::GetCurrentAnimState, &GameScriptItemInfo::SetCurrentAnimState),
|
|
||||||
"requiredAnimState", sol::property(&GameScriptItemInfo::GetRequiredAnimState, &GameScriptItemInfo::SetRequiredAnimState),
|
|
||||||
"goalAnimState", sol::property(&GameScriptItemInfo::GetGoalAnimState, &GameScriptItemInfo::SetGoalAnimState),
|
|
||||||
"animNumber", sol::property(&GameScriptItemInfo::GetAnimNumber, &GameScriptItemInfo::SetAnimNumber),
|
|
||||||
"frameNumber", sol::property(&GameScriptItemInfo::GetFrameNumber, &GameScriptItemInfo::SetFrameNumber),
|
|
||||||
"HP", sol::property(&GameScriptItemInfo::GetHP, &GameScriptItemInfo::SetHP),
|
|
||||||
"OCB", sol::property(&GameScriptItemInfo::GetOCB, &GameScriptItemInfo::SetOCB),
|
|
||||||
"itemFlags", sol::property(&GameScriptItemInfo::GetItemFlags, &GameScriptItemInfo::SetItemFlags),
|
|
||||||
"AIBits", sol::property(&GameScriptItemInfo::GetAIBits, &GameScriptItemInfo::SetAIBits),
|
|
||||||
"status", sol::property(&GameScriptItemInfo::GetStatus, &GameScriptItemInfo::SetStatus),
|
|
||||||
"hitStatus", sol::property(&GameScriptItemInfo::GetHitStatus, &GameScriptItemInfo::SetHitStatus),
|
|
||||||
"active", sol::property(&GameScriptItemInfo::GetActive, &GameScriptItemInfo::SetActive),
|
|
||||||
"room", sol::property(&GameScriptItemInfo::GetRoom, &GameScriptItemInfo::SetRoom),
|
|
||||||
"pos", sol::property(&GameScriptItemInfo::GetPos, &GameScriptItemInfo::SetPos),
|
|
||||||
"rot", sol::property(&GameScriptItemInfo::GetRot, &GameScriptItemInfo::SetRot),
|
|
||||||
"name", sol::property(&GameScriptItemInfo::GetName, &GameScriptItemInfo::SetName),
|
|
||||||
"Enable", &GameScriptItemInfo::EnableItem,
|
|
||||||
"Disable", &GameScriptItemInfo::DisableItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::GetLara()
|
|
||||||
{
|
|
||||||
return std::make_unique<GameScriptItemInfo>(Lara.itemNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::CreateEmpty()
|
|
||||||
{
|
{
|
||||||
short num = CreateItem();
|
short num = CreateItem();
|
||||||
ITEM_INFO * item = &g_Level.Items[num];
|
ITEM_INFO * item = &g_Level.Items[num];
|
||||||
return std::make_unique<GameScriptItemInfo>(num);
|
return std::make_unique<GameScriptItemInfo>(num, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::Create(
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** For more information on each parameter, see the
|
||||||
|
associated getters and setters. If you do not know what to set for these,
|
||||||
|
most can just be set them to zero (see usage) or use the overload which
|
||||||
|
takes no arguments.
|
||||||
|
@function ItemInfo.newItem
|
||||||
|
@tparam int object ID
|
||||||
|
@tparam string name Lua name of the item
|
||||||
|
@tparam Position position position in level
|
||||||
|
@tparam Rotation rotation rotation about x, y, and z axes
|
||||||
|
@tparam int room room ID item is in
|
||||||
|
@tparam int currentAnimState current animation state
|
||||||
|
@tparam int requiredAnimState required animation state
|
||||||
|
@tparam int goalAnimState goal animation state
|
||||||
|
@tparam int animNumber anim number
|
||||||
|
@tparam int frameNumber frame number
|
||||||
|
@tparam int hp HP of item
|
||||||
|
@tparam int OCB ocb of item
|
||||||
|
@tparam int itemFlags item flags
|
||||||
|
@tparam int AIBits byte with AI bits
|
||||||
|
@tparam int status status of object
|
||||||
|
@tparam bool active is item active or not?
|
||||||
|
@tparam bool hitStatus hit status of object
|
||||||
|
@return reference to new ItemInfo object
|
||||||
|
@usage
|
||||||
|
local item = ItemInfo.new(
|
||||||
|
950, -- object id. 950 is pistols
|
||||||
|
"test", -- name
|
||||||
|
Position.new(18907, 0, 21201),
|
||||||
|
Rotation.new(0,0,0),
|
||||||
|
0, -- room
|
||||||
|
0, -- currentAnimState
|
||||||
|
0, -- requiredAnimState
|
||||||
|
0, -- goalAnimState
|
||||||
|
0, -- animNumber
|
||||||
|
0, -- frameNumber
|
||||||
|
0, -- HP
|
||||||
|
0, -- OCB
|
||||||
|
{0,0,0,0,0,0,0,0}, -- itemFlags
|
||||||
|
0, -- AIBits
|
||||||
|
0, -- status
|
||||||
|
false, -- active
|
||||||
|
false, -- hitStatus
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*** Like the above, but the returned variable controls the
|
||||||
|
lifetime of the object (it will be destroyed when the variable goes
|
||||||
|
out of scope).
|
||||||
|
@function ItemInfo.newItemTemporary
|
||||||
|
@param see_above same as above function
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <bool temp> static std::unique_ptr<GameScriptItemInfo> Create(
|
||||||
GAME_OBJECT_ID objID,
|
GAME_OBJECT_ID objID,
|
||||||
std::string name,
|
std::string name,
|
||||||
GameScriptPosition pos,
|
GameScriptPosition pos,
|
||||||
|
@ -120,17 +160,17 @@ std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::Create(
|
||||||
short frameNumber,
|
short frameNumber,
|
||||||
short hp,
|
short hp,
|
||||||
short ocb,
|
short ocb,
|
||||||
sol::as_table_t<std::array<short, 8>> itemFlags,
|
sol::as_table_t<std::array<short, 8>> flags,
|
||||||
byte aiBits,
|
byte aiBits,
|
||||||
short status,
|
short status,
|
||||||
bool active,
|
bool active,
|
||||||
bool hitStatus
|
bool hitStatus
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
short num = CreateItem();
|
short num = CreateItem();
|
||||||
auto ptr = std::make_unique<GameScriptItemInfo>(num);
|
auto ptr = std::make_unique<GameScriptItemInfo>(num, temp);
|
||||||
|
|
||||||
ITEM_INFO * item = &g_Level.Items[num];
|
ITEM_INFO* item = &g_Level.Items[num];
|
||||||
ptr->SetPos(pos);
|
ptr->SetPos(pos);
|
||||||
ptr->SetRot(rot);
|
ptr->SetRot(rot);
|
||||||
ptr->SetRoom(room);
|
ptr->SetRoom(room);
|
||||||
|
@ -145,7 +185,7 @@ std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::Create(
|
||||||
ptr->SetFrameNumber(frameNumber);
|
ptr->SetFrameNumber(frameNumber);
|
||||||
ptr->SetHP(hp);
|
ptr->SetHP(hp);
|
||||||
ptr->SetOCB(ocb);
|
ptr->SetOCB(ocb);
|
||||||
ptr->SetItemFlags(itemFlags);
|
ptr->SetItemFlags(flags);
|
||||||
ptr->SetAIBits(aiBits);
|
ptr->SetAIBits(aiBits);
|
||||||
ptr->SetStatus(status);
|
ptr->SetStatus(status);
|
||||||
ptr->SetActive(active);
|
ptr->SetActive(active);
|
||||||
|
@ -154,6 +194,115 @@ std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::Create(
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GameScriptItemInfo> static GetLara()
|
||||||
|
{
|
||||||
|
return std::make_unique<GameScriptItemInfo>(Lara.itemNumber, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScriptItemInfo::Register(sol::state* state)
|
||||||
|
{
|
||||||
|
state->new_usertype<GameScriptItemInfo>(LUA_CLASS_NAME,
|
||||||
|
"newItem", sol::overload(Create<false>, CreateEmpty<false>),
|
||||||
|
"newItemTemporary", sol::overload(Create<true>, CreateEmpty<true>),
|
||||||
|
sol::meta_function::index, &index_error,
|
||||||
|
|
||||||
|
/// Initialise an item.
|
||||||
|
//Use this if you called new with no arguments
|
||||||
|
// @function ItemInfo.Init
|
||||||
|
"Init", &GameScriptItemInfo::Init,
|
||||||
|
|
||||||
|
/// Enable the item
|
||||||
|
// @function ItemInfo:EnableItem
|
||||||
|
"Enable", &GameScriptItemInfo::EnableItem,
|
||||||
|
|
||||||
|
/// Disable the item
|
||||||
|
// @function ItemInfo:DisableItem
|
||||||
|
"Disable", &GameScriptItemInfo::DisableItem,
|
||||||
|
|
||||||
|
/// Create a GameScriptItemInfo representing the Lara object.
|
||||||
|
// @function ItemInfo.GetLara
|
||||||
|
"GetLara", GetLara,
|
||||||
|
|
||||||
|
/// (int) object ID
|
||||||
|
// @mem objectID
|
||||||
|
"objectID", sol::property(&GameScriptItemInfo::GetObjectID, &GameScriptItemInfo::SetObjectID),
|
||||||
|
|
||||||
|
/// (int) State of current animation
|
||||||
|
// @mem currentAnimState
|
||||||
|
"currentAnimState", sol::property(&GameScriptItemInfo::GetCurrentAnimState, &GameScriptItemInfo::SetCurrentAnimState),
|
||||||
|
|
||||||
|
/// (int) State of required animation
|
||||||
|
// @mem requiredAnimState
|
||||||
|
"requiredAnimState", sol::property(&GameScriptItemInfo::GetRequiredAnimState, &GameScriptItemInfo::SetRequiredAnimState),
|
||||||
|
|
||||||
|
|
||||||
|
/// (int) State of goal animation
|
||||||
|
// @mem goalAnimState
|
||||||
|
"goalAnimState", sol::property(&GameScriptItemInfo::GetGoalAnimState, &GameScriptItemInfo::SetGoalAnimState),
|
||||||
|
|
||||||
|
/// (int) animation number
|
||||||
|
// @mem animNumber
|
||||||
|
"animNumber", sol::property(&GameScriptItemInfo::GetAnimNumber, &GameScriptItemInfo::SetAnimNumber),
|
||||||
|
|
||||||
|
/// (int) frame number
|
||||||
|
// @mem frameNumber
|
||||||
|
"frameNumber", sol::property(&GameScriptItemInfo::GetFrameNumber, &GameScriptItemInfo::SetFrameNumber),
|
||||||
|
|
||||||
|
/// (int) HP (hit points/health points) of object
|
||||||
|
//@raise an exception if the object is intelligent and an invalid
|
||||||
|
//hp value is given
|
||||||
|
// @mem HP
|
||||||
|
"HP", sol::property(&GameScriptItemInfo::GetHP, &GameScriptItemInfo::SetHP),
|
||||||
|
|
||||||
|
/// (int) OCB (object code bit) of object
|
||||||
|
// @mem OCB
|
||||||
|
"OCB", sol::property(&GameScriptItemInfo::GetOCB, &GameScriptItemInfo::SetOCB),
|
||||||
|
|
||||||
|
/// (table) item flags of object (table of 8 ints)
|
||||||
|
// @mem itemFlags
|
||||||
|
"itemFlags", sol::property(&GameScriptItemInfo::GetItemFlags, &GameScriptItemInfo::SetItemFlags),
|
||||||
|
|
||||||
|
/// (int) AIBits of object. Will be clamped to [0, 255]
|
||||||
|
// @mem AIBits
|
||||||
|
"AIBits", sol::property(&GameScriptItemInfo::GetAIBits, &GameScriptItemInfo::SetAIBits),
|
||||||
|
|
||||||
|
/// (int) status of object.
|
||||||
|
// possible values:
|
||||||
|
// 0 - not active
|
||||||
|
// 1 - active
|
||||||
|
// 2 - deactivated
|
||||||
|
// 3 - invisible
|
||||||
|
// @mem status
|
||||||
|
"status", sol::property(&GameScriptItemInfo::GetStatus, &GameScriptItemInfo::SetStatus),
|
||||||
|
|
||||||
|
/// (bool) hit status of object
|
||||||
|
// @mem hitStatus
|
||||||
|
"hitStatus", sol::property(&GameScriptItemInfo::GetHitStatus, &GameScriptItemInfo::SetHitStatus),
|
||||||
|
|
||||||
|
/// (bool) whether or not the object is active
|
||||||
|
// @mem active
|
||||||
|
"active", sol::property(&GameScriptItemInfo::GetActive, &GameScriptItemInfo::SetActive),
|
||||||
|
|
||||||
|
/// (short) room the item is in
|
||||||
|
// @mem room
|
||||||
|
"room", sol::property(&GameScriptItemInfo::GetRoom, &GameScriptItemInfo::SetRoom),
|
||||||
|
|
||||||
|
/// (@{Position}) position in level
|
||||||
|
// @mem pos
|
||||||
|
"pos", sol::property(&GameScriptItemInfo::GetPos, &GameScriptItemInfo::SetPos),
|
||||||
|
|
||||||
|
/// (@{Rotation}) rotation represented as degree angles about X, Y, and Z axes
|
||||||
|
// @mem rot
|
||||||
|
"rot", sol::property(&GameScriptItemInfo::GetRot, &GameScriptItemInfo::SetRot),
|
||||||
|
|
||||||
|
/// (string) unique string identifier.
|
||||||
|
// e.g. "door_back_room" or "cracked_greek_statue"
|
||||||
|
// @mem name
|
||||||
|
"name", sol::property(&GameScriptItemInfo::GetName, &GameScriptItemInfo::SetName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameScriptItemInfo::Init()
|
void GameScriptItemInfo::Init()
|
||||||
{
|
{
|
||||||
InitialiseItem(m_num);
|
InitialiseItem(m_num);
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
/***
|
|
||||||
Represents any object inside the game world.
|
|
||||||
Examples include statics, enemies, doors,
|
|
||||||
pickups, and Lara herself.
|
|
||||||
|
|
||||||
@classmod ItemInfo
|
|
||||||
@pragma nostrip
|
|
||||||
*/
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
class state;
|
class state;
|
||||||
template <typename T> struct as_table_t;
|
template <typename T> struct as_table_t;
|
||||||
|
@ -23,14 +14,8 @@ using callbackRemoveName = std::function<bool(std::string const&)>;
|
||||||
|
|
||||||
class GameScriptItemInfo
|
class GameScriptItemInfo
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
ITEM_INFO* m_item;
|
|
||||||
short m_num;
|
|
||||||
bool m_initialised = false;
|
|
||||||
static callbackSetName s_callbackSetName;
|
|
||||||
static callbackRemoveName s_callbackRemoveName;
|
|
||||||
public:
|
public:
|
||||||
GameScriptItemInfo(short num);
|
GameScriptItemInfo(short num, bool temporary);
|
||||||
~GameScriptItemInfo();
|
~GameScriptItemInfo();
|
||||||
GameScriptItemInfo& operator=(GameScriptItemInfo const& other) = delete;
|
GameScriptItemInfo& operator=(GameScriptItemInfo const& other) = delete;
|
||||||
GameScriptItemInfo(GameScriptItemInfo const& other) = delete;
|
GameScriptItemInfo(GameScriptItemInfo const& other) = delete;
|
||||||
|
@ -38,185 +23,71 @@ public:
|
||||||
|
|
||||||
static void Register(sol::state *);
|
static void Register(sol::state *);
|
||||||
|
|
||||||
/*** Create a GameScriptItemInfo representing the Lara object.
|
|
||||||
@function ItemInfo.GetLara
|
|
||||||
*/
|
|
||||||
static std::unique_ptr<GameScriptItemInfo> GetLara();
|
|
||||||
/*** If you create items with this you NEED to give a position, room,
|
|
||||||
and object number, and then call InitialiseItem before it will work.
|
|
||||||
@function ItemInfo.new
|
|
||||||
*/
|
|
||||||
static std::unique_ptr<GameScriptItemInfo> CreateEmpty();
|
|
||||||
|
|
||||||
/*** For more information on each parameter, see the
|
|
||||||
associated getters and setters. If you do not know what to set for these,
|
|
||||||
most can just be set them to zero (see usage) or use the overload which
|
|
||||||
takes no arguments.
|
|
||||||
@function ItemInfo.new
|
|
||||||
@tparam int object ID
|
|
||||||
@tparam string name Lua name of the item
|
|
||||||
@tparam Position position position in level
|
|
||||||
@tparam Rotation rotation rotation about x, y, and z axes
|
|
||||||
@tparam int room room ID item is in
|
|
||||||
@tparam int currentAnimState current animation state
|
|
||||||
@tparam int requiredAnimState required animation state
|
|
||||||
@tparam int goalAnimState goal animation state
|
|
||||||
@tparam int animNumber anim number
|
|
||||||
@tparam int frameNumber frame number
|
|
||||||
@tparam int hp HP of item
|
|
||||||
@tparam int OCB ocb of item
|
|
||||||
@tparam int itemFlags item flags
|
|
||||||
@tparam int AIBits byte with AI bits
|
|
||||||
@tparam int status status of object
|
|
||||||
@tparam bool active is item active or not?
|
|
||||||
@tparam bool hitStatus hit status of object
|
|
||||||
@return reference to new ItemInfo object
|
|
||||||
@usage
|
|
||||||
local item = ItemInfo.new(
|
|
||||||
950, -- object id. 950 is pistols
|
|
||||||
"test", -- name
|
|
||||||
Position.new(18907, 0, 21201),
|
|
||||||
Rotation.new(0,0,0),
|
|
||||||
0, -- room
|
|
||||||
0, -- currentAnimState
|
|
||||||
0, -- requiredAnimState
|
|
||||||
0, -- goalAnimState
|
|
||||||
0, -- animNumber
|
|
||||||
0, -- frameNumber
|
|
||||||
0, -- HP
|
|
||||||
0, -- OCB
|
|
||||||
{0,0,0,0,0,0,0,0}, -- itemFlags
|
|
||||||
0, -- AIBits
|
|
||||||
0, -- status
|
|
||||||
false, -- active
|
|
||||||
false, -- hitStatus
|
|
||||||
)
|
|
||||||
*/
|
|
||||||
static std::unique_ptr<GameScriptItemInfo> Create(
|
|
||||||
GAME_OBJECT_ID objID,
|
|
||||||
std::string Name,
|
|
||||||
GameScriptPosition pos,
|
|
||||||
GameScriptRotation aRot,
|
|
||||||
short room,
|
|
||||||
short aCurrentAnimState,
|
|
||||||
short aRequiredAnimState,
|
|
||||||
short goalAnimState,
|
|
||||||
short animNumber,
|
|
||||||
short frameNumber,
|
|
||||||
short aHp,
|
|
||||||
short aOcb,
|
|
||||||
sol::as_table_t<std::array<short, 8>> aFlags,
|
|
||||||
byte aAiBits,
|
|
||||||
short aStatus,
|
|
||||||
bool aActive,
|
|
||||||
bool aHitStatus
|
|
||||||
);
|
|
||||||
static void SetNameCallbacks(callbackSetName, callbackRemoveName);
|
static void SetNameCallbacks(callbackSetName, callbackRemoveName);
|
||||||
|
|
||||||
/// (int) object ID
|
|
||||||
//@mem objectID
|
|
||||||
GAME_OBJECT_ID GetObjectID() const;
|
GAME_OBJECT_ID GetObjectID() const;
|
||||||
void SetObjectID(GAME_OBJECT_ID id);
|
void SetObjectID(GAME_OBJECT_ID id);
|
||||||
|
|
||||||
/// (string) unique string identifier.
|
|
||||||
// e.g. "door_back_room" or "cracked_greek_statue"
|
|
||||||
//@mem name
|
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
void SetName(std::string const &);
|
void SetName(std::string const &);
|
||||||
|
|
||||||
/// (@{Position}) position in level
|
|
||||||
//@mem pos
|
|
||||||
GameScriptPosition GetPos() const;
|
GameScriptPosition GetPos() const;
|
||||||
void SetPos(GameScriptPosition const& pos);
|
void SetPos(GameScriptPosition const& pos);
|
||||||
|
|
||||||
/// (@{Rotation}) rotation represented as degree angles about X, Y, and Z axes
|
|
||||||
//@mem rot
|
|
||||||
GameScriptRotation GetRot() const;
|
GameScriptRotation GetRot() const;
|
||||||
void SetRot(GameScriptRotation const& rot);
|
void SetRot(GameScriptRotation const& rot);
|
||||||
|
|
||||||
/// (int) State of current animation
|
|
||||||
//@mem currentAnimState
|
|
||||||
//@todo what does this actually mean/should we expose it to the user?
|
|
||||||
short GetCurrentAnimState() const;
|
short GetCurrentAnimState() const;
|
||||||
void SetCurrentAnimState(short animState);
|
void SetCurrentAnimState(short animState);
|
||||||
|
|
||||||
/// (int) animation number
|
|
||||||
//@mem animNumber
|
|
||||||
short GetAnimNumber() const;
|
short GetAnimNumber() const;
|
||||||
void SetAnimNumber(short animNumber);
|
void SetAnimNumber(short animNumber);
|
||||||
|
|
||||||
/// (int) frame number
|
|
||||||
//@mem frameNumber
|
|
||||||
short GetFrameNumber() const;
|
short GetFrameNumber() const;
|
||||||
void SetFrameNumber(short frameNumber);
|
void SetFrameNumber(short frameNumber);
|
||||||
|
|
||||||
/// (int) State of required animation
|
|
||||||
//@mem requiredAnimState
|
|
||||||
//@todo what does this actually mean/should we expose it to the user?
|
|
||||||
short GetRequiredAnimState() const;
|
short GetRequiredAnimState() const;
|
||||||
void SetRequiredAnimState(short animState);
|
void SetRequiredAnimState(short animState);
|
||||||
|
|
||||||
/// (int) State of goal animation
|
|
||||||
//@mem goalAnimState
|
|
||||||
//@todo what does this actually mean/should we expose it to the user?
|
|
||||||
short GetGoalAnimState() const;
|
short GetGoalAnimState() const;
|
||||||
void SetGoalAnimState(short animState);
|
void SetGoalAnimState(short animState);
|
||||||
|
|
||||||
/// (int) HP (hit points/health points) of object
|
|
||||||
//@raise an exception if the object is intelligent and an invalid
|
|
||||||
//hp value is given
|
|
||||||
//@mem HP
|
|
||||||
short GetHP() const;
|
short GetHP() const;
|
||||||
void SetHP(short hp);
|
void SetHP(short hp);
|
||||||
|
|
||||||
/// (int) OCB (object code bit) of object
|
|
||||||
//@mem OCB
|
|
||||||
short GetOCB() const;
|
short GetOCB() const;
|
||||||
void SetOCB(short ocb);
|
void SetOCB(short ocb);
|
||||||
|
|
||||||
/// (table) item flags of object (table of 8 ints)
|
|
||||||
//@mem itemFlags
|
|
||||||
sol::as_table_t<std::array<short, 8>> GetItemFlags() const;
|
sol::as_table_t<std::array<short, 8>> GetItemFlags() const;
|
||||||
void SetItemFlags(sol::as_table_t<std::array<short, 8>> const & arr);
|
void SetItemFlags(sol::as_table_t<std::array<short, 8>> const & arr);
|
||||||
|
|
||||||
/// (int) AIBits of object. Will be clamped to [0, 255]
|
|
||||||
// @mem AIBits
|
|
||||||
byte GetAIBits() const;
|
byte GetAIBits() const;
|
||||||
void SetAIBits(byte bits);
|
void SetAIBits(byte bits);
|
||||||
|
|
||||||
/// (int) status of object.
|
|
||||||
// possible values:
|
|
||||||
// 0 - not active
|
|
||||||
// 1 - active
|
|
||||||
// 2 - deactivated
|
|
||||||
// 3 - invisible
|
|
||||||
// @mem status
|
|
||||||
short GetStatus() const;
|
short GetStatus() const;
|
||||||
void SetStatus(short status);
|
void SetStatus(short status);
|
||||||
|
|
||||||
/// (bool) hit status of object
|
|
||||||
// @mem hitStatus
|
|
||||||
bool GetHitStatus() const;
|
bool GetHitStatus() const;
|
||||||
void SetHitStatus(bool status);
|
void SetHitStatus(bool status);
|
||||||
|
|
||||||
/// (bool) whether or not the object is active
|
|
||||||
// @mem hitStatus
|
|
||||||
bool GetActive() const;
|
bool GetActive() const;
|
||||||
void SetActive(bool active);
|
void SetActive(bool active);
|
||||||
|
|
||||||
/// (short) room the item is in
|
|
||||||
// @mem room
|
|
||||||
short GetRoom() const;
|
short GetRoom() const;
|
||||||
void SetRoom(short Room);
|
void SetRoom(short Room);
|
||||||
|
|
||||||
/// Enable the item
|
|
||||||
// @function ItemInfo:EnableItem
|
|
||||||
void EnableItem();
|
void EnableItem();
|
||||||
|
|
||||||
/// Disable the item
|
|
||||||
// @function ItemInfo:DisableItem
|
|
||||||
void DisableItem();
|
void DisableItem();
|
||||||
|
|
||||||
/// Initialise an item. Use this if you called new with no arguments
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ITEM_INFO* m_item;
|
||||||
|
short m_num;
|
||||||
|
bool m_initialised;
|
||||||
|
bool m_temporary;
|
||||||
|
static callbackSetName s_callbackSetName;
|
||||||
|
static callbackRemoveName s_callbackRemoveName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue