OpenXcom  1.0
Open-source clone of the original X-Com
Base.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 "Target.h"
21 #include <string>
22 #include <vector>
23 #include <yaml-cpp/yaml.h>
24 
25 namespace OpenXcom
26 {
27 
28 class Mod;
29 class BaseFacility;
30 class Soldier;
31 class Craft;
32 class ItemContainer;
33 class Transfer;
34 class Language;
35 class Mod;
36 class SavedGame;
37 class ResearchProject;
38 class Production;
39 class Vehicle;
40 
45 class Base : public Target
46 {
47 private:
48  static const int BASE_SIZE = 6;
49  const Mod *_mod;
50  std::vector<BaseFacility*> _facilities;
51  std::vector<Soldier*> _soldiers;
52  std::vector<Craft*> _crafts;
53  std::vector<Transfer*> _transfers;
54  ItemContainer *_items;
55  int _scientists, _engineers;
56  std::vector<ResearchProject *> _research;
57  std::vector<Production *> _productions;
58  bool _inBattlescape;
59  bool _retaliationTarget;
60  std::vector<Vehicle*> _vehicles;
61  std::vector<BaseFacility*> _defenses;
62 
64  double getIgnoredStores();
65 
66  using Target::load;
67 public:
69  Base(const Mod *mod);
71  ~Base();
73  void load(const YAML::Node& node, SavedGame *save, bool newGame, bool newBattleGame = false);
75  YAML::Node save() const;
77  std::string getType() const;
79  std::string getName(Language *lang = 0) const;
81  int getMarker() const;
83  std::vector<BaseFacility*> *getFacilities();
85  std::vector<Soldier*> *getSoldiers();
87  std::vector<Craft*> *getCrafts();
89  std::vector<Transfer*> *getTransfers();
93  int getScientists() const;
95  void setScientists(int scientists);
97  int getEngineers() const;
99  void setEngineers(int engineers);
101  int detect(Target *target) const;
103  int insideRadarRange(Target *target) const;
105  int getAvailableSoldiers(bool checkCombatReadiness = false) const;
107  int getTotalSoldiers() const;
109  int getAvailableScientists() const;
111  int getTotalScientists() const;
113  int getAvailableEngineers() const;
115  int getTotalEngineers() const;
117  int getUsedQuarters() const;
119  int getAvailableQuarters() const;
121  double getUsedStores();
123  bool storesOverfull(double offset = 0.0);
125  int getAvailableStores() const;
127  int getUsedLaboratories() const;
129  int getAvailableLaboratories() const;
131  int getUsedWorkshops() const;
133  int getAvailableWorkshops() const;
135  int getUsedHangars() const;
137  int getAvailableHangars() const;
139  int getFreeLaboratories() const;
141  int getFreeWorkshops() const;
142 
143  int getAllocatedScientists() const;
144 
145  int getAllocatedEngineers() const;
147  int getDefenseValue() const;
149  int getShortRangeDetection() const;
151  int getLongRangeDetection() const;
153  int getCraftCount(const std::string &craft) const;
155  int getCraftMaintenance() const;
157  int getSoldierCount(const std::string &soldier) const;
159  int getPersonnelMaintenance() const;
161  int getFacilityMaintenance() const;
163  int getMonthlyMaintenace() const;
165  const std::vector<ResearchProject *> & getResearch() const;
171  void addProduction (Production * p);
173  void removeProduction (Production * p);
175  const std::vector<Production *> & getProductions() const;
177  bool getHyperDetection() const;
179  int getUsedPsiLabs() const;
181  int getAvailablePsiLabs() const;
183  int getFreePsiLabs() const;
185  int getFreeContainment() const;
187  int getAvailableContainment() const;
189  int getUsedContainment() const;
191  void setInBattlescape(bool inbattle);
193  bool isInBattlescape() const;
195  void setRetaliationTarget(bool mark = true);
197  bool getRetaliationTarget() const;
199  size_t getDetectionChance() const;
201  int getGravShields() const;
203  void setupDefenses();
205  std::vector<BaseFacility*> *getDefenses();
207  std::vector<Vehicle*> *getVehicles();
211  std::list<std::vector<BaseFacility*>::iterator> getDisconnectedFacilities(BaseFacility *remove);
213  void destroyFacility(std::vector<BaseFacility*>::iterator facility);
215  void cleanupDefenses(bool reclaimItems);
216 };
217 
218 }
int getAvailableQuarters() const
Gets the base&#39;s available living quarters.
Definition: Base.cpp:579
std::vector< BaseFacility * > * getFacilities()
Gets the base&#39;s facilities.
Definition: Base.cpp:312
void setupDefenses()
Setup base defenses.
Definition: Base.cpp:1353
int getAvailableStores() const
Gets the base&#39;s available storage space.
Definition: Base.cpp:645
bool getHyperDetection() const
Checks if this base is hyper-wave equipped.
Definition: Base.cpp:1139
void removeProduction(Production *p)
Remove a Base Production&#39;s.
Definition: Base.cpp:1112
int getMarker() const
Gets the base&#39;s marker sprite.
Definition: Base.cpp:300
int getTotalScientists() const
Gets the base&#39;s total scientists.
Definition: Base.cpp:512
const std::vector< ResearchProject * > & getResearch() const
Get the list of base&#39;s ResearchProject.
Definition: Base.cpp:1061
void load(const YAML::Node &node, SavedGame *save, bool newGame, bool newBattleGame=false)
Loads the base from YAML.
Definition: Base.cpp:106
void setRetaliationTarget(bool mark=true)
Mark this base for alien retaliation.
Definition: Base.cpp:1263
int getAvailablePsiLabs() const
Gets the base&#39;s total available psi lab space.
Definition: Base.cpp:1156
int getCraftMaintenance() const
Gets the base&#39;s craft maintenance.
Definition: Base.cpp:962
Represents a base facility placed in a base.
Definition: BaseFacility.h:36
int getGravShields() const
Gets how many Grav Shields the base has.
Definition: Base.cpp:1340
int getUsedLaboratories() const
Gets the base&#39;s used laboratory space.
Definition: Base.cpp:697
void destroyFacility(std::vector< BaseFacility *>::iterator facility)
destroy a facility and deal with the side effects.
Definition: Base.cpp:1564
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
const std::vector< Production * > & getProductions() const
Get the list of Base Production&#39;s.
Definition: Base.cpp:1127
std::vector< Vehicle * > * getVehicles()
Gets the base&#39;s vehicles.
Definition: Base.cpp:1453
int getUsedContainment() const
Gets the total amount of used Containment space.
Definition: Base.cpp:1192
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
int getUsedPsiLabs() const
Gets the base&#39;s used psi lab space.
Definition: Base.cpp:1174
~Base()
Cleans up the base.
Definition: Base.cpp:63
int getScientists() const
Gets the base&#39;s scientists.
Definition: Base.cpp:359
std::string getType() const
Gets the base&#39;s type.
Definition: Base.cpp:281
int getUsedQuarters() const
Gets the base&#39;s used living quarters.
Definition: Base.cpp:569
int getSoldierCount(const std::string &soldier) const
Gets the base&#39;s soldiers of a certain type.
Definition: Base.cpp:985
int getFreeWorkshops() const
Get the number of available space lab (not used by a Production)
Definition: Base.cpp:818
ItemContainer * getStorageItems()
Gets the base&#39;s items.
Definition: Base.cpp:350
void addResearch(ResearchProject *)
Add a new ResearchProject to the Base.
Definition: Base.cpp:1079
std::string getName(Language *lang=0) const
Gets the base&#39;s name.
Definition: Base.cpp:291
int getPersonnelMaintenance() const
Gets the base&#39;s personnel maintenance.
Definition: Base.cpp:1010
int getAvailableHangars() const
Gets the base&#39;s available hangars.
Definition: Base.cpp:792
int getTotalEngineers() const
Gets the base&#39;s total engineers.
Definition: Base.cpp:547
int getCraftCount(const std::string &craft) const
Gets the base&#39;s crafts of a certain type.
Definition: Base.cpp:937
int detect(Target *target) const
Checks if a target is detected by the base&#39;s radar.
Definition: Base.cpp:397
Contains strings used throughout the game for localization.
Definition: Language.h:39
size_t getDetectionChance() const
Get the detection chance for this base.
Definition: Base.cpp:1326
Represent a ResearchProject Contain information about assigned scientist, time already spent and cost...
Definition: ResearchProject.h:32
int getDefenseValue() const
Gets the base&#39;s defense value.
Definition: Base.cpp:877
Definition: Production.h:31
void addProduction(Production *p)
Add a new Production to Base.
Definition: Base.cpp:1070
int getAvailableWorkshops() const
Gets the base&#39;s available workshop space.
Definition: Base.cpp:748
YAML::Node save() const
Saves the base to YAML.
Definition: Base.cpp:239
void setInBattlescape(bool inbattle)
Sets the craft&#39;s battlescape status.
Definition: Base.cpp:1254
Represents the items contained by a certain entity, like base stores, craft equipment, etc.
Definition: ItemContainer.h:34
void setEngineers(int engineers)
Sets the base&#39;s engineers.
Definition: Base.cpp:386
int getAllocatedScientists() const
Returns the amount of scientists currently in use.
Definition: Base.cpp:845
std::vector< Transfer * > * getTransfers()
Gets the base&#39;s transfers.
Definition: Base.cpp:340
std::list< std::vector< BaseFacility * >::iterator > getDisconnectedFacilities(BaseFacility *remove)
Gets a sorted list of the facilities(=iterators) NOT connected to the Access Lift.
Definition: Base.cpp:1475
std::vector< BaseFacility * > * getDefenses()
Get a list of Defensive Facilities.
Definition: Base.cpp:1443
Represents a player base on the globe.
Definition: Base.h:45
void setScientists(int scientists)
Sets the base&#39;s scientists.
Definition: Base.cpp:368
int getMonthlyMaintenace() const
Gets the base&#39;s total monthly maintenance.
Definition: Base.cpp:1052
bool storesOverfull(double offset=0.0)
Checks if the base&#39;s stores are overfull.
Definition: Base.cpp:633
int getFreeLaboratories() const
Get the number of available space lab (not used by a ResearchProject)
Definition: Base.cpp:809
int getAvailableEngineers() const
Gets the base&#39;s available engineers.
Definition: Base.cpp:537
int getEngineers() const
Gets the base&#39;s engineers.
Definition: Base.cpp:377
int getUsedWorkshops() const
Gets the base&#39;s used workshop space.
Definition: Base.cpp:733
Base(const Mod *mod)
Creates a new base.
Definition: Base.cpp:55
void cleanupDefenses(bool reclaimItems)
Cleans up the defenses vector and optionally reclaims the tanks and their ammo.
Definition: Base.cpp:1735
bool getRetaliationTarget() const
Gets the retaliation status of this base.
Definition: Base.cpp:1272
int getAvailableSoldiers(bool checkCombatReadiness=false) const
Gets the base&#39;s available soldiers.
Definition: Base.cpp:461
int getFacilityMaintenance() const
Gets the base&#39;s facility maintenance.
Definition: Base.cpp:1034
int getTotalSoldiers() const
Gets the base&#39;s total soldiers.
Definition: Base.cpp:484
int getAvailableScientists() const
Gets the base&#39;s available scientists.
Definition: Base.cpp:502
std::vector< Craft * > * getCrafts()
Gets the base&#39;s crafts.
Definition: Base.cpp:330
void destroyDisconnectedFacilities()
Destroys all disconnected facilities in the base.
Definition: Base.cpp:1461
int getAvailableContainment() const
Gets the total amount of Containment space.
Definition: Base.cpp:1228
int getAllocatedEngineers() const
Returns the amount of engineers currently in use.
Definition: Base.cpp:862
int getShortRangeDetection() const
Gets the base&#39;s short range detection.
Definition: Base.cpp:895
int getAvailableLaboratories() const
Gets the base&#39;s available laboratory space.
Definition: Base.cpp:715
virtual void load(const YAML::Node &node)
Loads the target from YAML.
Definition: Target.cpp:51
std::vector< Soldier * > * getSoldiers()
Gets the base&#39;s soldiers.
Definition: Base.cpp:321
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
int getFreePsiLabs() const
Gets the base&#39;s total free psi lab space.
Definition: Base.cpp:827
int getFreeContainment() const
Gets the amount of free Containment space.
Definition: Base.cpp:836
int getUsedHangars() const
Gets the base&#39;s used hangars.
Definition: Base.cpp:766
double getUsedStores()
Gets the base&#39;s used storage space.
Definition: Base.cpp:597
Definition: BaseInfoState.cpp:40
int getLongRangeDetection() const
Gets the base&#39;s long range detection.
Definition: Base.cpp:916
bool isInBattlescape() const
Gets if the craft is in battlescape.
Definition: Base.cpp:1245
int insideRadarRange(Target *target) const
Checks if a target is inside the base&#39;s radar range.
Definition: Base.cpp:436
void removeResearch(ResearchProject *)
Remove a ResearchProject from the Base.
Definition: Base.cpp:1088