]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIManager.hxx
Modified Files:
[flightgear.git] / src / AIModel / AIManager.hxx
1 // AIManager.hxx - David Culp - based on:
2 // AIMgr.hxx - definition of FGAIMgr 
3 // - a global management class for FlightGear generated AI traffic
4 //
5 // Written by David Luff, started March 2002.
6 //
7 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22
23 #ifndef _FG_AIMANAGER_HXX
24 #define _FG_AIMANAGER_HXX
25
26 #include <list>
27
28 #include <simgear/structure/subsystem_mgr.hxx>
29 #include <simgear/structure/SGSharedPtr.hxx>
30
31 #include <Main/fg_props.hxx>
32
33 #include <AIModel/AIBase.hxx>
34 #include <AIModel/AIFlightPlan.hxx>
35
36 #include <Traffic/SchedFlight.hxx>
37 #include <Traffic/Schedule.hxx>
38
39 SG_USING_STD(list);
40
41 class FGAIThermal;
42
43 class FGAIManager : public SGSubsystem
44 {
45
46 private:
47
48     // A list of pointers to AI objects
49     typedef list <SGSharedPtr<FGAIBase> > ai_list_type;
50     typedef ai_list_type::iterator ai_list_iterator;
51     typedef ai_list_type::const_iterator ai_list_const_iterator;
52
53     ai_list_type ai_list;
54
55 public:
56
57     FGAIManager();
58     ~FGAIManager();
59
60     void init();
61     void reinit();
62     void bind();
63     void unbind();
64     void update(double dt);
65
66     void attach(SGSharedPtr<FGAIBase> model);
67
68     void destroyObject( int ID );
69
70     inline double get_user_latitude() const { return user_latitude; }
71     inline double get_user_longitude() const { return user_longitude; }
72     inline double get_user_altitude() const { return user_altitude; }
73     inline double get_user_heading() const { return user_heading; }
74     inline double get_user_pitch() const { return user_pitch; }
75     inline double get_user_yaw() const { return user_yaw; }
76     inline double get_user_speed() const {return user_speed; }
77     inline double get_wind_from_east() const {return wind_from_east; }
78     inline double get_wind_from_north() const {return wind_from_north; }
79
80     int getNumAiObjects(void) const;
81
82     void processScenario( const string &filename );
83
84   static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
85
86   static bool getStartPosition(const string& id, const string& pid,
87                                SGGeod& geodPos, double& hdng, SGVec3d& uvw);
88
89 private:
90
91     bool enabled;
92     int mNumAiTypeModels[FGAIBase::MAX_OBJECTS];
93     int mNumAiModels;
94
95     SGPropertyNode_ptr root;
96     SGPropertyNode_ptr wind_from_down_node;
97     SGPropertyNode_ptr user_latitude_node;
98     SGPropertyNode_ptr user_longitude_node;
99     SGPropertyNode_ptr user_altitude_node;
100     SGPropertyNode_ptr user_heading_node;
101     SGPropertyNode_ptr user_pitch_node;
102     SGPropertyNode_ptr user_yaw_node;
103     SGPropertyNode_ptr user_speed_node;
104     SGPropertyNode_ptr wind_from_east_node ;
105     SGPropertyNode_ptr wind_from_north_node ;
106
107     string scenario_filename;
108
109     double user_latitude;
110     double user_longitude;
111     double user_altitude;
112     double user_heading;
113     double user_pitch;
114     double user_yaw;
115     double user_speed;
116     double wind_from_east;
117     double wind_from_north;
118     double _dt;
119     void fetchUserState( void );
120
121     // used by thermals
122     double range_nearest;
123     double strength;
124     void processThermal( FGAIThermal* thermal ); 
125
126 };
127
128 #endif  // _FG_AIMANAGER_HXX