mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 20:46:47 +03:00
Change InventoryAdd/Remove/GetCount/SetCount and GameScriptInventoryObject to use ItemEnumPair.
This commit is contained in:
parent
5458e7a67e
commit
d3742cb87e
3 changed files with 14 additions and 25 deletions
|
@ -13,7 +13,6 @@
|
|||
#include "effect2.h"
|
||||
#include "pickup.h"
|
||||
#include "newinv2.h"
|
||||
#include "InventorySlots.h"
|
||||
#include "ObjectIDs.h"
|
||||
|
||||
#ifndef _DEBUG
|
||||
|
@ -109,25 +108,25 @@ static void Earthquake(int strength)
|
|||
}
|
||||
|
||||
// Inventory
|
||||
static void InventoryAdd(GAME_OBJECT_ID slot, sol::optional<int> count)
|
||||
static void InventoryAdd(ItemEnumPair slot, sol::optional<int> count)
|
||||
{
|
||||
PickedUpObject(slot, count.value_or(0));
|
||||
PickedUpObject(slot.m_pair.first, count.value_or(0));
|
||||
}
|
||||
|
||||
static void InventoryRemove(GAME_OBJECT_ID slot, sol::optional<int> count)
|
||||
static void InventoryRemove(ItemEnumPair slot, sol::optional<int> count)
|
||||
{
|
||||
RemoveObjectFromInventory(static_cast<GAME_OBJECT_ID>(inventry_objects_list[slot].object_number), count.value_or(0));
|
||||
RemoveObjectFromInventory(slot.m_pair.first, count.value_or(0));
|
||||
}
|
||||
|
||||
static int InventoryGetCount(GAME_OBJECT_ID slot)
|
||||
static int InventoryGetCount(ItemEnumPair slot)
|
||||
{
|
||||
return GetInventoryCount(slot);
|
||||
return GetInventoryCount(slot.m_pair.first);
|
||||
}
|
||||
|
||||
static void InventorySetCount(GAME_OBJECT_ID slot, int count)
|
||||
static void InventorySetCount(ItemEnumPair slot, int count)
|
||||
{
|
||||
// add the amount we'd need to add to get to count
|
||||
int currAmt = GetInventoryCount(slot);
|
||||
int currAmt = GetInventoryCount(slot.m_pair.first);
|
||||
InventoryAdd(slot, count - currAmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
#include "framework.h"
|
||||
#include "GameScriptInventoryObject.h"
|
||||
|
||||
GameScriptInventoryObject::GameScriptInventoryObject(std::string name, short slot, float yOffset, float scale, float xRot, float yRot, float zRot, short rotationFlags, int meshBits, __int64 operation)
|
||||
{
|
||||
this->name = name;
|
||||
this->slot = slot;
|
||||
this->yOffset = yOffset;
|
||||
this->scale = scale;
|
||||
this->xRot = xRot;
|
||||
this->yRot = yRot;
|
||||
this->zRot = zRot;
|
||||
this->rotationFlags = rotationFlags;
|
||||
this->meshBits = meshBits;
|
||||
this->operation = operation;
|
||||
}
|
||||
GameScriptInventoryObject::GameScriptInventoryObject(std::string const& name, ItemEnumPair slot, float yOffset, float scale, float xRot, float yRot, float zRot, short rotationFlags, int meshBits, __int64 operation) : name{ name }, slot{ slot.m_pair.second }, yOffset{ yOffset }, scale{ scale }, xRot{ xRot }, yRot{ yRot }, zRot{ zRot }, rotationFlags{ rotationFlags }, meshBits{ meshBits }, operation{ operation }
|
||||
{}
|
||||
|
||||
void GameScriptInventoryObject::Register(sol::state * lua)
|
||||
{
|
||||
lua->new_usertype<GameScriptInventoryObject>("InventoryObject",
|
||||
sol::constructors<GameScriptInventoryObject(std::string, short, float, float, float, float, float, short, int, __int64)>(),
|
||||
sol::constructors<GameScriptInventoryObject(std::string const &, ItemEnumPair, float, float, float, float, float, short, int, __int64)>(),
|
||||
"name", &GameScriptInventoryObject::name,
|
||||
"yOffset", &GameScriptInventoryObject::yOffset,
|
||||
"scale", &GameScriptInventoryObject::scale,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "ItemEnumPair.h"
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
|
@ -8,7 +9,7 @@ namespace sol {
|
|||
struct GameScriptInventoryObject
|
||||
{
|
||||
std::string name;
|
||||
short slot;
|
||||
inv_objects slot;
|
||||
float yOffset;
|
||||
float scale;
|
||||
float xRot;
|
||||
|
@ -18,7 +19,7 @@ struct GameScriptInventoryObject
|
|||
int meshBits;
|
||||
__int64 operation;
|
||||
|
||||
GameScriptInventoryObject(std::string name, short slot, float yOffset, float scale, float xRot, float yRot, float zRot, short rotationFlags, int meshBits, __int64 operation);
|
||||
GameScriptInventoryObject(std::string const & name, ItemEnumPair slot, float yOffset, float scale, float xRot, float yRot, float zRot, short rotationFlags, int meshBits, __int64 operation);
|
||||
|
||||
static void Register(sol::state* lua);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue