OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Craft.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_CRAFT_H
20 #define OPENXCOM_CRAFT_H
21 
22 #include "MovingTarget.h"
23 #include <vector>
24 #include <string>
25 
26 namespace OpenXcom
27 {
28 
29 class RuleCraft;
30 class Base;
31 class Soldier;
32 class CraftWeapon;
33 class ItemContainer;
34 class Ruleset;
35 class SavedGame;
36 class Vehicle;
37 
44 class Craft : public MovingTarget
45 {
46 private:
47  RuleCraft *_rules;
48  Base *_base;
49  int _id, _fuel, _damage, _interceptionOrder, _takeoff;
50  std::vector<CraftWeapon*> _weapons;
51  ItemContainer *_items;
52  std::vector<Vehicle*> _vehicles;
53  std::string _status;
54  bool _lowFuel, _inBattlescape, _inDogfight;
55  std::wstring _name;
56 public:
58  Craft(RuleCraft *rules, Base *base, int id = 0);
60  ~Craft();
62  void load(const YAML::Node& node, const Ruleset *rule, SavedGame *save);
64  YAML::Node save() const;
66  YAML::Node saveId() const;
68  RuleCraft *getRules() const;
70  void setRules(RuleCraft *rules);
72  int getId() const;
74  std::wstring getName(Language *lang) const;
76  void setName(const std::wstring &newName);
78  Base *getBase() const;
80  void setBase(Base *base);
82  void setBaseOnly(Base *base);
84  std::string getStatus() const;
86  void setStatus(const std::string &status);
88  std::string getAltitude() const;
90  void setDestination(Target *dest);
92  int getNumWeapons() const;
94  int getNumSoldiers() const;
96  int getNumEquipment() const;
98  int getNumVehicles() const;
100  std::vector<CraftWeapon*> *getWeapons();
104  std::vector<Vehicle*> *getVehicles();
106  int getFuel() const;
108  void setFuel(int fuel);
110  int getFuelPercentage() const;
112  int getDamage() const;
114  void setDamage(int damage);
116  int getDamagePercentage() const;
118  bool getLowFuel() const;
120  void setLowFuel(bool low);
122  double getDistanceFromBase() const;
124  int getFuelConsumption() const;
126  int getFuelLimit() const;
128  int getFuelLimit(Base *base) const;
130  void returnToBase();
132  bool detect(Target *target) const;
134  void think();
136  void checkup();
138  void consumeFuel();
140  void repair();
142  void refuel();
144  std::string rearm(Ruleset *rules);
146  void setInBattlescape(bool inbattle);
148  bool isInBattlescape() const;
150  bool isDestroyed() const;
152  int getSpaceAvailable() const;
154  int getSpaceUsed() const;
156  int getVehicleCount(const std::string &vehicle) const;
158  void setInDogfight(const bool inDogfight);
160  bool isInDogfight() const;
162  void setInterceptionOrder(const int order);
164  int getInterceptionOrder() const;
165 };
166 
167 }
168 
169 #endif
std::vector< CraftWeapon * > * getWeapons()
Gets the craft's weapons.
Definition: Craft.cpp:462
Represents a craft stored in a base.
Definition: Craft.h:44
bool getLowFuel() const
Gets whether the craft is running out of fuel.
Definition: Craft.cpp:562
std::vector< Vehicle * > * getVehicles()
Gets the craft's vehicles.
Definition: Craft.cpp:481
std::string getStatus() const
Gets the craft's status.
Definition: Craft.cpp:343
void setInDogfight(const bool inDogfight)
Sets the craft's dogfight status.
Definition: Craft.cpp:881
void setInBattlescape(bool inbattle)
Sets the craft's battlescape status.
Definition: Craft.cpp:805
ItemContainer * getItems()
Gets the craft's items.
Definition: Craft.cpp:471
std::string getAltitude() const
Gets the craft's altitude.
Definition: Craft.cpp:361
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
int getFuelLimit() const
Gets the craft's minimum fuel limit.
Definition: Craft.cpp:604
int getNumEquipment() const
Gets the craft's amount of equipment.
Definition: Craft.cpp:442
void refuel()
Refuels the craft.
Definition: Craft.cpp:728
Craft(RuleCraft *rules, Base *base, int id=0)
Creates a craft of the specified type.
Definition: Craft.cpp:49
void setBase(Base *base)
Sets the craft's base.
Definition: Craft.cpp:323
Base * getBase() const
Gets the craft's base.
Definition: Craft.cpp:314
void consumeFuel()
Consumes the craft's fuel.
Definition: Craft.cpp:706
~Craft()
Cleans up the craft.
Definition: Craft.cpp:66
int getId() const
Gets the craft's ID.
Definition: Craft.cpp:284
Contains strings used throughout the game for localization.
Definition: Language.h:42
int getFuelPercentage() const
Gets the craft's percentage of fuel.
Definition: Craft.cpp:519
void load(const YAML::Node &node, const Ruleset *rule, SavedGame *save)
Loads the craft from YAML.
Definition: Craft.cpp:85
Set of rules and stats for a game.
Definition: Ruleset.h:69
int getDamage() const
Gets the craft's amount of damage.
Definition: Craft.cpp:528
int getNumSoldiers() const
Gets the craft's amount of soldiers.
Definition: Craft.cpp:421
void setFuel(int fuel)
Sets the craft's amount of fuel.
Definition: Craft.cpp:501
void setStatus(const std::string &status)
Sets the craft's status.
Definition: Craft.cpp:352
int getDamagePercentage() const
Gets the craft's percentage of damage.
Definition: Craft.cpp:552
void repair()
Repairs the craft.
Definition: Craft.cpp:715
YAML::Node save() const
Saves the craft to YAML.
Definition: Craft.cpp:205
Represents the items contained by a certain entity, like base stores, craft equipment, etc.
Definition: ItemContainer.h:36
Represents a player base on the globe.
Definition: Base.h:47
int getVehicleCount(const std::string &vehicle) const
Gets the craft's vehicles of a certain type.
Definition: Craft.cpp:855
bool isInBattlescape() const
Gets if the craft is in battlescape.
Definition: Craft.cpp:796
Represents a specific type of craft.
Definition: RuleCraft.h:38
RuleCraft * getRules() const
Gets the craft's ruleset.
Definition: Craft.cpp:259
void setDestination(Target *dest)
Sets the craft's destination.
Definition: Craft.cpp:378
void setDamage(int damage)
Sets the craft's amount of damage.
Definition: Craft.cpp:537
int getSpaceAvailable() const
Gets the amount of space available inside a craft.
Definition: Craft.cpp:829
int getFuelConsumption() const
Gets the craft's fuel consumption.
Definition: Craft.cpp:592
void setBaseOnly(Base *base)
Sets the craft's base. (without setting the craft's coordinates)
Definition: Craft.cpp:334
void returnToBase()
Returns the craft to its base.
Definition: Craft.cpp:623
YAML::Node saveId() const
Saves the craft's ID to YAML.
Definition: Craft.cpp:247
int getInterceptionOrder() const
Gets interception number.
Definition: Craft.cpp:899
bool isInDogfight() const
Gets if the craft is in dogfight.
Definition: Craft.cpp:872
double getDistanceFromBase() const
Gets the craft's distance from its base.
Definition: Craft.cpp:582
std::wstring getName(Language *lang) const
Gets the craft's name.
Definition: Craft.cpp:295
bool detect(Target *target) const
Checks if a target is detected by the craft's radar.
Definition: Craft.cpp:694
void think()
Handles craft logic.
Definition: Craft.cpp:631
Base class for moving targets on the globe with a certain speed and destination.
Definition: MovingTarget.h:31
void setLowFuel(bool low)
Sets whether the craft is running out of fuel.
Definition: Craft.cpp:572
void checkup()
Does a craft full checkup.
Definition: Craft.cpp:656
int getSpaceUsed() const
Gets the amount of space used inside a craft.
Definition: Craft.cpp:839
int getNumVehicles() const
Gets the craft's amount of vehicles.
Definition: Craft.cpp:452
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
int getFuel() const
Gets the craft's amount of fuel.
Definition: Craft.cpp:491
std::string rearm(Ruleset *rules)
Rearms the craft.
Definition: Craft.cpp:751
void setInterceptionOrder(const int order)
Sets interception order (first craft to leave the base gets 1, second 2, etc.).
Definition: Craft.cpp:890
void setRules(RuleCraft *rules)
Sets the craft's ruleset.
Definition: Craft.cpp:269
void setName(const std::wstring &newName)
Sets the craft's name.
Definition: Craft.cpp:305
int getNumWeapons() const
Gets the craft's amount of weapons.
Definition: Craft.cpp:396
bool isDestroyed() const
Gets if craft is destroyed during dogfights.
Definition: Craft.cpp:819