]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIAircraft.hxx
Make the AI models a bit more intelligent. The Gear should be extended and retracted...
[flightgear.git] / src / AIModel / AIAircraft.hxx
index 759cca93c36e780357229b0ebd86c996493c190e..8d16f381e57136aa1134af72c1dad05750d40c30 100644 (file)
@@ -29,22 +29,44 @@ SG_USING_STD(string);
 
 
 class FGAIAircraft : public FGAIBase {
+
+private:
+
+       typedef struct {
+            double accel;
+            double decel;
+            double climb_rate;
+            double descent_rate;
+            double takeoff_speed;
+            double climb_speed;
+            double cruise_speed;
+            double descent_speed;
+            double land_speed;
+       } PERF_STRUCT;
        
 public:
+
+        enum aircraft_e {LIGHT=0, WW2_FIGHTER, JET_TRANSPORT, JET_FIGHTER};
+        static const PERF_STRUCT settings[];
        
        FGAIAircraft();
        ~FGAIAircraft();
        
        bool init();
+        virtual void bind();
+        virtual void unbind();
        void update(double dt);
 
-        void SetPerformance(PERF_STRUCT ps);
+        void SetPerformance(const PERF_STRUCT *ps);
         void AccelTo(double speed);
         void PitchTo(double angle);
         void RollTo(double angle);
         void YawTo(double angle);
         void ClimbTo(double altitude);
         void TurnTo(double heading);
+
+protected:
+        static FGAIAircraft *_self;
        
 private:
 
@@ -53,10 +75,20 @@ private:
 
         double dt; 
 
-        PERF_STRUCT performance;
+        const PERF_STRUCT *performance;
 
        void Run(double dt);
         double sign(double x); 
+
+        static bool _getGearDown();
 };
 
+inline bool FGAIAircraft::_getGearDown() {
+    return ((fgGetFloat("/position/altitude-agl-ft") < 150.0)
+             && (fgGetFloat("/orientation/pitch-deg") < 0.0)
+             && (fgGetFloat("/velocities/airspeed-kt")
+                   < _self->performance->land_speed*1.5));
+}
+
+
 #endif  // _FG_AIAircraft_HXX