diff --git a/Cargo.lock b/Cargo.lock index 8f1ca065..8b78db59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,6 +123,27 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alsa" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37fe60779335388a88c01ac6c3be40304d1e349de3ada3b15f7808bb90fa9dce" +dependencies = [ + "alsa-sys", + "bitflags 2.6.0", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "android-activity" version = "0.6.0" @@ -137,7 +158,7 @@ dependencies = [ "jni-sys", "libc", "log", - "ndk", + "ndk 0.9.0", "ndk-context", "ndk-sys 0.6.0+11769913", "num_enum", @@ -360,6 +381,12 @@ version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" +[[package]] +name = "atomic-arena" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5450eca8ce5abcfd5520727e975ebab30ccca96030550406b0ca718b224ead10" + [[package]] name = "atomic-waker" version = "1.1.2" @@ -826,6 +853,20 @@ dependencies = [ "bevy_winit", ] +[[package]] +name = "bevy_kira_audio" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180a9cb47545ec53a9bb0b4b2fc79af325f86334c7370722fceea90c765af5d9" +dependencies = [ + "anyhow", + "bevy", + "kira", + "parking_lot", + "thiserror", + "uuid", +] + [[package]] name = "bevy_log" version = "0.14.0" @@ -860,7 +901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51bd6ce2174d3237d30e0ab5b2508480cc7593ca4d96ffb3a3095f9fc6bbc34c" dependencies = [ "bevy_reflect", - "glam", + "glam 0.27.0", "rand", "serde", "smallvec", @@ -873,7 +914,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7ce4266293629a2d10459cc112dffe3b3e9229a4f2b8a4d20061b8dd53316d0" dependencies = [ - "glam", + "glam 0.27.0", ] [[package]] @@ -928,7 +969,7 @@ dependencies = [ "bevy_utils", "downcast-rs", "erased-serde", - "glam", + "glam 0.27.0", "serde", "smallvec", "smol_str", @@ -1264,6 +1305,26 @@ dependencies = [ "winit", ] +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.69", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -1449,6 +1510,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-expr" version = "0.15.8" @@ -1490,6 +1560,17 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading 0.8.4", +] + [[package]] name = "clap" version = "4.5.8" @@ -1796,6 +1877,49 @@ dependencies = [ "libc", ] +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f01585027057ff5f0a5bf276174ae4c1594a2c5bde93d5f46a016d76270f5a9" +dependencies = [ + "bindgen", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk 0.8.0", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", +] + [[package]] name = "cpufeatures" version = "0.2.12" @@ -1916,6 +2040,12 @@ dependencies = [ "syn 2.0.69", ] +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "data-encoding" version = "2.6.0" @@ -2061,7 +2191,7 @@ checksum = "5a9299a95fa5671ddf29ecc22b00e121843a65cb9ff24911e394b4ae556baf36" dependencies = [ "const_panic", "encase_derive", - "glam", + "glam 0.27.0", "thiserror", ] @@ -2091,6 +2221,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "epaint" version = "0.28.1" @@ -2418,6 +2557,15 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "glam" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" +dependencies = [ + "mint", +] + [[package]] name = "glam" version = "0.27.0" @@ -2429,6 +2577,12 @@ dependencies = [ "serde", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "glow" version = "0.13.1" @@ -2627,7 +2781,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd6b038160f086b0a7496edae34169ae22f328793cbe2b627a5a3d8373748ec" dependencies = [ "constgebra", - "glam", + "glam 0.27.0", ] [[package]] @@ -2931,6 +3085,21 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "kira" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8968f1eda49cdf4f6406fd5ffe590c3ca2778a1b0e50b5684974b138a99dfb2f" +dependencies = [ + "atomic-arena", + "cpal", + "glam 0.25.0", + "mint", + "ringbuf", + "send_wrapper", + "symphonia", +] + [[package]] name = "ktx2" version = "0.3.0" @@ -2946,6 +3115,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "leafwing-input-manager" version = "0.14.0" @@ -3147,6 +3322,7 @@ dependencies = [ "bevy-inspector-egui", "bevy_egui", "bevy_grid_squared", + "bevy_kira_audio", "bevy_pixel_camera", "bevy_webp_anim", "common_action", @@ -3248,6 +3424,12 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mint" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" + [[package]] name = "naga" version = "0.20.0" @@ -3290,6 +3472,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.6.0", + "jni-sys", + "log", + "ndk-sys 0.5.0+25.2.9519653", + "num_enum", + "thiserror", +] + [[package]] name = "ndk" version = "0.9.0" @@ -3693,6 +3889,29 @@ dependencies = [ "memchr", ] +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk 0.8.0", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -4208,6 +4427,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ringbuf" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79abed428d1fd2a128201cec72c5f6938e2da607c6f3745f769fabea399d950a" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "ron" version = "0.8.1" @@ -4467,6 +4695,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simd-adler32" version = "0.3.7" @@ -4607,6 +4841,77 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20e16a0f46cf5fd675563ef54f26e83e20f2366bcf027bcb3cc3ed2b98aaf2ca" +[[package]] +name = "symphonia" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9" +dependencies = [ + "lazy_static", + "symphonia-codec-vorbis", + "symphonia-core", + "symphonia-format-ogg", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-codec-vorbis" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a98765fb46a0a6732b007f7e2870c2129b6f78d87db7987e6533c8f164a9f30" +dependencies = [ + "log", + "symphonia-core", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-core" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "798306779e3dc7d5231bd5691f5a813496dc79d3f56bf82e25789f2094e022c3" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "bytemuck", + "lazy_static", + "log", +] + +[[package]] +name = "symphonia-format-ogg" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ada3505789516bcf00fc1157c67729eded428b455c27ca370e41f4d785bfa931" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-metadata" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc622b9841a10089c5b18e99eb904f4341615d5aa55bbf4eedde1be721a4023c" +dependencies = [ + "encoding_rs", + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-utils-xiph" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "484472580fa49991afda5f6550ece662237b00c6f562c7d9638d1b086ed010fe" +dependencies = [ + "symphonia-core", + "symphonia-metadata", +] + [[package]] name = "syn" version = "1.0.109" @@ -5029,6 +5334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom", + "rand", "serde", ] @@ -5797,7 +6103,7 @@ dependencies = [ "js-sys", "libc", "memmap2", - "ndk", + "ndk 0.9.0", "objc2", "objc2-app-kit", "objc2-foundation", diff --git a/Cargo.toml b/Cargo.toml index 7f2dc22e..a37faab1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ bevy-inspector-egui = { version = "0.25", default-features = false, features = [ ] } leafwing-input-manager = "0.14" bevy_egui = "0.28" +bevy_kira_audio = "0.20" scene_top_down = { path = "scenes/top_down" } scene_meditation = { path = "scenes/meditation" } diff --git a/README.md b/README.md index 1f573a75..2fdf8240 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,19 @@ We use some external dependencies. It's paramount that we keep the bevy related dependencies to a minimum with the current Bevy release schedule. With every extra dependency that also depends on Bevy it potentially takes longer to start upgrading. -- [`bevy_pixel_camera`][bevy_pixel_camera] +- [`bevy_pixel_camera`][bevy_pixel_camera] is used to scale the game to a pixel art resolution. This plugin seems to be no longer maintained and we will vendor it soon - [`bevy_webp_anim`][bevy_webp_anim] is a crate we maintain so not a problem -- [`bevy-inspector-egui`][bevy-inspector-egui] - [`leafwing-input-manager`][leafwing-input-manager] is maintained by a core Bevy contributor -- [`bevy_egui`][bevy_egui] +- [`bevy_kira_audio`][bevy_kira_audio] is used for audio. This decision was made based on some discord conversations that suggested it was better than the native Bevy audio plugin +- [`bevy_egui`][bevy_egui] and [`bevy-inspector-egui`][bevy-inspector-egui] are used for devtools +[bevy_egui]: https://github.com/mvlabat/bevy_egui +[bevy_kira_audio]: https://github.com/NiklasEi/bevy_kira_audio [bevy_pixel_camera]: https://github.com/drakmaniso/bevy_pixel_camera [bevy_webp_anim]: https://github.com/bausano/bevy-webp-anim [bevy-inspector-egui]: https://github.com/jakobhellermann/bevy-inspector-egui [leafwing-input-manager]: https://github.com/Leafwing-Studios/leafwing-input-manager [original-bevy_magic_light]: https://github.com/zaycev/bevy-magic-light-2d -[bevy_egui]: https://github.com/mvlabat/bevy_egui # Dev environment diff --git a/common/assets/src/paths.rs b/common/assets/src/paths.rs index f83ed13e..c0eeb865 100644 --- a/common/assets/src/paths.rs +++ b/common/assets/src/paths.rs @@ -123,3 +123,8 @@ pub mod ui { pub const HEARTBEAT_ATLAS_SIZE: UVec2 = UVec2::splat(70); } + +pub mod audio { + pub const DOOR_OPEN: &str = "audio/door_open.oga"; + pub const CALL_ELEVATOR: &str = "audio/call_elevator.oga"; +} diff --git a/main_game/assets/audio/elevator2FFX.oga b/main_game/assets/audio/call_elevator.oga similarity index 100% rename from main_game/assets/audio/elevator2FFX.oga rename to main_game/assets/audio/call_elevator.oga diff --git a/main_game/assets/audio/doorFFX.oga b/main_game/assets/audio/door_open.oga similarity index 100% rename from main_game/assets/audio/doorFFX.oga rename to main_game/assets/audio/door_open.oga diff --git a/main_game/assets/scenes/building1_player_floor.tscn b/main_game/assets/scenes/building1_player_floor.tscn index d2c8c868..a8e4880f 100644 --- a/main_game/assets/scenes/building1_player_floor.tscn +++ b/main_game/assets/scenes/building1_player_floor.tscn @@ -591,7 +591,7 @@ position = Vector2(132, -111) [node name="InspectLabel" type="Node" parent="PlayerApartment/BackwallFurniture/BrewTea"] metadata/zone = "Tea" metadata/action = "BrewTea" -metadata/label = "Winnie Put the Kettle On" +metadata/label = "Winnie Put the Kettle On" [node name="CandleLight" type="AnimatedSprite2D" parent="PlayerApartment/BackwallFurniture"] position = Vector2(-29.5, -132) diff --git a/main_game_lib/Cargo.toml b/main_game_lib/Cargo.toml index 44e5b646..6db8bcd9 100644 --- a/main_game_lib/Cargo.toml +++ b/main_game_lib/Cargo.toml @@ -20,6 +20,7 @@ devtools = [ [dependencies] bevy_egui = { workspace = true, optional = true } bevy_grid_squared.workspace = true +bevy_kira_audio.workspace = true bevy_pixel_camera.workspace = true bevy_webp_anim.workspace = true bevy-inspector-egui = { workspace = true, optional = true } diff --git a/main_game_lib/src/cutscene.rs b/main_game_lib/src/cutscene.rs index 25974b93..aaacbb9e 100644 --- a/main_game_lib/src/cutscene.rs +++ b/main_game_lib/src/cutscene.rs @@ -15,8 +15,12 @@ pub mod enter_dark_door; use std::sync::OnceLock; -use bevy::{ecs::system::SystemId, prelude::*, render::view::RenderLayers}; +use bevy::{ + asset::AssetPath, ecs::system::SystemId, prelude::*, + render::view::RenderLayers, +}; use bevy_grid_squared::{GridDirection, Square}; +use bevy_kira_audio::{Audio, AudioControl}; use common_ext::QueryExt; use common_loading_screen::{LoadingScreenSettings, LoadingScreenState}; use common_store::GlobalStore; @@ -238,6 +242,12 @@ pub enum CutsceneStep { /// Undoes [`Self::ClaimManualMainCameraControl`] by inserting /// [`ManualControl`] to the [`MainCamera`] entity. ReleaseManualMainCameraControl, + /// Plays an audio file. + /// Immediately transitions to the next step. + StartPlayingAudio { + /// Relative to the asset folder + asset_path: AssetPath<'static>, + }, } /// Marks a destination. @@ -469,6 +479,7 @@ struct CutsceneSystems { claim_manual_main_camera_control: SystemId, release_manual_main_camera_control: SystemId, begin_color_interpolation: SystemId, + start_playing_audio: SystemId, } impl CutsceneSystems { @@ -503,6 +514,7 @@ impl CutsceneSystems { .register_system(release_manual_main_camera_control), begin_color_interpolation: w .register_system(begin_color_interpolation), + start_playing_audio: w.register_system(start_playing_audio), } } } @@ -537,6 +549,7 @@ fn system_id(step: &CutsceneStep) -> SystemId { ClaimManualMainCameraControl => s.claim_manual_main_camera_control, BeginColorInterpolation { .. } => s.begin_color_interpolation, ReleaseManualMainCameraControl => s.release_manual_main_camera_control, + StartPlayingAudio { .. } => s.start_playing_audio, } } @@ -923,3 +936,19 @@ fn begin_color_interpolation( cutscene.schedule_next_step_or_despawn(&mut cmd); } + +fn start_playing_audio( + mut cmd: Commands, + mut cutscene: ResMut, + audio: Res