OpenXcom  1.0
Open-source clone of the original X-Com
MovingTarget.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include "Target.h"
21 
22 namespace OpenXcom
23 {
24 
29 class MovingTarget : public Target
30 {
31 protected:
32  static const double GLOBE_RADIUS;
33 
34  Target *_dest;
35  double _speedLon, _speedLat, _speedRadian;
36  double _meetPointLon, _meetPointLat;
37  int _speed;
38  bool _meetCalculated;
39 
41  virtual void calculateSpeed();
43  static double calculateRadianSpeed(int speed);
45  MovingTarget();
46 public:
48  virtual ~MovingTarget();
50  virtual void load(const YAML::Node& node);
52  virtual YAML::Node save() const;
54  Target *getDestination() const;
56  virtual void setDestination(Target *dest);
58  int getSpeed() const;
60  double getSpeedRadian() const;
62  void setSpeed(int speed);
64  bool reachedDestination() const;
66  void move();
68  void calculateMeetPoint();
70  double getMeetLatitude() const;
72  double getMeetLongitude() const;
74  void resetMeetPoint();
76  bool isMeetCalculated() const;
77 };
78 
79 }
bool reachedDestination() const
Has the moving target reached its destination?
Definition: MovingTarget.cpp:193
bool isMeetCalculated() const
Returns if the meeting point was calculated.
Definition: MovingTarget.cpp:314
virtual void calculateSpeed()
Calculates a new speed vector to the destination.
Definition: MovingTarget.cpp:163
void setSpeed(int speed)
Sets the moving target&#39;s speed.
Definition: MovingTarget.cpp:151
virtual void load(const YAML::Node &node)
Loads the moving target from YAML.
Definition: MovingTarget.cpp:46
double getMeetLatitude() const
Returns the latitude of the meeting point.
Definition: MovingTarget.cpp:291
double getSpeedRadian() const
Gets the moving target&#39;s radial speed.
Definition: MovingTarget.cpp:128
virtual void setDestination(Target *dest)
Sets the moving target&#39;s destination.
Definition: MovingTarget.cpp:86
int getSpeed() const
Gets the moving target&#39;s speed.
Definition: MovingTarget.cpp:119
double getMeetLongitude() const
Returns the longitude of the meeting point.
Definition: MovingTarget.cpp:300
void calculateMeetPoint()
Calculate meeting point with the target.
Definition: MovingTarget.cpp:226
static double calculateRadianSpeed(int speed)
Converts a speed to radians.
Definition: MovingTarget.cpp:140
virtual ~MovingTarget()
Cleans up the moving target.
Definition: MovingTarget.cpp:37
Target * getDestination() const
Gets the moving target&#39;s destination.
Definition: MovingTarget.cpp:77
void resetMeetPoint()
Reset meeting point calculation.
Definition: MovingTarget.cpp:309
MovingTarget()
Creates a moving target.
Definition: MovingTarget.cpp:30
Base class for moving targets on the globe with a certain speed and destination.
Definition: MovingTarget.h:29
void move()
Move towards the destination.
Definition: MovingTarget.cpp:205
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
Definition: BaseInfoState.cpp:40
virtual YAML::Node save() const
Saves the moving target to YAML.
Definition: MovingTarget.cpp:59