ed_journals/modules/status/models/flags.rs
1use serde::{Deserialize, Serialize};
2
3/// The current flags for the player. These flags are mostly for things that are related to
4/// the player's ship.
5#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
6pub struct Flags(u64);
7
8impl Flags {
9 /// Whether the player is currently docked at a station.
10 pub fn docked(&self) -> bool {
11 self.0 & 1 != 0
12 }
13
14 /// Whether the player is landed on a planetary surface.
15 pub fn landed(&self) -> bool {
16 self.0 & 2 != 0
17 }
18
19 /// Whether the landing gear is currently down.
20 pub fn landing_gear_down(&self) -> bool {
21 self.0 & 4 != 0
22 }
23
24 // TODO check what counts as up.
25 /// Whether the shields are up.
26 pub fn shields_up(&self) -> bool {
27 self.0 & 8 != 0
28 }
29
30 /// Whether player is currently flying in supercruise.
31 pub fn supercruise(&self) -> bool {
32 self.0 & 16 != 0
33 }
34
35 /// Whether flight assist has been turned off.
36 pub fn flight_assist_off(&self) -> bool {
37 self.0 & 32 != 0
38 }
39
40 // TODO check behaviour in SRV
41 /// Whether the hardpoints of the ship are currently deployed.
42 pub fn hardpoints_deployed(&self) -> bool {
43 self.0 & 64 != 0
44 }
45
46 /// Whether the player is in a wing.
47 pub fn in_wing(&self) -> bool {
48 self.0 & 128 != 0
49 }
50
51 /// Whether the lights of the current active vehicle are on.
52 pub fn lights_on(&self) -> bool {
53 self.0 & 256 != 0
54 }
55
56 /// Whether the cargo scoop of the current active vehicle is deployed.
57 pub fn cargo_scoop_deployed(&self) -> bool {
58 self.0 & 512 != 0
59 }
60
61 /// Whether silent running is currently active.
62 pub fn silent_running(&self) -> bool {
63 self.0 & 1024 != 0
64 }
65
66 // TODO figure out if this is also set when the tank is full, but the player is still within range.
67 /// Whether the player is currently fuel scooping.
68 pub fn scooping_fuel(&self) -> bool {
69 self.0 & 2048 != 0
70 }
71
72 /// Whether the SRV handbrake is currently on.
73 pub fn srv_handbrake(&self) -> bool {
74 self.0 & 4096 != 0
75 }
76
77 /// Whether the player is currently directly piloting the SRV turret.
78 pub fn srv_turret_view(&self) -> bool {
79 self.0 & 8192 != 0
80 }
81
82 /// Whether the turret of the SRV has been retracted. The turret is retracted when the player is
83 /// close to their own ship.
84 pub fn srv_turret_retracted(&self) -> bool {
85 self.0 & 16384 != 0
86 }
87
88 /// Whether the player has enabled drive assist in the SRV.
89 pub fn srv_drive_assist(&self) -> bool {
90 self.0 & 32768 != 0
91 }
92
93 /// Whether the FSD is currently masslocked. This prevents the player from charging the FSD.
94 pub fn fsd_masslocked(&self) -> bool {
95 self.0 & 65536 != 0
96 }
97
98 /// Whether the FSD is currently spinning up. This does not differentiate between charging to
99 /// jump to supercruise or hyperspace.
100 pub fn fsd_charging(&self) -> bool {
101 self.0 & 131072 != 0
102 }
103
104 /// Whether the FSD is currently cooling down. This prevents the player from charging the FSD.
105 pub fn fsd_cooldown(&self) -> bool {
106 self.0 & 262144 != 0
107 }
108
109 /// Whether the player's current vehicle is low on fuel, which is when the total fuel reserves
110 /// of the vehicle drop below 25%.
111 pub fn low_fuel(&self) -> bool {
112 self.0 & 524288 != 0
113 }
114
115 /// Whether the player's current vehicle is overheating, which is when the heat level exceeds
116 /// 100% heat.
117 pub fn overheating(&self) -> bool {
118 self.0 & 1048576 != 0
119 }
120
121 /// Whether the lat/long values are available in the status. Set when near a planet.
122 pub fn has_lat_long(&self) -> bool {
123 self.0 & 2097152 != 0
124 }
125
126 /// Whether the player is counted as 'in danger'. If this is true then the player has to wait
127 /// 15 seconds before they can log out of the game.
128 pub fn in_danger(&self) -> bool {
129 self.0 & 4194304 != 0
130 }
131
132 /// Whether the player is currently getting interdicted. This doesn't differentiate between an
133 /// attempt by an NPC or a player.
134 pub fn being_interdicted(&self) -> bool {
135 self.0 & 8388608 != 0
136 }
137
138 /// Whether the player is currently piloting the main ship (aka the mother ship.)
139 pub fn in_main_ship(&self) -> bool {
140 self.0 & 16777216 != 0
141 }
142
143 /// Whether the player is currently piloting a fighter.
144 pub fn in_fighter(&self) -> bool {
145 self.0 & 33554432 != 0
146 }
147
148 /// Whether the player is currently piloting an SRV.
149 pub fn in_srv(&self) -> bool {
150 self.0 & 67108864 != 0
151 }
152
153 /// Whether the current cockpit mode is currently set to analysis mode.
154 pub fn analysis_mode(&self) -> bool {
155 self.0 & 134217728 != 0
156 }
157
158 /// Whether night vision is currently active.
159 pub fn night_vision(&self) -> bool {
160 self.0 & 268435456 != 0
161 }
162
163 /// Is set when the average radius of the planet is used for the altitude instead of the
164 /// altitude to the actual terrain and elevation of the planet's surface.
165 pub fn altitude_from_average_radius(&self) -> bool {
166 self.0 & 536870912 != 0
167 }
168
169 /// Whether the player is currently jumping through hyperspace.
170 pub fn fsd_jump(&self) -> bool {
171 self.0 & 1073741824 != 0
172 }
173
174 /// Whether the SRV has the high beam lights active.
175 pub fn srv_high_beam(&self) -> bool {
176 self.0 & 2147483648 != 0
177 }
178}