OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AlienMission.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_ALIEN_MISSION_H
20 #define OPENXCOM_ALIEN_MISSION_H
21 
22 #include <string>
23 #include <yaml-cpp/yaml.h>
24 
25 namespace OpenXcom
26 {
27 
28 class RuleAlienMission;
29 class Ufo;
30 class Globe;
31 class Game;
32 class SavedGame;
33 class Ruleset;
34 class RuleRegion;
35 class RuleUfo;
36 class UfoTrajectory;
37 class AlienBase;
38 
46 {
47 private:
48  const RuleAlienMission &_rule;
49  std::string _region, _race;
50  size_t _nextWave;
51  size_t _nextUfoCounter;
52  size_t _spawnCountdown;
53  size_t _liveUfos;
54  int _uniqueID;
55  const AlienBase *_base;
56 public:
57  // Data
58 
60  AlienMission(const RuleAlienMission &rule);
62  ~AlienMission();
64  void load(const YAML::Node& node, SavedGame &game);
66  YAML::Node save() const;
68  const std::string &getType() const;
70  const std::string &getRegion() const { return _region; }
72  void setRegion(const std::string &region, const Ruleset &rules);
74  const std::string &getRace() const { return _race; }
76  void setRace(const std::string &race) { _race = race; }
78  size_t getWaveCountdown() const { return _spawnCountdown; }
80  void setWaveCountdown(size_t minutes);
82  void setId(int id);
84  int getId() const;
86  const AlienBase *getAlienBase() const;
88  void setAlienBase(const AlienBase *base);
89 
90  // Behaviour
91 
93  bool isOver() const;
95  void think(Game &engine, const Globe &globe);
97  void start(size_t initialCount = 0);
99  void increaseLiveUfos() { ++_liveUfos; }
101  void decreaseLiveUfos() { --_liveUfos; }
103  void ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe);
105  void ufoLifting(Ufo &ufo, Game &engine, const Globe &globe);
107  void ufoShotDown(Ufo &ufo, Game &engine, const Globe &globe);
109  void addScore(const double lon, const double lat, Game &engine);
110 private:
112  Ufo *spawnUfo(const SavedGame &game, const Ruleset &ruleset, const Globe &globe, const RuleUfo &ufoRule, const UfoTrajectory &trajectory);
114  void spawnAlienBase(const Globe &globe, Game &engine);
116  std::pair<double, double> getWaypoint(const UfoTrajectory &trajectory, const size_t nextWaypoint, const Globe &globe, const RuleRegion &region);
118  std::pair<double, double> getLandPoint(const Globe &globe, const RuleRegion &region, size_t zone);
119 };
120 
121 }
122 
123 #endif
size_t getWaveCountdown() const
Gets the minutes until next wave spawns.
Definition: AlienMission.h:78
Represents an alien base on the world.
Definition: AlienBase.h:32
~AlienMission()
Cleans up the mission info.
Definition: AlienMission.cpp:56
Represents an ongoing alien mission.
Definition: AlienMission.h:45
void ufoShotDown(Ufo &ufo, Game &engine, const Globe &globe)
Handle UFO shot down.
Definition: AlienMission.cpp:493
void setAlienBase(const AlienBase *base)
Sets the alien base for this mission.
Definition: AlienMission.cpp:589
void decreaseLiveUfos()
Decrease number of live UFOs.
Definition: AlienMission.h:101
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
Interactive globe view of the world.
Definition: Globe.h:44
bool isOver() const
Is this mission over?
Definition: AlienMission.cpp:127
const std::string & getRegion() const
Gets the mission's region.
Definition: AlienMission.h:70
const AlienBase * getAlienBase() const
Gets the alien base for this mission.
Definition: AlienMission.cpp:598
AlienMission(const RuleAlienMission &rule)
Creates a mission of the specified type.
Definition: AlienMission.cpp:51
Set of rules and stats for a game.
Definition: Ruleset.h:69
YAML::Node save() const
Saves the mission to YAML.
Definition: AlienMission.cpp:98
void think(Game &engine, const Globe &globe)
Handle UFO spawning for the mission.
Definition: AlienMission.cpp:153
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:49
void ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe)
Handle UFO reaching a waypoint.
Definition: AlienMission.cpp:360
void setRace(const std::string &race)
Sets the mission's race.
Definition: AlienMission.h:76
const std::string & getRace() const
Gets the mission's race.
Definition: AlienMission.h:74
int getId() const
Gets the unique ID for this mission.
Definition: AlienMission.cpp:578
void setWaveCountdown(size_t minutes)
Sets the minutes until next wave spawns.
Definition: AlienMission.cpp:554
void start(size_t initialCount=0)
Initialize with values from rules.
Definition: AlienMission.cpp:321
Stores fixed information about a mission type.
Definition: RuleAlienMission.h:61
void ufoLifting(Ufo &ufo, Game &engine, const Globe &globe)
Handle UFO lifting from the ground.
Definition: AlienMission.cpp:520
void increaseLiveUfos()
Increase number of live UFOs.
Definition: AlienMission.h:99
Represents an alien UFO on the map.
Definition: Ufo.h:41
const std::string & getType() const
Gets the mission's type.
Definition: AlienMission.cpp:116
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:44
void load(const YAML::Node &node, SavedGame &game)
Loads the mission from YAML.
Definition: AlienMission.cpp:76
Represents a specific type of UFO.
Definition: RuleUfo.h:37
void addScore(const double lon, const double lat, Game &engine)
Handle Points for mission successes.
Definition: AlienMission.cpp:609
Represents a specific region of the world.
Definition: RuleRegion.h:65
void setRegion(const std::string &region, const Ruleset &rules)
Sets the mission's region.
Definition: AlienMission.cpp:663
void setId(int id)
Sets the unique ID for this mission.
Definition: AlienMission.cpp:569