|
|
|
@ -1,5 +1,5 @@
|
|
|
|
use bevy::core_pipeline::{
|
|
|
|
use bevy::core_pipeline::{
|
|
|
|
bloom::{BloomCompositeMode, BloomPrefilterSettings}, contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, experimental::taa::TemporalAntiAliasBundle, fxaa::{Fxaa, FxaaPlugin, Sensitivity}
|
|
|
|
contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, fxaa::Fxaa
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
use crate::prelude::*;
|
|
|
|
use crate::prelude::*;
|
|
|
|
@ -25,6 +25,21 @@ impl Plugin for Display3dPlugin {
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
// Systems related to color and camera
|
|
|
|
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
color_grading_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
|
|
|
.run_if(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
|
|
|
|
fog_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
|
|
|
.run_if(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
|
|
|
|
bloom_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
|
|
|
.run_if(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
@ -41,6 +56,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
.run_if(state_changed::<game::TurnState>),
|
|
|
|
.run_if(state_changed::<game::TurnState>),
|
|
|
|
update_pieces
|
|
|
|
update_pieces
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(
|
|
|
|
.run_if(
|
|
|
|
any_component_changed::<Piece>()
|
|
|
|
any_component_changed::<Piece>()
|
|
|
|
.or_else(any_component_changed::<Side>())
|
|
|
|
.or_else(any_component_changed::<Side>())
|
|
|
|
@ -66,7 +82,10 @@ impl Plugin for Display3dPlugin {
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>),
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>),
|
|
|
|
skip_animation
|
|
|
|
skip_animation
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left))),
|
|
|
|
.run_if(pressed(KeyCode::Enter).or_else(pressed(MouseButton::Left))),
|
|
|
|
|
|
|
|
un_skip_animation
|
|
|
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
|
|
|
.run_if(just_released(KeyCode::Enter).or_else(just_released(MouseButton::Left))),
|
|
|
|
monitor_animations
|
|
|
|
monitor_animations
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(any_component_changed::<AnimationPlayer>()),
|
|
|
|
.run_if(any_component_changed::<AnimationPlayer>()),
|
|
|
|
@ -91,23 +110,28 @@ impl Plugin for Display3dPlugin {
|
|
|
|
(
|
|
|
|
(
|
|
|
|
// Toggle hidden/visible 3d entities
|
|
|
|
// Toggle hidden/visible 3d entities
|
|
|
|
manage_state_entities::<DisplayState>(),
|
|
|
|
manage_state_entities::<DisplayState>(),
|
|
|
|
fixup_shadows,
|
|
|
|
// fixup_shadows,
|
|
|
|
|
|
|
|
color_grading_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
|
|
|
fog_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
|
|
|
bloom_tweak
|
|
|
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
|
|
|
update_pieces.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
OnEnter(GameState::Play),
|
|
|
|
OnEnter(GameState::Play),
|
|
|
|
(
|
|
|
|
(
|
|
|
|
update_pieces.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
opening_animation
|
|
|
|
opening_animation
|
|
|
|
.run_if(run_once())
|
|
|
|
.run_if(run_once())
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
fixup_shadows.after(update_pieces),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(OnEnter(GameState::Title), (
|
|
|
|
.add_systems(OnEnter(GameState::Title), (
|
|
|
|
intro_title_dissolve,
|
|
|
|
|
|
|
|
fixup_shadows,
|
|
|
|
fixup_shadows,
|
|
|
|
|
|
|
|
intro_title_dissolve,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.add_systems(OnExit(GameState::Title), outro_title_dissolve)
|
|
|
|
.add_systems(OnExit(GameState::Title), outro_title_dissolve)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -327,22 +351,16 @@ fn hydrate_camera(
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
BloomSettings {
|
|
|
|
BloomSettings {
|
|
|
|
intensity: 0.05,
|
|
|
|
intensity: 0.0,
|
|
|
|
prefilter_settings: BloomPrefilterSettings {
|
|
|
|
|
|
|
|
threshold: 0.8,
|
|
|
|
|
|
|
|
threshold_softness: 0.5,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
composite_mode: BloomCompositeMode::Additive,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
FogSettings {
|
|
|
|
FogSettings {
|
|
|
|
color: Color::rgba(0.25, 0.25, 0.25, 1.0),
|
|
|
|
color: Color::rgba(0.25, 0.25, 0.25, 1.0),
|
|
|
|
falloff: FogFalloff::Exponential {
|
|
|
|
falloff: FogFalloff::Exponential {
|
|
|
|
density: 0.025,
|
|
|
|
density: 0.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// ScreenSpaceAmbientOcclusionBundle { ..default() },
|
|
|
|
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
let assets_handle = tweak
|
|
|
|
let assets_handle = tweak
|
|
|
|
@ -376,7 +394,7 @@ fn hydrate_camera(
|
|
|
|
/// Update display3d tweaks in the game
|
|
|
|
/// Update display3d tweaks in the game
|
|
|
|
/// Triggered on entering 3d state and when the tweakfile is updated.
|
|
|
|
/// Triggered on entering 3d state and when the tweakfile is updated.
|
|
|
|
fn update_tweaks(
|
|
|
|
fn update_tweaks(
|
|
|
|
mut camera_settings: Query<(Entity, &mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
|
|
|
|
mut camera_settings: Query<(&mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
@ -384,7 +402,7 @@ fn update_tweaks(
|
|
|
|
warn!("Updating tweaks!");
|
|
|
|
warn!("Updating tweaks!");
|
|
|
|
camera_settings
|
|
|
|
camera_settings
|
|
|
|
.iter_mut()
|
|
|
|
.iter_mut()
|
|
|
|
.for_each(|(entity, mut skybox, mut environment_map_light)| {
|
|
|
|
.for_each(|(mut skybox, mut environment_map_light)| {
|
|
|
|
skybox.brightness = tweak.get::<f32>("display3d_skybox_brightness").unwrap();
|
|
|
|
skybox.brightness = tweak.get::<f32>("display3d_skybox_brightness").unwrap();
|
|
|
|
environment_map_light.intensity = tweak
|
|
|
|
environment_map_light.intensity = tweak
|
|
|
|
.get::<f32>("display3d_environment_map_light_intensity")
|
|
|
|
.get::<f32>("display3d_environment_map_light_intensity")
|
|
|
|
@ -924,17 +942,27 @@ fn opening_animation(mut players: Query<&mut AnimationPlayer, (With<Camera>, Wit
|
|
|
|
|
|
|
|
|
|
|
|
// When called skips any running animations
|
|
|
|
// When called skips any running animations
|
|
|
|
fn skip_animation(
|
|
|
|
fn skip_animation(
|
|
|
|
mut players: Query<&mut AnimationPlayer>,
|
|
|
|
mut players: Query<&mut AnimationPlayer, With<Animating>>,
|
|
|
|
clips: Res<Assets<AnimationClip>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
time: Res<Time>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
let speed = tweak.get::<f32>("animation_fast_speed").unwrap();
|
|
|
|
players.iter_mut().for_each(|mut p| {
|
|
|
|
players.iter_mut().for_each(|mut p| {
|
|
|
|
if let Some(c) = clips.get(p.animation_clip()) {
|
|
|
|
debug!("Skipping animation");
|
|
|
|
info!("Skipping animation");
|
|
|
|
// HACK: Set the speed of the animation to turbo
|
|
|
|
// HACK: We should be able to skip to the end of an animation
|
|
|
|
p.set_speed(speed);
|
|
|
|
// But implementation details means this is as close as we can get...
|
|
|
|
})
|
|
|
|
p.seek_to(c.duration() - (2.0 * time.delta_seconds()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn un_skip_animation(
|
|
|
|
|
|
|
|
mut players: Query<&mut AnimationPlayer, With<Animating>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
players.iter_mut().for_each(|mut p| {
|
|
|
|
|
|
|
|
debug!("Un-Skipping animation");
|
|
|
|
|
|
|
|
p.set_speed(1.0);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1151,7 +1179,7 @@ struct Animating;
|
|
|
|
|
|
|
|
|
|
|
|
fn monitor_animations(
|
|
|
|
fn monitor_animations(
|
|
|
|
active: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, With<Animating>)>,
|
|
|
|
active: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, With<Animating>)>,
|
|
|
|
inactive: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, Without<Animating>)>,
|
|
|
|
mut inactive: Query<(Entity, &mut AnimationPlayer), (Changed<AnimationPlayer>, Without<Animating>)>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// Remove Animating component from players that are done
|
|
|
|
// Remove Animating component from players that are done
|
|
|
|
@ -1162,10 +1190,11 @@ fn monitor_animations(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Set inactive entities to active
|
|
|
|
// Set inactive entities to active
|
|
|
|
inactive.iter().for_each(|(entity, player)| {
|
|
|
|
inactive.iter_mut().for_each(|(entity, mut player)| {
|
|
|
|
if !player.is_finished() && *player.animation_clip() != Handle::<AnimationClip>::default() {
|
|
|
|
if !player.is_finished() && *player.animation_clip() != Handle::<AnimationClip>::default() {
|
|
|
|
info!("Entity {:?} is playing {:?}, adding animating marker", entity, player.animation_clip());
|
|
|
|
info!("Entity {:?} is playing {:?}, adding animating marker", entity, player.animation_clip());
|
|
|
|
commands.entity(entity).insert(Animating);
|
|
|
|
commands.entity(entity).insert(Animating);
|
|
|
|
|
|
|
|
player.set_speed(1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1207,6 +1236,8 @@ fn dissolve_animation(
|
|
|
|
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
|
|
|
|
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
|
|
|
|
object_materials: Query<(Entity, &Handle<DissolveMaterial>)>,
|
|
|
|
object_materials: Query<(Entity, &Handle<DissolveMaterial>)>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
keys: Res<ButtonInput<KeyCode>>,
|
|
|
|
|
|
|
|
mouse: Res<ButtonInput<MouseButton>>,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
query
|
|
|
|
query
|
|
|
|
@ -1214,24 +1245,34 @@ fn dissolve_animation(
|
|
|
|
.for_each(|(entity, dissolvable, mut dissolving)| {
|
|
|
|
.for_each(|(entity, dissolvable, mut dissolving)| {
|
|
|
|
debug!("Entity {:?} has Dissolving {:?}", entity, dissolving);
|
|
|
|
debug!("Entity {:?} has Dissolving {:?}", entity, dissolving);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
|
|
|
|
|
|
|
|
|
|
|
|
let percentage = match *dissolving {
|
|
|
|
let percentage = match *dissolving {
|
|
|
|
Dissolving::In(mut sec) => {
|
|
|
|
Dissolving::In(mut sec) => {
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
if skip {
|
|
|
|
sec = (sec - time.delta_seconds()).max(0.0);
|
|
|
|
1.0
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
|
|
|
|
sec = (sec - time.delta_seconds()).max(0.0);
|
|
|
|
|
|
|
|
|
|
|
|
*dissolving = Dissolving::In(sec);
|
|
|
|
*dissolving = Dissolving::In(sec);
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the target percentage value
|
|
|
|
// Calculate the target percentage value
|
|
|
|
1.0 - (sec / dissolvable.duration)
|
|
|
|
1.0 - (sec / dissolvable.duration)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Dissolving::Out(mut sec) => {
|
|
|
|
Dissolving::Out(mut sec) => {
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
if skip {
|
|
|
|
sec = (sec - time.delta_seconds()).max(0.0);
|
|
|
|
0.0
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
|
|
|
|
sec = (sec - time.delta_seconds()).max(0.0);
|
|
|
|
|
|
|
|
|
|
|
|
*dissolving = Dissolving::Out(sec);
|
|
|
|
*dissolving = Dissolving::Out(sec);
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the target percentage value
|
|
|
|
// Calculate the target percentage value
|
|
|
|
sec / dissolvable.duration
|
|
|
|
sec / dissolvable.duration
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -1273,3 +1314,54 @@ fn fixup_shadows(
|
|
|
|
l.shadows_enabled = true;
|
|
|
|
l.shadows_enabled = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn color_grading_tweak(
|
|
|
|
|
|
|
|
mut query: Query<&mut ColorGrading>,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
let exposure = tweak.get::<f32>("color_grading_exposure").unwrap();
|
|
|
|
|
|
|
|
let gamma = tweak.get::<f32>("color_grading_gamma").unwrap();
|
|
|
|
|
|
|
|
let pre_saturation = tweak.get::<f32>("color_grading_pre_saturation").unwrap();
|
|
|
|
|
|
|
|
let post_saturation = tweak.get::<f32>("color_grading_post_saturation").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query.iter_mut().for_each(|mut cg| {
|
|
|
|
|
|
|
|
*cg = ColorGrading {
|
|
|
|
|
|
|
|
exposure, gamma, pre_saturation, post_saturation
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn fog_tweak(
|
|
|
|
|
|
|
|
mut query: Query<&mut FogSettings>,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query.iter_mut().for_each(|mut fog| {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fog.falloff = FogFalloff::Exponential {
|
|
|
|
|
|
|
|
density: tweak.get::<f32>("color_fog_density").unwrap(),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn bloom_tweak(
|
|
|
|
|
|
|
|
mut query: Query<&mut BloomSettings>,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
query.iter_mut().for_each(|mut bloom| {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bloom.intensity = tweak.get::<f32>("color_bloom_intensity").unwrap();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|