OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Base.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_BASE_H
20 #define OPENXCOM_BASE_H
21 
22 #include "Target.h"
23 #include <string>
24 #include <vector>
25 #include <yaml-cpp/yaml.h>
26 
27 namespace OpenXcom
28 {
29 
30 class Ruleset;
31 class BaseFacility;
32 class Soldier;
33 class Craft;
34 class ItemContainer;
35 class Transfer;
36 class Language;
37 class Ruleset;
38 class SavedGame;
39 class ResearchProject;
40 class Production;
41 class Vehicle;
42 
47 class Base : public Target
48 {
49 private:
50  static const int BASE_SIZE = 6;
51  const Ruleset *_rule;
52  std::wstring _name;
53  std::vector<BaseFacility*> _facilities;
54  std::vector<Soldier*> _soldiers;
55  std::vector<Craft*> _crafts;
56  std::vector<Transfer*> _transfers;
57  ItemContainer *_items;
58  int _scientists, _engineers;
59  std::vector<ResearchProject *> _research;
60  std::vector<Production *> _productions;
61  bool _inBattlescape;
62  bool _retaliationTarget;
63  std::vector<Vehicle*> _vehicles;
64  std::vector<BaseFacility*> _defenses;
66  double getIgnoredStores();
67 public:
69  Base(const Ruleset *rule);
71  ~Base();
73  void load(const YAML::Node& node, SavedGame *save, bool newGame, bool newBattleGame = false);
75  YAML::Node save() const;
77  YAML::Node saveId() const;
79  std::wstring getName(Language* lang = 0) const;
81  void setName(const std::wstring &name);
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 getPersonnelMaintenance() const;
159  int getFacilityMaintenance() const;
161  int getMonthlyMaintenace() const;
163  const std::vector<ResearchProject *> & getResearch() const;
169  void addProduction (Production * p);
171  void removeProduction (Production * p);
173  const std::vector<Production *> & getProductions () const;
175  bool getHyperDetection() const;
177  int getUsedPsiLabs() const;
179  int getAvailablePsiLabs() const;
181  int getFreePsiLabs() const;
183  int getAvailableContainment() const;
185  int getUsedContainment() const;
187  void setInBattlescape(bool inbattle);
189  bool isInBattlescape() const;
191  void setRetaliationTarget(bool mark = true);
193  bool getRetaliationTarget() const;
195  size_t getDetectionChance(int difficulty) const;
197  int getGravShields() const;
199  void setupDefenses();
201  std::vector<BaseFacility*> *getDefenses();
203  std::vector<Vehicle*> *getVehicles();
207  std::list<std::vector<BaseFacility*>::iterator> getDisconnectedFacilities(BaseFacility *remove);
209  void destroyFacility(std::vector<BaseFacility*>::iterator facility);
210 };
211 
212 }
213 
214 #endif
std::vector< BaseFacility * > * getFacilities()
Gets the base's facilities.
Definition: Base.cpp:284
void setupDefenses()
Setup base defenses.
Definition: Base.cpp:1237
void removeProduction(Production *p)
Remove a Base Production's.
Definition: Base.cpp:1002
int getLongRangeDetection() const
Gets the base's long range detection.
Definition: Base.cpp:868
const std::vector< ResearchProject * > & getResearch() const
Get the list of base's ResearchProject.
Definition: Base.cpp:961
void load(const YAML::Node &node, SavedGame *save, bool newGame, bool newBattleGame=false)
Loads the base from YAML.
Definition: Base.cpp:105
void setRetaliationTarget(bool mark=true)
Mark this base for alien retaliation.
Definition: Base.cpp:1155
int getTotalSoldiers() const
Gets the base's total soldiers.
Definition: Base.cpp:448
int getAvailableWorkshops() const
Gets the base's available workshop space.
Definition: Base.cpp:712
Represents a base facility placed in a base.
Definition: BaseFacility.h:38
int getUsedWorkshops() const
Gets the base's used workshop space.
Definition: Base.cpp:697
void setName(const std::wstring &name)
Sets the base's name.
Definition: Base.cpp:275
ItemContainer * getItems()
Gets the base's items.
Definition: Base.cpp:321
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
int getUsedLaboratories() const
Gets the base's used laboratory space.
Definition: Base.cpp:661
int getFacilityMaintenance() const
Gets the base's facility maintenance.
Definition: Base.cpp:934
int getAvailableLaboratories() const
Gets the base's available laboratory space.
Definition: Base.cpp:679
std::vector< Vehicle * > * getVehicles()
Gets the base's vehicles.
Definition: Base.cpp:1315
~Base()
Cleans up the base.
Definition: Base.cpp:62
int getUsedQuarters() const
Gets the base's used living quarters.
Definition: Base.cpp:533
int getAvailableHangars() const
Gets the base's available hangars.
Definition: Base.cpp:756
int getAvailableStores() const
Gets the base's available storage space.
Definition: Base.cpp:609
int getScientists() const
Gets the base's scientists.
Definition: Base.cpp:330
int getFreeLaboratories() const
Get the number of available space lab (not used by a ResearchProject)
Definition: Base.cpp:773
void addResearch(ResearchProject *)
Add a new ResearchProject to the Base.
Definition: Base.cpp:979
int getAvailableScientists() const
Gets the base's available scientists.
Definition: Base.cpp:466
bool isInBattlescape() const
Gets if the craft is in battlescape.
Definition: Base.cpp:1137
int getEngineers() const
Gets the base's engineers.
Definition: Base.cpp:348
int getUsedContainment() const
Gets the total amount of used Containment Space.
Definition: Base.cpp:1081
bool getRetaliationTarget() const
Gets the retaliation status of this base.
Definition: Base.cpp:1164
const std::vector< Production * > & getProductions() const
Get the list of Base Production's.
Definition: Base.cpp:1016
Contains strings used throughout the game for localization.
Definition: Language.h:42
Represent a ResearchProject Contain information about assigned scientist, time already spent and cost...
Definition: ResearchProject.h:33
Set of rules and stats for a game.
Definition: Ruleset.h:69
int getFreeWorkshops() const
Get the number of available space lab (not used by a Production)
Definition: Base.cpp:782
int getFreePsiLabs() const
Gets the base's total free psi lab space.
Definition: Base.cpp:791
Definition: Production.h:31
int getAvailableQuarters() const
Gets the base's available living quarters.
Definition: Base.cpp:543
void addProduction(Production *p)
Add a new Production to Base.
Definition: Base.cpp:970
int getTotalEngineers() const
Gets the base's total engineers.
Definition: Base.cpp:511
int getCraftCount(const std::string &craft) const
Gets the base's crafts of a certain type.
Definition: Base.cpp:887
void setInBattlescape(bool inbattle)
Sets the craft's battlescape status.
Definition: Base.cpp:1146
Represents the items contained by a certain entity, like base stores, craft equipment, etc.
Definition: ItemContainer.h:36
void setEngineers(int engineers)
Sets the base's engineers.
Definition: Base.cpp:357
std::vector< Transfer * > * getTransfers()
Gets the base's transfers.
Definition: Base.cpp:312
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:1337
int getPersonnelMaintenance() const
Gets the base's personnel maintenance.
Definition: Base.cpp:920
YAML::Node saveId() const
Saves the base's ID to YAML.
Definition: Base.cpp:253
std::wstring getName(Language *lang=0) const
Gets the base's name.
Definition: Base.cpp:266
std::vector< BaseFacility * > * getDefenses()
Get a list of Defensive Facilities.
Definition: Base.cpp:1305
Represents a player base on the globe.
Definition: Base.h:47
void setScientists(int scientists)
Sets the base's scientists.
Definition: Base.cpp:339
bool storesOverfull(double offset=0.0)
Checks if the base's stores are overfull.
Definition: Base.cpp:597
int getMonthlyMaintenace() const
Gets the base's total monthly maintenance.
Definition: Base.cpp:952
void destroyFacility(std::vector< BaseFacility * >::iterator facility)
destroy a facility and deal with the side effects.
Definition: Base.cpp:1426
int getShortRangeDetection() const
Gets the base's short range detection.
Definition: Base.cpp:850
YAML::Node save() const
Saves the base to YAML.
Definition: Base.cpp:213
int getTotalScientists() const
Gets the base's total scientists.
Definition: Base.cpp:476
int getGravShields() const
Gets how many Grav Shields the base has.
Definition: Base.cpp:1224
int getDefenseValue() const
Gets the base's defense value.
Definition: Base.cpp:832
std::vector< Craft * > * getCrafts()
Gets the base's crafts.
Definition: Base.cpp:302
void destroyDisconnectedFacilities()
Destroys all disconnected facilities in the base.
Definition: Base.cpp:1323
int getAvailableContainment() const
Gets the total amount of Containment Space.
Definition: Base.cpp:1120
int getAllocatedEngineers() const
Returns the amount of engineers currently in use.
Definition: Base.cpp:817
std::vector< Soldier * > * getSoldiers()
Gets the base's soldiers.
Definition: Base.cpp:293
int getAvailablePsiLabs() const
Gets the base's total available psi lab space.
Definition: Base.cpp:1045
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
Base(const Ruleset *rule)
Creates a new base.
Definition: Base.cpp:54
int detect(Target *target) const
Checks if a target is detected by the base's radar.
Definition: Base.cpp:368
int insideRadarRange(Target *target) const
Checks if a target is inside the base's radar range.
Definition: Base.cpp:400
int getCraftMaintenance() const
Gets the base's craft maintenance.
Definition: Base.cpp:905
int getUsedPsiLabs() const
Gets the base's used psi lab space.
Definition: Base.cpp:1063
int getAllocatedScientists() const
Returns the amount of scientists currently in use.
Definition: Base.cpp:800
double getUsedStores()
Gets the base's used storage space.
Definition: Base.cpp:561
int getAvailableEngineers() const
Gets the base's available engineers.
Definition: Base.cpp:501
int getAvailableSoldiers(bool checkCombatReadiness=false) const
Gets the base's available soldiers.
Definition: Base.cpp:425
size_t getDetectionChance(int difficulty) const
Get the detection chance for this base.
Definition: Base.cpp:1217
bool getHyperDetection() const
Checks if this base is hyper-wave equipped.
Definition: Base.cpp:1028
void removeResearch(ResearchProject *)
Remove a ResearchProject from the Base.
Definition: Base.cpp:988
int getUsedHangars() const
Gets the base's used hangars.
Definition: Base.cpp:730