ScummVM API documentation
widgets.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 ULTIMA_SHARED_CORE_WIDGETS_H
23 #define ULTIMA_SHARED_CORE_WIDGETS_H
24 
25 #include "ultima/shared/core/map.h"
26 #include "ultima/shared/gfx/dungeon_surface.h"
27 
28 namespace Ultima {
29 namespace Shared {
30 
34 class StandardWidget : public MapWidget {
35 public:
39  StandardWidget(Game *game, Map::MapBase *map) : MapWidget(game, map) {}
40  StandardWidget(Game *game, Map::MapBase *map, const Point &pt, Direction dir = DIR_NONE) : MapWidget(game, map, pt, dir) {}
41 
45  ~StandardWidget() override {}
46 };
47 
48 class Creature : public StandardWidget {
49 protected:
50  int _hitPoints;
51  bool _isAttacking;
52 protected:
57  virtual uint attackDistance() const { return 0; }
58 
62  virtual void movement() {}
63 
67  virtual void attack() {}
68 public:
72  Creature(Game *game, Map::MapBase *map) : StandardWidget(game, map), _hitPoints(0), _isAttacking(false) {}
73  Creature(Game *game, Map::MapBase *map, int hitPoints) : StandardWidget(game, map),
74  _hitPoints(hitPoints), _isAttacking(false) {}
75  Creature(Game *game, Map::MapBase *map, int hitPoints, const Point &pt, Direction dir = DIR_NONE) :
76  StandardWidget(game, map, pt, dir), _hitPoints(hitPoints), _isAttacking(false) {}
77 
81  ~Creature() override {}
82 
86  void synchronize(Common::Serializer &s) override;
87 
93  void update(bool isPreUpdate) override;
94 
98  bool isDead() const { return _hitPoints <= 0; }
99 };
100 
101 
105 class DungeonWidget : public MapWidget {
106 public:
110  DungeonWidget(Game *game, Map::MapBase *map) : MapWidget(game, map) {}
111  DungeonWidget(Game *game, Map::MapBase *map, const Point &pt, Direction dir = DIR_NONE) : MapWidget(game, map, pt, dir) {}
112  DungeonWidget(Game *game, Map::MapBase *map, const Common::String &name, const Point &pt, Direction dir = DIR_NONE) :
113  MapWidget(game, map, name, pt, dir) {}
114 
118  ~DungeonWidget() override {}
119 
123  virtual void draw(DungeonSurface &s, uint distance) = 0;
124 };
125 
130 public:
131  virtual ~DungeonCreature() {}
132 
136  virtual bool isBlockingView() const = 0;
137 
141  virtual void draw(DungeonSurface &s, uint distance) = 0;
142 };
143 
144 } // End of namespace Shared
145 } // End of namespace Ultima
146 
147 #endif
MapWidget(Game *game, Map::MapBase *map)
Definition: map.h:499
Definition: str.h:59
virtual void update(bool isPreUpdate)
Definition: map.h:541
Definition: game.h:42
~Creature() override
Definition: widgets.h:81
DungeonWidget(Game *game, Map::MapBase *map)
Definition: widgets.h:110
Definition: widgets.h:48
Definition: widgets.h:34
Creature(Game *game, Map::MapBase *map)
Definition: widgets.h:72
bool isDead() const
Definition: widgets.h:98
Definition: dungeon_surface.h:37
Definition: map.h:487
virtual uint attackDistance() const
Definition: widgets.h:57
~StandardWidget() override
Definition: widgets.h:45
Definition: serializer.h:79
Definition: detection.h:27
Definition: widgets.h:129
Definition: rect.h:45
virtual void attack()
Definition: widgets.h:67
virtual void synchronize(Common::Serializer &s)
Definition: map.h:155
virtual void movement()
Definition: widgets.h:62
StandardWidget(Game *game, Map::MapBase *map)
Definition: widgets.h:39
Definition: widgets.h:105
~DungeonWidget() override
Definition: widgets.h:118