|
|
|
@ -39,15 +39,15 @@ 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>),
|
|
|
|
update_pieces.run_if(
|
|
|
|
update_pieces
|
|
|
|
resource_exists::<tweak::GameTweaks>.and_then(
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>)
|
|
|
|
|
|
|
|
.run_if(
|
|
|
|
any_component_changed::<Piece>()
|
|
|
|
any_component_changed::<Piece>()
|
|
|
|
.or_else(any_component_changed::<Side>())
|
|
|
|
.or_else(any_component_changed::<Side>())
|
|
|
|
.or_else(any_component_changed::<BoardIndex>())
|
|
|
|
.or_else(any_component_changed::<BoardIndex>())
|
|
|
|
.or_else(any_component_removed::<Animating>())
|
|
|
|
.or_else(any_component_removed::<Animating>())
|
|
|
|
.or_else(any_component_removed::<Captured>()),
|
|
|
|
.or_else(any_component_removed::<Captured>()),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
set_board_model.run_if(any_component_added::<game::BoardComponent>()),
|
|
|
|
set_board_model.run_if(any_component_added::<game::BoardComponent>()),
|
|
|
|
set_title_model.run_if(any_component_added::<TitleText>()),
|
|
|
|
set_title_model.run_if(any_component_added::<TitleText>()),
|
|
|
|
set_valid_move_model.run_if(any_component_added::<game::ValidMove>()),
|
|
|
|
set_valid_move_model.run_if(any_component_added::<game::ValidMove>()),
|
|
|
|
@ -65,14 +65,11 @@ impl Plugin for Display3dPlugin {
|
|
|
|
dissolve_animation.run_if(any_with_component::<Dissolving>),
|
|
|
|
dissolve_animation.run_if(any_with_component::<Dissolving>),
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>),
|
|
|
|
capture_piece.run_if(any_with_component::<game::Captured>),
|
|
|
|
skip_animation
|
|
|
|
skip_animation
|
|
|
|
.run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left)))
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(in_state(GameState::Play)),
|
|
|
|
.run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left))),
|
|
|
|
monitor_animations.run_if(in_state(GameState::Play)),
|
|
|
|
monitor_animations
|
|
|
|
debug_lights
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
.run_if(any_component_added::<SpotLight>()
|
|
|
|
.run_if(any_component_changed::<AnimationPlayer>()),
|
|
|
|
.or_else(any_component_added::<DirectionalLight>())
|
|
|
|
|
|
|
|
.or_else(any_component_added::<PointLight>())
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -94,6 +91,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
(
|
|
|
|
(
|
|
|
|
// Toggle hidden/visible 3d entities
|
|
|
|
// Toggle hidden/visible 3d entities
|
|
|
|
manage_state_entities::<DisplayState>(),
|
|
|
|
manage_state_entities::<DisplayState>(),
|
|
|
|
|
|
|
|
fixup_shadows,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -104,9 +102,13 @@ impl Plugin for Display3dPlugin {
|
|
|
|
opening_animation
|
|
|
|
opening_animation
|
|
|
|
.run_if(run_once())
|
|
|
|
.run_if(run_once())
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
.run_if(in_state(DisplayState::Display3d)),
|
|
|
|
|
|
|
|
fixup_shadows.after(update_pieces),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(OnEnter(GameState::Title), intro_title_dissolve)
|
|
|
|
.add_systems(OnEnter(GameState::Title), (
|
|
|
|
|
|
|
|
intro_title_dissolve,
|
|
|
|
|
|
|
|
fixup_shadows,
|
|
|
|
|
|
|
|
))
|
|
|
|
.add_systems(OnExit(GameState::Title), outro_title_dissolve)
|
|
|
|
.add_systems(OnExit(GameState::Title), outro_title_dissolve)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
@ -377,7 +379,6 @@ fn update_tweaks(
|
|
|
|
mut camera_settings: Query<(Entity, &mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
|
|
|
|
mut camera_settings: Query<(Entity, &mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if let Some(tweak) = tweaks.get(tweaks_file.handle.clone()) {
|
|
|
|
if let Some(tweak) = tweaks.get(tweaks_file.handle.clone()) {
|
|
|
|
warn!("Updating tweaks!");
|
|
|
|
warn!("Updating tweaks!");
|
|
|
|
@ -593,9 +594,9 @@ fn update_pieces(
|
|
|
|
.count();
|
|
|
|
.count();
|
|
|
|
|
|
|
|
|
|
|
|
if animating > 0 {
|
|
|
|
if animating > 0 {
|
|
|
|
debug!("Piece {:?} is animating. Skipping...", entity);
|
|
|
|
info!("Piece {:?} is animating. Skipping...", entity);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
debug!("Checking piece object scene for {:?}", entity);
|
|
|
|
info!("Checking piece object scene for {:?}", entity);
|
|
|
|
|
|
|
|
|
|
|
|
// Find name of this piece's model scene
|
|
|
|
// Find name of this piece's model scene
|
|
|
|
let scene_tweak_name: Option<String> = match (piece, side) {
|
|
|
|
let scene_tweak_name: Option<String> = match (piece, side) {
|
|
|
|
@ -611,10 +612,10 @@ fn update_pieces(
|
|
|
|
let scene_handle = models.named_scenes.get(&scene_tweak_name.unwrap()).unwrap();
|
|
|
|
let scene_handle = models.named_scenes.get(&scene_tweak_name.unwrap()).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// Set scene model for this piece
|
|
|
|
// Set scene model for this piece
|
|
|
|
if *scene != *scene_handle {
|
|
|
|
// if *scene != *scene_handle {
|
|
|
|
warn!("Updating scene for piece {:?}", entity);
|
|
|
|
warn!("Updating scene for piece {:?}", entity);
|
|
|
|
*scene = scene_handle.clone();
|
|
|
|
*scene = scene_handle.clone();
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -1162,8 +1163,8 @@ fn monitor_animations(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Set inactive entities to active
|
|
|
|
// Set inactive entities to active
|
|
|
|
inactive.iter().for_each(|(entity, player)| {
|
|
|
|
inactive.iter().for_each(|(entity, player)| {
|
|
|
|
if !player.is_finished() {
|
|
|
|
if !player.is_finished() && *player.animation_clip() != Handle::<AnimationClip>::default() {
|
|
|
|
info!("Entity {:?} is playing, adding animating marker", entity);
|
|
|
|
info!("Entity {:?} is playing {:?}, adding animating marker", entity, player.animation_clip());
|
|
|
|
commands.entity(entity).insert(Animating);
|
|
|
|
commands.entity(entity).insert(Animating);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -1256,11 +1257,12 @@ fn dissolve_animation(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn debug_lights(
|
|
|
|
fn fixup_shadows(
|
|
|
|
mut spot_lights: Query<&mut SpotLight, Added<SpotLight>>,
|
|
|
|
mut spot_lights: Query<&mut SpotLight>,
|
|
|
|
mut point_lights: Query<&mut PointLight, Added<PointLight>>,
|
|
|
|
mut point_lights: Query<&mut PointLight>,
|
|
|
|
mut directional_lights: Query<&mut DirectionalLight, Added<DirectionalLight>>,
|
|
|
|
mut directional_lights: Query<&mut DirectionalLight>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
info!("Fixing up shadows");
|
|
|
|
spot_lights.iter_mut().for_each(|mut l| {
|
|
|
|
spot_lights.iter_mut().for_each(|mut l| {
|
|
|
|
l.shadows_enabled = true;
|
|
|
|
l.shadows_enabled = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|