OpenXcom  1.0
Open-source clone of the original X-Com
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&#39;s weapons.
Definition: Craft.cpp:463
Represents a craft stored in a base.
Definition: Craft.h:44
int getDamagePercentage() const
Gets the craft&#39;s percentage of damage.
Definition: Craft.cpp:553
int getFuelLimit() const
Gets the craft&#39;s minimum fuel limit.
Definition: Craft.cpp:605
int getNumEquipment() const
Gets the craft&#39;s amount of equipment.
Definition: Craft.cpp:443
bool detect(Target *target) const
Checks if a target is detected by the craft&#39;s radar.
Definition: Craft.cpp:695
YAML::Node save() const
Saves the craft to YAML.
Definition: Craft.cpp:206
std::vector< Vehicle * > * getVehicles()
Gets the craft&#39;s vehicles.
Definition: Craft.cpp:482
void setInDogfight(const bool inDogfight)
Sets the craft&#39;s dogfight status.
Definition: Craft.cpp:882
void setInBattlescape(bool inbattle)
Sets the craft&#39;s battlescape status.
Definition: Craft.cpp:806
int getSpaceAvailable() const
Gets the amount of space available inside a craft.
Definition: Craft.cpp:830
ItemContainer * getItems()
Gets the craft&#39;s items.
Definition: Craft.cpp:472
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
bool isInBattlescape() const
Gets if the craft is in battlescape.
Definition: Craft.cpp:797
void refuel()
Refuels the craft.
Definition: Craft.cpp:729
Craft(RuleCraft *rules, Base *base, int id=0)
Creates a craft of the specified type.
Definition: Craft.cpp:50
void setBase(Base *base)
Sets the craft&#39;s base.
Definition: Craft.cpp:324
int getFuel() const
Gets the craft&#39;s amount of fuel.
Definition: Craft.cpp:492
int getNumSoldiers() const
Gets the craft&#39;s amount of soldiers.
Definition: Craft.cpp:422
void consumeFuel()
Consumes the craft&#39;s fuel.
Definition: Craft.cpp:707
~Craft()
Cleans up the craft.
Definition: Craft.cpp:67
int getId() const
Gets the craft&#39;s ID.
Definition: Craft.cpp:285
std::string getStatus() const
Gets the craft&#39;s status.
Definition: Craft.cpp:344
int getNumWeapons() const
Gets the craft&#39;s amount of weapons.
Definition: Craft.cpp:397
double getDistanceFromBase() const
Gets the craft&#39;s distance from its base.
Definition: Craft.cpp:583
Base * getBase() const
Gets the craft&#39;s base.
Definition: Craft.cpp:315
Contains strings used throughout the game for localization.
Definition: Language.h:42
int getDamage() const
Gets the craft&#39;s amount of damage.
Definition: Craft.cpp:529
void load(const YAML::Node &node, const Ruleset *rule, SavedGame *save)
Loads the craft from YAML.
Definition: Craft.cpp:86
Set of rules and stats for a game.
Definition: Ruleset.h:69
int getSpaceUsed() const
Gets the amount of space used inside a craft.
Definition: Craft.cpp:840
void setFuel(int fuel)
Sets the craft&#39;s amount of fuel.
Definition: Craft.cpp:502
std::wstring getName(Language *lang) const
Gets the craft&#39;s name.
Definition: Craft.cpp:296
void setStatus(const std::string &status)
Sets the craft&#39;s status.
Definition: Craft.cpp:353
void repair()
Repairs the craft.
Definition: Craft.cpp:716
std::string getAltitude() const
Gets the craft&#39;s altitude.
Definition: Craft.cpp:362
Represents the items contained by a certain entity, like base stores, craft equipment, etc.
Definition: ItemContainer.h:36
YAML::Node saveId() const
Saves the craft&#39;s ID to YAML.
Definition: Craft.cpp:248
bool getLowFuel() const
Gets whether the craft is running out of fuel.
Definition: Craft.cpp:563
int getInterceptionOrder() const
Gets interception number.
Definition: Craft.cpp:900
Represents a player base on the globe.
Definition: Base.h:47
Represents a specific type of craft.
Definition: RuleCraft.h:38
void setDestination(Target *dest)
Sets the craft&#39;s destination.
Definition: Craft.cpp:379
void setDamage(int damage)
Sets the craft&#39;s amount of damage.
Definition: Craft.cpp:538
void setBaseOnly(Base *base)
Sets the craft&#39;s base. (without setting the craft&#39;s coordinates)
Definition: Craft.cpp:335
void returnToBase()
Returns the craft to its base.
Definition: Craft.cpp:624
bool isInDogfight() const
Gets if the craft is in dogfight.
Definition: Craft.cpp:873
bool isDestroyed() const
Gets if craft is destroyed during dogfights.
Definition: Craft.cpp:820
void think()
Handles craft logic.
Definition: Craft.cpp:632
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:573
void checkup()
Does a craft full checkup.
Definition: Craft.cpp:657
int getFuelConsumption() const
Gets the craft&#39;s fuel consumption.
Definition: Craft.cpp:593
int getVehicleCount(const std::string &vehicle) const
Gets the craft&#39;s vehicles of a certain type.
Definition: Craft.cpp:856
RuleCraft * getRules() const
Gets the craft&#39;s ruleset.
Definition: Craft.cpp:260
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
std::string rearm(Ruleset *rules)
Rearms the craft.
Definition: Craft.cpp:752
int getNumVehicles() const
Gets the craft&#39;s amount of vehicles.
Definition: Craft.cpp:453
COPYING:
Definition: BaseInfoState.cpp:41
void setInterceptionOrder(const int order)
Sets interception order (first craft to leave the base gets 1, second 2, etc.).
Definition: Craft.cpp:891
int getFuelPercentage() const
Gets the craft&#39;s percentage of fuel.
Definition: Craft.cpp:520
void setRules(RuleCraft *rules)
Sets the craft&#39;s ruleset.
Definition: Craft.cpp:270
void setName(const std::wstring &newName)
Sets the craft&#39;s name.
Definition: Craft.cpp:306