Pol  Revision:4b29d2b
baseobject.h
Go to the documentation of this file.
1 #ifndef BASEOBJECT_H
2 #define BASEOBJECT_H
3 
4 #include "../clib/rawtypes.h"
5 
6 namespace Pol
7 {
8 namespace Realms
9 {
10 class Realm;
11 }
12 namespace Core
13 {
21 enum class UOBJ_CLASS : u8
22 {
23  CLASS_ITEM,
26  CLASS_NPC,
30 
31  INVALID = 0xff,
32 };
33 
34 // ULWObject: Lightweight object.
35 // Should contain minimal data structures (and no virtuals)
36 // can also be created with arbritary data check los.h
37 class ULWObject
38 {
39 protected:
40  ULWObject( UOBJ_CLASS uobj_class );
41  ULWObject( const ULWObject& ) = delete;
42  ULWObject& operator=( const ULWObject& ) = delete;
43  ~ULWObject() = default;
44 
45 public:
46  bool orphan() const;
47 
48  bool isa( UOBJ_CLASS uobj_class ) const;
49  bool ismobile() const;
50  bool isitem() const;
51  bool ismulti() const;
52 
53  u8 look_height() const; // where you're looking from, or to
54 
55 public:
59  u16 x;
60  u16 y;
61  s8 z;
63 
64 protected:
66 };
67 
68 inline ULWObject::ULWObject( UOBJ_CLASS uobj_class )
69  : realm( nullptr ),
70  serial( 0 ),
71  graphic( 0 ),
72  x( 0 ),
73  y( 0 ),
74  z( 0 ),
75  height( 0 ),
76  uobj_class_( uobj_class )
77 {
78 }
79 
80 inline u8 ULWObject::look_height() const
81 {
82  switch ( uobj_class_ )
83  {
89  return height / 2;
90 
94  return height;
95  }
96  return 0;
97 }
98 
99 inline bool ULWObject::isa( UOBJ_CLASS uobj_class ) const
100 {
101  return uobj_class_ == uobj_class;
102 }
103 
104 inline bool ULWObject::ismobile() const
105 {
107 }
108 
109 inline bool ULWObject::isitem() const
110 {
111  return !ismobile();
112 }
113 
114 inline bool ULWObject::ismulti() const
115 {
116  return ( uobj_class_ == UOBJ_CLASS::CLASS_MULTI );
117 }
118 
119 inline bool ULWObject::orphan() const
120 {
121  return ( serial == 0 );
122 }
123 
124 
125 } // namespace Core
126 } // namespace Pol
127 
128 #endif
unsigned char u8
Definition: rawtypes.h:25
bool ismobile() const
Definition: baseobject.h:104
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
bool orphan() const
Definition: baseobject.h:119
bool isitem() const
Definition: baseobject.h:109
signed char s8
Definition: rawtypes.h:29
u8 look_height() const
Definition: baseobject.h:80
const UOBJ_CLASS uobj_class_
Definition: baseobject.h:65
Realms::Realm * realm
Definition: baseobject.h:56
bool isa(UOBJ_CLASS uobj_class) const
Definition: baseobject.h:99
bool ismulti() const
Definition: baseobject.h:114
Definition: berror.cpp:12