Otclient
14/8/2020
container.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#ifndef CONTAINER_H
24
#define CONTAINER_H
25
26
#include "
declarations.h
"
27
#include "
item.h
"
28
29
#include <
framework/luaengine/luaobject.h
>
30
31
// @bindclass
32
class
Container
:
public
LuaObject
33
{
34
protected
:
35
Container
(
int
id
,
int
capacity,
const
std::string& name,
const
ItemPtr
& containerItem,
bool
hasParent
,
bool
isUnlocked
,
bool
hasPages
,
int
containerSize,
int
firstIndex);
36
37
public
:
38
ItemPtr
getItem
(
int
slot);
39
std::deque<ItemPtr>
getItems
() {
return
m_items; }
40
int
getItemsCount
() {
return
m_items.size(); }
41
Position
getSlotPosition
(
int
slot) {
return
Position
(0xffff, m_id | 0x40, slot); }
42
int
getId
() {
return
m_id; }
43
int
getCapacity
() {
return
m_capacity; }
44
ItemPtr
getContainerItem
() {
return
m_containerItem; }
45
std::string
getName
() {
return
m_name; }
46
bool
hasParent
() {
return
m_hasParent; }
47
bool
isClosed
() {
return
m_closed; }
48
bool
isUnlocked
() {
return
m_unlocked; }
49
bool
hasPages
() {
return
m_hasPages; }
50
int
getSize
() {
return
m_size; }
51
int
getFirstIndex
() {
return
m_firstIndex; }
52
ItemPtr
findItemById
(
uint
itemId,
int
subType);
53
54
protected
:
55
void
onOpen
(
const
ContainerPtr
& previousContainer);
56
void
onClose
();
57
void
onAddItem
(
const
ItemPtr
& item,
int
slot);
58
void
onAddItems
(
const
std::vector<ItemPtr>& items);
59
void
onUpdateItem
(
int
slot,
const
ItemPtr
& item);
60
void
onRemoveItem
(
int
slot,
const
ItemPtr
& lastItem);
61
62
friend
class
Game
;
63
64
private
:
65
void
updateItemsPositions();
66
67
int
m_id;
68
int
m_capacity;
69
ItemPtr
m_containerItem;
70
std::string m_name;
71
bool
m_hasParent;
72
bool
m_closed;
73
bool
m_unlocked;
74
bool
m_hasPages;
75
int
m_size;
76
int
m_firstIndex;
77
std::deque<ItemPtr> m_items;
78
};
79
80
#endif
Container::onClose
void onClose()
Definition:
container.cpp:52
Container::getContainerItem
ItemPtr getContainerItem()
Definition:
container.h:44
Container::onRemoveItem
void onRemoveItem(int slot, const ItemPtr &lastItem)
Definition:
container.cpp:109
Container::getCapacity
int getCapacity()
Definition:
container.h:43
Container::Container
Container(int id, int capacity, const std::string &name, const ItemPtr &containerItem, bool hasParent, bool isUnlocked, bool hasPages, int containerSize, int firstIndex)
Definition:
container.cpp:26
Container::onOpen
void onOpen(const ContainerPtr &previousContainer)
Definition:
container.cpp:47
Container::findItemById
ItemPtr findItemById(uint itemId, int subType)
Definition:
container.cpp:79
luaobject.h
Container::onAddItems
void onAddItems(const std::vector< ItemPtr > &items)
Definition:
container.cpp:87
declarations.h
uint
unsigned int uint
Definition:
types.h:31
Container::getItem
ItemPtr getItem(int slot)
Definition:
container.cpp:40
Position
Definition:
position.h:33
Container
Definition:
container.h:32
Container::getSize
int getSize()
Definition:
container.h:50
Container::isUnlocked
bool isUnlocked()
Definition:
container.h:48
Container::hasPages
bool hasPages()
Definition:
container.h:49
Container::getFirstIndex
int getFirstIndex()
Definition:
container.h:51
Container::getName
std::string getName()
Definition:
container.h:45
Container::getId
int getId()
Definition:
container.h:42
Container::getSlotPosition
Position getSlotPosition(int slot)
Definition:
container.h:41
Container::onUpdateItem
void onUpdateItem(int slot, const ItemPtr &item)
Definition:
container.cpp:94
stdext::shared_object_ptr< Item >
Container::getItemsCount
int getItemsCount()
Definition:
container.h:40
LuaObject
LuaObject, all script-able classes have it as base.
Definition:
luaobject.h:30
Container::onAddItem
void onAddItem(const ItemPtr &item, int slot)
Definition:
container.cpp:58
Container::isClosed
bool isClosed()
Definition:
container.h:47
Container::getItems
std::deque< ItemPtr > getItems()
Definition:
container.h:39
Container::hasParent
bool hasParent()
Definition:
container.h:46
Game
Definition:
game.h:61
item.h
src
client
container.h
Generated by
1.8.17
For more information visit
https://forum.opentibia.dev/