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();
66  std::wstring getDefaultName(Language *) const { return L""; }
67 
68  using Target::load;
69 public:
71  Base(const Mod *mod);
73  ~Base();
75  void load(const YAML::Node& node, SavedGame *save, bool newGame, bool newBattleGame = false);
77  YAML::Node save() const;
79  YAML::Node saveId() const;
81  std::wstring getName(Language *lang = 0) const;
83  int getMarker() const;
85  std::vector<BaseFacility*> *getFacilities();
87  std::vector<Soldier*> *getSoldiers();
89  std::vector<Craft*> *getCrafts();
91  std::vector<Transfer*> *getTransfers();
95  int getScientists() const;
97  void setScientists(int scientists);
99  int getEngineers() const;
101  void setEngineers(int engineers);
103  int detect(Target *target) const;
105  int insideRadarRange(Target *target) const;
107  int getAvailableSoldiers(bool checkCombatReadiness = false) const;
109  int getTotalSoldiers() const;
111  int getAvailableScientists() const;
113  int getTotalScientists() const;
115  int getAvailableEngineers() const;
117  int getTotalEngineers() const;
119  int getUsedQuarters() const;
121  int getAvailableQuarters() const;
123  double getUsedStores();
125  bool storesOverfull(double offset = 0.0);
127  int getAvailableStores() const;
129  int getUsedLaboratories() const;
131  int getAvailableLaboratories() const;
133  int getUsedWorkshops() const;
135  int getAvailableWorkshops() const;
137  int getUsedHangars() const;
139  int getAvailableHangars() const;
141  int getFreeLaboratories() const;
143  int getFreeWorkshops() const;
144 
145  int getAllocatedScientists() const;
146 
147  int getAllocatedEngineers() const;
149  int getDefenseValue() const;
151  int getShortRangeDetection() const;
153  int getLongRangeDetection() const;
155  int getCraftCount(const std::string &craft) const;
157  int getCraftMaintenance() const;
159  int getSoldierCount(const std::string &soldier) const;
161  int getPersonnelMaintenance() const;
163  int getFacilityMaintenance() const;
165  int getMonthlyMaintenace() const;
167  const std::vector<ResearchProject *> & getResearch() const;
173  void addProduction (Production * p);
175  void removeProduction (Production * p);
177  const std::vector<Production *> & getProductions() const;
179  bool getHyperDetection() const;
181  int getUsedPsiLabs() const;
183  int getAvailablePsiLabs() const;
185  int getFreePsiLabs() const;
187  int getFreeContainment() const;
189  int getAvailableContainment() const;
191  int getUsedContainment() const;
193  void setInBattlescape(bool inbattle);
195  bool isInBattlescape() const;
197  void setRetaliationTarget(bool mark = true);
199  bool getRetaliationTarget() const;
201  size_t getDetectionChance() const;
203  int getGravShields() const;
205  void setupDefenses();
207  std::vector<BaseFacility*> *getDefenses();
209  std::vector<Vehicle*> *getVehicles();
213  std::list<std::vector<BaseFacility*>::iterator> getDisconnectedFacilities(BaseFacility *remove);
215  void destroyFacility(std::vector<BaseFacility*>::iterator facility);
217  void cleanupDefenses(bool reclaimItems);
218 };
219 
220 }
int getAvailableQuarters() const
Gets the base&#39;s available living quarters.
Definition: Base.cpp:581
std::vector< BaseFacility * > * getFacilities()
Gets the base&#39;s facilities.
Definition: Base.cpp:314
void setupDefenses()
Setup base defenses.
Definition: Base.cpp:1344
int getAvailableStores() const
Gets the base&#39;s available storage space.
Definition: Base.cpp:647
bool getHyperDetection() const
Checks if this base is hyper-wave equipped.
Definition: Base.cpp:1130
void removeProduction(Production *p)
Remove a Base Production&#39;s.
Definition: Base.cpp:1104
int getMarker() const
Gets the base&#39;s marker.
Definition: Base.cpp:302
int getTotalScientists() const
Gets the base&#39;s total scientists.
Definition: Base.cpp:514
const std::vector< ResearchProject * > & getResearch() const
Get the list of base&#39;s ResearchProject.
Definition: Base.cpp:1063
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:1254
int getAvailablePsiLabs() const
Gets the base&#39;s total available psi lab space.
Definition: Base.cpp:1147
int getCraftMaintenance() const
Gets the base&#39;s craft maintenance.
Definition: Base.cpp:964
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:1331
int getUsedLaboratories() const
Gets the base&#39;s used laboratory space.
Definition: Base.cpp:699
void destroyFacility(std::vector< BaseFacility *>::iterator facility)
destroy a facility and deal with the side effects.
Definition: Base.cpp:1555
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:1118
std::vector< Vehicle * > * getVehicles()
Gets the base&#39;s vehicles.
Definition: Base.cpp:1444
int getUsedContainment() const
Gets the total amount of used Containment space.
Definition: Base.cpp:1183
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
YAML::Node saveId() const
Saves the base&#39;s ID to YAML.
Definition: Base.cpp:280
int getUsedPsiLabs() const
Gets the base&#39;s used psi lab space.
Definition: Base.cpp:1165
~Base()
Cleans up the base.
Definition: Base.cpp:63
int getScientists() const
Gets the base&#39;s scientists.
Definition: Base.cpp:361
int getUsedQuarters() const
Gets the base&#39;s used living quarters.
Definition: Base.cpp:571
int getSoldierCount(const std::string &soldier) const
Gets the base&#39;s soldiers of a certain type.
Definition: Base.cpp:987
int getFreeWorkshops() const
Get the number of available space lab (not used by a Production)
Definition: Base.cpp:820
ItemContainer * getStorageItems()
Gets the base&#39;s items.
Definition: Base.cpp:352
void addResearch(ResearchProject *)
Add a new ResearchProject to the Base.
Definition: Base.cpp:1081
int getPersonnelMaintenance() const
Gets the base&#39;s personnel maintenance.
Definition: Base.cpp:1012
int getAvailableHangars() const
Gets the base&#39;s available hangars.
Definition: Base.cpp:794
int getTotalEngineers() const
Gets the base&#39;s total engineers.
Definition: Base.cpp:549
int getCraftCount(const std::string &craft) const
Gets the base&#39;s crafts of a certain type.
Definition: Base.cpp:939
int detect(Target *target) const
Checks if a target is detected by the base&#39;s radar.
Definition: Base.cpp:399
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:1317
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:879
Definition: Production.h:31
void addProduction(Production *p)
Add a new Production to Base.
Definition: Base.cpp:1072
int getAvailableWorkshops() const
Gets the base&#39;s available workshop space.
Definition: Base.cpp:750
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:1245
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:388
int getAllocatedScientists() const
Returns the amount of scientists currently in use.
Definition: Base.cpp:847
std::vector< Transfer * > * getTransfers()
Gets the base&#39;s transfers.
Definition: Base.cpp:342
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:1466
std::vector< BaseFacility * > * getDefenses()
Get a list of Defensive Facilities.
Definition: Base.cpp:1434
Represents a player base on the globe.
Definition: Base.h:45
void setScientists(int scientists)
Sets the base&#39;s scientists.
Definition: Base.cpp:370
int getMonthlyMaintenace() const
Gets the base&#39;s total monthly maintenance.
Definition: Base.cpp:1054
bool storesOverfull(double offset=0.0)
Checks if the base&#39;s stores are overfull.
Definition: Base.cpp:635
int getFreeLaboratories() const
Get the number of available space lab (not used by a ResearchProject)
Definition: Base.cpp:811
int getAvailableEngineers() const
Gets the base&#39;s available engineers.
Definition: Base.cpp:539
int getEngineers() const
Gets the base&#39;s engineers.
Definition: Base.cpp:379
int getUsedWorkshops() const
Gets the base&#39;s used workshop space.
Definition: Base.cpp:735
std::wstring getName(Language *lang=0) const
Gets the base&#39;s name.
Definition: Base.cpp:293
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:1726
bool getRetaliationTarget() const
Gets the retaliation status of this base.
Definition: Base.cpp:1263
int getAvailableSoldiers(bool checkCombatReadiness=false) const
Gets the base&#39;s available soldiers.
Definition: Base.cpp:463
int getFacilityMaintenance() const
Gets the base&#39;s facility maintenance.
Definition: Base.cpp:1036
int getTotalSoldiers() const
Gets the base&#39;s total soldiers.
Definition: Base.cpp:486
int getAvailableScientists() const
Gets the base&#39;s available scientists.
Definition: Base.cpp:504
std::vector< Craft * > * getCrafts()
Gets the base&#39;s crafts.
Definition: Base.cpp:332
void destroyDisconnectedFacilities()
Destroys all disconnected facilities in the base.
Definition: Base.cpp:1452
int getAvailableContainment() const
Gets the total amount of Containment space.
Definition: Base.cpp:1219
int getAllocatedEngineers() const
Returns the amount of engineers currently in use.
Definition: Base.cpp:864
int getShortRangeDetection() const
Gets the base&#39;s short range detection.
Definition: Base.cpp:897
int getAvailableLaboratories() const
Gets the base&#39;s available laboratory space.
Definition: Base.cpp:717
virtual void load(const YAML::Node &node)
Loads the moving target from YAML.
Definition: Target.cpp:55
std::vector< Soldier * > * getSoldiers()
Gets the base&#39;s soldiers.
Definition: Base.cpp:323
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:33
int getFreePsiLabs() const
Gets the base&#39;s total free psi lab space.
Definition: Base.cpp:829
int getFreeContainment() const
Gets the amount of free Containment space.
Definition: Base.cpp:838
int getUsedHangars() const
Gets the base&#39;s used hangars.
Definition: Base.cpp:768
double getUsedStores()
Gets the base&#39;s used storage space.
Definition: Base.cpp:599
Definition: BaseInfoState.cpp:40
int getLongRangeDetection() const
Gets the base&#39;s long range detection.
Definition: Base.cpp:918
bool isInBattlescape() const
Gets if the craft is in battlescape.
Definition: Base.cpp:1236
int insideRadarRange(Target *target) const
Checks if a target is inside the base&#39;s radar range.
Definition: Base.cpp:438
void removeResearch(ResearchProject *)
Remove a ResearchProject from the Base.
Definition: Base.cpp:1090