Pol  Revision:3cfda13
corpse.h
Go to the documentation of this file.
1 #ifndef MOBILE_CORPSE_H
2 #define MOBILE_CORPSE_H
3 
4 #include "../../clib/compilerspecifics.h"
5 #include "../../clib/rawtypes.h"
6 #include "../containr.h"
7 #include "../item/item.h"
8 
9 namespace Pol
10 {
11 namespace Bscript
12 {
13 class BObjectImp;
14 } // namespace Bscript
15 namespace Clib
16 {
17 class ConfigElem;
18 class StreamWriter;
19 } // namespace Clib
20 namespace Items
21 {
22 class ContainerDesc;
23 class ItemDesc;
24 } // namespace Items
25 namespace Mobile
26 {
27 class Character;
28 } // namespace Mobile
29 namespace Multi
30 {
31 class UMulti;
32 } // namespace Multi
33 } // namespace Pol
34 
35 namespace Pol
36 {
37 namespace Core
38 {
39 // Corpses must NEVER EVER be movable.
40 // They can decay even if they are immobile.
41 class UCorpse : public UContainer
42 {
43  typedef UContainer base;
44 
45 public:
46  virtual ~UCorpse(){};
47  virtual size_t estimatedSize() const POL_OVERRIDE;
48  virtual u16 get_senditem_amount() const POL_OVERRIDE;
49 
50  virtual void add( Item* item ) POL_OVERRIDE;
51  virtual void remove( iterator itr ) POL_OVERRIDE;
52 
53  virtual void on_insert_add_item( Mobile::Character* mob, MoveType move,
54  Items::Item* new_item ) POL_OVERRIDE;
55  bool take_contents_to_grave() const;
56  void take_contents_to_grave( bool newvalue );
58  u32 ownerserial; // NPCs get deleted on death, so serial is used.
59  Items::Item* GetItemOnLayer( unsigned idx ) const;
60 
61 protected:
62  void RemoveItemFromLayer( Items::Item* item );
63  void PutItemOnLayer( Items::Item* item );
64 
65  explicit UCorpse( const Items::ContainerDesc& desc );
66  virtual void spill_contents( Multi::UMulti* supporting_multi ) POL_OVERRIDE;
67  virtual void printProperties( Clib::StreamWriter& sw ) const POL_OVERRIDE;
68  virtual void readProperties( Clib::ConfigElem& elem ) POL_OVERRIDE;
69  friend Items::Item* Items::Item::create( const Items::ItemDesc& itemdesc, u32 serial );
70  // virtual Bscript::BObjectImp* script_member( const char *membername );
71  virtual Bscript::BObjectImp* get_script_member( const char* membername ) const POL_OVERRIDE;
72  virtual Bscript::BObjectImp* get_script_member_id( const int id ) const POL_OVERRIDE;
73  // virtual Bscript::BObjectImp* set_script_member( const char *membername, const std::string&
74  // value );
75  // virtual Bscript::BObjectImp* set_script_member( const char *membername, int value );
76  virtual bool script_isa( unsigned isatype ) const POL_OVERRIDE;
78 };
79 
80 inline Items::Item* UCorpse::GetItemOnLayer( unsigned idx ) const
81 {
82  // Checks if the requested layer is valid
83  if ( Items::valid_equip_layer( idx ) )
84  return ITEM_ELEM_PTR( layer_list_[idx] );
85 
86  return EMPTY_ELEM;
87 }
88 }
89 }
90 
91 #endif
std::vector< Items::Item * > Contents
Definition: containr.h:113
static Item * create(u32 objtype, u32 serial=0)
Definition: itemcr.cpp:53
#define POL_OVERRIDE
Items::Item * GetItemOnLayer(unsigned idx) const
Definition: corpse.h:80
Contents::iterator iterator
Definition: containr.h:114
Contents layer_list_
Definition: corpse.h:77
#define ITEM_ELEM_PTR(elem)
Definition: containr.h:39
bool valid_equip_layer(int layer)
Definition: item.h:383
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
UContainer base
Definition: corpse.h:43
virtual ~UCorpse()
Definition: corpse.h:46
#define EMPTY_ELEM
Definition: containr.h:40
Definition: berror.cpp:12