OpenXcom  1.0
Open-source clone of the original X-Com
Ufo.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 "MovingTarget.h"
21 #include <string>
22 #include <yaml-cpp/yaml.h>
23 #include "Craft.h"
24 
25 namespace OpenXcom
26 {
27 
28 class RuleUfo;
29 class AlienMission;
30 class UfoTrajectory;
31 class SavedGame;
32 class Mod;
33 
40 class Ufo : public MovingTarget
41 {
42 public:
43  static const char *ALTITUDE_STRING[];
44  enum UfoStatus { FLYING, LANDED, CRASHED, DESTROYED };
45 private:
46  const 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  CraftId _shotDownByCraftId;
53  AlienMission *_mission;
54  const UfoTrajectory *_trajectory;
55  size_t _trajectoryPoint;
56  bool _detected, _hyperDetected, _processedIntercept;
57  int _shootingAt, _hitFrame, _fireCountdown, _escapeCountdown;
59  void calculateSpeed();
60 
61  using MovingTarget::load;
62  using MovingTarget::save;
63 public:
65  Ufo(const RuleUfo *rules);
67  ~Ufo();
69  void load(const YAML::Node& node, const Mod &ruleset, SavedGame &game);
71  YAML::Node save(bool newBattle) const;
73  YAML::Node saveId() const;
75  const RuleUfo *getRules() const;
77  void changeRules(const RuleUfo *rules);
79  int getId() const;
81  void setId(int id);
83  std::wstring getDefaultName(Language *lang) const;
85  int getMarker() const;
87  int getDamage() const;
89  void setDamage(int damage);
91  bool getDetected() const;
93  void setDetected(bool detected);
95  size_t getSecondsRemaining() const;
97  void setSecondsRemaining(size_t seconds);
99  std::string getDirection() const;
101  std::string getAltitude() const;
103  int getAltitudeInt() const;
105  void setAltitude(const std::string &altitude);
107  enum UfoStatus getStatus() const { return _status; }
109  void setStatus(enum UfoStatus status) {_status = status; }
111  bool isCrashed() const;
113  bool isDestroyed() const;
115  void think();
117  void setInBattlescape(bool inbattle);
119  bool isInBattlescape() const;
121  const std::string &getAlienRace() const;
123  void setShotDownByCraftId(const CraftId& craftId);
125  CraftId getShotDownByCraftId() const;
127  int getVisibility() const;
129  const std::string &getMissionType() const;
131  void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory);
133  bool getHyperDetected() const;
135  void setHyperDetected(bool hyperdetected);
137  size_t getTrajectoryPoint() const { return _trajectoryPoint; }
139  void setTrajectoryPoint(size_t np) { _trajectoryPoint = np; }
141  const UfoTrajectory &getTrajectory() const { return *_trajectory; }
143  AlienMission *getMission() const { return _mission; }
145  void setDestination(Target *dest);
147  int getShootingAt() const;
149  void setShootingAt(int target);
151  int getLandId() const;
153  void setLandId(int id);
155  int getCrashId() const;
157  void setCrashId(int id);
159  void setHitFrame(int frame);
161  int getHitFrame() const;
162  void setFireCountdown(int time);
163  int getFireCountdown() const;
164  void setEscapeCountdown(int time);
165  int getEscapeCountdown() const;
166  void setInterceptionProcessed(bool processed);
167  bool getInterceptionProcessed() const;
168 
169 };
170 
171 }
void setTrajectoryPoint(size_t np)
Sets the UFO&#39;s progress on the trajectory track.
Definition: Ufo.h:139
int getVisibility() const
Gets the UFO&#39;s visibility.
Definition: Ufo.cpp:616
void setHyperDetected(bool hyperdetected)
Sets the UFO&#39;s hyper detection status.
Definition: Ufo.cpp:686
int getHitFrame() const
Gets the UFO&#39;s hit frame.
Definition: Ufo.cpp:769
bool isInBattlescape() const
Gets if the UFO is in battlescape.
Definition: Ufo.cpp:575
bool isDestroyed() const
Gets if the UFO has been destroyed.
Definition: Ufo.cpp:453
Represents an ongoing alien mission.
Definition: AlienMission.h:46
void setId(int id)
Sets the UFO&#39;s ID.
Definition: Ufo.cpp:270
Ufo(const RuleUfo *rules)
Creates a UFO of the specified type.
Definition: Ufo.cpp:49
void setDetected(bool detected)
Sets the UFO&#39;s detection status.
Definition: Ufo.cpp:360
~Ufo()
Cleans up the UFO.
Definition: Ufo.cpp:62
void setHitFrame(int frame)
Sets the UFO&#39;s hit frame.
Definition: Ufo.cpp:760
int getShootingAt() const
Get which interceptor this ufo is engaging.
Definition: Ufo.cpp:706
int getLandId() const
Gets the UFO&#39;s landing site ID.
Definition: Ufo.cpp:724
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
bool isCrashed() const
Gets if the UFO has crashed.
Definition: Ufo.cpp:443
std::wstring getDefaultName(Language *lang) const
Gets the UFO&#39;s default name.
Definition: Ufo.cpp:280
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
void changeRules(const RuleUfo *rules)
Sets the UFO&#39;s ruleset.
Definition: Ufo.cpp:251
enum UfoStatus getStatus() const
Gets the UFO status.
Definition: Ufo.h:107
int getEscapeCountdown() const
Gets the escape timer for dogfights.
Definition: Ufo.cpp:787
std::string getDirection() const
Gets the UFO&#39;s direction.
Definition: Ufo.cpp:391
void setStatus(enum UfoStatus status)
Set the UFO&#39;s status.
Definition: Ufo.h:109
bool getDetected() const
Gets the UFO&#39;s detection status.
Definition: Ufo.cpp:351
virtual void load(const YAML::Node &node)
Loads the moving target from YAML.
Definition: MovingTarget.cpp:56
const UfoTrajectory & getTrajectory() const
Gets the UFO&#39;s trajectory.
Definition: Ufo.h:141
AlienMission * getMission() const
Gets the UFO&#39;s mission object.
Definition: Ufo.h:143
bool getHyperDetected() const
Gets the UFO&#39;s hyper detection status.
Definition: Ufo.cpp:677
bool getInterceptionProcessed() const
Gets if the ufo has had its timers decremented on this cycle of interception updates.
Definition: Ufo.cpp:825
std::string getAltitude() const
Gets the UFO&#39;s altitude.
Definition: Ufo.cpp:400
void setAltitude(const std::string &altitude)
Sets the UFO&#39;s altitude.
Definition: Ufo.cpp:425
void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory)
Sets the UFO&#39;s mission information.
Definition: Ufo.cpp:664
Contains strings used throughout the game for localization.
Definition: Language.h:39
CraftId getShotDownByCraftId() const
Gets the ID of craft which shot down the UFO.
Definition: Ufo.cpp:605
void setFireCountdown(int time)
Sets the number of ticks until the ufo fires its weapon.
Definition: Ufo.cpp:796
void setDamage(int damage)
Sets the UFO&#39;s amount of damage.
Definition: Ufo.cpp:330
void setShootingAt(int target)
Set which interceptor this ufo is engaging.
Definition: Ufo.cpp:715
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:47
size_t getTrajectoryPoint() const
Gets the UFO&#39;s progress on the trajectory track.
Definition: Ufo.h:137
size_t getSecondsRemaining() const
Gets the UFO&#39;s seconds left on the ground.
Definition: Ufo.cpp:371
const std::string & getMissionType() const
Gets the UFO&#39;s Mission type.
Definition: Ufo.cpp:651
void setInterceptionProcessed(bool processed)
Sets a flag denoting that this ufo has had its timers decremented.
Definition: Ufo.cpp:816
YAML::Node saveId() const
Saves the UFO&#39;s ID to YAML.
Definition: Ufo.cpp:229
void setInBattlescape(bool inbattle)
Sets the UFO&#39;s battlescape status.
Definition: Ufo.cpp:584
int getFireCountdown() const
Gets the number of ticks until the ufo is ready to fire.
Definition: Ufo.cpp:805
Represents an alien UFO on the map.
Definition: Ufo.h:40
int getCrashId() const
Gets the UFO&#39;s crash site ID.
Definition: Ufo.cpp:742
int getAltitudeInt() const
Gets the UFO&#39;s altitude.
Definition: Ufo.cpp:409
void setShotDownByCraftId(const CraftId &craftId)
Sets the ID of craft which shot down the UFO.
Definition: Ufo.cpp:600
Base class for moving targets on the globe with a certain speed and destination.
Definition: MovingTarget.h:29
void load(const YAML::Node &node, const Mod &ruleset, SavedGame &game)
Loads the UFO from YAML.
Definition: Ufo.cpp:112
void setSecondsRemaining(size_t seconds)
Sets the UFO&#39;s seconds left on the ground.
Definition: Ufo.cpp:382
void setDestination(Target *dest)
Sets the UFO&#39;s destination.
Definition: Ufo.cpp:695
void think()
Handles UFO logic.
Definition: Ufo.cpp:542
int getMarker() const
Gets the UFO&#39;s marker.
Definition: Ufo.cpp:300
Represents a specific type of UFO.
Definition: RuleUfo.h:35
int getDamage() const
Gets the UFO&#39;s amount of damage.
Definition: Ufo.cpp:321
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:33
void setLandId(int id)
Sets the UFO&#39;s landing site ID.
Definition: Ufo.cpp:733
void setCrashId(int id)
Sets the UFO&#39;s crash site ID.
Definition: Ufo.cpp:751
const std::string & getAlienRace() const
Gets the UFO&#39;s alien race.
Definition: Ufo.cpp:595
const RuleUfo * getRules() const
Gets the UFO&#39;s ruleset.
Definition: Ufo.cpp:241
Definition: BaseInfoState.cpp:40
void setEscapeCountdown(int time)
Sets the countdown timer for escaping a dogfight.
Definition: Ufo.cpp:778
virtual YAML::Node save() const
Saves the moving target to YAML.
Definition: MovingTarget.cpp:69
int getId() const
Gets the UFO&#39;s ID.
Definition: Ufo.cpp:261