1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef A_AIR_MOVE_TYPE_H_ 4 #define A_AIR_MOVE_TYPE_H_ 5 6 #include "MoveType.h" 7 #include "Sim/Misc/AirBaseHandler.h" 8 9 /** 10 * Supposed to be an abstract class. 11 * Do not create an instance of this class. 12 * Use either CHoverAirMoveType or CStrafeAirMoveType instead. 13 */ 14 class AAirMoveType : public AMoveType 15 { 16 CR_DECLARE(AAirMoveType) 17 public: 18 19 enum AircraftState { 20 AIRCRAFT_LANDED, 21 AIRCRAFT_FLYING, 22 AIRCRAFT_LANDING, 23 AIRCRAFT_CRASHING, 24 AIRCRAFT_TAKEOFF, 25 /// this is what happens to aircraft with dontLand=1 in fbi 26 AIRCRAFT_HOVERING 27 } aircraftState; 28 29 enum LandingPadState { 30 PAD_STATUS_FLYING = 0, 31 PAD_STATUS_LANDING = 1, 32 PAD_STATUS_ARRIVED = 2, 33 } padStatus; 34 35 AAirMoveType(CUnit* unit); 36 virtual ~AAirMoveType(); 37 38 virtual bool Update(); 39 virtual void UpdateLanded(); Takeoff()40 virtual void Takeoff() {} Land()41 virtual void Land() {} SetState(AircraftState state)42 virtual void SetState(AircraftState state) {} GetLandingState()43 virtual AircraftState GetLandingState() const { return AIRCRAFT_LANDING; } 44 CanApplyImpulse(const float3 &)45 bool CanApplyImpulse(const float3&) { return true; } 46 bool UseSmoothMesh() const; GetPadStatus()47 int GetPadStatus() const { return padStatus; } 48 49 void ReservePad(CAirBaseHandler::LandingPad* lp); 50 void UnreservePad(CAirBaseHandler::LandingPad* lp); 51 void DependentDied(CObject* o); 52 GetReservedPad()53 CAirBaseHandler::LandingPad* GetReservedPad() { return reservedPad; } 54 55 public: 56 /// goalpos to resume flying to after landing 57 float3 oldGoalPos; 58 float3 reservedLandingPos; 59 60 float wantedHeight; 61 /// to reset altitude back 62 float orgWantedHeight; 63 64 float accRate; 65 float decRate; 66 float altitudeRate; 67 68 /// mods can use this to disable plane collisions 69 bool collide; 70 /// controls use of smoothGround for determining altitude 71 bool useSmoothMesh; 72 bool autoLand; 73 74 protected: 75 void CheckForCollision(); 76 bool CanLandOnPad(const float3& padPos) const; 77 bool HaveLandedOnPad(const float3& padPos); 78 bool MoveToRepairPad(); 79 void UpdateFuel(bool slowUpdate = true); 80 81 /// unit found to be dangerously close to our path 82 CUnit* lastColWarning; 83 CAirBaseHandler::LandingPad* reservedPad; 84 85 /// 1=generally forward of us, 2=directly in path 86 int lastColWarningType; 87 int lastFuelUpdateFrame; 88 }; 89 90 #endif // A_AIR_MOVE_TYPE_H_ 91