add sound for ion engine
This commit is contained in:
parent
2b4fd9e5b5
commit
62abacf648
BIN
assets/sounds/ion.ogg
Normal file
BIN
assets/sounds/ion.ogg
Normal file
Binary file not shown.
|
@ -142,7 +142,7 @@ pub struct Vehicle;
|
||||||
pub enum EngineType {
|
pub enum EngineType {
|
||||||
Monopropellant,
|
Monopropellant,
|
||||||
Rocket,
|
Rocket,
|
||||||
//Ion,
|
Ion,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
|
13
src/audio.rs
13
src/audio.rs
|
@ -10,6 +10,7 @@ const ASSET_CONNECT: &str = "sounds/connect.ogg";
|
||||||
const ASSET_BGM: &str = "music/dead-space-style-ambient-music.ogg";
|
const ASSET_BGM: &str = "music/dead-space-style-ambient-music.ogg";
|
||||||
const ASSET_THRUSTER: &str = "sounds/thruster.ogg";
|
const ASSET_THRUSTER: &str = "sounds/thruster.ogg";
|
||||||
const ASSET_ROCKET: &str = "sounds/rocket.ogg";
|
const ASSET_ROCKET: &str = "sounds/rocket.ogg";
|
||||||
|
const ASSET_ION: &str = "sounds/ion.ogg";
|
||||||
//const ASSET_WAKEUP: &str = "sounds/wakeup.ogg";
|
//const ASSET_WAKEUP: &str = "sounds/wakeup.ogg";
|
||||||
const ASSET_BIKESTART: &str = "sounds/bikestart.ogg";
|
const ASSET_BIKESTART: &str = "sounds/bikestart.ogg";
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ pub enum Sfx {
|
||||||
#[derive(Component)] pub struct ComponentBGM;
|
#[derive(Component)] pub struct ComponentBGM;
|
||||||
#[derive(Component)] pub struct ComponentThrusterSound;
|
#[derive(Component)] pub struct ComponentThrusterSound;
|
||||||
#[derive(Component)] pub struct ComponentRocketSound;
|
#[derive(Component)] pub struct ComponentRocketSound;
|
||||||
|
#[derive(Component)] pub struct ComponentIonSound;
|
||||||
#[derive(Component)] struct SoundBGM(Handle<AudioSource>);
|
#[derive(Component)] struct SoundBGM(Handle<AudioSource>);
|
||||||
#[derive(Resource)] pub struct SoundClick(Handle<AudioSource>);
|
#[derive(Resource)] pub struct SoundClick(Handle<AudioSource>);
|
||||||
#[derive(Resource)] pub struct SoundSwitch(Handle<AudioSource>);
|
#[derive(Resource)] pub struct SoundSwitch(Handle<AudioSource>);
|
||||||
|
@ -94,6 +96,17 @@ pub fn setup(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
commands.spawn((
|
||||||
|
ComponentIonSound,
|
||||||
|
AudioBundle {
|
||||||
|
source: asset_server.load(ASSET_ION),
|
||||||
|
settings: PlaybackSettings {
|
||||||
|
mode: PlaybackMode::Loop,
|
||||||
|
paused: true,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
commands.insert_resource(SoundClick(asset_server.load(ASSET_CLICK)));
|
commands.insert_resource(SoundClick(asset_server.load(ASSET_CLICK)));
|
||||||
commands.insert_resource(SoundSwitch(asset_server.load(ASSET_SWITCH)));
|
commands.insert_resource(SoundSwitch(asset_server.load(ASSET_SWITCH)));
|
||||||
commands.insert_resource(SoundIncomingMessage(asset_server.load(ASSET_INCOMING_MESSAGE)));
|
commands.insert_resource(SoundIncomingMessage(asset_server.load(ASSET_INCOMING_MESSAGE)));
|
||||||
|
|
|
@ -47,6 +47,7 @@ fn run_camera_controller(
|
||||||
key_input: Res<ButtonInput<KeyCode>>,
|
key_input: Res<ButtonInput<KeyCode>>,
|
||||||
thruster_sound_controller: Query<&AudioSink, With<audio::ComponentThrusterSound>>,
|
thruster_sound_controller: Query<&AudioSink, With<audio::ComponentThrusterSound>>,
|
||||||
rocket_sound_controller: Query<&AudioSink, With<audio::ComponentRocketSound>>,
|
rocket_sound_controller: Query<&AudioSink, With<audio::ComponentRocketSound>>,
|
||||||
|
ion_sound_controller: Query<&AudioSink, With<audio::ComponentIonSound>>,
|
||||||
mut q_engine: Query<&mut actor::Engine, With<actor::PlayerDrivesThis>>,
|
mut q_engine: Query<&mut actor::Engine, With<actor::PlayerDrivesThis>>,
|
||||||
mut query: Query<(
|
mut query: Query<(
|
||||||
&mut Transform,
|
&mut Transform,
|
||||||
|
@ -181,5 +182,12 @@ fn run_camera_controller(
|
||||||
sink.pause()
|
sink.pause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(sink) = ion_sound_controller.get_single() {
|
||||||
|
if play_thruster_sound && engine.engine_type == actor::EngineType::Ion {
|
||||||
|
sink.play()
|
||||||
|
} else {
|
||||||
|
sink.pause()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ actor 10 -30 20 MeteorAceGT
|
||||||
scale 5
|
scale 5
|
||||||
vehicle yes
|
vehicle yes
|
||||||
thrust 70 13.7 9.4 0.5 20
|
thrust 70 13.7 9.4 0.5 20
|
||||||
engine rocket
|
engine ion
|
||||||
|
|
||||||
actor 10 0 70 suit
|
actor 10 0 70 suit
|
||||||
name Icarus
|
name Icarus
|
||||||
|
|
|
@ -567,6 +567,9 @@ pub fn load_defs(
|
||||||
["engine", "rocket"] => {
|
["engine", "rocket"] => {
|
||||||
state.engine_type = actor::EngineType::Rocket;
|
state.engine_type = actor::EngineType::Rocket;
|
||||||
}
|
}
|
||||||
|
["engine", "ion"] => {
|
||||||
|
state.engine_type = actor::EngineType::Ion;
|
||||||
|
}
|
||||||
|
|
||||||
// Parsing chats
|
// Parsing chats
|
||||||
["chat", chat_name] => {
|
["chat", chat_name] => {
|
||||||
|
|
Loading…
Reference in a new issue