TombEngine/TR5Main/Scripting/GameScriptItemInfo.h
hispidence 24b7d549f6 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.
2021-07-20 17:18:39 +01:00

93 lines
2.2 KiB
C++

#pragma once
#include <functional>
namespace sol {
class state;
template <typename T> struct as_table_t;
}
class GameScriptPosition;
class GameScriptRotation;
struct ITEM_INFO;
enum GAME_OBJECT_ID : short;
using callbackSetName = std::function<bool(std::string const&, short itemID)>;
using callbackRemoveName = std::function<bool(std::string const&)>;
class GameScriptItemInfo
{
public:
GameScriptItemInfo(short num, bool temporary);
~GameScriptItemInfo();
GameScriptItemInfo& operator=(GameScriptItemInfo const& other) = delete;
GameScriptItemInfo(GameScriptItemInfo const& other) = delete;
GameScriptItemInfo(GameScriptItemInfo && other) noexcept;
static void Register(sol::state *);
static void SetNameCallbacks(callbackSetName, callbackRemoveName);
GAME_OBJECT_ID GetObjectID() const;
void SetObjectID(GAME_OBJECT_ID id);
std::string GetName() const;
void SetName(std::string const &);
GameScriptPosition GetPos() const;
void SetPos(GameScriptPosition const& pos);
GameScriptRotation GetRot() const;
void SetRot(GameScriptRotation const& rot);
short GetCurrentAnimState() const;
void SetCurrentAnimState(short animState);
short GetAnimNumber() const;
void SetAnimNumber(short animNumber);
short GetFrameNumber() const;
void SetFrameNumber(short frameNumber);
short GetRequiredAnimState() const;
void SetRequiredAnimState(short animState);
short GetGoalAnimState() const;
void SetGoalAnimState(short animState);
short GetHP() const;
void SetHP(short hp);
short GetOCB() const;
void SetOCB(short ocb);
sol::as_table_t<std::array<short, 8>> GetItemFlags() const;
void SetItemFlags(sol::as_table_t<std::array<short, 8>> const & arr);
byte GetAIBits() const;
void SetAIBits(byte bits);
short GetStatus() const;
void SetStatus(short status);
bool GetHitStatus() const;
void SetHitStatus(bool status);
bool GetActive() const;
void SetActive(bool active);
short GetRoom() const;
void SetRoom(short Room);
void EnableItem();
void DisableItem();
void Init();
private:
ITEM_INFO* m_item;
short m_num;
bool m_initialised;
bool m_temporary;
static callbackSetName s_callbackSetName;
static callbackRemoveName s_callbackRemoveName;
};