mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-12 21:47:03 +03:00
More InventoryItem stuff.
This commit is contained in:
parent
4f0bb181b4
commit
a3ee57d1f4
7 changed files with 37 additions and 39 deletions
|
@ -78,9 +78,9 @@
|
||||||
<ClInclude Include="src\AudioTracks.h" />
|
<ClInclude Include="src\AudioTracks.h" />
|
||||||
<ClInclude Include="src\Flow\Animations\Animations.h" />
|
<ClInclude Include="src\Flow\Animations\Animations.h" />
|
||||||
<ClInclude Include="src\Flow\FlowHandler.h" />
|
<ClInclude Include="src\Flow\FlowHandler.h" />
|
||||||
|
<ClInclude Include="src\Flow\InventoryItem\InventoryItem.h" />
|
||||||
<ClInclude Include="src\GameScriptColor.h" />
|
<ClInclude Include="src\GameScriptColor.h" />
|
||||||
<ClInclude Include="src\GameScriptFreeFunctions.h" />
|
<ClInclude Include="src\GameScriptFreeFunctions.h" />
|
||||||
<ClInclude Include="src\GameScriptInventoryObject.h" />
|
|
||||||
<ClInclude Include="src\GameScriptLevel.h" />
|
<ClInclude Include="src\GameScriptLevel.h" />
|
||||||
<ClInclude Include="src\GameScriptMirror.h" />
|
<ClInclude Include="src\GameScriptMirror.h" />
|
||||||
<ClInclude Include="src\GameScriptPosition.h" />
|
<ClInclude Include="src\GameScriptPosition.h" />
|
||||||
|
@ -116,6 +116,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Flow\Animations\Animations.cpp" />
|
<ClCompile Include="src\Flow\Animations\Animations.cpp" />
|
||||||
<ClCompile Include="src\Flow\FlowHandler.cpp" />
|
<ClCompile Include="src\Flow\FlowHandler.cpp" />
|
||||||
|
<ClCompile Include="src\Flow\InventoryItem\InventoryItem.cpp" />
|
||||||
<ClCompile Include="src\Inventory\InventoryHandler.cpp" />
|
<ClCompile Include="src\Inventory\InventoryHandler.cpp" />
|
||||||
<ClCompile Include="src\Logic\LogicHandler.cpp" />
|
<ClCompile Include="src\Logic\LogicHandler.cpp" />
|
||||||
<ClCompile Include="src\Objects\AIObject\AIObject.cpp" />
|
<ClCompile Include="src\Objects\AIObject\AIObject.cpp" />
|
||||||
|
@ -128,7 +129,6 @@
|
||||||
<ClCompile Include="src\ScriptInterfaceState.cpp" />
|
<ClCompile Include="src\ScriptInterfaceState.cpp" />
|
||||||
<ClCompile Include="src\GameScriptColor.cpp" />
|
<ClCompile Include="src\GameScriptColor.cpp" />
|
||||||
<ClCompile Include="src\GameScriptFreeFunctions.cpp" />
|
<ClCompile Include="src\GameScriptFreeFunctions.cpp" />
|
||||||
<ClCompile Include="src\GameScriptInventoryObject.cpp" />
|
|
||||||
<ClCompile Include="src\GameScriptLevel.cpp" />
|
<ClCompile Include="src\GameScriptLevel.cpp" />
|
||||||
<ClCompile Include="src\GameScriptMirror.cpp" />
|
<ClCompile Include="src\GameScriptMirror.cpp" />
|
||||||
<ClCompile Include="src\GameScriptPosition.cpp" />
|
<ClCompile Include="src\GameScriptPosition.cpp" />
|
||||||
|
|
|
@ -183,9 +183,6 @@
|
||||||
<ClInclude Include="src\GameScriptFreeFunctions.h">
|
<ClInclude Include="src\GameScriptFreeFunctions.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\GameScriptInventoryObject.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\GameScriptLevel.h">
|
<ClInclude Include="src\GameScriptLevel.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -279,6 +276,9 @@
|
||||||
<ClInclude Include="src\Flow\Animations\Animations.h">
|
<ClInclude Include="src\Flow\Animations\Animations.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Flow\InventoryItem\InventoryItem.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="frameworkandsol.cpp">
|
<ClCompile Include="frameworkandsol.cpp">
|
||||||
|
@ -293,9 +293,6 @@
|
||||||
<ClCompile Include="src\GameScriptColor.cpp">
|
<ClCompile Include="src\GameScriptColor.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\GameScriptInventoryObject.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\GameScriptSkyLayer.cpp">
|
<ClCompile Include="src\GameScriptSkyLayer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -359,6 +356,9 @@
|
||||||
<ClCompile Include="src\Flow\Animations\Animations.cpp">
|
<ClCompile Include="src\Flow\Animations\Animations.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Flow\InventoryItem\InventoryItem.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "ReservedScriptNames.h"
|
#include "ReservedScriptNames.h"
|
||||||
#include "Sound/sound.h"
|
#include "Sound/sound.h"
|
||||||
#include "Game/savegame.h"
|
#include "Game/savegame.h"
|
||||||
#include "GameScriptInventoryObject.h"
|
#include "Flow/InventoryItem/InventoryItem.h"
|
||||||
#include "InventorySlots.h"
|
#include "InventorySlots.h"
|
||||||
#include "Game/gui.h"
|
#include "Game/gui.h"
|
||||||
#include "Objects/ScriptInterfaceObjectsHandler.h"
|
#include "Objects/ScriptInterfaceObjectsHandler.h"
|
||||||
|
@ -104,7 +104,7 @@ Specify which translations in the strings table correspond to which languages.
|
||||||
GameScriptLevel::Register(m_lua);
|
GameScriptLevel::Register(m_lua);
|
||||||
GameScriptSkyLayer::Register(m_lua);
|
GameScriptSkyLayer::Register(m_lua);
|
||||||
GameScriptMirror::Register(m_lua);
|
GameScriptMirror::Register(m_lua);
|
||||||
GameScriptInventoryObject::Register(m_lua);
|
InventoryItem::Register(table_flow);
|
||||||
GameScriptSettings::Register(m_lua);
|
GameScriptSettings::Register(m_lua);
|
||||||
Animations::Register(table_flow);
|
Animations::Register(table_flow);
|
||||||
GameScriptColor::Register(m_lua);
|
GameScriptColor::Register(m_lua);
|
||||||
|
@ -244,7 +244,7 @@ bool FlowHandler::DoFlow()
|
||||||
// Prepare inventory objects table
|
// Prepare inventory objects table
|
||||||
for (size_t i = 0; i < level->InventoryObjects.size(); i++)
|
for (size_t i = 0; i < level->InventoryObjects.size(); i++)
|
||||||
{
|
{
|
||||||
GameScriptInventoryObject* obj = &level->InventoryObjects[i];
|
InventoryItem* obj = &level->InventoryObjects[i];
|
||||||
if (obj->slot >= 0 && obj->slot < INVENTORY_TABLE_SIZE)
|
if (obj->slot >= 0 && obj->slot < INVENTORY_TABLE_SIZE)
|
||||||
{
|
{
|
||||||
InventoryObject* invObj = &inventry_objects_list[obj->slot];
|
InventoryObject* invObj = &inventry_objects_list[obj->slot];
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "frameworkandsol.h"
|
#include "frameworkandsol.h"
|
||||||
#include "GameScriptInventoryObject.h"
|
#include "InventoryItem.h"
|
||||||
#include "ScriptAssert.h"
|
#include "ScriptAssert.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/***
|
/***
|
||||||
Represents the properties of an object as it appears in the inventory.
|
Represents the properties of an object as it appears in the inventory.
|
||||||
|
|
||||||
@pregameclass InventoryObject
|
@tenclass Flow.InventoryItem
|
||||||
@pragma nostrip
|
@pragma nostrip
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ associated getters and setters.
|
||||||
@tparam ItemAction action is this usable, equippable, or examinable?
|
@tparam ItemAction action is this usable, equippable, or examinable?
|
||||||
@return an InventoryObject
|
@return an InventoryObject
|
||||||
*/
|
*/
|
||||||
GameScriptInventoryObject::GameScriptInventoryObject(std::string const& a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, RotationFlags a_rotationFlags, int a_meshBits, ItemOptions a_action) :
|
InventoryItem::InventoryItem(std::string const& a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, RotationFlags a_rotationFlags, int a_meshBits, ItemOptions a_action) :
|
||||||
name{ a_name },
|
name{ a_name },
|
||||||
slot{ a_slot.m_pair.second },
|
slot{ a_slot.m_pair.second },
|
||||||
yOffset{ a_yOffset },
|
yOffset{ a_yOffset },
|
||||||
|
@ -41,37 +41,37 @@ GameScriptInventoryObject::GameScriptInventoryObject(std::string const& a_name,
|
||||||
SetAction(a_action);
|
SetAction(a_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScriptInventoryObject::Register(sol::state * lua)
|
void InventoryItem::Register(sol::table & parent)
|
||||||
{
|
{
|
||||||
lua->new_usertype<GameScriptInventoryObject>("InventoryObject",
|
parent.new_usertype<InventoryItem>("InventoryObject",
|
||||||
sol::constructors<GameScriptInventoryObject(std::string const &, ItemEnumPair, short, float, GameScriptRotation const &, RotationFlags, int, ItemOptions), GameScriptInventoryObject()>(),
|
sol::constructors<InventoryItem(std::string const &, ItemEnumPair, short, float, GameScriptRotation const &, RotationFlags, int, ItemOptions), InventoryItem()>(),
|
||||||
/*** (string) string key for the item's (localised) name. Corresponds to an entry in strings.lua.
|
/*** (string) string key for the item's (localised) name. Corresponds to an entry in strings.lua.
|
||||||
@mem nameKey
|
@mem nameKey
|
||||||
*/
|
*/
|
||||||
"nameKey", &GameScriptInventoryObject::name,
|
"nameKey", &InventoryItem::name,
|
||||||
|
|
||||||
/*** (@{InvItem}) slot of item whose inventory display properties you wish to change
|
/*** (@{InvItem}) slot of item whose inventory display properties you wish to change
|
||||||
@mem slot
|
@mem slot
|
||||||
*/
|
*/
|
||||||
"slot", sol::property(&GameScriptInventoryObject::SetSlot),
|
"slot", sol::property(&InventoryItem::SetSlot),
|
||||||
|
|
||||||
/*** (float) y-axis offset (positive values will move the item lower).
|
/*** (float) y-axis offset (positive values will move the item lower).
|
||||||
A value of about 100 will cause the item to display directly below its usual position.
|
A value of about 100 will cause the item to display directly below its usual position.
|
||||||
@mem yOffset
|
@mem yOffset
|
||||||
*/
|
*/
|
||||||
"yOffset", &GameScriptInventoryObject::yOffset,
|
"yOffset", &InventoryItem::yOffset,
|
||||||
|
|
||||||
/*** (float) Item's size when displayed in the inventory as a multiple of its "regular" size.
|
/*** (float) Item's size when displayed in the inventory as a multiple of its "regular" size.
|
||||||
A value of 0.5 will cause the item to render at half the size,
|
A value of 0.5 will cause the item to render at half the size,
|
||||||
and a value of 2 will cause the item to render at twice the size.
|
and a value of 2 will cause the item to render at twice the size.
|
||||||
@mem scale
|
@mem scale
|
||||||
*/
|
*/
|
||||||
"scale", &GameScriptInventoryObject::scale,
|
"scale", &InventoryItem::scale,
|
||||||
|
|
||||||
/*** (@{Rotation}) Item's rotation about its origin when displayed in the inventory.
|
/*** (@{Rotation}) Item's rotation about its origin when displayed in the inventory.
|
||||||
@mem rot
|
@mem rot
|
||||||
*/
|
*/
|
||||||
"rot", &GameScriptInventoryObject::rot,
|
"rot", &InventoryItem::rot,
|
||||||
|
|
||||||
/*** (RotationAxis) Axis to rotate about when the item is being looked at in the inventory.
|
/*** (RotationAxis) Axis to rotate about when the item is being looked at in the inventory.
|
||||||
Note that this is entirely separate from the `rot` field described above.
|
Note that this is entirely separate from the `rot` field described above.
|
||||||
|
@ -79,12 +79,12 @@ Must be RotationAxis.X, RotationAxis.Y or RotationAxis.Z.
|
||||||
e.g. `myItem.rotAxisWhenCurrent = RotationAxis.X`
|
e.g. `myItem.rotAxisWhenCurrent = RotationAxis.X`
|
||||||
@mem rotAxisWhenCurrent
|
@mem rotAxisWhenCurrent
|
||||||
*/
|
*/
|
||||||
"rotAxisWhenCurrent", &GameScriptInventoryObject::rotationFlags,
|
"rotAxisWhenCurrent", &InventoryItem::rotationFlags,
|
||||||
|
|
||||||
/*** (int) __Not currently implemented__ (will have no effect regardless of what you set it to)
|
/*** (int) __Not currently implemented__ (will have no effect regardless of what you set it to)
|
||||||
@mem meshBits
|
@mem meshBits
|
||||||
*/
|
*/
|
||||||
"meshBits", &GameScriptInventoryObject::meshBits,
|
"meshBits", &InventoryItem::meshBits,
|
||||||
|
|
||||||
/*** (ItemAction) What can the player do with the item?
|
/*** (ItemAction) What can the player do with the item?
|
||||||
Must be one of:
|
Must be one of:
|
||||||
|
@ -94,12 +94,12 @@ Must be one of:
|
||||||
e.g. `myItem.action = ItemAction.EXAMINE`
|
e.g. `myItem.action = ItemAction.EXAMINE`
|
||||||
@mem action
|
@mem action
|
||||||
*/
|
*/
|
||||||
"action", sol::property(&GameScriptInventoryObject::SetAction)
|
"action", sol::property(&InventoryItem::SetAction)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add validation so the user can't choose something unimplemented
|
// Add validation so the user can't choose something unimplemented
|
||||||
void GameScriptInventoryObject::SetAction(ItemOptions a_action)
|
void InventoryItem::SetAction(ItemOptions a_action)
|
||||||
{
|
{
|
||||||
bool isSupported = (a_action == ItemOptions::OPT_EQUIP) ||
|
bool isSupported = (a_action == ItemOptions::OPT_EQUIP) ||
|
||||||
(a_action == ItemOptions::OPT_USE) ||
|
(a_action == ItemOptions::OPT_USE) ||
|
||||||
|
@ -117,7 +117,7 @@ void GameScriptInventoryObject::SetAction(ItemOptions a_action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScriptInventoryObject::SetSlot(ItemEnumPair a_slot)
|
void InventoryItem::SetSlot(ItemEnumPair a_slot)
|
||||||
{
|
{
|
||||||
slot = a_slot.m_pair.second;
|
slot = a_slot.m_pair.second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace sol {
|
||||||
class state;
|
class state;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GameScriptInventoryObject
|
struct InventoryItem
|
||||||
{
|
{
|
||||||
std::string name{};
|
std::string name{};
|
||||||
InventoryObjectTypes slot{ INV_OBJECT_PISTOLS };
|
InventoryObjectTypes slot{ INV_OBJECT_PISTOLS };
|
||||||
|
@ -31,10 +31,10 @@ struct GameScriptInventoryObject
|
||||||
int meshBits{ 0 };
|
int meshBits{ 0 };
|
||||||
ItemOptions action{ ItemOptions::OPT_USE };
|
ItemOptions action{ ItemOptions::OPT_USE };
|
||||||
|
|
||||||
GameScriptInventoryObject() = default;
|
InventoryItem() = default;
|
||||||
GameScriptInventoryObject(std::string const & a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, RotationFlags a_rotationFlags, int a_meshBits, ItemOptions a_actions);
|
InventoryItem(std::string const & a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, RotationFlags a_rotationFlags, int a_meshBits, ItemOptions a_actions);
|
||||||
|
|
||||||
static void Register(sol::state* lua);
|
static void Register(sol::table& lua);
|
||||||
|
|
||||||
void SetAction(ItemOptions a_action);
|
void SetAction(ItemOptions a_action);
|
||||||
void SetSlot(ItemEnumPair a_slot);
|
void SetSlot(ItemEnumPair a_slot);
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include "GameScriptSkyLayer.h"
|
#include "GameScriptSkyLayer.h"
|
||||||
#include "GameScriptMirror.h"
|
#include "GameScriptMirror.h"
|
||||||
#include "GameScriptColor.h"
|
#include "GameScriptColor.h"
|
||||||
#include "GameScriptInventoryObject.h"
|
|
||||||
#include <GameScriptFog.h>
|
#include <GameScriptFog.h>
|
||||||
#include "ScriptInterfaceLevel.h"
|
#include "ScriptInterfaceLevel.h"
|
||||||
|
#include "Flow/InventoryItem/InventoryItem.h"
|
||||||
|
|
||||||
static const std::unordered_map<std::string, WeatherType> kWeatherTypes
|
static const std::unordered_map<std::string, WeatherType> kWeatherTypes
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ struct GameScriptLevel : public ScriptInterfaceLevel
|
||||||
GameScriptMirror Mirror;
|
GameScriptMirror Mirror;
|
||||||
int LevelFarView{ 0 };
|
int LevelFarView{ 0 };
|
||||||
bool UnlimitedAir{ false };
|
bool UnlimitedAir{ false };
|
||||||
std::vector<GameScriptInventoryObject> InventoryObjects;
|
std::vector<InventoryItem> InventoryObjects;
|
||||||
|
|
||||||
float GetWeatherStrength() const override;
|
float GetWeatherStrength() const override;
|
||||||
bool GetSkyLayerEnabled(int index) const override;
|
bool GetSkyLayerEnabled(int index) const override;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ScriptAssert.h"
|
#include "ScriptAssert.h"
|
||||||
#include "GameScriptPosition.h"
|
#include "GameScriptPosition.h"
|
||||||
#include "ScriptUtil.h"
|
#include "ScriptUtil.h"
|
||||||
|
#include "ReservedScriptNames.h"
|
||||||
/***
|
/***
|
||||||
AI object
|
AI object
|
||||||
|
|
||||||
|
@ -11,11 +12,8 @@ AI object
|
||||||
@pragma nostrip
|
@pragma nostrip
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static auto index_error = index_error_maker(AIObject, ScriptReserved_AIObject);
|
||||||
constexpr auto LUA_CLASS_NAME{ "AIObject" };
|
static auto newindex_error = newindex_error_maker(AIObject, ScriptReserved_AIObject);
|
||||||
|
|
||||||
static auto index_error = index_error_maker(AIObject, LUA_CLASS_NAME);
|
|
||||||
static auto newindex_error = newindex_error_maker(AIObject, LUA_CLASS_NAME);
|
|
||||||
|
|
||||||
AIObject::AIObject(AI_OBJECT & ref, bool temp) : m_aiObject{ref}, m_temporary{ temp }
|
AIObject::AIObject(AI_OBJECT & ref, bool temp) : m_aiObject{ref}, m_temporary{ temp }
|
||||||
{};
|
{};
|
||||||
|
@ -29,7 +27,7 @@ AIObject::~AIObject() {
|
||||||
|
|
||||||
void AIObject::Register(sol::table & parent)
|
void AIObject::Register(sol::table & parent)
|
||||||
{
|
{
|
||||||
parent.new_usertype<AIObject>(LUA_CLASS_NAME,
|
parent.new_usertype<AIObject>(ScriptReserved_AIObject,
|
||||||
sol::meta_function::index, index_error,
|
sol::meta_function::index, index_error,
|
||||||
sol::meta_function::new_index, newindex_error,
|
sol::meta_function::new_index, newindex_error,
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue