]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIManager.hxx
560e82e7926821eb813a64f2fe9714a885c1bdbd
[flightgear.git] / src / AIModel / AIManager.hxx
1 // AIManager.hxx - experimental! - 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., 675 Mass Ave, Cambridge, MA 02139, 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
30 #include <Main/fg_props.hxx>
31
32 #include <AIModel/AIBase.hxx>
33 #include <AIModel/AIScenario.hxx>
34 #include <AIModel/AIFlightPlan.hxx>
35
36 SG_USING_STD(list);
37 class FGAIThermal;
38
39
40 class FGAIManager : public SGSubsystem
41 {
42
43 private:
44
45     // A list of pointers to AI objects
46     typedef list <FGAIBase*> ai_list_type;
47     typedef ai_list_type::iterator ai_list_iterator;
48     typedef ai_list_type::const_iterator ai_list_const_iterator;
49
50     // Everything put in this list should be created dynamically
51     // on the heap and ***DELETED WHEN REMOVED!!!!!***
52     ai_list_type ai_list;
53     ai_list_iterator ai_list_itr;
54
55     // array of already-assigned ID's
56     typedef vector <int> id_vector_type;
57     id_vector_type ids;                    
58     id_vector_type::iterator id_itr;
59
60 public:
61
62     FGAIManager();
63     ~FGAIManager();
64
65     void init();
66     void bind();
67     void unbind();
68     void update(double dt);
69
70     int assignID();
71     void freeID(int ID);
72
73     int createBallistic( FGAIModelEntity *entity );
74     int createAircraft( FGAIModelEntity *entity );
75     int createThermal( FGAIModelEntity *entity );
76     int createStorm( FGAIModelEntity *entity );
77     int createShip( FGAIModelEntity *entity );
78
79     void destroyObject( int ID );
80
81     inline double get_user_latitude() { return user_latitude; }
82     inline double get_user_longitude() { return user_longitude; }
83     inline double get_user_altitude() { return user_altitude; }
84     inline double get_user_heading() { return user_heading; }
85     inline double get_user_pitch() { return user_pitch; }
86     inline double get_user_yaw() { return user_yaw; }
87     inline double get_user_speed() {return user_speed; }
88
89     void processScenario( string filename );
90     int getNum( FGAIBase::object_type ot);
91
92 private:
93
94     bool initDone;
95     bool enabled;
96     int numObjects[FGAIBase::MAX_OBJECTS];
97     SGPropertyNode* root;
98     SGPropertyNode* wind_from_down_node;
99     string scenario_filename;
100
101     double user_latitude;
102     double user_longitude;
103     double user_altitude;
104     double user_heading;
105     double user_pitch;
106     double user_yaw;
107     double user_speed;
108     double _dt;
109     int dt_count;
110     void fetchUserState( void );
111
112     // used by thermals
113     double range_nearest;
114     double strength;
115     void processThermal( FGAIThermal* thermal ); 
116
117 };
118
119 #endif  // _FG_AIMANAGER_HXX