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 "ultima/ultima8/world/item.h"
26 #include "ultima/shared/std/containers.h"
27 
28 #include "ultima/ultima8/usecode/intrinsics.h"
29 #include "ultima/ultima8/misc/classtype.h"
30 
31 namespace Ultima {
32 namespace Ultima8 {
33 
34 class UCList;
35 
36 class Container : public Item {
37  friend class ItemFactory;
38  friend class ContainerGump;
39  friend class PaperdollGump;
40 public:
41  Container();
42  ~Container() override;
43 
44  ENABLE_RUNTIME_CLASSTYPE()
45 
46 
47  virtual bool CanAddItem(Item *item, bool checkwghtvol = false);
51 
56  virtual bool addItem(Item *item, bool checkwghtvol = false);
57 
61  virtual bool removeItem(Item *item);
62 
66  virtual bool moveItemToEnd(Item *item);
67 
71  void removeContents();
72 
74  void destroyContents();
75 
77  void setFlagRecursively(uint32 mask) override;
78 
84  void containerSearch(UCList *itemlist, const uint8 *loopscript,
85  uint32 scriptsize, bool recurse) const;
86 
90  Item *getFirstItemWithShape(uint16 shapeno, bool recurse);
91 
95  void getItemsWithShapeFamily(Std::vector<Item *> &itemlist, uint16 family, bool recurse);
96 
99  uint32 getTotalWeight() const override;
100 
102  virtual uint32 getCapacity() const;
103 
105  virtual uint32 getContentVolume() const;
106 
109  ObjId assignObjId() override;
110 
112  void clearObjId() override;
113 
115  void destroy(bool delnow = false) override;
116 
117  Common::String dumpInfo() const override;
118 
119  bool loadData(Common::ReadStream *rs, uint32 version);
120  void saveData(Common::WriteStream *ws) override;
121 
122  INTRINSIC(I_removeContents);
123  INTRINSIC(I_destroyContents);
124 
125 protected:
126  Std::list<Item *> _contents;
127 };
128 
129 } // End of namespace Ultima8
130 } // End of namespace Ultima
131 
132 #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: item.h:42
virtual bool moveItemToEnd(Item *item)
void clearObjId() override
Clear objIDs of self and contents.
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:37
virtual bool removeItem(Item *item)
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:36
Definition: uc_list.h:41
Definition: containers.h:200
void setFlagRecursively(uint32 mask) override
Set flag on container and all its contents recursively.
Definition: stream.h:385
void getItemsWithShapeFamily(Std::vector< Item *> &itemlist, uint16 family, bool recurse)
void destroy(bool delnow=false) override
Destroy self.
Definition: containers.h:38
Definition: item_factory.h:32
virtual bool CanAddItem(Item *item, bool checkwghtvol=false)