ScummVM API documentation
game_controller.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_CONTROLLERS_GAME_CONTROLLER_H
23 #define ULTIMA4_CONTROLLERS_GAME_CONTROLLER_H
24 
25 #include "ultima/ultima4/controllers/controller.h"
26 #include "ultima/ultima4/core/coords.h"
27 #include "ultima/ultima4/core/observer.h"
28 #include "ultima/ultima4/game/portal.h"
29 #include "ultima/ultima4/game/player.h"
30 #include "ultima/ultima4/map/location.h"
31 #include "ultima/ultima4/views/tileview.h"
32 
33 namespace Ultima {
34 namespace Ultima4 {
35 
44 class GameController : public Controller, public Observer<Party *, PartyEvent &>, public Observer<Location *, MoveEvent &>,
45  public TurnCompleter {
46 private:
50  void avatarMoved(MoveEvent &event);
51 
55  void avatarMovedInDungeon(MoveEvent &event);
56 
60  void creatureCleanup();
61 
65  void checkBridgeTrolls();
66 
70  void checkRandomCreatures();
71 
77  void checkSpecialCreatures(Direction dir);
78 
82  bool checkMoongates();
83 
87  bool createBalloon(Map *map);
88 
93  bool attackAt(const Coords &coords);
94 public:
100  static void flashTile(const Coords &coords, MapTile tile, int timeFactor);
101 
102  static void flashTile(const Coords &coords, const Common::String &tilename, int timeFactor);
103  static void doScreenAnimationsWhilePausing(int timeFactor);
104 public:
105  TileView _mapArea;
106  bool _paused;
107  int _pausedTimer;
108  bool _combatFinished;
109 public:
110  GameController();
111 
112  /* controller functions */
113 
117  void setActive() override;
118 
122  void keybinder(KeybindingAction action) override;
123 
127  bool mousePressed(const Common::Point &mousePos) override;
128 
132  void timerFired() override;
133 
134  /* main game functions */
135  void init();
136  void initScreen();
137  void initScreenWithoutReloadingState();
138  void setMap(Map *map, bool saveLocation, const Portal *portal, TurnCompleter *turnCompleter = nullptr);
139 
145  int exitToParentMap();
146 
152  void finishTurnAfterCombatEnds() override {
153  _combatFinished = true;
154  finishTurn();
155  }
156 
162  void finishTurn() override;
163 
167  void update(Party *party, PartyEvent &event) override;
168 
172  void update(Location *location, MoveEvent &event) override;
173 
179  void initMoons();
180 
185  void updateMoons(bool showmoongates);
186 
187  void attack(Direction dir = DIR_NONE);
188 };
189 
190 extern GameController *g_game;
191 
192 } // End of namespace Ultima4
193 } // End of namespace Ultima
194 
195 #endif
bool mousePressed(const Common::Point &mousePos) override
Definition: portal.h:53
Definition: str.h:59
Definition: map.h:134
Definition: game_controller.h:44
Definition: movement.h:53
Definition: coords.h:31
Definition: observer.h:37
void keybinder(KeybindingAction action) override
static void flashTile(const Coords &coords, MapTile tile, int timeFactor)
Definition: controller.h:153
Definition: controller.h:35
Definition: player.h:262
Definition: detection.h:27
Definition: player.h:285
Definition: tileview.h:42
Definition: map_tile.h:34
Definition: rect.h:45
void updateMoons(bool showmoongates)
Definition: location.h:49
void finishTurnAfterCombatEnds() override
Definition: game_controller.h:152
void update(Party *party, PartyEvent &event) override