ScummVM API documentation
container.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA8_WORLD_CONTAINER_H
23 #define ULTIMA8_WORLD_CONTAINER_H
24 
25 #include "common/list.h"
26 #include "ultima/ultima8/world/item.h"
27 #include "ultima/ultima8/usecode/intrinsics.h"
28 #include "ultima/ultima8/misc/classtype.h"
29 
30 namespace Ultima {
31 namespace Ultima8 {
32 
33 class UCList;
34 
35 class Container : public Item {
36  friend class ItemFactory;
37  friend class ContainerGump;
38  friend class PaperdollGump;
39 public:
40  Container();
41  ~Container() override;
42 
43  ENABLE_RUNTIME_CLASSTYPE()
44 
45 
46  virtual bool CanAddItem(Item *item, bool checkwghtvol = false);
50 
55  virtual bool addItem(Item *item, bool checkwghtvol = false);
56 
60  virtual bool removeItem(Item *item);
61 
65  virtual bool moveItemToEnd(Item *item);
66 
70  void removeContents();
71 
73  void destroyContents();
74 
76  void setFlagRecursively(uint32 mask) override;
77 
83  void containerSearch(UCList *itemlist, const uint8 *loopscript,
84  uint32 scriptsize, bool recurse) const;
85 
89  Item *getFirstItemWithShape(uint16 shapeno, bool recurse);
90 
94  void getItemsWithShapeFamily(Common::Array<Item *> &itemlist, uint16 family, bool recurse);
95 
98  uint32 getTotalWeight() const override;
99 
101  virtual uint32 getCapacity() const;
102 
104  virtual uint32 getContentVolume() const;
105 
108  ObjId assignObjId() override;
109 
111  void clearObjId() override;
112 
114  void destroy(bool delnow = false) override;
115 
116  Common::String dumpInfo() const override;
117 
118  bool loadData(Common::ReadStream *rs, uint32 version);
119  void saveData(Common::WriteStream *ws) override;
120 
121  INTRINSIC(I_removeContents);
122  INTRINSIC(I_destroyContents);
123 
124 protected:
125  Common::List<Item *> _contents;
126 };
127 
128 } // End of namespace Ultima8
129 } // End of namespace Ultima
130 
131 #endif
ObjId assignObjId() override
Definition: str.h:59
virtual uint32 getCapacity() const
Get the container&#39;s capacity.
Item * getFirstItemWithShape(uint16 shapeno, bool recurse)
Definition: stream.h:77
Definition: container_gump.h:37
Definition: array.h:52
Definition: item.h:42
virtual bool moveItemToEnd(Item *item)
void clearObjId() override
Clear objIDs of self and contents.
Definition: list.h:44
uint32 getTotalWeight() const override
Definition: detection.h:27
Common::String dumpInfo() const override
dump some info about this object to a string
Definition: paperdoll_gump.h:36
virtual bool removeItem(Item *item)
void getItemsWithShapeFamily(Common::Array< Item *> &itemlist, uint16 family, bool recurse)
void containerSearch(UCList *itemlist, const uint8 *loopscript, uint32 scriptsize, bool recurse) const
void destroyContents()
Destroy all contents.
virtual uint32 getContentVolume() const
Get the total volume used up by the container&#39;s current contents.
virtual bool addItem(Item *item, bool checkwghtvol=false)
Definition: container.h:35
Definition: uc_list.h:45
void setFlagRecursively(uint32 mask) override
Set flag on container and all its contents recursively.
Definition: stream.h:385
void destroy(bool delnow=false) override
Destroy self.
Definition: item_factory.h:34
virtual bool CanAddItem(Item *item, bool checkwghtvol=false)