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