From d3d46a7788242acfcd5df6c29dcb3b19d406bdb1 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Wed, 22 Nov 2023 16:28:39 -0800 Subject: [PATCH] Got tiles working --- assets/audio/martian.audio.tweak | 2 +- src/display3d.rs | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/assets/audio/martian.audio.tweak b/assets/audio/martian.audio.tweak index 729fd3d..d91f944 100644 --- a/assets/audio/martian.audio.tweak +++ b/assets/audio/martian.audio.tweak @@ -9,7 +9,7 @@ idle = "/SFX/3D/3DPickup-Idle-PutdownWhirr" invalid = "/sfx/3D/3DInvalidMove" [music] -main = "/Music/Main Track Opt2" +main = "/Music/Main Track2" [menu] select = "/SFX/MenuSelect" \ No newline at end of file diff --git a/src/display3d.rs b/src/display3d.rs index c8d2e68..2a0a221 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -27,6 +27,7 @@ impl Plugin for Display3dPlugin { hydrate_camera.run_if(any_component_added::), set_piece_model.run_if(any_component_added::), set_board_model.run_if(any_component_added::), + set_board_model.run_if(any_component_added::), set_tile_hitbox.run_if(any_component_added::), set_piece_position.run_if(any_component_changed::), set_piece_texture.run_if(any_component_changed::), @@ -81,6 +82,9 @@ impl Plugin for Display3dPlugin { #[derive(Debug, Component)] pub(crate) struct Display3d; +#[derive(Debug, Component)] +struct TilesComponent; + #[derive(Debug, Resource)] struct AssetsMap { models: Handle, @@ -130,6 +134,9 @@ fn initialize(mut commands: Commands, board: Res, assets: Res, (With, With)>, + mut boards: Query<&mut Handle, (With, Without, With)>, + mut tiles: Query<&mut Handle, (With, Without, With)>, assets_map: Res, gltfs: Res>, ) { - events.iter_mut().for_each(|mut handle| { + boards.iter_mut().for_each(|mut handle| { let gltf = gltfs.get(&assets_map.models).expect("Load GLTF content"); *handle = gltf .named_scenes .get("Gameboard") .expect("Game board model") .clone(); - }) + }); + tiles.iter_mut().for_each(|mut handle| { + let gltf = gltfs.get(&assets_map.models).expect("Load GLTF content"); + *handle = gltf + .named_scenes + .get("Tiles") + .expect("Game tiles model") + .clone(); + }); } /// Sets a piece location given it's board index