|
|
|
@ -86,10 +86,10 @@ impl Plugin for Display3dPlugin {
|
|
|
|
switch_sides
|
|
|
|
switch_sides
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(state_changed::<game::TurnState>)
|
|
|
|
.run_if(state_changed::<game::TurnState>)
|
|
|
|
.run_if(in_state(ai::PlayState::Human))
|
|
|
|
|
|
|
|
.run_if(any_component_added::<Selected>()
|
|
|
|
.run_if(any_component_added::<Selected>()
|
|
|
|
.or_else(any_component_removed::<Selected>())
|
|
|
|
.or_else(any_component_removed::<Selected>())
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
.run_if(should_switch_sides),
|
|
|
|
// Camera moving up when first piece is selected in the game
|
|
|
|
// Camera moving up when first piece is selected in the game
|
|
|
|
vantage_point
|
|
|
|
vantage_point
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
@ -426,11 +426,14 @@ fn hydrate_camera(
|
|
|
|
.get::<f32>("display3d_environment_map_light_intensity")
|
|
|
|
.get::<f32>("display3d_environment_map_light_intensity")
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let side = state.get().0;
|
|
|
|
|
|
|
|
|
|
|
|
debug!("Hydrating camera {:?}", entity);
|
|
|
|
debug!("Hydrating camera {:?}", entity);
|
|
|
|
// Populate the components for the camera
|
|
|
|
// Populate the components for the camera
|
|
|
|
commands.entity(entity).insert((
|
|
|
|
commands.entity(entity).insert((
|
|
|
|
DisplayState::Display3d,
|
|
|
|
DisplayState::Display3d,
|
|
|
|
Display3d,
|
|
|
|
Display3d,
|
|
|
|
|
|
|
|
side,
|
|
|
|
Camera3dBundle {
|
|
|
|
Camera3dBundle {
|
|
|
|
camera: Camera {
|
|
|
|
camera: Camera {
|
|
|
|
is_active: true,
|
|
|
|
is_active: true,
|
|
|
|
@ -996,8 +999,23 @@ fn set_animation_player_speed(
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn should_switch_sides(
|
|
|
|
|
|
|
|
query: Query<&Side, (With<Camera>, With<Display3d>)>,
|
|
|
|
|
|
|
|
state: Res<State<ai::PlayState>>,
|
|
|
|
|
|
|
|
) -> bool {
|
|
|
|
|
|
|
|
query.iter().all(|side| {
|
|
|
|
|
|
|
|
match state.get() {
|
|
|
|
|
|
|
|
ai::PlayState::AiBogo => match side {
|
|
|
|
|
|
|
|
Side::A => true,
|
|
|
|
|
|
|
|
Side::B => false,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ai::PlayState::Human => true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_sides(
|
|
|
|
fn switch_sides(
|
|
|
|
mut players: Query<&mut AnimationPlayer, (With<Camera>, With<Display3d>)>,
|
|
|
|
mut players: Query<(&mut AnimationPlayer, &mut Side), (With<Camera>, With<Display3d>)>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
state: Res<State<game::TurnState>>,
|
|
|
|
state: Res<State<game::TurnState>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
@ -1010,9 +1028,7 @@ fn switch_sides(
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
|
|
|
|
let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
|
|
|
|
players.iter_mut().for_each(|mut player| {
|
|
|
|
players.iter_mut().for_each(|(mut player, mut side)| {
|
|
|
|
debug!("Switching sides");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let animation_key = match state.get() {
|
|
|
|
let animation_key = match state.get() {
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_a",
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_a",
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_b",
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_b",
|
|
|
|
@ -1023,6 +1039,7 @@ fn switch_sides(
|
|
|
|
animation.clone(),
|
|
|
|
animation.clone(),
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
*side = state.get().0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|