OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::Base Class Reference

Represents a player base on the globe. More...

#include <Base.h>

Inheritance diagram for OpenXcom::Base:
OpenXcom::Target

Public Member Functions

 Base (const Ruleset *rule)
 Creates a new base. More...
 
 ~Base ()
 Cleans up the base. More...
 
void load (const YAML::Node &node, SavedGame *save, bool newGame, bool newBattleGame=false)
 Loads the base from YAML. More...
 
YAML::Node save () const
 Saves the base to YAML. More...
 
YAML::Node saveId () const
 Saves the base's ID to YAML. More...
 
std::wstring getName (Language *lang=0) const
 Gets the base's name. More...
 
void setName (const std::wstring &name)
 Sets the base's name. More...
 
std::vector< BaseFacility * > * getFacilities ()
 Gets the base's facilities. More...
 
std::vector< Soldier * > * getSoldiers ()
 Gets the base's soldiers. More...
 
std::vector< Craft * > * getCrafts ()
 Gets the base's crafts. More...
 
std::vector< Transfer * > * getTransfers ()
 Gets the base's transfers. More...
 
ItemContainergetItems ()
 Gets the base's items. More...
 
int getScientists () const
 Gets the base's scientists. More...
 
void setScientists (int scientists)
 Sets the base's scientists. More...
 
int getEngineers () const
 Gets the base's engineers. More...
 
void setEngineers (int engineers)
 Sets the base's engineers. More...
 
int detect (Target *target) const
 Checks if a target is detected by the base's radar. More...
 
int insideRadarRange (Target *target) const
 Checks if a target is inside the base's radar range. More...
 
int getAvailableSoldiers (bool checkCombatReadiness=false) const
 Gets the base's available soldiers. More...
 
int getTotalSoldiers () const
 Gets the base's total soldiers. More...
 
int getAvailableScientists () const
 Gets the base's available scientists. More...
 
int getTotalScientists () const
 Gets the base's total scientists. More...
 
int getAvailableEngineers () const
 Gets the base's available engineers. More...
 
int getTotalEngineers () const
 Gets the base's total engineers. More...
 
int getUsedQuarters () const
 Gets the base's used living quarters. More...
 
int getAvailableQuarters () const
 Gets the base's available living quarters. More...
 
double getUsedStores ()
 Gets the base's used storage space. More...
 
bool storesOverfull (double offset=0.0)
 Checks if the base's stores are overfull. More...
 
int getAvailableStores () const
 Gets the base's available storage space. More...
 
int getUsedLaboratories () const
 Gets the base's used laboratory space. More...
 
int getAvailableLaboratories () const
 Gets the base's available laboratory space. More...
 
int getUsedWorkshops () const
 Gets the base's used workshop space. More...
 
int getAvailableWorkshops () const
 Gets the base's available workshop space. More...
 
int getUsedHangars () const
 Gets the base's used hangars. More...
 
int getAvailableHangars () const
 Gets the base's available hangars. More...
 
int getFreeLaboratories () const
 Get the number of available space lab (not used by a ResearchProject) More...
 
int getFreeWorkshops () const
 Get the number of available space lab (not used by a Production) More...
 
int getAllocatedScientists () const
 Returns the amount of scientists currently in use. More...
 
int getAllocatedEngineers () const
 Returns the amount of engineers currently in use. More...
 
int getDefenseValue () const
 Gets the base's defense value. More...
 
int getShortRangeDetection () const
 Gets the base's short range detection. More...
 
int getLongRangeDetection () const
 Gets the base's long range detection. More...
 
int getCraftCount (const std::string &craft) const
 Gets the base's crafts of a certain type. More...
 
int getCraftMaintenance () const
 Gets the base's craft maintenance. More...
 
int getPersonnelMaintenance () const
 Gets the base's personnel maintenance. More...
 
int getFacilityMaintenance () const
 Gets the base's facility maintenance. More...
 
int getMonthlyMaintenace () const
 Gets the base's total monthly maintenance. More...
 
const std::vector
< ResearchProject * > & 
getResearch () const
 Get the list of base's ResearchProject. More...
 
void addResearch (ResearchProject *)
 Add a new ResearchProject to the Base. More...
 
void removeResearch (ResearchProject *)
 Remove a ResearchProject from the Base. More...
 
void addProduction (Production *p)
 Add a new Production to Base. More...
 
void removeProduction (Production *p)
 Remove a Base Production's. More...
 
const std::vector< Production * > & getProductions () const
 Get the list of Base Production's. More...
 
bool getHyperDetection () const
 Checks if this base is hyper-wave equipped. More...
 
int getUsedPsiLabs () const
 Gets the base's used psi lab space. More...
 
int getAvailablePsiLabs () const
 Gets the base's total available psi lab space. More...
 
int getFreePsiLabs () const
 Gets the base's total free psi lab space. More...
 
int getAvailableContainment () const
 Gets the total amount of Containment Space. More...
 
int getUsedContainment () const
 Gets the total amount of used Containment Space. More...
 
void setInBattlescape (bool inbattle)
 Sets the craft's battlescape status. More...
 
bool isInBattlescape () const
 Gets if the craft is in battlescape. More...
 
void setRetaliationTarget (bool mark=true)
 Mark this base for alien retaliation. More...
 
bool getRetaliationTarget () const
 Gets the retaliation status of this base. More...
 
size_t getDetectionChance (int difficulty) const
 Get the detection chance for this base. More...
 
int getGravShields () const
 Gets how many Grav Shields the base has.
 
void setupDefenses ()
 Setup base defenses.
 
std::vector< BaseFacility * > * getDefenses ()
 Get a list of Defensive Facilities.
 
std::vector< Vehicle * > * getVehicles ()
 Gets the base's vehicles. More...
 
void destroyDisconnectedFacilities ()
 Destroys all disconnected facilities in the base.
 
std::list< std::vector
< BaseFacility * >::iterator > 
getDisconnectedFacilities (BaseFacility *remove)
 Gets a sorted list of the facilities(=iterators) NOT connected to the Access Lift. More...
 
void destroyFacility (std::vector< BaseFacility * >::iterator facility)
 destroy a facility and deal with the side effects. More...
 
- Public Member Functions inherited from OpenXcom::Target
virtual ~Target ()
 Cleans up the target. More...
 
void load (const YAML::Node &node)
 Loads the moving target from YAML. More...
 
double getLongitude () const
 Gets the target's longitude. More...
 
void setLongitude (double lon)
 Sets the target's longitude. More...
 
double getLatitude () const
 Gets the target's latitude. More...
 
void setLatitude (double lat)
 Sets the target's latitude. More...
 
std::vector< Target * > * getFollowers ()
 Gets the target's followers. More...
 
double getDistance (const Target *target) const
 Gets the distance to another target. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenXcom::Target
 Target ()
 Creates a target. More...
 

Detailed Description

Represents a player base on the globe.

Bases can contain facilities, personnel, crafts and equipment.

Constructor & Destructor Documentation

OpenXcom::Base::Base ( const Ruleset rule)

Creates a new base.

Initializes an empty base.

Parameters
rulePointer to ruleset.
OpenXcom::Base::~Base ( )

Cleans up the base.

Deletes the contents of the base from memory.

Member Function Documentation

void OpenXcom::Base::addProduction ( Production p)

Add a new Production to Base.

Add a new Production to the Base.

Parameters
pA pointer to a Production
void OpenXcom::Base::addResearch ( ResearchProject project)

Add a new ResearchProject to the Base.

Add A new ResearchProject to Base.

Parameters
projectThe project to add
void OpenXcom::Base::destroyFacility ( std::vector< BaseFacility * >::iterator  facility)

destroy a facility and deal with the side effects.

Removes a base module, and deals with the ramifications thereof.

Parameters
facilityAn iterator reference to the facility to destroy and remove.
int OpenXcom::Base::detect ( Target target) const

Checks if a target is detected by the base's radar.

Returns if a certain target is covered by the base's radar range, taking in account the range and chance.

Parameters
targetPointer to target to compare.
Returns
0 - not detected, 1 - detected by conventional radar, 2 - detected by hyper-wave decoder.
int OpenXcom::Base::getAllocatedEngineers ( ) const

Returns the amount of engineers currently in use.

Returns
Amount of engineers.
int OpenXcom::Base::getAllocatedScientists ( ) const

Returns the amount of scientists currently in use.

Returns
Amount of scientists.
int OpenXcom::Base::getAvailableContainment ( ) const

Gets the total amount of Containment Space.

Returns the total amount of Containment Space available in the base.

Returns
Containment Lab space.
int OpenXcom::Base::getAvailableEngineers ( ) const

Gets the base's available engineers.

Returns the amount of engineers contained in the base without any assignments.

Returns
Number of engineers.
int OpenXcom::Base::getAvailableHangars ( ) const

Gets the base's available hangars.

Returns the total amount of hangars available in the base.

Returns
Number of hangars.
int OpenXcom::Base::getAvailableLaboratories ( ) const

Gets the base's available laboratory space.

Returns the total amount of laboratories available in the base.

Returns
Laboratory space.
int OpenXcom::Base::getAvailablePsiLabs ( ) const

Gets the base's total available psi lab space.

Returns the total amount of Psi Lab Space available in the base.

Returns
Psi Lab space.
int OpenXcom::Base::getAvailableQuarters ( ) const

Gets the base's available living quarters.

Returns the total amount of living quarters available in the base.

Returns
Living space.
int OpenXcom::Base::getAvailableScientists ( ) const

Gets the base's available scientists.

Returns the amount of scientists contained in the base without any assignments.

Returns
Number of scientists.
int OpenXcom::Base::getAvailableSoldiers ( bool  checkCombatReadiness = false) const

Gets the base's available soldiers.

Returns the amount of soldiers contained in the base without any assignments.

Parameters
checkCombatReadinessdoes what it says on the tin.
Returns
Number of soldiers.
int OpenXcom::Base::getAvailableStores ( ) const

Gets the base's available storage space.

Returns the total amount of stores available in the base.

Returns
Storage space.
int OpenXcom::Base::getAvailableWorkshops ( ) const

Gets the base's available workshop space.

Returns the total amount of workshops available in the base.

Returns
Workshop space.
int OpenXcom::Base::getCraftCount ( const std::string &  craft) const

Gets the base's crafts of a certain type.

Returns the total amount of craft of a certain type stored in the base.

Parameters
craftCraft type.
Returns
Number of craft.
int OpenXcom::Base::getCraftMaintenance ( ) const

Gets the base's craft maintenance.

Returns the total amount of monthly costs for maintaining the craft in the base.

Returns
Maintenance costs.
std::vector< Craft * > * OpenXcom::Base::getCrafts ( )

Gets the base's crafts.

Returns the list of crafts in the base.

Returns
Pointer to the craft list.
int OpenXcom::Base::getDefenseValue ( ) const

Gets the base's defense value.

Returns the total defense value of all the facilities in the base.

Returns
Defense value.
size_t OpenXcom::Base::getDetectionChance ( int  difficulty) const

Get the detection chance for this base.

Calculate the detection chance of this base.

Big bases without mindshields are easier to detect.

Parameters
difficultyThe savegame difficulty.
Returns
The detection chance.
std::list< std::vector< BaseFacility * >::iterator > OpenXcom::Base::getDisconnectedFacilities ( BaseFacility remove)

Gets a sorted list of the facilities(=iterators) NOT connected to the Access Lift.

Parameters
removeFacility to ignore (in case of facility dismantling).
Returns
a sorted list of iterators pointing to elements in _facilities.
int OpenXcom::Base::getEngineers ( ) const

Gets the base's engineers.

Returns the amount of engineers currently in the base.

Returns
Number of engineers.
std::vector< BaseFacility * > * OpenXcom::Base::getFacilities ( )

Gets the base's facilities.

Returns the list of facilities in the base.

Returns
Pointer to the facility list.
int OpenXcom::Base::getFacilityMaintenance ( ) const

Gets the base's facility maintenance.

Returns the total amount of monthly costs for maintaining the facilities in the base.

Returns
Maintenance costs.
int OpenXcom::Base::getFreeLaboratories ( ) const

Get the number of available space lab (not used by a ResearchProject)

Return laboratories space not used by a ResearchProject.

Returns
laboratories space not used by a ResearchProject
int OpenXcom::Base::getFreePsiLabs ( ) const

Gets the base's total free psi lab space.

Return psilab space not in use.

Returns
psilab space not in use
int OpenXcom::Base::getFreeWorkshops ( ) const

Get the number of available space lab (not used by a Production)

Return workshop space not used by a Production.

Returns
workshop space not used by a Production
bool OpenXcom::Base::getHyperDetection ( ) const

Checks if this base is hyper-wave equipped.

Returns whether or not this base is equipped with hyper-wave detection facilities.

Returns
True if the base has hyper-wave detection.
ItemContainer * OpenXcom::Base::getItems ( )

Gets the base's items.

Returns the list of items in the base.

Returns
Pointer to the item list.
int OpenXcom::Base::getLongRangeDetection ( ) const

Gets the base's long range detection.

Returns the total amount of long range detection facilities in the base.

Returns
Defense value.
int OpenXcom::Base::getMonthlyMaintenace ( ) const

Gets the base's total monthly maintenance.

Returns the total amount of all the maintenance monthly costs in the base.

Returns
Maintenance costs.
std::wstring OpenXcom::Base::getName ( Language lang = 0) const
virtual

Gets the base's name.

Returns the custom name for the base.

Parameters
langLanguage to get strings from.
Returns
Name.

Implements OpenXcom::Target.

int OpenXcom::Base::getPersonnelMaintenance ( ) const

Gets the base's personnel maintenance.

Returns the total amount of monthly costs for maintaining the personnel in the base.

Returns
Maintenance costs.
const std::vector< Production * > & OpenXcom::Base::getProductions ( ) const

Get the list of Base Production's.

Returns
the list of Base Production's
const std::vector< ResearchProject * > & OpenXcom::Base::getResearch ( ) const

Get the list of base's ResearchProject.

Returns the list of all base's ResearchProject.

Returns
list of base's ResearchProject
bool OpenXcom::Base::getRetaliationTarget ( ) const

Gets the retaliation status of this base.

Get the base's retaliation status.

Returns
If the base is a valid target for alien retaliation.
int OpenXcom::Base::getScientists ( ) const

Gets the base's scientists.

Returns the amount of scientists currently in the base.

Returns
Number of scientists.
int OpenXcom::Base::getShortRangeDetection ( ) const

Gets the base's short range detection.

Returns the total amount of short range detection facilities in the base.

Returns
Defense value.
std::vector< Soldier * > * OpenXcom::Base::getSoldiers ( )

Gets the base's soldiers.

Returns the list of soldiers in the base.

Returns
Pointer to the soldier list.
int OpenXcom::Base::getTotalEngineers ( ) const

Gets the base's total engineers.

Returns the total amount of engineers contained in the base.

Returns
Number of engineers.
int OpenXcom::Base::getTotalScientists ( ) const

Gets the base's total scientists.

Returns the total amount of scientists contained in the base.

Returns
Number of scientists.
int OpenXcom::Base::getTotalSoldiers ( ) const

Gets the base's total soldiers.

Returns the total amount of soldiers contained in the base.

Returns
Number of soldiers.
std::vector< Transfer * > * OpenXcom::Base::getTransfers ( )

Gets the base's transfers.

Returns the list of transfers destined to this base.

Returns
Pointer to the transfer list.
int OpenXcom::Base::getUsedContainment ( ) const

Gets the total amount of used Containment Space.

Returns the total amount of used Containment Space in the base.

Returns
Containment Lab space.
int OpenXcom::Base::getUsedHangars ( ) const

Gets the base's used hangars.

Returns the amount of hangars used up by crafts in the base.

Returns
Storage space.
int OpenXcom::Base::getUsedLaboratories ( ) const

Gets the base's used laboratory space.

Returns the amount of laboratories used up by research projects in the base.

Returns
Laboratory space.
int OpenXcom::Base::getUsedPsiLabs ( ) const

Gets the base's used psi lab space.

Returns the total amount of used Psi Lab Space in the base.

Returns
used Psi Lab space.
int OpenXcom::Base::getUsedQuarters ( ) const

Gets the base's used living quarters.

Returns the amount of living quarters used up by personnel in the base.

Returns
Living space.
double OpenXcom::Base::getUsedStores ( )

Gets the base's used storage space.

Returns the amount of stores used up by equipment in the base, and equipment about to arrive.

Returns
Storage space.
int OpenXcom::Base::getUsedWorkshops ( ) const

Gets the base's used workshop space.

Returns the amount of workshops used up by manufacturing projects in the base.

Returns
Storage space.
std::vector< Vehicle * > * OpenXcom::Base::getVehicles ( )

Gets the base's vehicles.

Returns the list of vehicles currently equipped in the base.

Returns
Pointer to vehicle list.
int OpenXcom::Base::insideRadarRange ( Target target) const

Checks if a target is inside the base's radar range.

Returns if a certain target is inside the base's radar range, taking in account the positions of both.

Parameters
targetPointer to target to compare.
Returns
0 - outside radar range, 1 - inside conventional radar range, 2 - inside hyper-wave decoder range.
bool OpenXcom::Base::isInBattlescape ( ) const

Gets if the craft is in battlescape.

Returns the base's battlescape status.

Returns
Is the craft on the battlescape?
void OpenXcom::Base::load ( const YAML::Node &  node,
SavedGame save,
bool  newGame,
bool  newBattleGame = false 
)

Loads the base from YAML.

Loads the base from a YAML file.

Parameters
nodeYAML node.
savePointer to saved game.
newGameIs this the first base of a new game?
newBattleGameIs this the base of a skirmish game?
void OpenXcom::Base::removeProduction ( Production p)

Remove a Base Production's.

Remove a Production from the Base.

Parameters
pA pointer to a Production
void OpenXcom::Base::removeResearch ( ResearchProject project)

Remove a ResearchProject from the Base.

Remove a ResearchProject from base.

Parameters
projectthe project to remove
YAML::Node OpenXcom::Base::save ( ) const
virtual

Saves the base to YAML.

Saves the base to a YAML file.

Returns
YAML node.

Reimplemented from OpenXcom::Target.

YAML::Node OpenXcom::Base::saveId ( ) const
virtual

Saves the base's ID to YAML.

Saves the base's unique identifiers to a YAML file.

Returns
YAML node.

Reimplemented from OpenXcom::Target.

void OpenXcom::Base::setEngineers ( int  engineers)

Sets the base's engineers.

Changes the amount of engineers currently in the base.

Parameters
engineersNumber of engineers.
void OpenXcom::Base::setInBattlescape ( bool  inbattle)

Sets the craft's battlescape status.

Changes the base's battlescape status.

Parameters
inbattleTrue if it's in battle, False otherwise.
void OpenXcom::Base::setName ( const std::wstring &  name)

Sets the base's name.

Changes the custom name for the base.

Parameters
nameName.
void OpenXcom::Base::setRetaliationTarget ( bool  mark = true)

Mark this base for alien retaliation.

Mark the base as a valid alien retaliation target.

Parameters
markMark (if true) or unmark (if false) the base.
void OpenXcom::Base::setScientists ( int  scientists)

Sets the base's scientists.

Changes the amount of scientists currently in the base.

Parameters
scientistsNumber of scientists.
bool OpenXcom::Base::storesOverfull ( double  offset = 0.0)

Checks if the base's stores are overfull.

Supplying an offset will add/subtract to the used capacity before performing the check. A positive offset simulates adding items to the stores, whereas a negative offset can be used to check whether sufficient items have been removed to stop the stores overflowing.

Parameters
offsetAdjusts the used capacity.
Returns
True if the base's stores are over their limit.

The documentation for this class was generated from the following files: