|
|
|
|
@ -237,12 +237,12 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
|
|
|
|
|
parent.spawn((
|
|
|
|
|
DisplayState::Display3d,
|
|
|
|
|
Display3d,
|
|
|
|
|
GameState::Title,
|
|
|
|
|
// GameState::Title,
|
|
|
|
|
SceneBundle { ..default() },
|
|
|
|
|
TitleText,
|
|
|
|
|
Dissolvable {
|
|
|
|
|
start: 1.0,
|
|
|
|
|
duration: 3.0,
|
|
|
|
|
start: 0.0,
|
|
|
|
|
duration: 6.0,
|
|
|
|
|
}, // Marks title text as dissolving
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
@ -1196,7 +1196,7 @@ fn setup_dissolve_materials(
|
|
|
|
|
Added<Handle<StandardMaterial>>,
|
|
|
|
|
>,
|
|
|
|
|
// Only process newly created pieces (we do not delete pieces at runtime)
|
|
|
|
|
query: Query<Entity, (With<Dissolvable>, Added<Children>)>,
|
|
|
|
|
query: Query<&Dissolvable, Added<Children>>,
|
|
|
|
|
// Children of pieces are the actual meshes that need materials
|
|
|
|
|
parents: Query<&Parent>,
|
|
|
|
|
// Used to create DissolveMaterial
|
|
|
|
|
@ -1214,8 +1214,16 @@ fn setup_dissolve_materials(
|
|
|
|
|
.for_each(|(child, std_handle, name)| {
|
|
|
|
|
info!("Setting up dissolve material for {:?} {:?}", name, child);
|
|
|
|
|
|
|
|
|
|
// Get dissolvable data for percentage start
|
|
|
|
|
let dissolvable = query
|
|
|
|
|
.iter_many(parents.iter_ancestors(child))
|
|
|
|
|
.next()
|
|
|
|
|
.expect("Dissolving data");
|
|
|
|
|
|
|
|
|
|
// Extension we will add to existing gltf-sourced materials
|
|
|
|
|
let extension = DissolveExtension { percentage: 1.0 };
|
|
|
|
|
let extension = DissolveExtension {
|
|
|
|
|
percentage: dissolvable.start,
|
|
|
|
|
};
|
|
|
|
|
// Base material we will extend for the duration of the dissolve effect
|
|
|
|
|
let mut base: StandardMaterial = standard_materials
|
|
|
|
|
.get(std_handle)
|
|
|
|
|
@ -1242,8 +1250,11 @@ fn setup_dissolve_materials(
|
|
|
|
|
/// 3. Play the same "captured" animation in reverse
|
|
|
|
|
/// The animation is like a 'beam me up scotty' sorta thing.
|
|
|
|
|
fn capture_piece(
|
|
|
|
|
events: Query<Entity, (With<Display3d>, Added<game::Captured>)>,
|
|
|
|
|
mut query: Query<(&mut Transform, &Side), (With<Display3d>, With<game::Captured>)>,
|
|
|
|
|
events: Query<(Entity, &Dissolvable), (With<Display3d>, Added<game::Captured>)>,
|
|
|
|
|
mut query: Query<
|
|
|
|
|
(&mut Transform, &Side, &Dissolvable),
|
|
|
|
|
(With<Display3d>, With<game::Captured>),
|
|
|
|
|
>,
|
|
|
|
|
dissolving: Query<Entity, With<Dissolving>>,
|
|
|
|
|
mut state: Local<Option<game::CaptureFlow>>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
@ -1252,9 +1263,11 @@ fn capture_piece(
|
|
|
|
|
match *state {
|
|
|
|
|
// State is None, so we need to initiate the animation
|
|
|
|
|
None => {
|
|
|
|
|
*state = events.iter().next().map(|entity| {
|
|
|
|
|
*state = events.iter().next().map(|(entity, dissolvable)| {
|
|
|
|
|
// Insert the "Dissolving::Out" tag on the entity we want to fade out
|
|
|
|
|
commands.entity(entity).insert(Dissolving::Out(3.0));
|
|
|
|
|
commands
|
|
|
|
|
.entity(entity)
|
|
|
|
|
.insert(Dissolving::Out(dissolvable.duration));
|
|
|
|
|
|
|
|
|
|
// Set the next state to start fading out
|
|
|
|
|
game::CaptureFlow::FadeOut(entity)
|
|
|
|
|
@ -1273,7 +1286,7 @@ fn capture_piece(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
game::CaptureFlow::Store(entity) => {
|
|
|
|
|
let (mut t, side) = query
|
|
|
|
|
let (mut t, side, dissolvable) = query
|
|
|
|
|
.get_mut(entity)
|
|
|
|
|
.expect("Visibility and Transform of captured piece");
|
|
|
|
|
|
|
|
|
|
@ -1287,7 +1300,9 @@ fn capture_piece(
|
|
|
|
|
t.translation =
|
|
|
|
|
capture_translation(side, score.captures(!*side).saturating_sub(1));
|
|
|
|
|
|
|
|
|
|
commands.entity(entity).insert(Dissolving::In(3.0));
|
|
|
|
|
commands
|
|
|
|
|
.entity(entity)
|
|
|
|
|
.insert(Dissolving::In(dissolvable.duration));
|
|
|
|
|
|
|
|
|
|
*state = s.next();
|
|
|
|
|
}
|
|
|
|
|
@ -1351,15 +1366,25 @@ fn monitor_animations(
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn intro_title_dissolve(mut query: Query<Entity, With<TitleText>>, mut commands: Commands) {
|
|
|
|
|
query.iter_mut().for_each(|entity| {
|
|
|
|
|
commands.entity(entity).insert(Dissolving::In(3.0));
|
|
|
|
|
fn intro_title_dissolve(
|
|
|
|
|
mut query: Query<(Entity, &Dissolvable), With<TitleText>>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
query.iter_mut().for_each(|(entity, dissolving)| {
|
|
|
|
|
commands
|
|
|
|
|
.entity(entity)
|
|
|
|
|
.insert(Dissolving::In(dissolving.duration));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn outro_title_dissolve(mut query: Query<Entity, With<TitleText>>, mut commands: Commands) {
|
|
|
|
|
query.iter_mut().for_each(|entity| {
|
|
|
|
|
commands.entity(entity).insert(Dissolving::Out(3.0));
|
|
|
|
|
fn outro_title_dissolve(
|
|
|
|
|
mut query: Query<(Entity, &Dissolvable), With<TitleText>>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
query.iter_mut().for_each(|(entity, dissolving)| {
|
|
|
|
|
commands
|
|
|
|
|
.entity(entity)
|
|
|
|
|
.insert(Dissolving::Out(dissolving.duration));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|