diff --git a/assets/martian.tweak.toml b/assets/martian.tweak.toml index 3fadfca..27a0c2d 100644 --- a/assets/martian.tweak.toml +++ b/assets/martian.tweak.toml @@ -272,4 +272,7 @@ QueenRed = "QueenRedPieceIdle" ### Animation Settings ###################### [animation] -fast_speed = 2.0 \ No newline at end of file +fast_movement_speed = 2.0 +fast_text_speed = 4.0 +fast_dissolve_speed = 1.0 +fast_light_speed = 1.0 \ No newline at end of file diff --git a/src/display3d.rs b/src/display3d.rs index af2561e..cc3f1b4 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -1,6 +1,7 @@ use bevy::core_pipeline::{ contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, fxaa::Fxaa, }; +use gltf::Animation; use crate::prelude::*; @@ -14,7 +15,7 @@ impl Plugin for Display3dPlugin { )) .init_state::() .init_resource::() - .insert_resource(AnimationSpeed(1.0)) + .init_resource::() .insert_resource(Msaa::Off) .insert_resource(AmbientLight { color: Color::WHITE, @@ -202,7 +203,23 @@ enum DissolvingAnimation { } #[derive(Debug, Resource)] -struct AnimationSpeed(f32); +pub(crate) struct AnimationSpeed { + pub movement: f32, + pub text: f32, + pub dissolve: f32, + pub light: f32, +} + +impl Default for AnimationSpeed { + fn default() -> Self { + AnimationSpeed { + movement: 1.0, + text: 1.0, + dissolve: 1.0, + light: 1.0, + } + } +} #[derive(Debug, Resource, Clone)] struct AssetsMap { @@ -1011,15 +1028,20 @@ fn set_animation_speed( keys: Res>, mouse: Res>, ) { - animation_speed.0 = if keys.pressed(KeyCode::Enter) || mouse.pressed(MouseButton::Left) { + *animation_speed = if keys.pressed(KeyCode::Enter) || mouse.pressed(MouseButton::Left) { let tweak = tweaks .get(tweaks_file.handle.clone()) .expect("Load tweakfile"); - let speed = tweak.get::("animation_fast_speed").unwrap(); - speed + let movement = tweak.get::("animation_fast_movement_speed").unwrap(); + let text = tweak.get::("animation_fast_text_speed").unwrap(); + let dissolve = tweak.get::("animation_fast_dissolve_speed").unwrap(); + let light = tweak.get::("animation_fast_light_speed").unwrap(); + AnimationSpeed { movement, text, dissolve, light } } else { - 1.0 - } + AnimationSpeed::default() + }; + + info!("Animation speed: {:?}", animation_speed.movement); } // When an animation starts, or the animation speed changes, update player speed @@ -1028,7 +1050,7 @@ fn set_animation_player_speed( animation_speed: Res, ) { players.iter_mut().for_each(|mut p| { - p.set_speed(animation_speed.0); + p.set_speed(animation_speed.movement); }) } @@ -1331,7 +1353,7 @@ fn dissolve_animation( let percentage = match *dissolving { Dissolving::In(mut sec) => { // Check if seconds is below 0.0 - sec = (sec - (time.delta_seconds() * animation_speed.0)).max(0.0); + sec = (sec - (time.delta_seconds() * animation_speed.dissolve)).max(0.0); *dissolving = Dissolving::In(sec); @@ -1340,7 +1362,7 @@ fn dissolve_animation( } Dissolving::Out(mut sec) => { // Check if seconds is below 0.0 - sec = (sec - (time.delta_seconds() * animation_speed.0)).max(0.0); + sec = (sec - (time.delta_seconds() * animation_speed.dissolve)).max(0.0); *dissolving = Dissolving::Out(sec); @@ -1449,21 +1471,14 @@ fn animate_title_light_in( mut t: Local, mut started: Local, time: Res