implement factory reset

This commit is contained in:
yuni 2024-10-27 00:20:46 +02:00
parent bb724c9a10
commit 6b82b39e1c
3 changed files with 27 additions and 2 deletions

View file

@ -2,6 +2,7 @@
- Implement fast travel (must be unlocked by getting phone number of FASTravel) - Implement fast travel (must be unlocked by getting phone number of FASTravel)
- Implement phone calls - Implement phone calls
- Implement factory reset
- Chats don't automatically advance now, the player has to press "Continue" - Chats don't automatically advance now, the player has to press "Continue"
- Add sparkles to Jupiter's ring ✨😍✨ best visible from Farview Station - Add sparkles to Jupiter's ring ✨😍✨ best visible from Farview Station
- Add setting to change pointer - Add setting to change pointer

View file

@ -105,6 +105,7 @@ pub enum Turn {
On, On,
Off, Off,
Toggle, Toggle,
Unchanged,
} }
impl Turn { impl Turn {
@ -113,6 +114,7 @@ impl Turn {
Turn::On => true, Turn::On => true,
Turn::Off => false, Turn::Off => false,
Turn::Toggle => !current_state, Turn::Toggle => !current_state,
Turn::Unchanged => current_state,
} }
} }
} }
@ -122,6 +124,7 @@ pub enum Cycle {
Last, Last,
Next, Next,
Previous, Previous,
Unchanged,
} }
impl Cycle { impl Cycle {
@ -147,6 +150,9 @@ impl Cycle {
Some(current_index - 1) Some(current_index - 1)
} }
} }
Cycle::Unchanged => {
Some(current_index)
}
} }
} }
} }
@ -170,7 +176,7 @@ pub fn handle_game_event(
mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>, mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>,
mut q_window: Query<&mut Window, With<PrimaryWindow>>, mut q_window: Query<&mut Window, With<PrimaryWindow>>,
mut q_light: Query<&mut DirectionalLight>, mut q_light: Query<&mut DirectionalLight>,
mut q_flashlight: Query<&mut SpotLight, With<actor::PlayersFlashLight>>, mut q_flashlight: Query<(&mut Visibility, &mut SpotLight), With<actor::PlayersFlashLight>>,
mut mapcam: ResMut<camera::MapCam>, mut mapcam: ResMut<camera::MapCam>,
mut log: ResMut<hud::Log>, mut log: ResMut<hud::Log>,
opt: Res<var::CommandLineOptions>, opt: Res<var::CommandLineOptions>,
@ -268,8 +274,9 @@ pub fn handle_game_event(
); );
} }
GameEvent::UpdateFlashlight => { GameEvent::UpdateFlashlight => {
for mut spotlight in &mut q_flashlight { for (mut visibility, mut spotlight) in &mut q_flashlight {
spotlight.intensity = actor::FLASHLIGHT_INTENSITY[prefs.flashlight_power]; spotlight.intensity = actor::FLASHLIGHT_INTENSITY[prefs.flashlight_power];
*visibility = bool2vis(settings.flashlight_active);
} }
} }
GameEvent::PhoneCall => { GameEvent::PhoneCall => {

View file

@ -79,6 +79,7 @@ pub const MENUDEF: &[(&str, MenuAction)] = &[
("", MenuAction::ToggleCamera), ("", MenuAction::ToggleCamera),
("", MenuAction::ToggleShadows), ("", MenuAction::ToggleShadows),
("Fullscreen [F11]", MenuAction::ToggleFullscreen), ("Fullscreen [F11]", MenuAction::ToggleFullscreen),
("FACTORY RESET", MenuAction::ResetSettings),
("Take Off Helmet", MenuAction::Restart), ("Take Off Helmet", MenuAction::Restart),
("Quit", MenuAction::Quit), ("Quit", MenuAction::Quit),
]; ];
@ -99,6 +100,7 @@ pub enum MenuAction {
ToggleCamera, ToggleCamera,
ToggleFullscreen, ToggleFullscreen,
ToggleShadows, ToggleShadows,
ResetSettings,
Restart, Restart,
Quit, Quit,
} }
@ -780,6 +782,21 @@ pub fn handle_input(
ew_game.send(GameEvent::SetMenu(Turn::Off)); ew_game.send(GameEvent::SetMenu(Turn::Off));
ew_updatemenu.send(UpdateMenuEvent); ew_updatemenu.send(UpdateMenuEvent);
} }
MenuAction::ResetSettings => {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::PowerDown));
*settings = Settings::default();
*prefs = Preferences::default();
prefs.save();
ew_game.send(GameEvent::SetShadows(Turn::Unchanged));
ew_game.send(GameEvent::SetFullscreen(Turn::Unchanged));
ew_game.send(GameEvent::SetSound(game::Cycle::Unchanged));
ew_game.send(GameEvent::SetMusic(game::Cycle::Unchanged));
ew_game.send(GameEvent::SetAR(Turn::Unchanged));
ew_game.send(GameEvent::UpdateFlashlight);
ew_updatepointer.send(hud::UpdatePointerEvent);
ew_updateavatar.send(hud::UpdateAvatarEvent);
ew_updatemenu.send(UpdateMenuEvent);
}
MenuAction::Restart => { MenuAction::Restart => {
settings.god_mode = false; settings.god_mode = false;
ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::Depressurization)); ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::Depressurization));