@ -203,6 +203,7 @@ fn hydrate_camera(
let skybox_handle = tweak
let skybox_handle = tweak
. get_handle ::< Image > ( "display3d_models_skybox_file" )
. get_handle ::< Image > ( "display3d_models_skybox_file" )
. unwrap ( ) ;
. unwrap ( ) ;
info ! ( "Hydrating camera {:?}" , entity ) ;
// Populate the components for the camera
// Populate the components for the camera
commands . entity ( entity ) . insert ( (
commands . entity ( entity ) . insert ( (
Display3d ,
Display3d ,
@ -434,18 +435,6 @@ fn set_board_model(
. expect ( "Game board model" )
. expect ( "Game board model" )
. clone ( ) ;
. clone ( ) ;
} ) ;
} ) ;
// TODO: Get rid of this -- upstream asset has merged tiles back into gameboard scene
let assets_handle = tweak
. get_handle ::< Gltf > ( "display3d_models_assets_file" )
. unwrap ( ) ;
tiles . iter_mut ( ) . for_each ( | mut handle | {
let gltf = gltfs . get ( assets_handle . clone ( ) ) . expect ( "Load GLTF content" ) ;
* handle = gltf
. named_scenes
. get ( "Tiles" )
. expect ( "Game tiles model" )
. clone ( ) ;
} ) ;
}
}
/// Sets a piece location given it's board index
/// Sets a piece location given it's board index
@ -867,7 +856,8 @@ fn pick_up(
> ,
> ,
gltfs : Res < Assets < Gltf > > ,
gltfs : Res < Assets < Gltf > > ,
children : Query < & Children > ,
children : Query < & Children > ,
mut players : Query < & mut AnimationPlayer > ,
mut players : Query < ( & Name , & mut AnimationPlayer ) > ,
clips : Res < Assets < AnimationClip > > ,
tweaks : Res < Assets < Tweaks > > ,
tweaks : Res < Assets < Tweaks > > ,
tweaks_file : Res < tweak ::GameTweaks > ,
tweaks_file : Res < tweak ::GameTweaks > ,
) {
) {
@ -879,31 +869,40 @@ fn pick_up(
. 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" ) ;
info ! ( "Pickup animation for {:?}" , entity ) ;
children . iter_descendants ( entity ) . for_each ( | child | {
children . iter_descendants ( entity ) . for_each ( | child | {
if let Ok ( mut player ) = players . get_mut ( child ) {
info ! ( " Child: {:?}" , child ) ;
info ! ( "Picking up {:?} {:?}" , entity , piece ) ;
if let Ok ( ( name , mut player ) ) = players . get_mut ( child ) {
let animation = gltf . named_animations . get (
info ! ( "Picking up {:?} ({:?}) {:?}" , name , entity , piece ) ;
let pickup_handle = gltf . named_animations . get (
tweak
tweak
. get ::< String > ( "display3d_models_animations_pick_up ")
. get ::< String > ( "display3d_models_animations_pick_up _queen ")
. unwrap ( )
. unwrap ( )
. as_str ( ) ,
. as_str ( ) ,
) ;
) .expect ( "Pickup Animation" ) ;
let idle = gltf . named_animations . get (
let idle _handle = gltf . named_animations . get (
tweak
tweak
. get ::< String > ( "display3d_models_animations_idle ")
. get ::< String > ( "display3d_models_animations_idle _queen ")
. unwrap ( )
. unwrap ( )
. as_str ( ) ,
. as_str ( ) ,
) ;
) . expect ( "Idle animation" ) ;
player
if let Some ( pickup_clip ) = clips . get ( pickup_handle ) {
. start_with_transition (
info ! ( "Animation clip: {:#?}" , pickup_clip ) ;
animation . expect ( "Pickup Animation" ) . clone ( ) ,
if let Some ( idle_clip ) = clips . get ( idle_handle ) {
Duration ::from_secs_f32 ( 0.75 ) ,
if pickup_clip . compatible_with ( name ) & & idle_clip . compatible_with ( name ) {
)
player
. start_with_transition (
. start_with_transition (
idle . expect ( "Idle animation" ) . clone ( ) ,
pickup_handle . clone ( ) ,
Duration ::from_secs_f32 ( 1.5 ) ,
Duration ::from_secs_f32 ( 0.75 ) ,
)
)
. set_repeat ( RepeatAnimation ::Forever ) ;
. start_with_transition (
idle_handle . clone ( ) ,
Duration ::from_secs_f32 ( 1.5 ) ,
)
. set_repeat ( RepeatAnimation ::Forever ) ;
}
} ;
}
}
}
} )
} )
} ) ;
} ) ;
@ -914,7 +913,8 @@ fn put_down(
mut query : Query < & game ::Piece , ( With < game ::Piece > , With < game ::Selectable > , With < Display3d > ) > ,
mut query : Query < & game ::Piece , ( 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 < & mut AnimationPlayer > ,
mut players : Query < ( & Name , & mut AnimationPlayer ) > ,
clips : Res < Assets < AnimationClip > > ,
tweaks : Res < Assets < Tweaks > > ,
tweaks : Res < Assets < Tweaks > > ,
tweaks_file : Res < tweak ::GameTweaks > ,
tweaks_file : Res < tweak ::GameTweaks > ,
) {
) {
@ -922,26 +922,30 @@ 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) = 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 ( ) ;
let gltf = gltfs . get ( assets_handle ) . expect ( "Load GLTF content" ) ;
let gltf = gltfs . get ( assets_handle ) . expect ( "Load GLTF content" ) ;
children . iter_descendants ( entity ) . for_each ( | child | {
children . iter_descendants ( entity ) . for_each ( | child | {
if let Ok ( 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 animation = gltf . named_animations . get (
let putdown_handle = gltf . named_animations . get (
tweak
tweak
. get ::< String > ( "display3d_models_animations_put_down ")
. get ::< String > ( "display3d_models_animations_put_down _queen ")
. unwrap ( )
. unwrap ( )
. as_str ( ) ,
. as_str ( ) ,
) ;
) . expect ( "PutDown Animation" ) ;
player
if let Some ( putdown_clip ) = clips . get ( putdown_handle ) {
. start_with_transition (
if putdown_clip . compatible_with ( name ) {
animation . expect ( "PutDown Animation" ) . clone ( ) ,
player
Duration ::from_secs_f32 ( 0.75 ) ,
. start_with_transition (
)
putdown_handle . clone ( ) ,
. set_repeat ( RepeatAnimation ::Never ) ;
Duration ::from_secs_f32 ( 0.75 ) ,
)
. set_repeat ( RepeatAnimation ::Never ) ;
}
}
}
}
} )
} )
}
}