Debian Codegraph @

src/AIModel/AIShip.hxx

raw symbols SCIP
1 /*
2 * SPDX-FileName: AIShip.hxx
3 * SPDX-FileComment: AIBase derived class creates an AI ship
4 * SPDX-FileCopyrightText: Copyright (C) 2003 David P. Culp - [email protected]
5 * SPDX-FileContributor: with major amendments and additions by Vivian Meazza, 2004 - 2007
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #pragma once
10
11 #include <string_view>
12
13 #include <simgear/scene/material/mat.hxx>
14
15 #include "AIBase.hxx"
16 #include "AIFlightPlan.hxx"
17
18
19 class FGAIManager;
20
21 class FGAIShip : public FGAIBase
22 {
23 public:
24 explicit FGAIShip(object_type ot = object_type::otShip);
25 virtual ~FGAIShip() = default;
26
27 std::string_view getTypeString(void) const override { return "ship"; }
28 void readFromScenario(SGPropertyNode* scFileNode) override;
29
30 bool init(ModelSearchOrder searchOrder) override;
31 void bind() override;
32 void update(double dt) override;
33 void reinit() override;
34 double getDefaultModelRadius() override { return 200.0; }
35
36 void setRudder(float r);
37 void setRoll(double rl);
38 void ProcessFlightPlan(double dt);
39 void AccelTo(double speed);
40 void PitchTo(double angle);
41 void RollTo(double angle);
42
43 #if 0
44 void YawTo(double angle);
45 #endif
46
47 void ClimbTo(double altitude);
48 void TurnTo(double heading);
49 void setCurrName(const std::string&);
50 void setNextName(const std::string&);
51 void setPrevName(const std::string&);
52 void setLeadAngleGain(double g);
53 void setLeadAngleLimit(double l);
54 void setLeadAngleProp(double p);
55 void setRudderConstant(double rc);
56 void setSpeedConstant(double sc);
57 void setFixedTurnRadius(double ft);
58 void setRollFactor(double rf);
59
60 void setTunnel(bool t);
61 void setInitialTunnel(bool t);
62
63 void setWPNames();
64 void setWPPos();
65
66 double sign(double x);
67
68 bool _hdg_lock = false;
69 bool _serviceable = false;
70 bool _waiting;
71 bool _new_waypoint;
72 bool _tunnel, _initial_tunnel;
73 bool _restart;
74
75 double _rudder_constant = 0.0;
76 double _speed_constant = 0.0;
77 double _hdg_constant, _limit;
78 double _elevation_ft;
79 double _missed_range = 0.0;
80 double _tow_angle;
81 double _wait_count = 0.0;
82 double _missed_count, _wp_range;
83 double _dt_count, _next_run;
84
85 FGAIWaypoint* prev = nullptr; // the one behind you
86 FGAIWaypoint* curr = nullptr; // the one ahead
87 FGAIWaypoint* next = nullptr; // the next plus 1
88
89 protected:
90
91 private:
92 void setRepeat(bool r);
93 void setRestart(bool r);
94 void setMissed(bool m);
95
96 void setServiceable(bool s);
97 void Run(double dt);
98 void setStartTime(const std::string&);
99 void setUntilTime(const std::string&);
100 //void setWPPos();
101 void setWPAlt();
102 void setXTrackError();
103
104 SGGeod wppos;
105
106 double getRange(double lat, double lon, double lat2, double lon2) const;
107 double getCourse(double lat, double lon, double lat2, double lon2) const;
108 double getDaySeconds();
109 double processTimeString(const std::string& time);
110
111 bool initFlightPlan();
112 bool advanceFlightPlan(double elapsed_sec, double day_sec);
113
114 float _rudder = 0.0f;
115 float _tgt_rudder = 0.0f;
116
117 double _roll_constant, _roll_factor;
118 double _sp_turn_radius_ft = 0.0;
119 double _rd_turn_radius_ft = 0.0;
120 double _fixed_turn_radius = 0.0;
121 double _old_range, _range_rate;
122 double _missed_time_sec;
123 double _start_sec = 0.0;
124 double _day;
125 double _lead_angle;
126 double _lead_angle_gain = 0.0;
127 double _lead_angle_limit = 0.0;
128 double _proportion = 0.0;
129 double _course = 0.0;
130 double _xtrack_error;
131 double _curr_alt, _prev_alt;
132
133 std::string _prev_name, _curr_name, _next_name;
134 std::string _start_time, _until_time;
135
136 bool _repeat = false;
137 bool _fp_init;
138 bool _missed;
139 };