|
|
|
@ -4,18 +4,24 @@ use crate::{
|
|
|
|
tweak::Tweaks,
|
|
|
|
tweak::Tweaks,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use bevy::{
|
|
|
|
use bevy::{
|
|
|
|
animation::RepeatAnimation, core_pipeline::{
|
|
|
|
animation::RepeatAnimation,
|
|
|
|
|
|
|
|
core_pipeline::{
|
|
|
|
experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasSettings},
|
|
|
|
experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasSettings},
|
|
|
|
prepass::MotionVectorPrepass,
|
|
|
|
prepass::MotionVectorPrepass,
|
|
|
|
tonemapping::{DebandDither, Tonemapping},
|
|
|
|
tonemapping::{DebandDither, Tonemapping},
|
|
|
|
Skybox,
|
|
|
|
Skybox,
|
|
|
|
}, input::mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel}, pbr::{
|
|
|
|
},
|
|
|
|
ExtendedMaterial, MaterialExtension,
|
|
|
|
input::mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
|
|
|
|
ScreenSpaceAmbientOcclusionBundle, ScreenSpaceAmbientOcclusionSettings,
|
|
|
|
pbr::{
|
|
|
|
}, render::{
|
|
|
|
ExtendedMaterial, MaterialExtension, ScreenSpaceAmbientOcclusionBundle,
|
|
|
|
|
|
|
|
ScreenSpaceAmbientOcclusionSettings,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
render::{
|
|
|
|
render_resource::{AsBindGroup, ShaderRef, TextureViewDescriptor, TextureViewDimension},
|
|
|
|
render_resource::{AsBindGroup, ShaderRef, TextureViewDescriptor, TextureViewDimension},
|
|
|
|
view::ColorGrading,
|
|
|
|
view::ColorGrading,
|
|
|
|
}, utils::HashMap, window::PrimaryWindow
|
|
|
|
},
|
|
|
|
|
|
|
|
utils::HashMap,
|
|
|
|
|
|
|
|
window::PrimaryWindow,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use tweaks::*;
|
|
|
|
use tweaks::*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,7 +78,9 @@ impl Plugin for Display3dPlugin {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
setup_capture_piece.run_if(any_component_changed::<Handle<StandardMaterial>>),
|
|
|
|
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(|keys: Res<Input<KeyCode>>| -> bool { keys.just_pressed(KeyCode::Return) }),
|
|
|
|
skip_animation.run_if(|keys: Res<Input<KeyCode>>| -> bool {
|
|
|
|
|
|
|
|
keys.just_pressed(KeyCode::Return)
|
|
|
|
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -1288,7 +1296,13 @@ struct Backup<T: Component>(T);
|
|
|
|
/// Sets up all pieces to have an associated "dissolve" material ready for capture
|
|
|
|
/// Sets up all pieces to have an associated "dissolve" material ready for capture
|
|
|
|
fn setup_capture_piece(
|
|
|
|
fn setup_capture_piece(
|
|
|
|
// All entities with materials are candidates for this procedure
|
|
|
|
// All entities with materials are candidates for this procedure
|
|
|
|
events: Query<(Entity, &Handle<StandardMaterial>), (Added<Handle<StandardMaterial>>, Changed<Handle<StandardMaterial>>)>,
|
|
|
|
events: Query<
|
|
|
|
|
|
|
|
(Entity, &Handle<StandardMaterial>),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
Added<Handle<StandardMaterial>>,
|
|
|
|
|
|
|
|
Changed<Handle<StandardMaterial>>,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
>,
|
|
|
|
// Only process newly created pieces (we do not delete pieces at runtime)
|
|
|
|
// Only process newly created pieces (we do not delete pieces at runtime)
|
|
|
|
query: Query<Entity, (With<Piece>, Added<Children>)>,
|
|
|
|
query: Query<Entity, (With<Piece>, Added<Children>)>,
|
|
|
|
// Children of pieces are the actual meshes that need materials
|
|
|
|
// Children of pieces are the actual meshes that need materials
|
|
|
|
@ -1305,9 +1319,7 @@ fn setup_capture_piece(
|
|
|
|
events
|
|
|
|
events
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
// Only process if this is a child of a piece
|
|
|
|
// Only process if this is a child of a piece
|
|
|
|
.filter(|(child, _)| {
|
|
|
|
.filter(|(child, _)| query.iter_many(parents.iter_ancestors(*child)).count() > 0)
|
|
|
|
query.iter_many(parents.iter_ancestors(*child)).count() > 0
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// Handle this entity (mesh)
|
|
|
|
// Handle this entity (mesh)
|
|
|
|
.for_each(|(child, std_handle)| {
|
|
|
|
.for_each(|(child, std_handle)| {
|
|
|
|
let dis_handle = match cache.get(std_handle) {
|
|
|
|
let dis_handle = match cache.get(std_handle) {
|
|
|
|
@ -1322,7 +1334,7 @@ fn setup_capture_piece(
|
|
|
|
.clone();
|
|
|
|
.clone();
|
|
|
|
|
|
|
|
|
|
|
|
dissolve_materials.add(ExtendedMaterial { base, extension })
|
|
|
|
dissolve_materials.add(ExtendedMaterial { base, extension })
|
|
|
|
},
|
|
|
|
}
|
|
|
|
Some(dis_handle) => dis_handle.clone(),
|
|
|
|
Some(dis_handle) => dis_handle.clone(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -1330,9 +1342,7 @@ fn setup_capture_piece(
|
|
|
|
cache.insert(std_handle.clone(), dis_handle.clone());
|
|
|
|
cache.insert(std_handle.clone(), dis_handle.clone());
|
|
|
|
|
|
|
|
|
|
|
|
// Add the dissolve handle as a Backup(T)
|
|
|
|
// Add the dissolve handle as a Backup(T)
|
|
|
|
commands
|
|
|
|
commands.entity(child).insert(Backup(dis_handle.clone()));
|
|
|
|
.entity(child)
|
|
|
|
|
|
|
|
.insert(Backup(dis_handle.clone()));
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1351,8 +1361,16 @@ fn capture_piece(
|
|
|
|
mut kids: Local<Vec<Entity>>,
|
|
|
|
mut kids: Local<Vec<Entity>>,
|
|
|
|
mut prog: Local<f32>,
|
|
|
|
mut prog: Local<f32>,
|
|
|
|
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
|
|
|
|
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
|
|
|
|
object_standard_materials: Query<(Entity, &Handle<StandardMaterial>, &Backup<Handle<DissolveMaterial>>)>,
|
|
|
|
object_standard_materials: Query<(
|
|
|
|
object_dissolve_materials: Query<(Entity, &Handle<DissolveMaterial>, &Backup<Handle<StandardMaterial>>)>,
|
|
|
|
Entity,
|
|
|
|
|
|
|
|
&Handle<StandardMaterial>,
|
|
|
|
|
|
|
|
&Backup<Handle<DissolveMaterial>>,
|
|
|
|
|
|
|
|
)>,
|
|
|
|
|
|
|
|
object_dissolve_materials: Query<(
|
|
|
|
|
|
|
|
Entity,
|
|
|
|
|
|
|
|
&Handle<DissolveMaterial>,
|
|
|
|
|
|
|
|
&Backup<Handle<StandardMaterial>>,
|
|
|
|
|
|
|
|
)>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
@ -1381,7 +1399,8 @@ fn capture_piece(
|
|
|
|
|
|
|
|
|
|
|
|
// Return child entity to be processed later in flow
|
|
|
|
// Return child entity to be processed later in flow
|
|
|
|
child
|
|
|
|
child
|
|
|
|
}).collect();
|
|
|
|
})
|
|
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
|
|
// Set the next state to start fading out
|
|
|
|
// Set the next state to start fading out
|
|
|
|
game::CaptureFlow::FadeOut(entity)
|
|
|
|
game::CaptureFlow::FadeOut(entity)
|
|
|
|
@ -1408,9 +1427,8 @@ fn capture_piece(
|
|
|
|
// This takes effect after updating all children
|
|
|
|
// This takes effect after updating all children
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
object_dissolve_materials
|
|
|
|
object_dissolve_materials.iter_many(kids.iter()).for_each(
|
|
|
|
.iter_many(kids.iter())
|
|
|
|
|(_child, dis_handle, _)| {
|
|
|
|
.for_each(|(_child, dis_handle, _)| {
|
|
|
|
|
|
|
|
let dissolve_material = dissolve_materials
|
|
|
|
let dissolve_material = dissolve_materials
|
|
|
|
.get_mut(dis_handle)
|
|
|
|
.get_mut(dis_handle)
|
|
|
|
.expect("Get the dissolve material");
|
|
|
|
.expect("Get the dissolve material");
|
|
|
|
@ -1422,7 +1440,7 @@ fn capture_piece(
|
|
|
|
"Play fade out animation {:?} {:?}",
|
|
|
|
"Play fade out animation {:?} {:?}",
|
|
|
|
delta, dissolve_material.extension.percentage
|
|
|
|
delta, dissolve_material.extension.percentage
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1435,8 +1453,14 @@ fn capture_piece(
|
|
|
|
*v = Visibility::Hidden;
|
|
|
|
*v = Visibility::Hidden;
|
|
|
|
|
|
|
|
|
|
|
|
// HACK: This is dirty. Why side, but score.captures(!side)?
|
|
|
|
// HACK: This is dirty. Why side, but score.captures(!side)?
|
|
|
|
info!("Capture translation: ({:?}, {:?}) {:?}", side, score.captures(!*side).saturating_sub(1), t.translation);
|
|
|
|
info!(
|
|
|
|
t.translation = capture_translation(side, score.captures(!*side).saturating_sub(1));
|
|
|
|
"Capture translation: ({:?}, {:?}) {:?}",
|
|
|
|
|
|
|
|
side,
|
|
|
|
|
|
|
|
score.captures(!*side).saturating_sub(1),
|
|
|
|
|
|
|
|
t.translation
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
t.translation =
|
|
|
|
|
|
|
|
capture_translation(side, score.captures(!*side).saturating_sub(1));
|
|
|
|
|
|
|
|
|
|
|
|
*state = s.next();
|
|
|
|
*state = s.next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1465,7 +1489,8 @@ fn capture_piece(
|
|
|
|
|
|
|
|
|
|
|
|
// Play fade-in animation
|
|
|
|
// Play fade-in animation
|
|
|
|
{
|
|
|
|
{
|
|
|
|
object_dissolve_materials.iter_many(kids.iter()).for_each(|(child, dis_handle, Backup(std_handle))| {
|
|
|
|
object_dissolve_materials.iter_many(kids.iter()).for_each(
|
|
|
|
|
|
|
|
|(child, dis_handle, Backup(std_handle))| {
|
|
|
|
let dissolve_material = dissolve_materials
|
|
|
|
let dissolve_material = dissolve_materials
|
|
|
|
.get_mut(dis_handle)
|
|
|
|
.get_mut(dis_handle)
|
|
|
|
.expect("Get the dissolve material");
|
|
|
|
.expect("Get the dissolve material");
|
|
|
|
@ -1488,7 +1513,8 @@ fn capture_piece(
|
|
|
|
.remove::<Handle<DissolveMaterial>>()
|
|
|
|
.remove::<Handle<DissolveMaterial>>()
|
|
|
|
.remove::<Backup<Handle<StandardMaterial>>>();
|
|
|
|
.remove::<Backup<Handle<StandardMaterial>>>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|