]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIShip.hxx
f4a622310c6b5ef3d09a08132245809adc8daea9
[flightgear.git] / src / AIModel / AIShip.hxx
1 // FGAIShip - AIBase derived class creates an AI ship
2 //
3 // Written by David Culp, started November 2003.
4 // with major amendments and additions by Vivian Meazza, 2004 - 2007 
5 //
6 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifndef _FG_AISHIP_HXX
23 #define _FG_AISHIP_HXX
24
25 #include "AIBase.hxx"
26 #include "AIFlightPlan.hxx"
27
28 class FGAIManager;
29
30 class FGAIShip : public FGAIBase {
31
32 public:
33
34     FGAIShip(object_type ot = otShip);
35     virtual ~FGAIShip();
36
37     virtual void readFromScenario(SGPropertyNode* scFileNode);
38
39     virtual bool init(bool search_in_AI_path=false);
40     virtual void bind();
41     virtual void unbind();
42     virtual void update(double dt);
43     void setFlightPlan(FGAIFlightPlan* f);
44     void setName(const string&);
45     void setRudder(float r);
46     void setRoll(double rl);
47     void ProcessFlightPlan( double dt);
48     void AccelTo(double speed);
49     void PitchTo(double angle);
50     void RollTo(double angle);
51     void YawTo(double angle);
52     void ClimbTo(double altitude);
53     void TurnTo(double heading);
54     void setCurrName(const string&);
55     void setNextName(const string&);
56     void setPrevName(const string&);
57
58     bool _hdg_lock;
59     bool _serviceable;
60
61     virtual const char* getTypeString(void) const { return "ship"; }
62
63 protected:
64
65     string _name; // The name of this ship.
66
67 private:
68
69     FGAIFlightPlan::waypoint* prev; // the one behind you
70     FGAIFlightPlan::waypoint* curr; // the one ahead
71     FGAIFlightPlan::waypoint* next; // the next plus 1
72
73     virtual void reinit() { init(); }
74
75     void setRepeat(bool r);
76     void setMissed(bool m);
77     void setWPNames();
78     void setServiceable(bool s);
79     void Run(double dt);
80     void setStartTime(const string&);
81     void setUntilTime(const string&);
82
83
84     double getRange(double lat, double lon, double lat2, double lon2) const;
85     double getCourse(double lat, double lon, double lat2, double lon2) const;
86     double sign(double x);
87     double getDaySeconds();
88     double processTimeString(const string& time);
89
90     bool initFlightPlan();
91     bool advanceFlightPlan (double elapsed_sec, double day_sec);
92
93     float _rudder, _tgt_rudder;
94
95     double _rudder_constant, _roll_constant, _speed_constant, _hdg_constant, _roll_factor;
96     double _sp_turn_radius_ft, _rd_turn_radius_ft;
97     double _wp_range, _old_range, _range_rate;
98     double _dt_count, _missed_count, _wait_count;
99     double _next_run;
100     double _missed_time_sec;
101     double _start_sec;
102     double _day;
103
104     string _prev_name, _curr_name, _next_name;
105     string _path;
106     string _start_time, _until_time;
107
108     bool _repeat;
109     bool _fp_init;
110     bool _new_waypoint;
111     bool _missed, _waiting;
112
113 };
114
115 #endif  // _FG_AISHIP_HXX