OpenXcom  1.0
Open-source clone of the original X-Com
AlienMission.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <string>
21 #include <yaml-cpp/yaml.h>
22 
23 namespace OpenXcom
24 {
25 
26 class RuleAlienMission;
27 class Ufo;
28 class Globe;
29 class Game;
30 class SavedGame;
31 class Mod;
32 class RuleRegion;
33 struct MissionWave;
34 class UfoTrajectory;
35 class AlienBase;
36 class MissionSite;
37 struct MissionArea;
38 class AlienDeployment;
39 
47 {
48 private:
49  const RuleAlienMission &_rule;
50  std::string _region, _race;
51  size_t _nextWave;
52  size_t _nextUfoCounter;
53  size_t _spawnCountdown;
54  size_t _liveUfos;
55  int _uniqueID, _missionSiteZone;
56  const AlienBase *_base;
57 public:
58  // Data
59 
61  AlienMission(const RuleAlienMission &rule);
63  ~AlienMission();
65  void load(const YAML::Node& node, SavedGame &game);
67  YAML::Node save() const;
69  const RuleAlienMission &getRules() const { return _rule; }
71  const std::string &getRegion() const { return _region; }
73  void setRegion(const std::string &region, const Mod &rules);
75  const std::string &getRace() const { return _race; }
77  void setRace(const std::string &race) { _race = race; }
79  size_t getWaveCountdown() const { return _spawnCountdown; }
81  void setWaveCountdown(size_t minutes);
83  void setId(int id);
85  int getId() const;
87  const AlienBase *getAlienBase() const;
89  void setAlienBase(const AlienBase *base);
90 
91  // Behaviour
92 
94  bool isOver() const;
96  void think(Game &engine, const Globe &globe);
98  void start(size_t initialCount = 0);
100  void increaseLiveUfos() { ++_liveUfos; }
102  void decreaseLiveUfos() { --_liveUfos; }
104  void ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe);
106  void ufoLifting(Ufo &ufo, SavedGame &game);
108  void ufoShotDown(Ufo &ufo);
110  void addScore(double lon, double lat, SavedGame &game) const;
112  void setMissionSiteZone(int zone);
113 private:
115  Ufo *spawnUfo(const SavedGame &game, const Mod &mod, const Globe &globe, const MissionWave &wave, const UfoTrajectory &trajectory);
117  void spawnAlienBase(Game &engine, const MissionArea &area, std::pair<double, double> pos);
119  std::pair<double, double> getWaypoint(const UfoTrajectory &trajectory, const size_t nextWaypoint, const Globe &globe, const RuleRegion &region);
121  std::pair<double, double> getLandPoint(const Globe &globe, const RuleRegion &region, size_t zone);
123  MissionSite *spawnMissionSite(SavedGame &game, AlienDeployment *deployment, const MissionArea &area);
125  void logMissionError(int zone, const RuleRegion &region);
126 
127 };
128 
129 }
void ufoShotDown(Ufo &ufo)
Handle UFO shot down.
Definition: AlienMission.cpp:537
const RuleAlienMission & getRules() const
Gets the mission&#39;s ruleset.
Definition: AlienMission.h:69
Represents an alien base on the world.
Definition: AlienBase.h:31
~AlienMission()
Cleans up the mission info.
Definition: AlienMission.cpp:55
Represents an ongoing alien mission.
Definition: AlienMission.h:46
const std::string & getRegion() const
Gets the mission&#39;s region.
Definition: AlienMission.h:71
bool isOver() const
Is this mission over?
Definition: AlienMission.cpp:135
void setAlienBase(const AlienBase *base)
Sets the alien base for this mission.
Definition: AlienMission.cpp:632
void decreaseLiveUfos()
Decrease number of live UFOs.
Definition: AlienMission.h:102
const AlienBase * getAlienBase() const
Gets the alien base for this mission.
Definition: AlienMission.cpp:641
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
Represents an alien mission site on the world.
Definition: MissionSite.h:33
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
Interactive globe view of the world.
Definition: Globe.h:43
int getId() const
Gets the unique ID for this mission.
Definition: AlienMission.cpp:621
AlienMission(const RuleAlienMission &rule)
Creates a mission of the specified type.
Definition: AlienMission.cpp:50
void setRegion(const std::string &region, const Mod &rules)
Sets the mission&#39;s region.
Definition: AlienMission.cpp:716
Defines a rectangle in polar coordinates.
Definition: RuleRegion.h:33
void think(Game &engine, const Globe &globe)
Handle UFO spawning for the mission.
Definition: AlienMission.cpp:161
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:47
void ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe)
Handle UFO reaching a waypoint.
Definition: AlienMission.cpp:421
void setRace(const std::string &race)
Sets the mission&#39;s race.
Definition: AlienMission.h:77
void setWaveCountdown(size_t minutes)
Sets the minutes until next wave spawns.
Definition: AlienMission.cpp:597
Information about a mission wave.
Definition: RuleAlienMission.h:34
void start(size_t initialCount=0)
Initialize with values from rules.
Definition: AlienMission.cpp:382
Stores fixed information about a mission type.
Definition: RuleAlienMission.h:67
const std::string & getRace() const
Gets the mission&#39;s race.
Definition: AlienMission.h:75
void increaseLiveUfos()
Increase number of live UFOs.
Definition: AlienMission.h:100
Represents an alien UFO on the map.
Definition: Ufo.h:40
The core of the game engine, manages the game&#39;s entire contents and structure.
Definition: Game.h:41
Represents a specific type of Alien Deployment.
Definition: AlienDeployment.h:63
void load(const YAML::Node &node, SavedGame &game)
Loads the mission from YAML.
Definition: AlienMission.cpp:77
void setMissionSiteZone(int zone)
Keep track of the city/whatever that we&#39;re going to target.
Definition: AlienMission.cpp:819
size_t getWaveCountdown() const
Gets the minutes until next wave spawns.
Definition: AlienMission.h:79
YAML::Node save() const
Saves the mission to YAML.
Definition: AlienMission.cpp:110
Represents a specific region of the world.
Definition: RuleRegion.h:71
void addScore(double lon, double lat, SavedGame &game) const
Handle Points for mission successes.
Definition: AlienMission.cpp:652
Definition: BaseInfoState.cpp:40
void ufoLifting(Ufo &ufo, SavedGame &game)
Handle UFO lifting from the ground.
Definition: AlienMission.cpp:563
void setId(int id)
Sets the unique ID for this mission.
Definition: AlienMission.cpp:612