|
|
|
|
@ -1,33 +1,4 @@
|
|
|
|
|
use crate::{
|
|
|
|
|
game::{Board, BoardIndex, Piece, Side},
|
|
|
|
|
prelude::*,
|
|
|
|
|
tweak::Tweaks,
|
|
|
|
|
};
|
|
|
|
|
use bevy::{
|
|
|
|
|
animation::RepeatAnimation,
|
|
|
|
|
core_pipeline::{
|
|
|
|
|
bloom::BloomSettings,
|
|
|
|
|
experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasSettings},
|
|
|
|
|
prepass::MotionVectorPrepass,
|
|
|
|
|
tonemapping::{DebandDither, Tonemapping},
|
|
|
|
|
Skybox,
|
|
|
|
|
},
|
|
|
|
|
input::{
|
|
|
|
|
mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
|
|
|
|
|
ButtonState,
|
|
|
|
|
},
|
|
|
|
|
pbr::{
|
|
|
|
|
ExtendedMaterial, MaterialExtension, ScreenSpaceAmbientOcclusionBundle,
|
|
|
|
|
ScreenSpaceAmbientOcclusionSettings,
|
|
|
|
|
},
|
|
|
|
|
render::{
|
|
|
|
|
render_resource::{AsBindGroup, ShaderRef, TextureViewDescriptor, TextureViewDimension},
|
|
|
|
|
view::ColorGrading,
|
|
|
|
|
},
|
|
|
|
|
utils::HashMap,
|
|
|
|
|
window::PrimaryWindow,
|
|
|
|
|
};
|
|
|
|
|
use tweaks::*;
|
|
|
|
|
use crate::prelude::*;
|
|
|
|
|
|
|
|
|
|
pub(crate) struct Display3dPlugin;
|
|
|
|
|
|
|
|
|
|
@ -43,7 +14,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
(
|
|
|
|
|
initialize,
|
|
|
|
|
fix_skybox.before(initialize),
|
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>()),
|
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.add_systems(
|
|
|
|
|
@ -62,7 +33,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
set_piece_position.run_if(any_component_changed::<BoardIndex>()),
|
|
|
|
|
set_piece_texture
|
|
|
|
|
.run_if(any_component_changed::<Side>())
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>()),
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
select
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(in_state(DisplayState::Display3d))
|
|
|
|
|
@ -71,10 +42,10 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
put_down.run_if(any_component_removed::<game::Selected>()),
|
|
|
|
|
switch_sides
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(state_changed::<game::TurnState>()),
|
|
|
|
|
.run_if(state_changed::<game::TurnState>),
|
|
|
|
|
update_tweaks
|
|
|
|
|
.run_if(on_event::<AssetEvent<Tweaks>>())
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>()),
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
scale_lighting.run_if(
|
|
|
|
|
any_component_added::<DirectionalLight>()
|
|
|
|
|
.or_else(any_component_added::<SpotLight>())
|
|
|
|
|
@ -82,9 +53,9 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
.or_else(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
|
),
|
|
|
|
|
setup_capture_piece.run_if(any_component_changed::<Handle<StandardMaterial>>()),
|
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>()),
|
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>),
|
|
|
|
|
skip_animation
|
|
|
|
|
.run_if(just_pressed(KeyCode::Return).or_else(just_pressed(MouseButton::Left)))
|
|
|
|
|
.run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left)))
|
|
|
|
|
.run_if(in_state(GameState::Play)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
@ -96,9 +67,9 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
gizmo_system,
|
|
|
|
|
selected_gizmo,
|
|
|
|
|
moves_gizmo,
|
|
|
|
|
debug_selected.run_if(any_with_component::<game::Selected>()),
|
|
|
|
|
debug_selected.run_if(any_with_component::<game::Selected>),
|
|
|
|
|
)
|
|
|
|
|
.run_if(resource_exists::<debug::DebugEnabled>())
|
|
|
|
|
.run_if(resource_exists::<debug::DebugEnabled>)
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
|
)
|
|
|
|
|
@ -112,8 +83,8 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
.add_systems(
|
|
|
|
|
OnEnter(GameState::Play),
|
|
|
|
|
(
|
|
|
|
|
set_piece_texture.run_if(resource_exists::<tweak::GameTweaks>()),
|
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>()),
|
|
|
|
|
set_piece_texture.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
|
opening_animation
|
|
|
|
|
.run_if(run_once())
|
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
|
@ -142,7 +113,7 @@ fn load_assets(
|
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
|
|
|
) {
|
|
|
|
|
let hitbox_shape = meshes.add(shape::Box::new(1.0, 0.1, 1.0).into());
|
|
|
|
|
let hitbox_shape = meshes.add(Cuboid::new(1.0, 0.1, 1.0));
|
|
|
|
|
let hitbox_material = materials.add(StandardMaterial {
|
|
|
|
|
base_color: Color::NONE,
|
|
|
|
|
perceptual_roughness: 0.0,
|
|
|
|
|
@ -278,12 +249,15 @@ fn hydrate_camera(
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
BloomSettings { ..default() },
|
|
|
|
|
Skybox(skybox_handle.clone()),
|
|
|
|
|
Skybox {
|
|
|
|
|
image: skybox_handle.clone(),
|
|
|
|
|
brightness: 1.0,
|
|
|
|
|
},
|
|
|
|
|
EnvironmentMapLight {
|
|
|
|
|
diffuse_map: skybox_handle.clone(),
|
|
|
|
|
specular_map: skybox_handle.clone(),
|
|
|
|
|
intensity: 1.0,
|
|
|
|
|
},
|
|
|
|
|
UiCameraConfig { show_ui: true },
|
|
|
|
|
FogSettings { ..default() },
|
|
|
|
|
ScreenSpaceAmbientOcclusionBundle { ..default() },
|
|
|
|
|
TemporalAntiAliasSettings { ..default() },
|
|
|
|
|
@ -341,23 +315,24 @@ fn update_tweaks(
|
|
|
|
|
camera_settings.iter_mut().for_each(
|
|
|
|
|
|(entity, mut fog, mut color_grading, mut tonemapping, mut bloom)| {
|
|
|
|
|
*fog = tweak
|
|
|
|
|
.get::<TweakFogSettings>("display3d_fog")
|
|
|
|
|
.get::<tweaks::TweakFogSettings>("display3d_fog")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.into();
|
|
|
|
|
*color_grading = tweak
|
|
|
|
|
.get::<TweakColorGrading>("display3d_color_grading")
|
|
|
|
|
.get::<tweaks::TweakColorGrading>("display3d_color_grading")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.into();
|
|
|
|
|
*tonemapping = tweak
|
|
|
|
|
.get::<TweakTonemapping>("display3d_color_tonemapping")
|
|
|
|
|
.get::<tweaks::TweakTonemapping>("display3d_color_tonemapping")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.into();
|
|
|
|
|
*bloom = tweak
|
|
|
|
|
.get::<TweakBloomSettings>("display3d_bloom")
|
|
|
|
|
.get::<tweaks::TweakBloomSettings>("display3d_bloom")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.into();
|
|
|
|
|
|
|
|
|
|
let quality_level = tweak.get::<TweakScreenSpaceAmbientOcclusionQualityLevel>(
|
|
|
|
|
let quality_level = tweak
|
|
|
|
|
.get::<tweaks::TweakScreenSpaceAmbientOcclusionQualityLevel>(
|
|
|
|
|
"display3d_ssao_quality_level",
|
|
|
|
|
);
|
|
|
|
|
match quality_level {
|
|
|
|
|
@ -373,7 +348,10 @@ fn update_tweaks(
|
|
|
|
|
commands
|
|
|
|
|
.entity(entity)
|
|
|
|
|
.remove::<ScreenSpaceAmbientOcclusionSettings>();
|
|
|
|
|
let msaa: Msaa = tweak.get::<TweakMsaa>("display3d_msaa").unwrap().into();
|
|
|
|
|
let msaa: Msaa = tweak
|
|
|
|
|
.get::<tweaks::TweakMsaa>("display3d_msaa")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.into();
|
|
|
|
|
commands.insert_resource(msaa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -542,7 +520,7 @@ fn gizmo_system(mut gizmos: Gizmos) {
|
|
|
|
|
|
|
|
|
|
/// TODO: This has bad feel, needs to be tuned
|
|
|
|
|
fn move_camera(
|
|
|
|
|
buttons: Res<Input<MouseButton>>,
|
|
|
|
|
buttons: Res<ButtonInput<MouseButton>>,
|
|
|
|
|
mut events: EventReader<MouseMotion>,
|
|
|
|
|
mut camera: Query<&mut Transform, (With<Display3d>, With<Camera>)>,
|
|
|
|
|
) {
|
|
|
|
|
@ -1132,17 +1110,7 @@ fn scale_lighting(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) mod tweaks {
|
|
|
|
|
use bevy::{
|
|
|
|
|
core_pipeline::{bloom::BloomSettings, tonemapping::Tonemapping},
|
|
|
|
|
math::Vec3,
|
|
|
|
|
pbr::{FogFalloff, FogSettings, ScreenSpaceAmbientOcclusionQualityLevel},
|
|
|
|
|
prelude::*,
|
|
|
|
|
render::{
|
|
|
|
|
color::Color,
|
|
|
|
|
view::{ColorGrading, Msaa},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub enum TweakTonemapping {
|
|
|
|
|
|