-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventoryPickup.cpp
69 lines (55 loc) · 1.38 KB
/
InventoryPickup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "InventoryPickup.h"
InventoryPickup::InventoryPickup(std::shared_ptr<TypeInventory> inventoryType) : Inventory(inventoryType)
{
clearInv();
}
void InventoryPickup::clearInv(void)
{
maxRows = 0;
maxColumns = 1;
maxSize = 0;
groundItemsIndex = 0;
groundItems.clear();
inv.clear();
//groundItems.push_back(nullptr);
//inv.push_back(nullptr);
}
void InventoryPickup::increaseRowCount(void)
{
maxRows++;
maxSize = maxRows * maxColumns;
groundItems.push_back(nullptr);
inv.push_back(nullptr);
}
void InventoryPickup::addItemStack(std::shared_ptr<GroundItemStack> groundItem, std::shared_ptr<Item> item)
{
increaseRowCount();
groundItems[groundItemsIndex] = groundItem;
for(int i = 0; i < groundItem->getAmount(); i++)
{
addItem(item);
}
groundItemsIndex++;
//std::cout << "groundItems count of groundItem: " << std::count(groundItems.begin(), groundItems.end(), groundItem) << std::endl;
//bool itemExists = false;
/*for(auto tmpGroundItem : groundItems)
{
if(tmpGroundItem != nullptr)
if(groundItem->getId() == tmpGroundItem->getId())
itemExists = true;
}
if(!itemExists)
{
increaseRowCount();
groundItems[groundItemsIndex] = groundItem;
for(int i = 0; i < groundItem->getAmount(); i++)
{
addItem(item);
}
groundItemsIndex++;
}*/
}
std::vector<std::shared_ptr<GroundItemStack> > InventoryPickup::getGroundItems(void)
{
return groundItems;
}