2021-06-28 18:23:26 +01:00
|
|
|
#pragma once
|
2021-07-17 23:46:09 +01:00
|
|
|
#include <functional>
|
2021-06-28 18:23:26 +01:00
|
|
|
|
2021-07-17 23:46:09 +01:00
|
|
|
/***
|
|
|
|
Represents any object inside the game world.
|
|
|
|
Examples include statics, enemies, doors,
|
|
|
|
pickups, and Lara herself.
|
|
|
|
|
|
|
|
@classmod ItemInfo
|
|
|
|
@pragma nostrip
|
|
|
|
*/
|
2021-06-28 18:23:26 +01:00
|
|
|
namespace sol {
|
|
|
|
class state;
|
2021-06-30 14:08:12 +01:00
|
|
|
template <typename T> struct as_table_t;
|
2021-06-28 18:23:26 +01:00
|
|
|
}
|
2021-06-30 14:08:12 +01:00
|
|
|
class GameScriptPosition;
|
|
|
|
class GameScriptRotation;
|
2021-07-01 19:27:57 +01:00
|
|
|
struct ITEM_INFO;
|
2021-07-17 23:46:09 +01:00
|
|
|
enum GAME_OBJECT_ID : short;
|
|
|
|
|
|
|
|
using callbackSetName = std::function<bool(std::string const&, short itemID)>;
|
|
|
|
using callbackRemoveName = std::function<bool(std::string const&)>;
|
2021-06-28 18:23:26 +01:00
|
|
|
|
|
|
|
class GameScriptItemInfo
|
|
|
|
{
|
|
|
|
private:
|
2021-07-01 19:27:57 +01:00
|
|
|
ITEM_INFO* m_item;
|
2021-06-28 18:23:26 +01:00
|
|
|
short m_num;
|
2021-07-17 23:46:09 +01:00
|
|
|
static callbackSetName s_callbackSetName;
|
|
|
|
static callbackRemoveName s_callbackRemoveName;
|
2021-06-28 18:23:26 +01:00
|
|
|
public:
|
|
|
|
GameScriptItemInfo(short num);
|
|
|
|
~GameScriptItemInfo();
|
|
|
|
GameScriptItemInfo& operator=(GameScriptItemInfo const& other) = delete;
|
|
|
|
GameScriptItemInfo(GameScriptItemInfo const& other) = delete;
|
2021-07-01 19:27:57 +01:00
|
|
|
GameScriptItemInfo(GameScriptItemInfo && other) noexcept;
|
2021-07-05 18:19:10 +01:00
|
|
|
|
2021-06-28 18:23:26 +01:00
|
|
|
static void Register(sol::state *);
|
2021-07-17 23:46:09 +01:00
|
|
|
/*** If you create items with this you need to give a position, rotation,
|
|
|
|
room, and object number, and then call InitialiseItem before it will work.
|
|
|
|
@function ItemInfo.new
|
|
|
|
*/
|
2021-06-30 14:08:12 +01:00
|
|
|
static std::unique_ptr<GameScriptItemInfo> CreateEmpty();
|
2021-07-17 23:50:10 +01:00
|
|
|
|
2021-07-17 23:46:09 +01:00
|
|
|
/*** 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 currentAnim current animation
|
|
|
|
@tparam int requiredAnim required animation
|
|
|
|
@tparam int goalAnim goal animation
|
|
|
|
@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, -- currentAnim
|
|
|
|
0, -- requiredAnim
|
|
|
|
0, -- goalAnim
|
|
|
|
0, -- HP
|
|
|
|
0, -- OCB
|
|
|
|
{0,0,0,0,0,0,0,0}, -- itemFlags
|
|
|
|
0, -- AIBits
|
|
|
|
0, -- status
|
|
|
|
false, -- active
|
|
|
|
false, -- hitStatus
|
|
|
|
)
|
|
|
|
*/
|
2021-06-28 18:23:26 +01:00
|
|
|
static std::unique_ptr<GameScriptItemInfo> Create(
|
2021-07-17 23:46:09 +01:00
|
|
|
GAME_OBJECT_ID objID,
|
2021-07-05 18:19:10 +01:00
|
|
|
std::string Name,
|
2021-06-30 14:08:12 +01:00
|
|
|
GameScriptPosition pos,
|
|
|
|
GameScriptRotation aRot,
|
2021-07-01 19:27:57 +01:00
|
|
|
short room,
|
2021-06-30 14:08:12 +01:00
|
|
|
short aCurrentAnim,
|
|
|
|
short aRequiredAnim,
|
2021-07-01 19:27:57 +01:00
|
|
|
short goalAnim,
|
2021-06-30 14:08:12 +01:00
|
|
|
short aHp,
|
|
|
|
short aOcb,
|
|
|
|
sol::as_table_t<std::array<short, 8>> aFlags,
|
|
|
|
byte aAiBits,
|
|
|
|
short aStatus,
|
|
|
|
bool aActive,
|
|
|
|
bool aHitStatus
|
|
|
|
);
|
2021-07-17 23:46:09 +01:00
|
|
|
static void SetNameCallbacks(callbackSetName, callbackRemoveName);
|
|
|
|
|
|
|
|
/// (int) object ID
|
|
|
|
//@mem objectID
|
|
|
|
GAME_OBJECT_ID GetObjectID() const;
|
|
|
|
void SetObjectID(GAME_OBJECT_ID id);
|
|
|
|
|
|
|
|
/// (string) unique string identifier.
|
|
|
|
// e.g. "door_back_room" or "cracked_greek_statue"
|
|
|
|
//@mem name
|
2021-07-05 18:19:10 +01:00
|
|
|
std::string GetName() const;
|
|
|
|
void SetName(std::string const &);
|
2021-07-17 23:46:09 +01:00
|
|
|
|
|
|
|
/// (@{Position}) position in level
|
|
|
|
//@mem pos
|
2021-06-30 14:08:12 +01:00
|
|
|
GameScriptPosition GetPos() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetPos(GameScriptPosition const& pos);
|
|
|
|
|
|
|
|
/// (@{Rotation}) rotation represented as degree angles about X, Y, and Z axes
|
|
|
|
//@mem rot
|
2021-06-30 14:08:12 +01:00
|
|
|
GameScriptRotation GetRot() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetRot(GameScriptRotation const& rot);
|
|
|
|
|
|
|
|
/// (int) ID of current animation
|
|
|
|
//@mem currentAnim
|
|
|
|
//@todo what does this actually mean/should we expose it to the user?
|
2021-06-30 14:08:12 +01:00
|
|
|
short GetCurrentAnim() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetCurrentAnim(short anim);
|
|
|
|
|
|
|
|
/// (int) ID of required animation
|
|
|
|
//@mem requiredAnim
|
|
|
|
//@todo what does this actually mean/should we expose it to the user?
|
2021-06-30 14:08:12 +01:00
|
|
|
short GetRequiredAnim() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetRequiredAnim(short anim);
|
|
|
|
|
|
|
|
/// (int) ID of goal animation
|
|
|
|
//@mem goalAnim
|
|
|
|
//@todo what does this actually mean/should we expose it to the user?
|
|
|
|
short GetGoalAnim() const;
|
|
|
|
void SetGoalAnim(short state);
|
|
|
|
|
|
|
|
/// (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
|
2021-06-30 14:08:12 +01:00
|
|
|
short GetHP() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetHP(short hp);
|
|
|
|
|
|
|
|
/// (int) OCB (object code bit) of object
|
|
|
|
//@mem OCB
|
2021-06-30 14:08:12 +01:00
|
|
|
short GetOCB() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetOCB(short ocb);
|
|
|
|
|
|
|
|
/// (table) item flags of object (table of 8 ints)
|
|
|
|
//@mem itemFlags
|
2021-06-30 14:08:12 +01:00
|
|
|
sol::as_table_t<std::array<short, 8>> GetItemFlags() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetItemFlags(sol::as_table_t<std::array<short, 8>> const & arr);
|
|
|
|
|
|
|
|
/// (int) AIBits of object. Will be clamped to [0, 255]
|
|
|
|
// @mem AIBits
|
2021-06-30 14:08:12 +01:00
|
|
|
byte GetAIBits() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetAIBits(byte bits);
|
|
|
|
|
|
|
|
/// (int) status of object.
|
|
|
|
// possible values:
|
|
|
|
// 0 - not active
|
|
|
|
// 1 - active
|
|
|
|
// 2 - deactivated
|
|
|
|
// 3 - invisible
|
|
|
|
// @mem status
|
2021-06-30 14:08:12 +01:00
|
|
|
short GetStatus() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetStatus(short status);
|
|
|
|
|
|
|
|
/// (bool) hit status of object
|
|
|
|
// @mem hitStatus
|
2021-06-30 14:08:12 +01:00
|
|
|
bool GetHitStatus() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetHitStatus(bool status);
|
|
|
|
|
|
|
|
/// (bool) whether or not the object is active
|
|
|
|
// @mem hitStatus
|
2021-06-30 14:08:12 +01:00
|
|
|
bool GetActive() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetActive(bool active);
|
|
|
|
|
|
|
|
/// (short) room the item is in
|
|
|
|
// @mem room
|
2021-07-01 19:27:57 +01:00
|
|
|
short GetRoom() const;
|
2021-07-17 23:46:09 +01:00
|
|
|
void SetRoom(short Room);
|
|
|
|
|
|
|
|
/// Enable the item
|
|
|
|
// @function ItemInfo:EnableItem
|
2021-07-01 19:27:57 +01:00
|
|
|
void EnableItem();
|
2021-07-17 23:46:09 +01:00
|
|
|
|
|
|
|
/// Disable the item
|
|
|
|
// @function ItemInfo:DisableItem
|
2021-07-01 19:27:57 +01:00
|
|
|
void DisableItem();
|
2021-06-30 14:08:12 +01:00
|
|
|
|
2021-07-17 23:46:09 +01:00
|
|
|
/// Initialise an item. Use this if you called new with no arguments
|
2021-06-30 14:08:12 +01:00
|
|
|
void Init();
|
2021-06-28 18:23:26 +01:00
|
|
|
};
|