OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Ufo.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_UFO_H
20 #define OPENXCOM_UFO_H
21 
22 #include "MovingTarget.h"
23 #include <string>
24 #include <yaml-cpp/yaml.h>
25 
26 namespace OpenXcom
27 {
28 
29 class RuleUfo;
30 class AlienMission;
31 class UfoTrajectory;
32 class SavedGame;
33 class Ruleset;
34 
41 class Ufo : public MovingTarget
42 {
43 public:
44  enum UfoStatus { FLYING, LANDED, CRASHED, DESTROYED };
45 private:
46  RuleUfo *_rules;
47  int _id, _crashId, _landId, _damage;
48  std::string _direction, _altitude;
49  enum UfoStatus _status;
50  size_t _secondsRemaining;
51  bool _inBattlescape;
52  int _shotDownByCraftId;
53  AlienMission *_mission;
54  const UfoTrajectory *_trajectory;
55  size_t _trajectoryPoint;
56  bool _detected, _hyperDetected;
57  int _shootingAt, _hitFrame;
59  void calculateSpeed();
60 public:
62  Ufo(RuleUfo *rules);
64  ~Ufo();
66  void load(const YAML::Node& node, const Ruleset &ruleset, SavedGame &game);
68  YAML::Node save(bool newBattle) const;
70  YAML::Node saveId() const;
72  RuleUfo *getRules() const;
74  int getId() const;
76  void setId(int id);
78  std::wstring getName(Language *lang) const;
80  int getDamage() const;
82  void setDamage(int damage);
84  bool getDetected() const;
86  void setDetected(bool detected);
88  size_t getSecondsRemaining() const;
90  void setSecondsRemaining(size_t seconds);
92  std::string getDirection() const;
94  std::string getAltitude() const;
96  void setAltitude(const std::string &altitude);
98  enum UfoStatus getStatus() const { return _status; }
100  void setStatus(enum UfoStatus status) {_status = status; }
102  bool isCrashed() const;
104  bool isDestroyed() const;
106  void think();
108  void setInBattlescape(bool inbattle);
110  bool isInBattlescape() const;
112  const std::string &getAlienRace() const;
114  void setShotDownByCraftId(const int id);
116  int getShotDownByCraftId() const;
118  int getVisibility() const;
120  const std::string &getMissionType() const;
122  void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory);
124  bool getHyperDetected() const;
126  void setHyperDetected(bool hyperdetected);
128  size_t getTrajectoryPoint() const { return _trajectoryPoint; }
130  void setTrajectoryPoint(size_t np) { _trajectoryPoint = np; }
132  const UfoTrajectory &getTrajectory() const { return *_trajectory; }
134  AlienMission *getMission() const { return _mission; }
136  void setDestination(Target *dest);
138  int getShootingAt() const;
140  void setShootingAt(int target);
142  int getLandId() const;
144  void setLandId(int id);
146  int getCrashId() const;
148  void setCrashId(int id);
150  void setHitFrame(int frame);
152  int getHitFrame();
153 
154 };
155 
156 }
157 
158 #endif
void setTrajectoryPoint(size_t np)
Sets the UFO's progress on the trajectory track.
Definition: Ufo.h:130
void setHyperDetected(bool hyperdetected)
Sets the UFO's hyper detection status.
Definition: Ufo.cpp:625
Represents an ongoing alien mission.
Definition: AlienMission.h:45
void setId(int id)
Sets the UFO's ID.
Definition: Ufo.cpp:243
size_t getSecondsRemaining() const
Gets the UFO's seconds left on the ground.
Definition: Ufo.cpp:326
void setDetected(bool detected)
Sets the UFO's detection status.
Definition: Ufo.cpp:315
~Ufo()
Cleans up the UFO.
Definition: Ufo.cpp:55
void setHitFrame(int frame)
Sets the UFO's hit frame.
Definition: Ufo.cpp:671
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
int getDamage() const
Gets the UFO's amount of damage.
Definition: Ufo.cpp:276
enum UfoStatus getStatus() const
Gets the UFO status.
Definition: Ufo.h:98
bool isCrashed() const
Gets if the UFO has crashed.
Definition: Ufo.cpp:382
void setStatus(enum UfoStatus status)
Set the UFO's status.
Definition: Ufo.h:100
const UfoTrajectory & getTrajectory() const
Gets the UFO's trajectory.
Definition: Ufo.h:132
int getLandId() const
Gets the UFO's landing site ID.
Definition: Ufo.cpp:651
AlienMission * getMission() const
Gets the UFO's mission object.
Definition: Ufo.h:134
void setAltitude(const std::string &altitude)
Sets the UFO's altitude.
Definition: Ufo.cpp:364
void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory)
Sets the UFO's mission information.
Definition: Ufo.cpp:603
bool isDestroyed() const
Gets if the UFO has been destroyed.
Definition: Ufo.cpp:392
Contains strings used throughout the game for localization.
Definition: Language.h:42
void setDamage(int damage)
Sets the UFO's amount of damage.
Definition: Ufo.cpp:285
Set of rules and stats for a game.
Definition: Ruleset.h:69
RuleUfo * getRules() const
Gets the UFO's ruleset.
Definition: Ufo.cpp:224
std::string getDirection() const
Gets the UFO's direction.
Definition: Ufo.cpp:346
void setShootingAt(int target)
Set which interceptor this ufo is engaging.
Definition: Ufo.cpp:646
int getShotDownByCraftId() const
Gets the ID of craft which shot down the UFO.
Definition: Ufo.cpp:544
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:49
size_t getTrajectoryPoint() const
Gets the UFO's progress on the trajectory track.
Definition: Ufo.h:128
bool getDetected() const
Gets the UFO's detection status.
Definition: Ufo.cpp:306
virtual YAML::Node save() const
Saves the moving target to YAML.
Definition: MovingTarget.cpp:69
int getId() const
Gets the UFO's ID.
Definition: Ufo.cpp:234
const std::string & getMissionType() const
Gets the UFO's Mission type.
Definition: Ufo.cpp:590
bool getHyperDetected() const
Gets the UFO's hyper detection status.
Definition: Ufo.cpp:616
int getShootingAt() const
Get which interceptor this ufo is engaging.
Definition: Ufo.cpp:641
int getCrashId() const
Gets the UFO's crash site ID.
Definition: Ufo.cpp:661
void setInBattlescape(bool inbattle)
Sets the UFO's battlescape status.
Definition: Ufo.cpp:523
int getHitFrame()
Gets the UFO's hit frame.
Definition: Ufo.cpp:676
Represents an alien UFO on the map.
Definition: Ufo.h:41
YAML::Node saveId() const
Saves the UFO's ID to YAML.
Definition: Ufo.cpp:212
const std::string & getAlienRace() const
Gets the UFO's alien race.
Definition: Ufo.cpp:534
Ufo(RuleUfo *rules)
Creates a UFO of the specified type.
Definition: Ufo.cpp:43
Base class for moving targets on the globe with a certain speed and destination.
Definition: MovingTarget.h:31
void setSecondsRemaining(size_t seconds)
Sets the UFO's seconds left on the ground.
Definition: Ufo.cpp:337
void setDestination(Target *dest)
Sets the UFO's destination.
Definition: Ufo.cpp:634
void think()
Handles UFO logic.
Definition: Ufo.cpp:481
Represents a specific type of UFO.
Definition: RuleUfo.h:37
std::wstring getName(Language *lang) const
Gets the UFO's name.
Definition: Ufo.cpp:253
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
void setShotDownByCraftId(const int id)
Sets the ID of craft which shot down the UFO.
Definition: Ufo.cpp:539
void setLandId(int id)
Sets the UFO's landing site ID.
Definition: Ufo.cpp:656
void setCrashId(int id)
Sets the UFO's crash site ID.
Definition: Ufo.cpp:666
void load(const YAML::Node &node, const Ruleset &ruleset, SavedGame &game)
Loads the UFO from YAML.
Definition: Ufo.cpp:105
std::string getAltitude() const
Gets the UFO's altitude.
Definition: Ufo.cpp:355
bool isInBattlescape() const
Gets if the UFO is in battlescape.
Definition: Ufo.cpp:514
int getVisibility() const
Gets the UFO's visibility.
Definition: Ufo.cpp:555