ScummVM API documentation
tile.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
22#ifndef ULTIMA4_MAP_TILE_H
23#define ULTIMA4_MAP_TILE_H
24
25#include "ultima/ultima4/map/direction.h"
26#include "ultima/ultima4/core/types.h"
27#include "ultima/ultima4/map/tileset.h"
28
29namespace Ultima {
30namespace Ultima4 {
31
32class ConfigElement;
33class Image;
34class Tileset;
35class TileAnim;
36
37/* attr masks */
38#define MASK_SHIP 0x0001
39#define MASK_HORSE 0x0002
40#define MASK_BALLOON 0x0004
41#define MASK_DISPEL 0x0008
42#define MASK_TALKOVER 0x0010
43#define MASK_DOOR 0x0020
44#define MASK_LOCKEDDOOR 0x0040
45#define MASK_CHEST 0x0080
46#define MASK_ATTACKOVER 0x0100
47#define MASK_CANLANDBALLOON 0x0200
48#define MASK_REPLACEMENT 0x0400
49#define MASK_WATER_REPLACEMENT 0x0800
50#define MASK_FOREGROUND 0x1000
51#define MASK_LIVING_THING 0x2000
52
53
54/* movement masks */
55#define MASK_SWIMABLE 0x0001
56#define MASK_SAILABLE 0x0002
57#define MASK_UNFLYABLE 0x0004
58#define MASK_CREATURE_UNWALKABLE 0x0008
59
64class Tile : private Uncopyable {
65public:
66 Tile(Tileset *tileset);
67 ~Tile();
68
72 void loadProperties(const ConfigElement &conf);
73
74 TileId getId() const {
75 return _id;
76 }
77 const Common::String &getName() const {
78 return _name;
79 }
80 int getWidth() const {
81 return _w;
82 }
83 int getHeight() const {
84 return _h;
85 }
86 int getFrames() const {
87 return _frames;
88 }
89 int getScale() const {
90 return _scale;
91 }
92 TileAnim *getAnim() const {
93 return _anim;
94 }
95 Image *getImage();
96 const Common::String &getLooksLike() const {
97 return _looksLike;
98 }
99
100 bool isTiledInDungeon() const {
101 return _tiledInDungeon;
102 }
103 bool isLandForeground() const {
104 return _foreground;
105 }
106 bool isWaterForeground() const {
107 return _waterForeground;
108 }
109
110 int canWalkOn(Direction d) const {
111 return DIR_IN_MASK(d, rule->_walkOnDirs);
112 }
113 int canWalkOff(Direction d) const {
114 return DIR_IN_MASK(d, rule->_walkOffDirs);
115 }
116
121 int canAttackOver() const {
122 return isWalkable() || isSwimable() || isSailable() || (rule->_mask & MASK_ATTACKOVER);
123 }
124 int canLandBalloon() const {
125 return rule->_mask & MASK_CANLANDBALLOON;
126 }
127 int isLivingObject() const {
128 return rule->_mask & MASK_LIVING_THING;
129 }
130 int isReplacement() const {
131 return rule->_mask & MASK_REPLACEMENT;
132 }
133 int isWaterReplacement() const {
134 return rule->_mask & MASK_WATER_REPLACEMENT;
135 }
136
137 int isWalkable() const {
138 return rule->_walkOnDirs > 0;
139 }
140 bool isCreatureWalkable() const {
141 return canWalkOn(DIR_ADVANCE) && !(rule->_movementMask & MASK_CREATURE_UNWALKABLE);
142 }
143 bool isDungeonWalkable() const;
144 bool isDungeonFloor() const;
145 int isSwimable() const {
146 return rule->_movementMask & MASK_SWIMABLE;
147 }
148 int isSailable() const {
149 return rule->_movementMask & MASK_SAILABLE;
150 }
151 bool isWater() const {
152 return (isSwimable() || isSailable());
153 }
154 int isFlyable() const {
155 return !(rule->_movementMask & MASK_UNFLYABLE);
156 }
157 int isDoor() const {
158 return rule->_mask & MASK_DOOR;
159 }
160 int isLockedDoor() const {
161 return rule->_mask & MASK_LOCKEDDOOR;
162 }
163 int isChest() const {
164 return rule->_mask & MASK_CHEST;
165 }
166 int isShip() const {
167 return rule->_mask & MASK_SHIP;
168 }
169 bool isPirateShip() const {
170 return _name == "pirate_ship";
171 }
172 int isHorse() const {
173 return rule->_mask & MASK_HORSE;
174 }
175 int isBalloon() const {
176 return rule->_mask & MASK_BALLOON;
177 }
178 int canDispel() const {
179 return rule->_mask & MASK_DISPEL;
180 }
181 int canTalkOver() const {
182 return rule->_mask & MASK_TALKOVER;
183 }
184 TileSpeed getSpeed() const {
185 return rule->_speed;
186 }
187 TileEffect getEffect() const {
188 return rule->_effect;
189 }
190
191 bool isOpaque() const;
192
197 bool isForeground() const;
198 Direction directionForFrame(int frame) const;
199 int frameForDirection(Direction d) const;
200
201 static void resetNextId() {
202 _nextId = 0;
203 }
204 static bool canTalkOverTile(const Tile *tile) {
205 return tile->canTalkOver() != 0;
206 }
207 static bool canAttackOverTile(const Tile *tile) {
208 return tile->canAttackOver() != 0;
209 }
210 void deleteImage();
211
212private:
216 void loadImage();
217
218private:
219 TileId _id;
220 Common::String _name;
221 Tileset *_tileSet;
222 int _w, _h;
223 int _frames;
224 int _scale;
225 TileAnim *_anim;
226 bool _opaque;
228 bool _foreground;
229 bool _waterForeground;
231 TileRule *rule;
232 Common::String _imageName;
233 Common::String _looksLike;
235 Image *_image;
236 bool _tiledInDungeon;
237 Common::Array<Direction> _directions;
238
239 Common::String _animationRule;
240
241
242 static TileId _nextId;
243};
244
245} // End of namespace Ultima4
246} // End of namespace Ultima
247
248#endif
Definition: str.h:59
Definition: config.h:126
Definition: tile.h:64
bool isForeground() const
void loadProperties(const ConfigElement &conf)
int canAttackOver() const
Definition: tile.h:121
Definition: tileset.h:59
Definition: types.h:70