| 1 | /* |
| 2 | * SPDX-FileName: AIEscort.hxx |
| 3 | * SPDX-FileCopyrightText: Written by Vivian Meazza, started August 2009 - vivian.meazza at lineone.net |
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <list> |
| 10 | #include <string> |
| 11 | #include <string_view> |
| 12 | |
| 13 | #include <simgear/compiler.h> |
| 14 | |
| 15 | #include "AIBase.hxx" |
| 16 | |
| 17 | #include "AIShip.hxx" |
| 18 | |
| 19 | #include "AIBase.hxx" |
| 20 | #include "AIManager.hxx" |
| 21 | |
| 22 | |
| 23 | class FGAIEscort : public FGAIShip |
| 24 | { |
| 25 | public: |
| 26 | FGAIEscort(); |
| 27 | virtual ~FGAIEscort() = default; |
| 28 | |
| 29 | std::string_view getTypeString(void) const override { return "escort"; } |
| 30 | void readFromScenario(SGPropertyNode* scFileNode) override; |
| 31 | |
| 32 | bool init(ModelSearchOrder searchOrder) override; |
| 33 | void bind() override; |
| 34 | void reinit() override; |
| 35 | void update(double dt) override; |
| 36 | |
| 37 | private: |
| 38 | void setStnRange(double r); |
| 39 | void setStnBrg(double y); |
| 40 | void setStationSpeed(); |
| 41 | void setStnLimit(double l); |
| 42 | void setStnAngleLimit(double l); |
| 43 | void setStnSpeed(double s); |
| 44 | void setStnHtFt(double h); |
| 45 | void setStnPatrol(bool p); |
| 46 | void setStnDegTrue(bool t); |
| 47 | void setParent(); |
| 48 | |
| 49 | void setMaxSpeed(double m); |
| 50 | void setUpdateInterval(double i); |
| 51 | |
| 52 | void RunEscort(double dt); |
| 53 | |
| 54 | bool getGroundElev(SGGeod inpos); |
| 55 | |
| 56 | SGVec3d getCartHitchPosAt(const SGVec3d& off) const; |
| 57 | |
| 58 | void calcRangeBearing(double lat, double lon, double lat2, double lon2, |
| 59 | double& range, double& bearing) const; |
| 60 | double calcTrueBearingDeg(double bearing, double heading); |
| 61 | |
| 62 | SGGeod _selectedpos; |
| 63 | SGGeod _tgtpos; |
| 64 | |
| 65 | bool _solid = true; // if true ground is solid for FDMs |
| 66 | double _tgtrange = 0.0; |
| 67 | double _tgtbrg = 0.0; |
| 68 | double _ht_agl_ft = 0.0; |
| 69 | double _relbrg = 0.0; |
| 70 | double _parent_speed = 0.0; |
| 71 | double _parent_hdg = 0.0; |
| 72 | double _interval = 0.0; |
| 73 | |
| 74 | double _stn_relbrg = 0.0; |
| 75 | double _stn_truebrg = 0.0; |
| 76 | double _stn_brg = 0.0; |
| 77 | double _stn_range = 0.0; |
| 78 | double _stn_height = 0.0; |
| 79 | double _stn_speed = 0.0; |
| 80 | double _stn_angle_limit = 0.0; |
| 81 | double _stn_limit = 0.0; |
| 82 | |
| 83 | bool _MPControl = false; |
| 84 | bool _patrol = false; |
| 85 | bool _stn_deg_true = false; |
| 86 | }; |