|
|
|
|
@ -86,6 +86,12 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
switch_sides
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(state_changed::<game::TurnState>),
|
|
|
|
|
vantage_point
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(not(state_changed::<game::TurnState>))
|
|
|
|
|
.run_if(any_component_added::<Selected>()
|
|
|
|
|
.or_else(any_component_removed::<Selected>())
|
|
|
|
|
),
|
|
|
|
|
update_pieces
|
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
@ -1006,13 +1012,56 @@ fn switch_sides(
|
|
|
|
|
debug!("Switching sides");
|
|
|
|
|
|
|
|
|
|
let animation_key = match state.get() {
|
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_a_sight",
|
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_b_sight",
|
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_a",
|
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_b",
|
|
|
|
|
};
|
|
|
|
|
let animation_val = tweak.get::<String>(animation_key).unwrap();
|
|
|
|
|
let animation = gltf.named_animations.get(animation_val.as_str()).expect("Camera Transition Animation");
|
|
|
|
|
player.start_with_transition(
|
|
|
|
|
animation.clone(),
|
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn vantage_point(
|
|
|
|
|
selected: Query<Entity, With<Selected>>,
|
|
|
|
|
mut players: Query<&mut AnimationPlayer, (With<Camera>, With<Display3d>)>,
|
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
|
state: Res<State<game::TurnState>>,
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
) {
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
let assets_handle = tweak
|
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
|
.unwrap();
|
|
|
|
|
let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
|
|
|
|
|
players.iter_mut().for_each(|mut player| {
|
|
|
|
|
info!("Getting a better view");
|
|
|
|
|
|
|
|
|
|
let animation_key = match state.get() {
|
|
|
|
|
game::TurnState(game::Side::A) => {
|
|
|
|
|
if selected.iter().count() == 1 {
|
|
|
|
|
"display3d_models_animations_turn_up_a"
|
|
|
|
|
} else {
|
|
|
|
|
"display3d_models_animations_turn_down_a"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
game::TurnState(game::Side::B) => {
|
|
|
|
|
if selected.iter().count() == 1 {
|
|
|
|
|
"display3d_models_animations_turn_up_b"
|
|
|
|
|
} else {
|
|
|
|
|
"display3d_models_animations_turn_down_b"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let animation_val = tweak.get::<String>(animation_key).unwrap();
|
|
|
|
|
let animation = gltf.named_animations.get(animation_val.as_str());
|
|
|
|
|
let animation = gltf.named_animations.get(animation_val.as_str()).expect("Camera Transition Animation");
|
|
|
|
|
player.start_with_transition(
|
|
|
|
|
animation.expect("Camera Transition Animation").clone(),
|
|
|
|
|
animation.clone(),
|
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|