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 targeting objects with left click (AR only)
- Implement matching velocity to targeted objects with space
- Implement damage from g-forces, passing out
- Implement damage from g-forces
- Implement god mode
- Fix crash by avoiding legacy fullscreen mode
- v0.5.3:

View file

@ -452,7 +452,6 @@ fn handle_damage(
fn handle_gforce(
time: Res<Time>,
mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>,
settings: Res<settings::Settings>,
) {
let dt = time.delta_seconds();
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;
}
if !settings.god_mode {
if gforce.blackout > 0.0001 {
gforce.blackout *= 0.984;
}
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
}
}
// Blackout disabled for now
// if !settings.god_mode {
// if gforce.blackout > 0.0001 {
// gforce.blackout *= 0.984;
// }
// 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
// }
// }
}
}

View file

@ -1,5 +1,5 @@
use bevy::prelude::*;
use crate::{actor, camera, settings};
use crate::{camera, settings};
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(Update, spawn_effects);
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>();
}
}
@ -19,7 +20,9 @@ pub enum Effects {
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 Effect {
@ -34,28 +37,28 @@ pub struct SpawnEffectEvent {
}
pub fn setup(
mut commands: Commands,
settings: Res<settings::Settings>,
mut ew_effect: EventWriter<SpawnEffectEvent>,
) {
if !settings.dev_mode {
ew_effect.send(SpawnEffectEvent { class: Effects::FadeIn(Color::BLACK), duration: 4.0 });
}
commands.spawn((
BlackOutOverlay,
NodeBundle {
style: Style {
width: Val::Vw(100.0),
height: Val::Vh(100.0),
position_type: PositionType::Absolute,
top: Val::Px(0.0),
left: Val::Px(0.0),
..default()
},
background_color: Color::BLACK.into(),
..default()
},
));
// Blackout disabled for now
// commands.spawn((
// BlackOutOverlay,
// NodeBundle {
// style: Style {
// width: Val::Vw(100.0),
// height: Val::Vh(100.0),
// position_type: PositionType::Absolute,
// top: Val::Px(0.0),
// left: Val::Px(0.0),
// ..default()
// },
// background_color: Color::BLACK.into(),
// ..default()
// },
// ));
}
pub fn spawn_effects(
@ -109,14 +112,15 @@ pub fn update_fadeblack(
}
}
pub fn update_blackout(
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;
let factor = 1.0 / (1.0 - threshold);
let alpha = (factor * (gforce.blackout - threshold)).clamp(0.0, 1.0);
bgcolor.0.set_a(alpha as f32);
}
}
// Blackout disabled for now
//pub fn update_blackout(
// 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;
// let factor = 1.0 / (1.0 - threshold);
// let alpha = (factor * (gforce.blackout - threshold)).clamp(0.0, 1.0);
// bgcolor.0.set_a(alpha as f32);
// }
//}