forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemGroup.h
111 lines (106 loc) · 3.27 KB
/
ItemGroup.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef ITEMGROUP_H
#define ITEMGROUP_H
#include <vector>
#include "GameItem.h"
#include "LsbObject.h"
#include "LsbReader.h"
class ItemGroup
{
std::vector<GameItem *> items;
std::map<unsigned long, GameItem *> renderSlotMap;
std::map<unsigned short, GameItem *> internalSlotMap;
unsigned long largestRenderSlot = 0;
unsigned short largestInternalSlot = 0;
unsigned long largestEquipmentSlot = 0;
unsigned long largestConsumableSlot = 0;
unsigned long largestMagicalSlot = 0;
unsigned long largestIngredientSlot = 0;
unsigned long largestKeysSlot = 0;
unsigned long largestMiscSlot = 0;
public:
ItemGroup();
std::vector<GameItem *>& getItems() {
return items;
}
void addItem(GameItem *item) {
if (item != 0 && item->getObject() != 0) {
LsbObject *slotObject = item->getObject()->lookupByUniquePath("Slot");
unsigned short internalSlot = SLOT_INVALID;
if (slotObject != 0) {
internalSlot = *((unsigned short *)slotObject->getData());
}
if (internalSlot != SLOT_INVALID) {
if (internalSlot > largestInternalSlot) {
largestInternalSlot = internalSlot;
}
internalSlotMap[internalSlot] = item;
}
}
unsigned long renderSlot = item->getRenderSlot();
if (renderSlot > largestRenderSlot) {
if (renderSlot != SLOT_INVALID) {
largestRenderSlot = renderSlot;
}
}
unsigned long equipmentSlot = item->getEquipmentSlot();
if (equipmentSlot > largestEquipmentSlot) {
largestEquipmentSlot = equipmentSlot;
}
unsigned long consumableSlot = item->getConsumableSlot();
if (consumableSlot > largestConsumableSlot) {
largestConsumableSlot = consumableSlot;
}
unsigned long magicalSlot = item->getMagicalSlot();
if (magicalSlot > largestMagicalSlot) {
largestMagicalSlot = magicalSlot;
}
unsigned long ingredientSlot = item->getIngredientSlot();
if (ingredientSlot > largestIngredientSlot) {
largestIngredientSlot = ingredientSlot;
}
unsigned long keysSlot = item->getKeysSlot();
if (keysSlot > largestKeysSlot) {
largestKeysSlot = keysSlot;
}
unsigned long miscSlot = item->getMiscSlot();
if (miscSlot > largestMiscSlot) {
largestMiscSlot = miscSlot;
}
renderSlotMap[renderSlot] = item;
items.push_back(item);
}
bool removeItem(GameItem *item) {
for (int i=0; i<items.size(); ++i) {
if (items[i] == item) {
items.erase(items.begin() + i);
return true;
}
}
return false;
}
GameItem *getItemByRenderSlot(unsigned long renderSlot) {
if (renderSlotMap.find(renderSlot) != renderSlotMap.end()) {
return renderSlotMap[renderSlot];
}
return 0;
}
unsigned long getLargestRenderSlot() {
return largestRenderSlot;
}
unsigned short getLargestInternalSlot() {
return largestInternalSlot;
}
unsigned long getLargestEquipmentSlot() const;
void setLargestEquipmentSlot(unsigned long value);
unsigned long getLargestConsumableSlot() const;
void setLargestConsumableSlot(unsigned long value);
unsigned long getLargestMagicalSlot() const;
void setLargestMagicalSlot(unsigned long value);
unsigned long getLargestIngredientSlot() const;
void setLargestIngredientSlot(unsigned long value);
unsigned long getLargestKeysSlot() const;
void setLargestKeysSlot(unsigned long value);
unsigned long getLargestMiscSlot() const;
void setLargestMiscSlot(unsigned long value);
};
#endif // ITEMGROUP_H