OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | Protected Member Functions | Static 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...
 
virtual 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...
 
double getSpeedRadian () const
 Gets the moving target's radial 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...
 
void calculateMeetPoint ()
 Calculate meeting point with the target.
 
double getMeetLatitude () const
 Returns the latitude of the meeting point. More...
 
double getMeetLongitude () const
 Returns the longitude of the meeting point. More...
 
void resetMeetPoint ()
 Reset meeting point calculation. More...
 
bool isMeetCalculated () const
 Returns if the meeting point was calculated.
 
- Public Member Functions inherited from OpenXcom::Target
virtual ~Target ()
 Cleans up the target. More...
 
YAML::Node saveId () const
 Saves the target's ID to YAML. More...
 
virtual std::string getType () const =0
 Gets the target's type.
 
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...
 
int getId () const
 Gets the target's ID. More...
 
void setId (int id)
 Sets the target's ID. More...
 
virtual std::string getName (Language *lang) const
 Gets the target's name. More...
 
void setName (const std::string &newName)
 Sets the target's name. More...
 
virtual std::string getDefaultName (Language *lang) const
 Gets the target's default name. More...
 
virtual std::string getMarkerName () const
 Gets the target's marker name. More...
 
virtual int getMarker () const =0
 Gets the target's marker sprite.
 
std::vector< MovingTarget * > * getFollowers ()
 Gets the target's followers. More...
 
std::vector< Craft * > getCraftFollowers () const
 Gets the target's craft 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...
 

Static Protected Member Functions

static double calculateRadianSpeed (int speed)
 Converts a speed to radians. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ MovingTarget()

OpenXcom::MovingTarget::MovingTarget ( )
protected

Creates a moving target.

Initializes a moving target with blank coordinates.

◆ ~MovingTarget()

OpenXcom::MovingTarget::~MovingTarget ( )
virtual

Cleans up the moving target.

Make sure to cleanup the target's destination followers.

Member Function Documentation

◆ calculateRadianSpeed()

double OpenXcom::MovingTarget::calculateRadianSpeed ( int  speed)
staticprotected

Converts a speed to radians.

Converts a speed in degrees to a speed in radians.

Each nautical mile is 1/60th of a degree. Each hour contains 720 5-seconds.

Parameters
speedSpeed in degrees.
Returns
Speed in radians.

◆ calculateSpeed()

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.

◆ getDestination()

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

Gets the moving target's destination.

Returns the destination the moving target is heading to.

Returns
Pointer to destination.

◆ getMeetLatitude()

double OpenXcom::MovingTarget::getMeetLatitude ( ) const

Returns the latitude of the meeting point.

Returns
Angle in rad.

◆ getMeetLongitude()

double OpenXcom::MovingTarget::getMeetLongitude ( ) const

Returns the longitude of the meeting point.

Returns
Angle in rad.

◆ getSpeed()

int OpenXcom::MovingTarget::getSpeed ( ) const

Gets the moving target's speed.

Returns the speed of the moving target.

Returns
Speed in knots.

◆ getSpeedRadian()

double OpenXcom::MovingTarget::getSpeedRadian ( ) const

Gets the moving target's radial speed.

Returns the radial speed of the moving target.

Returns
Speed in 1 / 5 sec.

◆ load()

void OpenXcom::MovingTarget::load ( const YAML::Node &  node)
virtual

Loads the moving target from YAML.

Loads the moving target from a YAML file.

Parameters
nodeYAML node.

Reimplemented from OpenXcom::Target.

◆ move()

void OpenXcom::MovingTarget::move ( )

Move towards the destination.

Executes a movement cycle for the moving target.

◆ reachedDestination()

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.

◆ resetMeetPoint()

void OpenXcom::MovingTarget::resetMeetPoint ( )

Reset meeting point calculation.

Forces the meeting point to be recalculated in the event that the target has changed direction.

◆ save()

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.

◆ setDestination()

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.

◆ setSpeed()

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: