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 
40  virtual void calculateSpeed();
42  MovingTarget();
43 public:
45  virtual ~MovingTarget();
47  virtual void load(const YAML::Node& node);
49  virtual YAML::Node save() const;
51  Target *getDestination() const;
53  virtual void setDestination(Target *dest);
55  int getSpeed() const;
57  double getSpeedRadian() const;
59  void setSpeed(int speed);
61  bool reachedDestination() const;
63  void move();
65  void calculateMeetPoint();
67  double getMeetLatitude() const;
69  double getMeetLongitude() const;
70 };
71 
72 }
bool reachedDestination() const
Has the moving target reached its destination?
Definition: MovingTarget.cpp:187
virtual void calculateSpeed()
Calculates a new speed vector to the destination.
Definition: MovingTarget.cpp:157
void setSpeed(int speed)
Sets the moving target&#39;s speed.
Definition: MovingTarget.cpp:143
virtual void load(const YAML::Node &node)
Loads the moving target from YAML.
Definition: MovingTarget.cpp:56
double getMeetLatitude() const
Returns the latitude of the meeting point.
Definition: MovingTarget.cpp:280
double getSpeedRadian() const
Gets the moving target&#39;s radial speed.
Definition: MovingTarget.cpp:132
virtual void setDestination(Target *dest)
Sets the moving target&#39;s destination.
Definition: MovingTarget.cpp:96
int getSpeed() const
Gets the moving target&#39;s speed.
Definition: MovingTarget.cpp:123
double getMeetLongitude() const
Returns the longitude of the meeting point.
Definition: MovingTarget.cpp:289
void calculateMeetPoint()
Calculate meeting point with the target.
Definition: MovingTarget.cpp:220
virtual ~MovingTarget()
Cleans up the moving target.
Definition: MovingTarget.cpp:37
Target * getDestination() const
Gets the moving target&#39;s destination.
Definition: MovingTarget.cpp:87
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:199
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:33
Definition: BaseInfoState.cpp:40
virtual YAML::Node save() const
Saves the moving target to YAML.
Definition: MovingTarget.cpp:69