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\Flow\Animations\Animations.h" />
|
||||
<ClInclude Include="src\Flow\FlowHandler.h" />
|
||||
<ClInclude Include="src\Flow\InventoryItem\InventoryItem.h" />
|
||||
<ClInclude Include="src\GameScriptColor.h" />
|
||||
<ClInclude Include="src\GameScriptFreeFunctions.h" />
|
||||
<ClInclude Include="src\GameScriptInventoryObject.h" />
|
||||
<ClInclude Include="src\GameScriptLevel.h" />
|
||||
<ClInclude Include="src\GameScriptMirror.h" />
|
||||
<ClInclude Include="src\GameScriptPosition.h" />
|
||||
|
@ -116,6 +116,7 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="src\Flow\Animations\Animations.cpp" />
|
||||
<ClCompile Include="src\Flow\FlowHandler.cpp" />
|
||||
<ClCompile Include="src\Flow\InventoryItem\InventoryItem.cpp" />
|
||||
<ClCompile Include="src\Inventory\InventoryHandler.cpp" />
|
||||
<ClCompile Include="src\Logic\LogicHandler.cpp" />
|
||||
<ClCompile Include="src\Objects\AIObject\AIObject.cpp" />
|
||||
|
@ -128,7 +129,6 @@
|
|||
<ClCompile Include="src\ScriptInterfaceState.cpp" />
|
||||
<ClCompile Include="src\GameScriptColor.cpp" />
|
||||
<ClCompile Include="src\GameScriptFreeFunctions.cpp" />
|
||||
<ClCompile Include="src\GameScriptInventoryObject.cpp" />
|
||||
<ClCompile Include="src\GameScriptLevel.cpp" />
|
||||
<ClCompile Include="src\GameScriptMirror.cpp" />
|
||||
<ClCompile Include="src\GameScriptPosition.cpp" />
|
||||
|
|
|
@ -183,9 +183,6 @@
|
|||
<ClInclude Include="src\GameScriptFreeFunctions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\GameScriptInventoryObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\GameScriptLevel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -279,6 +276,9 @@
|
|||
<ClInclude Include="src\Flow\Animations\Animations.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Flow\InventoryItem\InventoryItem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="frameworkandsol.cpp">
|
||||
|
@ -293,9 +293,6 @@
|
|||
<ClCompile Include="src\GameScriptColor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptInventoryObject.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptSkyLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -359,6 +356,9 @@
|
|||
<ClCompile Include="src\Flow\Animations\Animations.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Flow\InventoryItem\InventoryItem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "ReservedScriptNames.h"
|
||||
#include "Sound/sound.h"
|
||||
#include "Game/savegame.h"
|
||||
#include "GameScriptInventoryObject.h"
|
||||
#include "Flow/InventoryItem/InventoryItem.h"
|
||||
#include "InventorySlots.h"
|
||||
#include "Game/gui.h"
|
||||
#include "Objects/ScriptInterfaceObjectsHandler.h"
|
||||
|
@ -104,7 +104,7 @@ Specify which translations in the strings table correspond to which languages.
|
|||
GameScriptLevel::Register(m_lua);
|
||||
GameScriptSkyLayer::Register(m_lua);
|
||||
GameScriptMirror::Register(m_lua);
|
||||
GameScriptInventoryObject::Register(m_lua);
|
||||
InventoryItem::Register(table_flow);
|
||||
GameScriptSettings::Register(m_lua);
|
||||
Animations::Register(table_flow);
|
||||
GameScriptColor::Register(m_lua);
|
||||
|
@ -244,7 +244,7 @@ bool FlowHandler::DoFlow()
|
|||
// Prepare inventory objects table
|
||||
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)
|
||||
{
|
||||
InventoryObject* invObj = &inventry_objects_list[obj->slot];
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "frameworkandsol.h"
|
||||
#include "GameScriptInventoryObject.h"
|
||||
#include "InventoryItem.h"
|
||||
#include "ScriptAssert.h"
|
||||
#include <string>
|
||||
|
||||
/***
|
||||
Represents the properties of an object as it appears in the inventory.
|
||||
|
||||
@pregameclass InventoryObject
|
||||
@tenclass Flow.InventoryItem
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
|
@ -29,7 +29,7 @@ associated getters and setters.
|
|||
@tparam ItemAction action is this usable, equippable, or examinable?
|
||||
@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 },
|
||||
slot{ a_slot.m_pair.second },
|
||||
yOffset{ a_yOffset },
|
||||
|
@ -41,37 +41,37 @@ GameScriptInventoryObject::GameScriptInventoryObject(std::string const& a_name,
|
|||
SetAction(a_action);
|
||||
}
|
||||
|
||||
void GameScriptInventoryObject::Register(sol::state * lua)
|
||||
void InventoryItem::Register(sol::table & parent)
|
||||
{
|
||||
lua->new_usertype<GameScriptInventoryObject>("InventoryObject",
|
||||
sol::constructors<GameScriptInventoryObject(std::string const &, ItemEnumPair, short, float, GameScriptRotation const &, RotationFlags, int, ItemOptions), GameScriptInventoryObject()>(),
|
||||
parent.new_usertype<InventoryItem>("InventoryObject",
|
||||
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.
|
||||
@mem nameKey
|
||||
*/
|
||||
"nameKey", &GameScriptInventoryObject::name,
|
||||
"nameKey", &InventoryItem::name,
|
||||
|
||||
/*** (@{InvItem}) slot of item whose inventory display properties you wish to change
|
||||
@mem slot
|
||||
*/
|
||||
"slot", sol::property(&GameScriptInventoryObject::SetSlot),
|
||||
"slot", sol::property(&InventoryItem::SetSlot),
|
||||
|
||||
/*** (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.
|
||||
@mem yOffset
|
||||
*/
|
||||
"yOffset", &GameScriptInventoryObject::yOffset,
|
||||
"yOffset", &InventoryItem::yOffset,
|
||||
|
||||
/*** (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,
|
||||
and a value of 2 will cause the item to render at twice the size.
|
||||
@mem scale
|
||||
*/
|
||||
"scale", &GameScriptInventoryObject::scale,
|
||||
"scale", &InventoryItem::scale,
|
||||
|
||||
/*** (@{Rotation}) Item's rotation about its origin when displayed in the inventory.
|
||||
@mem rot
|
||||
*/
|
||||
"rot", &GameScriptInventoryObject::rot,
|
||||
"rot", &InventoryItem::rot,
|
||||
|
||||
/*** (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.
|
||||
|
@ -79,12 +79,12 @@ Must be RotationAxis.X, RotationAxis.Y or RotationAxis.Z.
|
|||
e.g. `myItem.rotAxisWhenCurrent = RotationAxis.X`
|
||||
@mem rotAxisWhenCurrent
|
||||
*/
|
||||
"rotAxisWhenCurrent", &GameScriptInventoryObject::rotationFlags,
|
||||
"rotAxisWhenCurrent", &InventoryItem::rotationFlags,
|
||||
|
||||
/*** (int) __Not currently implemented__ (will have no effect regardless of what you set it to)
|
||||
@mem meshBits
|
||||
*/
|
||||
"meshBits", &GameScriptInventoryObject::meshBits,
|
||||
"meshBits", &InventoryItem::meshBits,
|
||||
|
||||
/*** (ItemAction) What can the player do with the item?
|
||||
Must be one of:
|
||||
|
@ -94,12 +94,12 @@ Must be one of:
|
|||
e.g. `myItem.action = ItemAction.EXAMINE`
|
||||
@mem action
|
||||
*/
|
||||
"action", sol::property(&GameScriptInventoryObject::SetAction)
|
||||
"action", sol::property(&InventoryItem::SetAction)
|
||||
);
|
||||
}
|
||||
|
||||
// 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) ||
|
||||
(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;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace sol {
|
|||
class state;
|
||||
}
|
||||
|
||||
struct GameScriptInventoryObject
|
||||
struct InventoryItem
|
||||
{
|
||||
std::string name{};
|
||||
InventoryObjectTypes slot{ INV_OBJECT_PISTOLS };
|
||||
|
@ -31,10 +31,10 @@ struct GameScriptInventoryObject
|
|||
int meshBits{ 0 };
|
||||
ItemOptions action{ ItemOptions::OPT_USE };
|
||||
|
||||
GameScriptInventoryObject() = 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() = default;
|
||||
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 SetSlot(ItemEnumPair a_slot);
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "GameScriptSkyLayer.h"
|
||||
#include "GameScriptMirror.h"
|
||||
#include "GameScriptColor.h"
|
||||
#include "GameScriptInventoryObject.h"
|
||||
#include <GameScriptFog.h>
|
||||
#include "ScriptInterfaceLevel.h"
|
||||
#include "Flow/InventoryItem/InventoryItem.h"
|
||||
|
||||
static const std::unordered_map<std::string, WeatherType> kWeatherTypes
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ struct GameScriptLevel : public ScriptInterfaceLevel
|
|||
GameScriptMirror Mirror;
|
||||
int LevelFarView{ 0 };
|
||||
bool UnlimitedAir{ false };
|
||||
std::vector<GameScriptInventoryObject> InventoryObjects;
|
||||
std::vector<InventoryItem> InventoryObjects;
|
||||
|
||||
float GetWeatherStrength() const override;
|
||||
bool GetSkyLayerEnabled(int index) const override;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ScriptAssert.h"
|
||||
#include "GameScriptPosition.h"
|
||||
#include "ScriptUtil.h"
|
||||
#include "ReservedScriptNames.h"
|
||||
/***
|
||||
AI object
|
||||
|
||||
|
@ -11,11 +12,8 @@ AI object
|
|||
@pragma nostrip
|
||||
*/
|
||||
|
||||
|
||||
constexpr auto LUA_CLASS_NAME{ "AIObject" };
|
||||
|
||||
static auto index_error = index_error_maker(AIObject, LUA_CLASS_NAME);
|
||||
static auto newindex_error = newindex_error_maker(AIObject, LUA_CLASS_NAME);
|
||||
static auto index_error = index_error_maker(AIObject, ScriptReserved_AIObject);
|
||||
static auto newindex_error = newindex_error_maker(AIObject, ScriptReserved_AIObject);
|
||||
|
||||
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)
|
||||
{
|
||||
parent.new_usertype<AIObject>(LUA_CLASS_NAME,
|
||||
parent.new_usertype<AIObject>(ScriptReserved_AIObject,
|
||||
sol::meta_function::index, index_error,
|
||||
sol::meta_function::new_index, newindex_error,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue