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