|
|
|
@ -30,12 +30,13 @@ 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>),
|
|
|
|
set_piece_model
|
|
|
|
update_pieces.run_if(
|
|
|
|
.run_if(any_component_added::<Piece>().or_else(any_component_changed::<Piece>())),
|
|
|
|
resource_exists::<tweak::GameTweaks>.and_then(
|
|
|
|
set_piece_texture
|
|
|
|
any_component_changed::<Piece>()
|
|
|
|
.run_if(any_component_changed::<Side>().or_else(any_component_added::<Side>()))
|
|
|
|
.or_else(any_component_changed::<Side>())
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
.or_else(any_component_changed::<BoardIndex>())
|
|
|
|
set_piece_position.run_if(any_component_changed::<BoardIndex>()),
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
set_board_model.run_if(
|
|
|
|
set_board_model.run_if(
|
|
|
|
any_component_added::<game::BoardComponent>()
|
|
|
|
any_component_added::<game::BoardComponent>()
|
|
|
|
.or_else(any_component_added::<TilesComponent>())
|
|
|
|
.or_else(any_component_added::<TilesComponent>())
|
|
|
|
@ -79,7 +80,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
OnEnter(GameState::Play),
|
|
|
|
OnEnter(GameState::Play),
|
|
|
|
(
|
|
|
|
(
|
|
|
|
set_piece_texture.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
update_pieces.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
|
|
|
|
opening_animation
|
|
|
|
opening_animation
|
|
|
|
.run_if(run_once())
|
|
|
|
.run_if(run_once())
|
|
|
|
@ -381,51 +382,6 @@ fn fix_skybox(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the model for each piece based on the game::Piece::* marker
|
|
|
|
|
|
|
|
fn set_piece_model(
|
|
|
|
|
|
|
|
mut events: Query<
|
|
|
|
|
|
|
|
(&mut Handle<Scene>, &Piece),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
Or<(Added<game::Piece>, Changed<game::Piece>)>,
|
|
|
|
|
|
|
|
With<Display3d>,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
>,
|
|
|
|
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
events.iter_mut().for_each(|(mut handle, piece)| {
|
|
|
|
|
|
|
|
let assets_handle = tweak
|
|
|
|
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
|
|
|
|
|
|
|
|
*handle = match piece {
|
|
|
|
|
|
|
|
game::Piece::Pawn => gltf.named_scenes.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_scenes_pawn")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
game::Piece::Drone => gltf.named_scenes.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_scenes_drone")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
game::Piece::Queen => gltf.named_scenes.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_scenes_queen")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.expect("Game board model")
|
|
|
|
|
|
|
|
.clone();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn set_board_model(
|
|
|
|
fn set_board_model(
|
|
|
|
mut boards: Query<
|
|
|
|
mut boards: Query<
|
|
|
|
@ -461,18 +417,6 @@ fn set_board_model(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets a piece location given it's board index
|
|
|
|
|
|
|
|
fn set_piece_position(
|
|
|
|
|
|
|
|
mut events: Query<
|
|
|
|
|
|
|
|
(&mut Transform, &BoardIndex),
|
|
|
|
|
|
|
|
(With<game::Piece>, With<Display3d>, Changed<BoardIndex>),
|
|
|
|
|
|
|
|
>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
events.iter_mut().for_each(|(mut t, i)| {
|
|
|
|
|
|
|
|
t.translation = board_translation(i);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Given a board index returns the Vec3 location in space
|
|
|
|
/// Given a board index returns the Vec3 location in space
|
|
|
|
fn board_translation(&BoardIndex { x, y }: &BoardIndex) -> Vec3 {
|
|
|
|
fn board_translation(&BoardIndex { x, y }: &BoardIndex) -> Vec3 {
|
|
|
|
// Scale x down by 4 to account for -4..4 scaling
|
|
|
|
// Scale x down by 4 to account for -4..4 scaling
|
|
|
|
@ -550,184 +494,58 @@ fn mouse_zoom(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the Texture for a piece given it's position (left or right) on the bord.
|
|
|
|
// The dumbest way to achieve this goal
|
|
|
|
/// Executed when Side is changed or upon entry to Display3d state
|
|
|
|
// Essentially we iterate over every piece and set the appropriate model and texture
|
|
|
|
/// Getting this to run _after_ GLTF is loaded is a pain.
|
|
|
|
fn update_pieces(
|
|
|
|
/// PERF: We are saving what to work on in a Vector which is bad.
|
|
|
|
mut query: Query<(Entity, &Piece, &Side, &BoardIndex, &mut Transform, &mut Handle<Scene>, &AnimationPlayer)>,
|
|
|
|
/// CAVEAT: We are only exeucting this when a piece changes or state is changed.
|
|
|
|
|
|
|
|
fn set_piece_texture(
|
|
|
|
|
|
|
|
query: Query<
|
|
|
|
|
|
|
|
(Entity, &Piece, &Side),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
With<game::Piece>,
|
|
|
|
|
|
|
|
With<Display3d>,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
>,
|
|
|
|
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
|
|
|
|
mut models: Query<(&Name, &mut Handle<StandardMaterial>)>,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
query.iter().for_each(|(entity, piece, side)| {
|
|
|
|
let tweak = tweaks
|
|
|
|
debug!("Checking piece texture for {:?}", entity);
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
let tweak = tweaks.get(tweaks_file.handle.clone()).unwrap();
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
let assets_handle = tweak
|
|
|
|
let assets_handle = tweak
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
if let Some(gltf) = gltfs.get(assets_handle) {
|
|
|
|
let models = gltfs.get(assets_handle).unwrap();
|
|
|
|
// Why can't we just models.iter_many_mut(...).for_each(...)??
|
|
|
|
|
|
|
|
let mut stuff = models.iter_many_mut(children.iter_descendants(entity));
|
|
|
|
query.iter_mut().for_each(|(entity, piece, side, board_index, mut transform, mut scene, animation_player)| {
|
|
|
|
while let Some((n, mut m)) = stuff.fetch_next() {
|
|
|
|
// Set position of piece
|
|
|
|
debug!("Setting piece texture for {:?}", n);
|
|
|
|
let new_translation = board_translation(board_index);
|
|
|
|
match (*piece, side, n.as_str()) {
|
|
|
|
if transform.translation != new_translation {
|
|
|
|
(Piece::Queen, Side::A, "Queen.0") => {
|
|
|
|
transform.translation = new_translation;
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_queen_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Queen texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Queen, Side::A, "Queen.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_dots_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Queen, Side::B, "Queen.0") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_queen_blue")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Blue Queen texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Queen, Side::B, "Queen.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_dots_blue")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Drone, Side::A, "Drone.0") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_drone_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Drone texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Drone, Side::A, "Drone.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_dots_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Drone, Side::B, "Drone.0") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_drone_blue")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Blue Drone texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Drone, Side::B, "Drone.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_dots_blue")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Blue Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Pawn, Side::A, "Pawn.0") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_pawn_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Pawn texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Pawn, Side::A, "Pawn.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_dots_red")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Red Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Pawn, Side::B, "Pawn.0") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
|
|
|
|
.named_materials
|
|
|
|
|
|
|
|
.get(
|
|
|
|
|
|
|
|
tweak
|
|
|
|
|
|
|
|
.get::<String>("display3d_models_materials_pawn_blue")
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.as_str(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Blue Pawn texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(Piece::Pawn, Side::B, "Pawn.1") => {
|
|
|
|
|
|
|
|
*m = gltf
|
|
|
|
// Find name of this piece's model scene
|
|
|
|
.named_materials
|
|
|
|
let scene_tweak_name: Option<String> = match (piece, side) {
|
|
|
|
.get(
|
|
|
|
(Piece::Pawn, Side::A) => {
|
|
|
|
tweak
|
|
|
|
tweak.get("display3d_models_scenes_pawn_red")
|
|
|
|
.get::<String>("display3d_models_materials_dots_blue")
|
|
|
|
},
|
|
|
|
.unwrap()
|
|
|
|
(Piece::Pawn, Side::B) => {
|
|
|
|
.as_str(),
|
|
|
|
tweak.get("display3d_models_scenes_pawn_blue")
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("Load Blue Dots texture")
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => warn!("???"),
|
|
|
|
(Piece::Drone, Side::A) => {
|
|
|
|
|
|
|
|
tweak.get("display3d_models_scenes_drone_red")
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
(Piece::Drone, Side::B) => {
|
|
|
|
|
|
|
|
tweak.get("display3d_models_scenes_drone_blue")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(Piece::Queen, Side::A) => {
|
|
|
|
|
|
|
|
tweak.get("display3d_models_scenes_queen_red")
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
(Piece::Queen, Side::B) => {
|
|
|
|
|
|
|
|
tweak.get("display3d_models_scenes_queen_blue")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get model scene for this piece
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -854,13 +672,9 @@ fn set_valid_move_model(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn _play_valid_move_animation(_players: Query<&AnimationPlayer>) {
|
|
|
|
|
|
|
|
todo!();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn pick_up(
|
|
|
|
fn pick_up(
|
|
|
|
mut events: Query<
|
|
|
|
mut events: Query<
|
|
|
|
(Entity, &game::Piece),
|
|
|
|
(Entity, &game::Piece, &game::Side),
|
|
|
|
(With<game::Piece>, With<Display3d>, Added<game::Selected>),
|
|
|
|
(With<game::Piece>, With<Display3d>, Added<game::Selected>),
|
|
|
|
>,
|
|
|
|
>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
@ -873,7 +687,7 @@ fn pick_up(
|
|
|
|
let tweak = tweaks
|
|
|
|
let tweak = tweaks
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
events.iter_mut().for_each(|(entity, piece)| {
|
|
|
|
events.iter_mut().for_each(|(entity, piece, side)| {
|
|
|
|
let assets_handle = tweak
|
|
|
|
let assets_handle = tweak
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
@ -884,7 +698,7 @@ fn pick_up(
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
info!("Picking up {:?} ({:?}) {:?}", name, entity, piece);
|
|
|
|
info!("Picking up {:?} ({:?}) {:?}", name, entity, piece);
|
|
|
|
let pickup_animation =
|
|
|
|
let pickup_animation =
|
|
|
|
format!("display3d_models_animations_pick_up_{:?}", piece).to_ascii_lowercase();
|
|
|
|
format!("display3d_models_animations_pick_up_{:?}_{}", piece, side.color_str()).to_ascii_lowercase();
|
|
|
|
let pickup_handle = gltf
|
|
|
|
let pickup_handle = gltf
|
|
|
|
.named_animations
|
|
|
|
.named_animations
|
|
|
|
.get(
|
|
|
|
.get(
|
|
|
|
@ -895,7 +709,7 @@ fn pick_up(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.expect("Pickup Animation");
|
|
|
|
.expect("Pickup Animation");
|
|
|
|
let idle_animation =
|
|
|
|
let idle_animation =
|
|
|
|
format!("display3d_models_animations_idle_{:?}", piece).to_ascii_lowercase();
|
|
|
|
format!("display3d_models_animations_idle_{:?}_{}", piece, side.color_str()).to_ascii_lowercase();
|
|
|
|
let idle_handle = gltf
|
|
|
|
let idle_handle = gltf
|
|
|
|
.named_animations
|
|
|
|
.named_animations
|
|
|
|
.get(
|
|
|
|
.get(
|
|
|
|
@ -928,7 +742,7 @@ fn pick_up(
|
|
|
|
|
|
|
|
|
|
|
|
fn put_down(
|
|
|
|
fn put_down(
|
|
|
|
mut events: RemovedComponents<game::Selected>,
|
|
|
|
mut events: RemovedComponents<game::Selected>,
|
|
|
|
mut query: Query<&game::Piece, (With<game::Piece>, With<game::Selectable>, With<Display3d>)>,
|
|
|
|
mut query: Query<(&game::Piece, &game::Side), (With<game::Piece>, With<game::Selectable>, With<Display3d>)>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
mut players: Query<(&Name, &mut AnimationPlayer)>,
|
|
|
|
mut players: Query<(&Name, &mut AnimationPlayer)>,
|
|
|
|
@ -940,7 +754,7 @@ fn put_down(
|
|
|
|
.get(&tweaks_file.handle.clone())
|
|
|
|
.get(&tweaks_file.handle.clone())
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
events.read().for_each(|entity| {
|
|
|
|
events.read().for_each(|entity| {
|
|
|
|
if let Ok(piece) = query.get_mut(entity) {
|
|
|
|
if let Ok((piece, side)) = query.get_mut(entity) {
|
|
|
|
let assets_handle = tweak
|
|
|
|
let assets_handle = tweak
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.get_handle::<Gltf>("display3d_models_assets_file")
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
@ -949,7 +763,7 @@ fn put_down(
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
if let Ok((name, mut player)) = players.get_mut(child) {
|
|
|
|
info!("Putting down {:?}", entity);
|
|
|
|
info!("Putting down {:?}", entity);
|
|
|
|
let putdown_animation =
|
|
|
|
let putdown_animation =
|
|
|
|
format!("display3d_models_animations_put_down_{:?}", piece)
|
|
|
|
format!("display3d_models_animations_put_down_{:?}_{}", piece, side.color_str())
|
|
|
|
.to_ascii_lowercase();
|
|
|
|
.to_ascii_lowercase();
|
|
|
|
let putdown_handle = gltf
|
|
|
|
let putdown_handle = gltf
|
|
|
|
.named_animations
|
|
|
|
.named_animations
|
|
|
|
@ -962,6 +776,7 @@ fn put_down(
|
|
|
|
.expect("PutDown Animation");
|
|
|
|
.expect("PutDown Animation");
|
|
|
|
if let Some(putdown_clip) = clips.get(putdown_handle) {
|
|
|
|
if let Some(putdown_clip) = clips.get(putdown_handle) {
|
|
|
|
if putdown_clip.compatible_with(name) {
|
|
|
|
if putdown_clip.compatible_with(name) {
|
|
|
|
|
|
|
|
info!("Compatible with both clips!");
|
|
|
|
player
|
|
|
|
player
|
|
|
|
.start_with_transition(
|
|
|
|
.start_with_transition(
|
|
|
|
putdown_handle.clone(),
|
|
|
|
putdown_handle.clone(),
|
|
|
|
|