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::Craft Class Reference

Represents a craft stored in a base. More...

#include <Craft.h>

Inheritance diagram for OpenXcom::Craft:
OpenXcom::MovingTarget OpenXcom::Target

Public Member Functions

 Craft (RuleCraft *rules, Base *base, int id=0)
 Creates a craft of the specified type. More...
 
 ~Craft ()
 Cleans up the craft. More...
 
void load (const YAML::Node &node, const Ruleset *rule, SavedGame *save)
 Loads the craft from YAML. More...
 
YAML::Node save () const
 Saves the craft to YAML. More...
 
YAML::Node saveId () const
 Saves the craft's ID to YAML. More...
 
RuleCraftgetRules () const
 Gets the craft's ruleset. More...
 
void setRules (RuleCraft *rules)
 Sets the craft's ruleset. More...
 
int getId () const
 Gets the craft's ID. More...
 
std::wstring getName (Language *lang) const
 Gets the craft's name. More...
 
void setName (const std::wstring &newName)
 Sets the craft's name. More...
 
BasegetBase () const
 Gets the craft's base. More...
 
void setBase (Base *base)
 Sets the craft's base. More...
 
void setBaseOnly (Base *base)
 Sets the craft's base. (without setting the craft's coordinates) More...
 
std::string getStatus () const
 Gets the craft's status. More...
 
void setStatus (const std::string &status)
 Sets the craft's status. More...
 
std::string getAltitude () const
 Gets the craft's altitude. More...
 
void setDestination (Target *dest)
 Sets the craft's destination. More...
 
int getNumWeapons () const
 Gets the craft's amount of weapons. More...
 
int getNumSoldiers () const
 Gets the craft's amount of soldiers. More...
 
int getNumEquipment () const
 Gets the craft's amount of equipment. More...
 
int getNumVehicles () const
 Gets the craft's amount of vehicles. More...
 
std::vector< CraftWeapon * > * getWeapons ()
 Gets the craft's weapons. More...
 
ItemContainergetItems ()
 Gets the craft's items. More...
 
std::vector< Vehicle * > * getVehicles ()
 Gets the craft's vehicles. More...
 
int getFuel () const
 Gets the craft's amount of fuel. More...
 
void setFuel (int fuel)
 Sets the craft's amount of fuel. More...
 
int getFuelPercentage () const
 Gets the craft's percentage of fuel. More...
 
int getDamage () const
 Gets the craft's amount of damage. More...
 
void setDamage (int damage)
 Sets the craft's amount of damage. More...
 
int getDamagePercentage () const
 Gets the craft's percentage of damage. More...
 
bool getLowFuel () const
 Gets whether the craft is running out of fuel. More...
 
void setLowFuel (bool low)
 Sets whether the craft is running out of fuel. More...
 
double getDistanceFromBase () const
 Gets the craft's distance from its base. More...
 
int getFuelConsumption () const
 Gets the craft's fuel consumption. More...
 
int getFuelLimit () const
 Gets the craft's minimum fuel limit. More...
 
int getFuelLimit (Base *base) const
 Gets the craft's minimum fuel limit to go to a base. More...
 
void returnToBase ()
 Returns the craft to its base. More...
 
bool detect (Target *target) const
 Checks if a target is detected by the craft's radar. More...
 
void think ()
 Handles craft logic. More...
 
void checkup ()
 Does a craft full checkup. More...
 
void consumeFuel ()
 Consumes the craft's fuel. More...
 
void repair ()
 Repairs the craft. More...
 
void refuel ()
 Refuels the craft. More...
 
std::string rearm (Ruleset *rules)
 Rearms the craft. More...
 
void setInBattlescape (bool inbattle)
 Sets the craft's battlescape status. More...
 
bool isInBattlescape () const
 Gets if the craft is in battlescape. More...
 
bool isDestroyed () const
 Gets if craft is destroyed during dogfights. More...
 
int getSpaceAvailable () const
 Gets the amount of space available inside a craft. More...
 
int getSpaceUsed () const
 Gets the amount of space used inside a craft. More...
 
int getVehicleCount (const std::string &vehicle) const
 Gets the craft's vehicles of a certain type. More...
 
void setInDogfight (const bool inDogfight)
 Sets the craft's dogfight status. More...
 
bool isInDogfight () const
 Gets if the craft is in dogfight. More...
 
void setInterceptionOrder (const int order)
 Sets interception order (first craft to leave the base gets 1, second 2, etc.). More...
 
int getInterceptionOrder () const
 Gets interception number. More...
 
- Public Member Functions inherited from OpenXcom::MovingTarget
virtual ~MovingTarget ()
 Cleans up the moving target. More...
 
void load (const YAML::Node &node)
 Loads the moving target from YAML. More...
 
TargetgetDestination () const
 Gets the moving target's destination. More...
 
int getSpeed () const
 Gets the moving target's speed. More...
 
void setSpeed (int speed)
 Sets the moving target's speed. More...
 
bool reachedDestination () const
 Has the moving target reached its destination? More...
 
void move ()
 Move towards the destination. 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::MovingTarget
virtual void calculateSpeed ()
 Calculates a new speed vector to the destination. More...
 
 MovingTarget ()
 Creates a moving target. More...
 
- Protected Member Functions inherited from OpenXcom::Target
 Target ()
 Creates a target. More...
 

Detailed Description

Represents a craft stored in a base.

Contains variable info about a craft like position, fuel, damage, etc.

See also
RuleCraft

Constructor & Destructor Documentation

OpenXcom::Craft::Craft ( RuleCraft rules,
Base base,
int  id = 0 
)

Creates a craft of the specified type.

Initializes a craft of the specified type and assigns it the latest craft ID available.

Parameters
rulesPointer to ruleset.
basePointer to base of origin.
idID to assign to the craft (0 to not assign).
OpenXcom::Craft::~Craft ( )

Cleans up the craft.

Delete the contents of the craft from memory.

Member Function Documentation

void OpenXcom::Craft::checkup ( )

Does a craft full checkup.

Checks the condition of all the craft's systems to define its new status (eg.

when arriving at base).

void OpenXcom::Craft::consumeFuel ( )

Consumes the craft's fuel.

Consumes the craft's fuel every 10 minutes while it's on the air.

bool OpenXcom::Craft::detect ( Target target) const

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

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

Parameters
targetPointer to target to compare.
Returns
True if it's detected, False otherwise.
std::string OpenXcom::Craft::getAltitude ( ) const

Gets the craft's altitude.

Returns the current altitude of the craft.

Returns
Altitude.
Base * OpenXcom::Craft::getBase ( ) const

Gets the craft's base.

Returns the base the craft belongs to.

Returns
Pointer to base.
int OpenXcom::Craft::getDamage ( ) const

Gets the craft's amount of damage.

Returns the amount of damage this craft has taken.

Returns
Amount of damage.
int OpenXcom::Craft::getDamagePercentage ( ) const

Gets the craft's percentage of damage.

Returns the ratio between the amount of damage this craft can take and the total it can take before it's destroyed.

Returns
Percentage of damage.
double OpenXcom::Craft::getDistanceFromBase ( ) const

Gets the craft's distance from its base.

Returns the current distance between the craft and the base it belongs to.

Returns
Distance in radian.
int OpenXcom::Craft::getFuel ( ) const

Gets the craft's amount of fuel.

Returns the amount of fuel currently contained in this craft.

Returns
Amount of fuel.
int OpenXcom::Craft::getFuelConsumption ( ) const

Gets the craft's fuel consumption.

Returns the amount of fuel the craft uses up while it's on the air, based on its speed.

Returns
Fuel amount.
int OpenXcom::Craft::getFuelLimit ( ) const

Gets the craft's minimum fuel limit.

Returns the minimum required fuel for the craft to make it back to base.

Returns
Fuel amount.
int OpenXcom::Craft::getFuelLimit ( Base base) const

Gets the craft's minimum fuel limit to go to a base.

Returns the minimum required fuel for the craft to go to a base.

Parameters
basePointer to target base.
Returns
Fuel amount.
int OpenXcom::Craft::getFuelPercentage ( ) const

Gets the craft's percentage of fuel.

Returns the ratio between the amount of fuel currently contained in this craft and the total it can carry.

Returns
Percentage of fuel.
int OpenXcom::Craft::getId ( ) const

Gets the craft's ID.

Returns the craft's unique ID.

Each craft can be identified by its type and ID.

Returns
Unique ID.
int OpenXcom::Craft::getInterceptionOrder ( ) const

Gets interception number.

Gets interception order.

Returns
Interception order.
ItemContainer * OpenXcom::Craft::getItems ( )

Gets the craft's items.

Returns the list of items in the craft.

Returns
Pointer to the item list.
bool OpenXcom::Craft::getLowFuel ( ) const

Gets whether the craft is running out of fuel.

Returns whether the craft is currently low on fuel (only has enough to head back to base).

Returns
True if it's low, false otherwise.
std::wstring OpenXcom::Craft::getName ( Language lang) const
virtual

Gets the craft's name.

Returns the craft's unique identifying name.

If there's no custom name, the language default is used.

Parameters
langLanguage to get strings from.
Returns
Full name.

Implements OpenXcom::Target.

int OpenXcom::Craft::getNumEquipment ( ) const

Gets the craft's amount of equipment.

Returns the amount of equipment currently equipped on this craft.

Returns
Number of items.
int OpenXcom::Craft::getNumSoldiers ( ) const

Gets the craft's amount of soldiers.

Returns the amount of soldiers from a list that are currently attached to this craft.

Returns
Number of soldiers.
int OpenXcom::Craft::getNumVehicles ( ) const

Gets the craft's amount of vehicles.

Returns the amount of vehicles currently contained in this craft.

Returns
Number of vehicles.
int OpenXcom::Craft::getNumWeapons ( ) const

Gets the craft's amount of weapons.

Returns the amount of weapons currently equipped on this craft.

Returns
Number of weapons.
RuleCraft * OpenXcom::Craft::getRules ( ) const

Gets the craft's ruleset.

Returns the ruleset for the craft's type.

Returns
Pointer to ruleset.
int OpenXcom::Craft::getSpaceAvailable ( ) const

Gets the amount of space available inside a craft.

Returns the amount of space available for soldiers and vehicles.

Returns
Space available.
int OpenXcom::Craft::getSpaceUsed ( ) const

Gets the amount of space used inside a craft.

Returns the amount of space in use by soldiers and vehicles.

Returns
Space used.
std::string OpenXcom::Craft::getStatus ( ) const

Gets the craft's status.

Returns the current status of the craft.

Returns
Status string.
int OpenXcom::Craft::getVehicleCount ( const std::string &  vehicle) const

Gets the craft's vehicles of a certain type.

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

Parameters
vehicleVehicle type.
Returns
Number of vehicles.
std::vector< Vehicle * > * OpenXcom::Craft::getVehicles ( )

Gets the craft's vehicles.

Returns the list of vehicles currently equipped in the craft.

Returns
Pointer to vehicle list.
std::vector< CraftWeapon * > * OpenXcom::Craft::getWeapons ( )

Gets the craft's weapons.

Returns the list of weapons currently equipped in the craft.

Returns
Pointer to weapon list.
bool OpenXcom::Craft::isDestroyed ( ) const

Gets if craft is destroyed during dogfights.

Returns the craft destroyed status.

If the amount of damage the craft take is more than it's health it will be destroyed.

Returns
Is the craft destroyed?
bool OpenXcom::Craft::isInBattlescape ( ) const

Gets if the craft is in battlescape.

Returns the craft's battlescape status.

Returns
Is the craft on the battlescape?
bool OpenXcom::Craft::isInDogfight ( ) const

Gets if the craft is in dogfight.

Returns the craft's dogfight status.

Returns
Is the craft ion a dogfight?
void OpenXcom::Craft::load ( const YAML::Node &  node,
const Ruleset rule,
SavedGame save 
)

Loads the craft from YAML.

Loads the craft from a YAML file.

Parameters
nodeYAML node.
ruleRuleset for the saved game.
savePointer to the saved game.
std::string OpenXcom::Craft::rearm ( Ruleset rules)

Rearms the craft.

Rearms the craft's weapons by adding ammo every hour while it's docked in the base.

Parameters
rulesPointer to ruleset.
Returns
The ammo ID missing for rearming, or "" if none.
void OpenXcom::Craft::refuel ( )

Refuels the craft.

Refuels the craft every 30 minutes while it's docked in the base.

void OpenXcom::Craft::repair ( )

Repairs the craft.

Repairs the craft's damage every hour while it's docked in the base.

void OpenXcom::Craft::returnToBase ( )

Returns the craft to its base.

Sends the craft back to its origin base.

YAML::Node OpenXcom::Craft::save ( ) const
virtual

Saves the craft to YAML.

Saves the craft to a YAML file.

Returns
YAML node.

Reimplemented from OpenXcom::MovingTarget.

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

Saves the craft's ID to YAML.

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

Returns
YAML node.

Reimplemented from OpenXcom::Target.

void OpenXcom::Craft::setBase ( Base base)

Sets the craft's base.

Changes the base the craft belongs to.

Parameters
basePointer to base.
void OpenXcom::Craft::setBaseOnly ( Base base)

Sets the craft's base. (without setting the craft's coordinates)

Changes the base the craft belongs to.

(without setting the craft's coordinates)

Parameters
basePointer to base.
void OpenXcom::Craft::setDamage ( int  damage)

Sets the craft's amount of damage.

Changes the amount of damage this craft has taken.

Parameters
damageAmount of damage.
void OpenXcom::Craft::setDestination ( Target dest)
virtual

Sets the craft's destination.

Changes the destination the craft is heading to.

Parameters
destPointer to new destination.

Reimplemented from OpenXcom::MovingTarget.

void OpenXcom::Craft::setFuel ( int  fuel)

Sets the craft's amount of fuel.

Changes the amount of fuel currently contained in this craft.

Parameters
fuelAmount of fuel.
void OpenXcom::Craft::setInBattlescape ( bool  inbattle)

Sets the craft's battlescape status.

Changes the craft's battlescape status.

Parameters
inbattleTrue if it's in battle, False otherwise.
void OpenXcom::Craft::setInDogfight ( const bool  inDogfight)

Sets the craft's dogfight status.

Changes the craft's dogfight status.

Parameters
inDogfightTrue if it's in dogfight, False otherwise.
void OpenXcom::Craft::setInterceptionOrder ( const int  order)

Sets interception order (first craft to leave the base gets 1, second 2, etc.).

Parameters
orderInterception order.
void OpenXcom::Craft::setLowFuel ( bool  low)

Sets whether the craft is running out of fuel.

Changes whether the craft is currently low on fuel (only has enough to head back to base).

Parameters
lowTrue if it's low, false otherwise.
void OpenXcom::Craft::setName ( const std::wstring &  newName)

Sets the craft's name.

Changes the craft's custom name.

Parameters
newNameNew custom name. If set to blank, the language default is used.
void OpenXcom::Craft::setRules ( RuleCraft rules)

Sets the craft's ruleset.

Changes the ruleset for the craft's type.

Parameters
rulesPointer to ruleset.
Warning
NOT TO BE USED IN NORMAL CIRCUMSTANCES.
void OpenXcom::Craft::setStatus ( const std::string &  status)

Sets the craft's status.

Changes the current status of the craft.

Parameters
statusStatus string.
void OpenXcom::Craft::think ( )

Handles craft logic.

Moves the craft to its destination.


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