ScummVM API documentation
object.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 #ifndef ULTIMA4_GAME_OBJECT_H
22 #define ULTIMA4_GAME_OBJECT_H
23 
24 #include "ultima/ultima4/core/coords.h"
25 #include "ultima/ultima4/map/map_tile.h"
26 #include "ultima/ultima4/core/types.h"
27 
28 namespace Ultima {
29 namespace Ultima4 {
30 
31 class Object;
32 
33 typedef Std::deque<Object *> ObjectDeque;
34 
35 enum ObjectMovementBehavior {
36  MOVEMENT_FIXED,
37  MOVEMENT_WANDER,
38  MOVEMENT_FOLLOW_AVATAR,
39  MOVEMENT_ATTACK_AVATAR
40 };
41 
42 class Object {
43 public:
44  enum Type {
45  UNKNOWN,
46  CREATURE,
47  PERSON
48  };
49 
50  Object(Type type = UNKNOWN) :
51  _tile(0),
52  _prevTile(0),
53  _movementBehavior(MOVEMENT_FIXED),
54  _objType(type),
55  _focused(false),
56  _visible(true),
57  _animated(true) {
58  }
59 
60  virtual ~Object() {}
61 
62  // Methods
63  MapTile &getTile() {
64  return _tile;
65  }
66  MapTile &getPrevTile() {
67  return _prevTile;
68  }
69  const Coords &getCoords() const {
70  return _coords;
71  }
72  const Coords &getPrevCoords() const {
73  return _prevCoords;
74  }
75  ObjectMovementBehavior getMovementBehavior() const {
76  return _movementBehavior;
77  }
78  Type getType() const {
79  return _objType;
80  }
81  bool hasFocus() const {
82  return _focused;
83  }
84  bool isVisible() const {
85  return _visible;
86  }
87  bool isAnimated() const {
88  return _animated;
89  }
90 
91  void setTile(MapTile t) {
92  _tile = t;
93  }
94  void setTile(Tile *t) {
95  _tile = t->getId();
96  }
97  void setPrevTile(MapTile t) {
98  _prevTile = t;
99  }
100  void setCoords(Coords c) {
101  _prevCoords = _coords;
102  _coords = c;
103  }
104  void setPrevCoords(Coords c) {
105  _prevCoords = c;
106  }
107  void setMovementBehavior(ObjectMovementBehavior b) {
108  _movementBehavior = b;
109  }
110  void setType(Type t) {
111  _objType = t;
112  }
113  void setFocus(bool f = true) {
114  _focused = f;
115  }
116  void setVisible(bool v = true) {
117  _visible = v;
118  }
119  void setAnimated(bool a = true) {
120  _animated = a;
121  }
122 
123  void setMap(class Map *m);
124  Map *getMap();
125  void remove();
127  bool setDirection(Direction d);
128 
129  void animateMovement();
130 
131  // Properties
132 protected:
133  MapTile _tile, _prevTile;
134  Coords _coords, _prevCoords;
135  ObjectMovementBehavior _movementBehavior;
136  Type _objType;
139  bool _focused;
140  bool _visible;
141  bool _animated;
142 };
143 
144 } // End of namespace Ultima4
145 } // End of namespace Ultima
146 
147 #endif
Definition: containers.h:186
Definition: map.h:134
Definition: coords.h:31
Std::deque< class Map * > _maps
Definition: object.h:137
Definition: detection.h:27
Definition: map_tile.h:34
Definition: object.h:42
Definition: queue.h:75
Definition: tile.h:65