|
|
|
|
@ -79,7 +79,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
in_state(debug::DebugState::Enabled)
|
|
|
|
|
.and_then(on_event::<MouseMotion>())
|
|
|
|
|
.or_else(just_pressed(MouseButton::Left))
|
|
|
|
|
),
|
|
|
|
|
).before(select),
|
|
|
|
|
select
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(in_state(DisplayState::Display3d))
|
|
|
|
|
@ -639,7 +639,7 @@ fn update_pieces(
|
|
|
|
|
if animating > 0 {
|
|
|
|
|
info!("Piece {:?} is animating. Skipping...", entity);
|
|
|
|
|
} else {
|
|
|
|
|
info!("Checking piece object scene for {:?}", entity);
|
|
|
|
|
debug!("Checking piece object scene for {:?}", entity);
|
|
|
|
|
|
|
|
|
|
// Find name of this piece's model scene
|
|
|
|
|
let scene_tweak_name: Option<String> = match (piece, side) {
|
|
|
|
|
@ -655,10 +655,10 @@ fn update_pieces(
|
|
|
|
|
let scene_handle = models.named_scenes.get(&scene_tweak_name.unwrap()).unwrap();
|
|
|
|
|
|
|
|
|
|
// Set scene model for this piece
|
|
|
|
|
// if *scene != *scene_handle {
|
|
|
|
|
warn!("Updating scene for piece {:?}", entity);
|
|
|
|
|
*scene = scene_handle.clone();
|
|
|
|
|
// }
|
|
|
|
|
if *scene != *scene_handle {
|
|
|
|
|
warn!("Updating scene for piece {:?}", entity);
|
|
|
|
|
*scene = scene_handle.clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@ -688,7 +688,7 @@ fn select(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default, Resource)]
|
|
|
|
|
struct PiecePointer(Option<Entity>);
|
|
|
|
|
pub(crate) struct PiecePointer(pub Option<Entity>);
|
|
|
|
|
|
|
|
|
|
/// Select tiles and pieces in 3d
|
|
|
|
|
/// There is a bug where we are selecting multiple entities...
|
|
|
|
|
@ -840,13 +840,11 @@ fn pick_up(
|
|
|
|
|
children.iter_descendants(entity).for_each(|child| {
|
|
|
|
|
info!(" Child: {:?}", child);
|
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
|
info!("Picking up {:?} ({:?}) {:?}", name, entity, piece);
|
|
|
|
|
let pickup_animation = format!(
|
|
|
|
|
"display3d_models_animations_pick_up_{:?}_{}",
|
|
|
|
|
piece,
|
|
|
|
|
side.color_str()
|
|
|
|
|
)
|
|
|
|
|
.to_ascii_lowercase();
|
|
|
|
|
"display3d_models_animations_pick_up_{}",
|
|
|
|
|
name.as_str(),
|
|
|
|
|
);
|
|
|
|
|
info!("Picking up {:?} ({:?}) {:?} {:?}", name, entity, piece, pickup_animation);
|
|
|
|
|
let pickup_handle = gltf
|
|
|
|
|
.named_animations
|
|
|
|
|
.get(
|
|
|
|
|
@ -857,11 +855,9 @@ fn pick_up(
|
|
|
|
|
)
|
|
|
|
|
.expect("Pickup Animation");
|
|
|
|
|
let idle_animation = format!(
|
|
|
|
|
"display3d_models_animations_idle_{:?}_{}",
|
|
|
|
|
piece,
|
|
|
|
|
side.color_str()
|
|
|
|
|
)
|
|
|
|
|
.to_ascii_lowercase();
|
|
|
|
|
"display3d_models_animations_idle_{}",
|
|
|
|
|
name.as_str()
|
|
|
|
|
);
|
|
|
|
|
let idle_handle = gltf
|
|
|
|
|
.named_animations
|
|
|
|
|
.get(
|
|
|
|
|
@ -919,12 +915,7 @@ fn put_down(
|
|
|
|
|
children.iter_descendants(entity).for_each(|child| {
|
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
|
info!("Putting down {:?}", entity);
|
|
|
|
|
let putdown_animation = format!(
|
|
|
|
|
"display3d_models_animations_put_down_{:?}_{}",
|
|
|
|
|
piece,
|
|
|
|
|
side.color_str()
|
|
|
|
|
)
|
|
|
|
|
.to_ascii_lowercase();
|
|
|
|
|
let putdown_animation = format!("display3d_models_animations_put_down_{}", name.as_str());
|
|
|
|
|
let putdown_handle = gltf
|
|
|
|
|
.named_animations
|
|
|
|
|
.get(
|
|
|
|
|
@ -943,10 +934,18 @@ fn put_down(
|
|
|
|
|
Duration::from_secs_f32(0.75),
|
|
|
|
|
)
|
|
|
|
|
.set_repeat(RepeatAnimation::Never);
|
|
|
|
|
} else {
|
|
|
|
|
info!("Clip {:?}({:?}) not compatible with {:?}", putdown_animation, putdown_clip, name);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
info!("Clip not found");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
info!("Player not found");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
info!("Piece+Side not found for entity");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
@ -1200,7 +1199,7 @@ fn debug_textures(mut events: EventReader<AssetEvent<StandardMaterial>>) {
|
|
|
|
|
|
|
|
|
|
// Marker for entities which are currently animating
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
|
struct Animating;
|
|
|
|
|
pub(crate) struct Animating;
|
|
|
|
|
|
|
|
|
|
fn monitor_animations(
|
|
|
|
|
active: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, With<Animating>)>,
|
|
|
|
|
|