disable blackout for now, i dont like it, too confusing

This commit is contained in:
yuni 2024-04-08 01:47:38 +02:00
parent a44a7faa42
commit 9218398c77
3 changed files with 47 additions and 43 deletions

View file

@ -155,7 +155,7 @@ python -m http.server -d wasm
- Implement zooming with right click (AR only) - Implement zooming with right click (AR only)
- Implement targeting objects with left click (AR only) - Implement targeting objects with left click (AR only)
- Implement matching velocity to targeted objects with space - Implement matching velocity to targeted objects with space
- Implement damage from g-forces, passing out - Implement damage from g-forces
- Implement god mode - Implement god mode
- Fix crash by avoiding legacy fullscreen mode - Fix crash by avoiding legacy fullscreen mode
- v0.5.3: - v0.5.3:

View file

@ -452,7 +452,6 @@ fn handle_damage(
fn handle_gforce( fn handle_gforce(
time: Res<Time>, time: Res<Time>,
mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>, mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>,
settings: Res<settings::Settings>,
) { ) {
let dt = time.delta_seconds(); let dt = time.delta_seconds();
let factor = 1.0 / dt / 9.81; let factor = 1.0 / dt / 9.81;
@ -468,16 +467,17 @@ fn handle_gforce(
hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0; hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0;
} }
if !settings.god_mode { // Blackout disabled for now
if gforce.blackout > 0.0001 { // if !settings.god_mode {
gforce.blackout *= 0.984; // if gforce.blackout > 0.0001 {
} // gforce.blackout *= 0.984;
else if gforce.blackout > 0.0 { // }
gforce.blackout = 0.0; // else if gforce.blackout > 0.0 {
} // gforce.blackout = 0.0;
if gforce.gforce > gforce.blackout_threshold { // }
gforce.blackout += (gforce.gforce - gforce.blackout_threshold).powf(2.0) / 300000.0 // if gforce.gforce > gforce.blackout_threshold {
} // gforce.blackout += (gforce.gforce - gforce.blackout_threshold).powf(2.0) / 300000.0
} // }
// }
} }
} }

View file

@ -1,5 +1,5 @@
use bevy::prelude::*; use bevy::prelude::*;
use crate::{actor, camera, settings}; use crate::{camera, settings};
pub struct EffectsPlugin; pub struct EffectsPlugin;
@ -9,7 +9,8 @@ impl Plugin for EffectsPlugin {
app.add_systems(Startup, spawn_effects.after(setup).after(camera::setup_camera)); app.add_systems(Startup, spawn_effects.after(setup).after(camera::setup_camera));
app.add_systems(Update, spawn_effects); app.add_systems(Update, spawn_effects);
app.add_systems(Update, update_fadeblack); app.add_systems(Update, update_fadeblack);
app.add_systems(Update, update_blackout); // Blackout disabled for now
//app.add_systems(Update, update_blackout);
app.add_event::<SpawnEffectEvent>(); app.add_event::<SpawnEffectEvent>();
} }
} }
@ -19,7 +20,9 @@ pub enum Effects {
FadeIn(Color), FadeIn(Color),
} }
#[derive(Component)] pub struct BlackOutOverlay; // Blackout disabled for now
//#[derive(Component)] pub struct BlackOutOverlay;
#[derive(Component)] pub struct FadeBlack; #[derive(Component)] pub struct FadeBlack;
#[derive(Component)] #[derive(Component)]
pub struct Effect { pub struct Effect {
@ -34,28 +37,28 @@ pub struct SpawnEffectEvent {
} }
pub fn setup( pub fn setup(
mut commands: Commands,
settings: Res<settings::Settings>, settings: Res<settings::Settings>,
mut ew_effect: EventWriter<SpawnEffectEvent>, mut ew_effect: EventWriter<SpawnEffectEvent>,
) { ) {
if !settings.dev_mode { if !settings.dev_mode {
ew_effect.send(SpawnEffectEvent { class: Effects::FadeIn(Color::BLACK), duration: 4.0 }); ew_effect.send(SpawnEffectEvent { class: Effects::FadeIn(Color::BLACK), duration: 4.0 });
} }
commands.spawn(( // Blackout disabled for now
BlackOutOverlay, // commands.spawn((
NodeBundle { // BlackOutOverlay,
style: Style { // NodeBundle {
width: Val::Vw(100.0), // style: Style {
height: Val::Vh(100.0), // width: Val::Vw(100.0),
position_type: PositionType::Absolute, // height: Val::Vh(100.0),
top: Val::Px(0.0), // position_type: PositionType::Absolute,
left: Val::Px(0.0), // top: Val::Px(0.0),
..default() // left: Val::Px(0.0),
}, // ..default()
background_color: Color::BLACK.into(), // },
..default() // background_color: Color::BLACK.into(),
}, // ..default()
)); // },
// ));
} }
pub fn spawn_effects( pub fn spawn_effects(
@ -109,14 +112,15 @@ pub fn update_fadeblack(
} }
} }
pub fn update_blackout( // Blackout disabled for now
mut q_effect: Query<&mut BackgroundColor, With<BlackOutOverlay>>, //pub fn update_blackout(
q_player: Query<&actor::ExperiencesGForce, With<actor::Player>> // mut q_effect: Query<&mut BackgroundColor, With<BlackOutOverlay>>,
) { // q_player: Query<&actor::ExperiencesGForce, With<actor::Player>>
if let (Ok(gforce), Ok(mut bgcolor)) = (q_player.get_single(), q_effect.get_single_mut()) { //) {
let threshold = 0.3; // if let (Ok(gforce), Ok(mut bgcolor)) = (q_player.get_single(), q_effect.get_single_mut()) {
let factor = 1.0 / (1.0 - threshold); // let threshold = 0.3;
let alpha = (factor * (gforce.blackout - threshold)).clamp(0.0, 1.0); // let factor = 1.0 / (1.0 - threshold);
bgcolor.0.set_a(alpha as f32); // let alpha = (factor * (gforce.blackout - threshold)).clamp(0.0, 1.0);
} // bgcolor.0.set_a(alpha as f32);
} // }
//}