diff --git a/README.md b/README.md index 1ffc19c..015b8e7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ More information here: https://bevy-cheatbook.github.io/setup/cross/linux-window - https://pixabay.com/sound-effects/click-button-140881 - https://pixabay.com/sound-effects/data-transmission-sound-from-14664-72309 - https://pixabay.com/sound-effects/thrusters-loopwav-14699 +- https://pixabay.com/sound-effects/rocket-loop-99748 - Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database) - Custom font Yupiter is based on: - Noto Sans Symbols 2, Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols) diff --git a/assets/sounds/rocket.ogg b/assets/sounds/rocket.ogg new file mode 100644 index 0000000..2e9a860 Binary files /dev/null and b/assets/sounds/rocket.ogg differ diff --git a/src/actor.rs b/src/actor.rs index d4d7779..ebf0630 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -125,12 +125,20 @@ impl Default for LifeForm { fn default() -> Self { Self { #[derive(Component)] pub struct Vehicle; +#[derive(Copy, Clone, PartialEq)] +pub enum EngineType { + Monopropellant, + Rocket, + //Ion, +} + #[derive(Component)] pub struct Engine { pub thrust_forward: f32, pub thrust_back: f32, pub thrust_sideways: f32, pub reaction_wheels: f32, + pub engine_type: EngineType, } impl Default for Engine { fn default() -> Self { @@ -139,6 +147,7 @@ impl Default for Engine { thrust_back: 1.0, thrust_sideways: 1.0, reaction_wheels: 1.0, + engine_type: EngineType::Monopropellant, } } } diff --git a/src/audio.rs b/src/audio.rs index 7c5bb8a..48b3673 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -10,6 +10,7 @@ const ASSET_CONNECT: &str = "sounds/connect.ogg"; const ASSET_RADIO: &str = "external/LP - Girls Go Wild (Official Music Video) [M7XRN0oHGIM].mp3"; const ASSET_BGM: &str = "external/Ben Prunty - FTL - 12 Void (Explore).mp3"; const ASSET_THRUSTER: &str = "sounds/thruster.ogg"; +const ASSET_ROCKET: &str = "sounds/rocket.ogg"; const ASSET_WAKEUP: &str = "sounds/wakeup.ogg"; pub struct AudioPlugin; @@ -39,6 +40,7 @@ pub enum Sfx { #[derive(Component)] pub struct ComponentBGM; #[derive(Component)] pub struct ComponentRadio; #[derive(Component)] pub struct ComponentThrusterSound; +#[derive(Component)] pub struct ComponentRocketSound; #[derive(Component)] struct SoundBGM(Handle); #[derive(Component)] pub struct SoundRadio(Handle); #[derive(Resource)] pub struct SoundClick(Handle); @@ -93,6 +95,17 @@ pub fn setup( }, }, )); + commands.spawn(( + ComponentRocketSound, + AudioBundle { + source: asset_server.load(ASSET_ROCKET), + settings: PlaybackSettings { + mode: PlaybackMode::Loop, + paused: true, + ..default() + }, + }, + )); commands.insert_resource(SoundClick(asset_server.load(ASSET_CLICK))); commands.insert_resource(SoundSwitch(asset_server.load(ASSET_SWITCH))); commands.insert_resource(SoundIncomingMessage(asset_server.load(ASSET_INCOMING_MESSAGE))); diff --git a/src/camera.rs b/src/camera.rs index 356a3c6..5df76e0 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -52,6 +52,7 @@ fn run_camera_controller( mut mouse_events: EventReader, key_input: Res>, thruster_sound_controller: Query<&AudioSink, With>, + rocket_sound_controller: Query<&AudioSink, With>, q_engine: Query<&actor::Engine, With>, mut query: Query<(&mut Transform, &mut CameraController, &mut actor::Actor, &actor::Engine), With>, ) { @@ -156,7 +157,14 @@ fn run_camera_controller( } if let Ok(sink) = thruster_sound_controller.get_single() { - if play_thruster_sound { + if play_thruster_sound && engine.engine_type == actor::EngineType::Monopropellant { + sink.play() + } else { + sink.pause() + } + } + if let Ok(sink) = rocket_sound_controller.get_single() { + if play_thruster_sound && engine.engine_type == actor::EngineType::Rocket { sink.play() } else { sink.pause() diff --git a/src/defs.txt b/src/defs.txt index de3f4e9..83b8b58 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -81,6 +81,7 @@ actor 10 -30 20 bike scale 5 vehicle yes thrust 50 0 10 0.5 + engine rocket actor 10 0 70 suit name Icarus diff --git a/src/world.rs b/src/world.rs index 5ec6427..a941ac1 100644 --- a/src/world.rs +++ b/src/world.rs @@ -215,14 +215,12 @@ pub fn setup( }); } -#[derive(Debug)] enum DefClass { Actor, Chat, None, } -#[derive(Debug)] struct ParserState { class: DefClass, @@ -246,6 +244,7 @@ struct ParserState { thrust_sideways: f32, thrust_back: f32, reaction_wheels: f32, + engine_type: actor::EngineType, oxygen: f32, // Chat fields @@ -284,6 +283,7 @@ impl Default for ParserState { thrust_sideways: default_engine.thrust_forward, thrust_back: default_engine.thrust_back, reaction_wheels: default_engine.reaction_wheels, + engine_type: default_engine.engine_type, oxygen: nature::OXY_D, delay: 0.0, @@ -357,6 +357,7 @@ impl ParserState { thrust_back: self.thrust_back, thrust_sideways: self.thrust_sideways, reaction_wheels: self.reaction_wheels, + engine_type: self.engine_type, }; let component_suit = actor::Suit { oxygen: self.oxygen, @@ -557,6 +558,9 @@ pub fn load_defs( state.reaction_wheels = reaction_wheels_float; } } + ["engine", "rocket"] => { + state.engine_type = actor::EngineType::Rocket; + } // Parsing chats ["chat", chat_name] => {