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 _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  std::string getType() const;
75  const RuleUfo *getRules() const;
77  void changeRules(const RuleUfo *rules);
79  std::string getDefaultName(Language *lang) const;
81  std::string getMarkerName() const;
83  int getMarker() const;
85  int getDamage() const;
87  void setDamage(int damage);
89  bool getDetected() const;
91  void setDetected(bool detected);
93  size_t getSecondsRemaining() const;
95  void setSecondsRemaining(size_t seconds);
97  std::string getDirection() const;
99  std::string getAltitude() const;
101  int getAltitudeInt() const;
103  void setAltitude(const std::string &altitude);
105  enum UfoStatus getStatus() const { return _status; }
107  void setStatus(enum UfoStatus status) {_status = status; }
109  bool isCrashed() const;
111  bool isDestroyed() const;
113  void think();
115  void setInBattlescape(bool inbattle);
117  bool isInBattlescape() const;
119  const std::string &getAlienRace() const;
121  void setShotDownByCraftId(const CraftId& craftId);
123  CraftId getShotDownByCraftId() const;
125  int getVisibility() const;
127  const std::string &getMissionType() const;
129  void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory);
131  bool getHyperDetected() const;
133  void setHyperDetected(bool hyperdetected);
135  size_t getTrajectoryPoint() const { return _trajectoryPoint; }
137  void setTrajectoryPoint(size_t np) { _trajectoryPoint = np; }
139  const UfoTrajectory &getTrajectory() const { return *_trajectory; }
141  AlienMission *getMission() const { return _mission; }
143  void setDestination(Target *dest);
145  int getShootingAt() const;
147  void setShootingAt(int target);
149  int getLandId() const;
151  void setLandId(int id);
153  int getCrashId() const;
155  void setCrashId(int id);
157  void setHitFrame(int frame);
159  int getHitFrame() const;
160  void setFireCountdown(int time);
161  int getFireCountdown() const;
162  void setEscapeCountdown(int time);
163  int getEscapeCountdown() const;
164  void setInterceptionProcessed(bool processed);
165  bool getInterceptionProcessed() const;
166 
167 };
168 
169 }
void setTrajectoryPoint(size_t np)
Sets the UFO&#39;s progress on the trajectory track.
Definition: Ufo.h:137
int getVisibility() const
Gets the UFO&#39;s visibility.
Definition: Ufo.cpp:592
void setHyperDetected(bool hyperdetected)
Sets the UFO&#39;s hyper detection status.
Definition: Ufo.cpp:662
int getHitFrame() const
Gets the UFO&#39;s hit frame.
Definition: Ufo.cpp:745
bool isInBattlescape() const
Gets if the UFO is in battlescape.
Definition: Ufo.cpp:551
bool isDestroyed() const
Gets if the UFO has been destroyed.
Definition: Ufo.cpp:429
Represents an ongoing alien mission.
Definition: AlienMission.h:46
std::string getType() const
Gets the UFO&#39;s type.
Definition: Ufo.cpp:215
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:336
~Ufo()
Cleans up the UFO.
Definition: Ufo.cpp:62
void setHitFrame(int frame)
Sets the UFO&#39;s hit frame.
Definition: Ufo.cpp:736
int getShootingAt() const
Get which interceptor this ufo is engaging.
Definition: Ufo.cpp:682
int getLandId() const
Gets the UFO&#39;s landing site ID.
Definition: Ufo.cpp:700
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:419
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:234
enum UfoStatus getStatus() const
Gets the UFO status.
Definition: Ufo.h:105
int getEscapeCountdown() const
Gets the escape timer for dogfights.
Definition: Ufo.cpp:763
std::string getDirection() const
Gets the UFO&#39;s direction.
Definition: Ufo.cpp:367
void setStatus(enum UfoStatus status)
Set the UFO&#39;s status.
Definition: Ufo.h:107
bool getDetected() const
Gets the UFO&#39;s detection status.
Definition: Ufo.cpp:327
virtual void load(const YAML::Node &node)
Loads the moving target from YAML.
Definition: MovingTarget.cpp:46
const UfoTrajectory & getTrajectory() const
Gets the UFO&#39;s trajectory.
Definition: Ufo.h:139
AlienMission * getMission() const
Gets the UFO&#39;s mission object.
Definition: Ufo.h:141
std::string getDefaultName(Language *lang) const
Gets the UFO&#39;s default name.
Definition: Ufo.cpp:244
bool getHyperDetected() const
Gets the UFO&#39;s hyper detection status.
Definition: Ufo.cpp:653
bool getInterceptionProcessed() const
Gets if the ufo has had its timers decremented on this cycle of interception updates.
Definition: Ufo.cpp:801
std::string getAltitude() const
Gets the UFO&#39;s altitude.
Definition: Ufo.cpp:376
void setAltitude(const std::string &altitude)
Sets the UFO&#39;s altitude.
Definition: Ufo.cpp:401
void setMissionInfo(AlienMission *mission, const UfoTrajectory *trajectory)
Sets the UFO&#39;s mission information.
Definition: Ufo.cpp:640
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:581
void setFireCountdown(int time)
Sets the number of ticks until the ufo fires its weapon.
Definition: Ufo.cpp:772
void setDamage(int damage)
Sets the UFO&#39;s amount of damage.
Definition: Ufo.cpp:306
void setShootingAt(int target)
Set which interceptor this ufo is engaging.
Definition: Ufo.cpp:691
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:135
size_t getSecondsRemaining() const
Gets the UFO&#39;s seconds left on the ground.
Definition: Ufo.cpp:347
const std::string & getMissionType() const
Gets the UFO&#39;s Mission type.
Definition: Ufo.cpp:627
void setInterceptionProcessed(bool processed)
Sets a flag denoting that this ufo has had its timers decremented.
Definition: Ufo.cpp:792
std::string getMarkerName() const
Gets the UFO&#39;s marker name.
Definition: Ufo.cpp:261
void setInBattlescape(bool inbattle)
Sets the UFO&#39;s battlescape status.
Definition: Ufo.cpp:560
int getFireCountdown() const
Gets the number of ticks until the ufo is ready to fire.
Definition: Ufo.cpp:781
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:718
int getAltitudeInt() const
Gets the UFO&#39;s altitude.
Definition: Ufo.cpp:385
void setShotDownByCraftId(const CraftId &craftId)
Sets the ID of craft which shot down the UFO.
Definition: Ufo.cpp:576
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:99
void setSecondsRemaining(size_t seconds)
Sets the UFO&#39;s seconds left on the ground.
Definition: Ufo.cpp:358
void setDestination(Target *dest)
Sets the UFO&#39;s destination.
Definition: Ufo.cpp:671
void think()
Handles UFO logic.
Definition: Ufo.cpp:518
int getMarker() const
Gets the UFO&#39;s marker sprite.
Definition: Ufo.cpp:278
Represents a specific type of UFO.
Definition: RuleUfo.h:35
int getDamage() const
Gets the UFO&#39;s amount of damage.
Definition: Ufo.cpp:297
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
void setLandId(int id)
Sets the UFO&#39;s landing site ID.
Definition: Ufo.cpp:709
void setCrashId(int id)
Sets the UFO&#39;s crash site ID.
Definition: Ufo.cpp:727
const std::string & getAlienRace() const
Gets the UFO&#39;s alien race.
Definition: Ufo.cpp:571
const RuleUfo * getRules() const
Gets the UFO&#39;s ruleset.
Definition: Ufo.cpp:224
Definition: BaseInfoState.cpp:40
void setEscapeCountdown(int time)
Sets the countdown timer for escaping a dogfight.
Definition: Ufo.cpp:754
virtual YAML::Node save() const
Saves the moving target to YAML.
Definition: MovingTarget.cpp:59