1 /* GemRB - Infinity Engine Emulator
2  * Copyright (C) 2003 The GemRB Project
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  *
19  */
20 
21 #ifndef CONTAINER_H
22 #define CONTAINER_H
23 
24 #include <array>
25 
26 #include "Inventory.h"
27 #include "Scriptable/Scriptable.h"
28 #include "Video.h"
29 
30 namespace GemRB {
31 
32 //container flags
33 #define CONT_LOCKED      1
34 //#define CONT_          2 // "disable if no owner" comment from original bg2 source
35 //#define CONT_          4 // "magically locked", probably was meant to prevent lockpicking
36 #define CONT_RESET       8
37 //#define CONT_          16 // "Remove only"
38 #define CONT_DISABLED    (32|128)   //bg2 and pst uses different bits, luckily they are not overlapping
39 
40 class GEM_EXPORT Container : public Highlightable {
41 public:
42 	Container(void);
43 	~Container(void) override;
44 	void SetContainerLocked(bool lock);
45 	//turns the container to a pile
46 	void DestroyContainer();
47 	//removes an item from the container's inventory
48 	CREItem *RemoveItem(unsigned int idx, unsigned int count);
49 	//adds an item to the container's inventory
50 	int AddItem(CREItem *item);
51 	//draws the ground icons
52 	Region DrawingRegion() const override;
53 	void Draw(bool highlight, const Region &screen, Color tint, BlitFlags flags) const;
54 
55 	int IsOpen() const;
56 	void TryPickLock(const Actor *actor);
57 	void TryBashLock(Actor *actor);
58 	bool TryUnlock(Actor *actor);
59 	void dump() const;
TrapResets()60 	int TrapResets() const override { return Flags & CONT_RESET; }
61 private:
62 	//updates the ground icons for a pile
63 	void RefreshGroundIcons();
64 	void FreeGroundIcons();
65 public:
66 	Point toOpen;
67 	ieWord Type;
68 	ieDword Flags;
69 	ieWord LockDifficulty;
70 	Inventory inventory;
71 	ieStrRef OpenFail;
72 	//these are not saved
73 	std::array<Holder<Sprite2D>, 3> groundicons;
74 	//keyresref is stored in Highlightable
75 };
76 
77 }
78 
79 #endif
80