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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 #ifndef ULTIMA4_GAME_OBJECT_H
23 #define ULTIMA4_GAME_OBJECT_H
24 
25 #include "ultima/ultima4/core/coords.h"
26 #include "ultima/ultima4/map/map_tile.h"
27 #include "ultima/ultima4/core/types.h"
28 
29 namespace Ultima {
30 namespace Ultima4 {
31 
32 class Object;
33 
34 typedef Std::deque<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 
~Object()61 	virtual ~Object() {}
62 
63 	// Methods
getTile()64 	MapTile &getTile() {
65 		return _tile;
66 	}
getPrevTile()67 	MapTile &getPrevTile() {
68 		return _prevTile;
69 	}
getCoords()70 	const Coords &getCoords() const {
71 		return _coords;
72 	}
getPrevCoords()73 	const Coords &getPrevCoords() const {
74 		return _prevCoords;
75 	}
getMovementBehavior()76 	ObjectMovementBehavior getMovementBehavior() const {
77 		return _movementBehavior;
78 	}
getType()79 	Type getType() const {
80 		return _objType;
81 	}
hasFocus()82 	bool hasFocus() const {
83 		return _focused;
84 	}
isVisible()85 	bool isVisible() const {
86 		return _visible;
87 	}
isAnimated()88 	bool isAnimated() const {
89 		return _animated;
90 	}
91 
setTile(MapTile t)92 	void setTile(MapTile t) {
93 		_tile = t;
94 	}
setTile(Tile * t)95 	void setTile(Tile *t) {
96 		_tile = t->getId();
97 	}
setPrevTile(MapTile t)98 	void setPrevTile(MapTile t) {
99 		_prevTile = t;
100 	}
setCoords(Coords c)101 	void setCoords(Coords c) {
102 		_prevCoords = _coords;
103 		_coords = c;
104 	}
setPrevCoords(Coords c)105 	void setPrevCoords(Coords c) {
106 		_prevCoords = c;
107 	}
setMovementBehavior(ObjectMovementBehavior b)108 	void setMovementBehavior(ObjectMovementBehavior b) {
109 		_movementBehavior = b;
110 	}
setType(Type t)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();  /**< Removes itself from any maps that it is a part of */
127 
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;
138 	Std::deque<class Map *> _maps;           /**< A list of maps this object is a part of */
139 
140 	bool _focused;
141 	bool _visible;
142 	bool _animated;
143 };
144 
145 } // End of namespace Ultima4
146 } // End of namespace Ultima
147 
148 #endif
149