Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions src/launching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ pub struct ThrusterTouch {
pub active_touch_id: Option<u64>,
}

#[derive(Resource, Default)]
pub struct LaunchCounter {
pub count: u32,
}

pub(super) fn plugin(app: &mut App) {
app.init_resource::<LaunchArmed>();
app.init_resource::<ThrusterTouch>();
app.init_resource::<LaunchCounter>();
app.add_systems(
Update,
(
Expand Down Expand Up @@ -99,6 +105,7 @@ fn start_new_launch(
mut score: ResMut<Score>,
satellite_price_factor: Res<SatellitePriceFactor>,
current_marked: Query<Entity, With<NavigationInstruments>>,
mut launch_counter: ResMut<LaunchCounter>,
) {

let Some(launch_pad_transform) = launch_pad_query.iter().next() else { return; };
Expand Down Expand Up @@ -146,6 +153,24 @@ fn start_new_launch(
} else {
return;
}

// Increment launch counter and play appropriate sound
launch_counter.count += 1;
if launch_counter.count % 10 == 0 {
// Every 10th launch: play special sound (using warning sound as placeholder)
commands.spawn((
AudioPlayer::new(solar_system_assets.warning_sound.clone()),
PlaybackSettings::DESPAWN,
));
info!("Special launch sound! (Launch #{})", launch_counter.count);
} else {
// Regular launch: play normal beep sound
commands.spawn((
AudioPlayer::new(solar_system_assets.warning_sound.clone()),
PlaybackSettings::DESPAWN,
));
}

// Ensure only the newly launched satellite will be selected
for e in current_marked.iter() {
commands.entity(e).remove::<NavigationInstruments>();
Expand Down Expand Up @@ -246,7 +271,8 @@ fn start_launch_from_touch_end(
mut score: ResMut<Score>,
current_marked: Query<Entity, With<NavigationInstruments>>,
time: Res<Time>,
price: Res<SatellitePriceFactor>
price: Res<SatellitePriceFactor>,
mut launch_counter: ResMut<LaunchCounter>,
) {
let Some(launch_pad_transform) = launch_pad_query.iter().next() else { return; };
let launch_position = launch_pad_transform.translation;
Expand Down Expand Up @@ -295,6 +321,24 @@ fn start_launch_from_touch_end(
} else {
return;
}

// Increment launch counter and play appropriate sound
launch_counter.count += 1;
if launch_counter.count % 10 == 0 {
// Every 10th launch: play special sound
commands.spawn((
AudioPlayer::new(solar_system_assets.warning_sound.clone()),
PlaybackSettings::DESPAWN,
));
info!("Special launch sound! (Launch #{})", launch_counter.count);
} else {
// Regular launch: play normal beep sound
commands.spawn((
AudioPlayer::new(solar_system_assets.warning_sound.clone()),
PlaybackSettings::DESPAWN,
));
}

// Ensure only the newly launched satellite will be selected
for e in current_marked.iter() {
commands.entity(e).remove::<NavigationInstruments>();
Expand Down Expand Up @@ -528,5 +572,4 @@ fn sun_thruster_touch(
_ => {}
}
}
}

}