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 | Protected Member Functions | List of all members
OpenXcom::MovingTarget Class Reference

Base class for moving targets on the globe with a certain speed and destination. More...

#include <MovingTarget.h>

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

Public Member Functions

virtual ~MovingTarget ()
 Cleans up the moving target. More...
 
void load (const YAML::Node &node)
 Loads the moving target from YAML. More...
 
virtual YAML::Node save () const
 Saves the moving target to YAML. More...
 
TargetgetDestination () const
 Gets the moving target's destination. More...
 
virtual void setDestination (Target *dest)
 Sets 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...
 
virtual YAML::Node saveId () const
 Saves the target's ID to 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...
 
virtual std::wstring getName (Language *lang) const =0
 Gets the target's name.
 
std::vector< Target * > * getFollowers ()
 Gets the target's followers. More...
 
double getDistance (const Target *target) const
 Gets the distance to another target. More...
 

Protected Member Functions

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

Base class for moving targets on the globe with a certain speed and destination.

Constructor & Destructor Documentation

OpenXcom::MovingTarget::MovingTarget ( )
protected

Creates a moving target.

Initializes a moving target with blank coordinates.

OpenXcom::MovingTarget::~MovingTarget ( )
virtual

Cleans up the moving target.

Make sure to cleanup the target's destination followers.

Member Function Documentation

void OpenXcom::MovingTarget::calculateSpeed ( )
protectedvirtual

Calculates a new speed vector to the destination.

Calculates the speed vector based on the great circle distance to destination and current raw speed.

Target * OpenXcom::MovingTarget::getDestination ( ) const

Gets the moving target's destination.

Returns the destination the moving target is heading to.

Returns
Pointer to destination.
int OpenXcom::MovingTarget::getSpeed ( ) const

Gets the moving target's speed.

Returns the speed of the moving target.

Returns
Speed in knots.
void OpenXcom::MovingTarget::load ( const YAML::Node &  node)

Loads the moving target from YAML.

Loads the moving target from a YAML file.

Parameters
nodeYAML node.
void OpenXcom::MovingTarget::move ( )

Move towards the destination.

Executes a movement cycle for the moving target.

bool OpenXcom::MovingTarget::reachedDestination ( ) const

Has the moving target reached its destination?

Checks if the moving target has reached its destination.

Returns
True if it has, False otherwise.
YAML::Node OpenXcom::MovingTarget::save ( ) const
virtual

Saves the moving target to YAML.

Saves the moving target to a YAML file.

Returns
YAML node.

Reimplemented from OpenXcom::Target.

Reimplemented in OpenXcom::Craft.

void OpenXcom::MovingTarget::setDestination ( Target dest)
virtual

Sets the moving target's destination.

Changes the destination the moving target is heading to.

Parameters
destPointer to destination.

Reimplemented in OpenXcom::Ufo, and OpenXcom::Craft.

void OpenXcom::MovingTarget::setSpeed ( int  speed)

Sets the moving target's speed.

Changes the speed of the moving target and converts it from standard knots (nautical miles per hour) into radians per 5 in-game seconds.

Parameters
speedSpeed in knots.

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