Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1881,3 +1881,4 @@
1. [EFB] Restructured APIs and made Navigraph Auth a reusable component - @MicahBCode (Mischa Binder)
1. [ECAM] Added F units to CRZ and COND pages for Cabin temps. Currently tied to kg/lbs option in EFB -Patrick Macken (@PatM on Discord)
1. [A32NX/FCU] Fixed bug where the FCU selected altitude would immediately switch to 1000s on selecting the 1000ft inteval knob - @elliot747 (Elliot)
1. [Sounds] Fixed boarding complete and welcome onboard announcements playing simultaneously by adding a delay between them - @Ditoo29 (dito29 on Discord)
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,7 @@
<WwiseRTPC LocalVar="A32NX_SOUND_ANNOUNCEMENTS_ENABLED" Units="number" Index="0" RTPCName="LOCALVAR_A32NX_ANNOUNCEMENT_TOGGLE" />
</Sound>

<Sound WwiseEvent="welcomeonboard" WwiseData="true" NodeName="SOUND_FWD_GALLEY" ConeHeading="180" CancelConeHeadingWhenInside="false" Continuous="false" LocalVar="A32NX_SOUND_BOARDING_COMPLETE">
<Sound WwiseEvent="welcomeonboard" WwiseData="true" NodeName="SOUND_FWD_GALLEY" ConeHeading="180" CancelConeHeadingWhenInside="false" Continuous="false" LocalVar="A32NX_SOUND_WELCOME_ONBOARD">
Comment thread
Ditoo29 marked this conversation as resolved.
<Range LowerBound="1" />
<Requires LocalVar="A32NX_CIDS_IS_POWERED">
<Range LowerBound="1" />
Expand Down
65 changes: 46 additions & 19 deletions fbw-common/src/wasm/systems/systems/src/payload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,23 +664,33 @@ pub struct BoardingSounds {
pax_deboard_id: VariableIdentifier,
pax_complete_id: VariableIdentifier,
pax_ambience_id: VariableIdentifier,
pax_welcome_id: VariableIdentifier,

pax_boarding: bool,
pax_deboarding: bool,
pax_complete: bool,
pax_ambience: bool,
pax_welcome: bool,

welcome_timer: Duration,
}
impl BoardingSounds {
// Set a timer for 10 seconds between "Boarding Completed" and "Welcome Onboard"
const BOARDING_COMPLETE_WELCOME_DELAY: Duration = Duration::from_secs(10);

pub fn new(context: &mut InitContext) -> Self {
BoardingSounds {
pax_board_id: context.get_identifier("SOUND_PAX_BOARDING".to_owned()),
pax_deboard_id: context.get_identifier("SOUND_PAX_DEBOARDING".to_owned()),
pax_complete_id: context.get_identifier("SOUND_BOARDING_COMPLETE".to_owned()),
pax_ambience_id: context.get_identifier("SOUND_PAX_AMBIENCE".to_owned()),
pax_welcome_id: context.get_identifier("SOUND_WELCOME_ONBOARD".to_owned()),
pax_boarding: false,
pax_deboarding: false,
pax_complete: false,
pax_ambience: false,
pax_welcome: false,
welcome_timer: Duration::ZERO,
}
}

Expand Down Expand Up @@ -709,13 +719,27 @@ impl BoardingSounds {
}

pub fn play_sound_pax_complete(&mut self, playing: bool) {
if playing && !self.pax_complete {
self.welcome_timer = Duration::from_millis(1);
self.pax_welcome = false;
}
self.pax_complete = playing;
}

pub fn play_sound_pax_ambience(&mut self, playing: bool) {
self.pax_ambience = playing;
}

pub fn update_welcome(&mut self, delta: Duration) {
if self.welcome_timer > Duration::ZERO && !self.pax_welcome {
self.welcome_timer += delta;
if self.welcome_timer >= Self::BOARDING_COMPLETE_WELCOME_DELAY {
self.pax_welcome = true;
self.welcome_timer = Duration::ZERO;
}
}
}
Comment on lines +733 to +741
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using DelayedTrueLogicGate which essentially implements exactly this logic?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this is why I wanted a Rust expert to look at this! What are the best ways to get an UpdateContext to BoardingSounds ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is ultimately called in the update function one could pass the UpdateContext there.


pub fn stop_boarding_sounds(&mut self) {
self.pax_boarding = false;
self.pax_deboarding = false;
Expand All @@ -728,6 +752,7 @@ impl SimulationElement for BoardingSounds {
writer.write(&self.pax_deboard_id, self.pax_deboarding);
writer.write(&self.pax_complete_id, self.pax_complete);
writer.write(&self.pax_ambience_id, self.pax_ambience);
writer.write(&self.pax_welcome_id, self.pax_welcome);
}
}

Expand Down Expand Up @@ -962,25 +987,25 @@ impl<const P: usize, const G: usize, const C: usize> PayloadManager<P, G, C> {
if !self.is_boarding_allowed() {
self.reset_time();
self.stop_boarding_sounds();
return;
}
let ms_delay = if self.board_rate() == BoardingRate::Instant {
0
} else if self.board_rate() == BoardingRate::Fast {
self.fast_rate.into()
} else {
self.real_rate.into()
};
self.update_time(delta_time);

if self.time().as_millis() > ms_delay {
self.reset_time();
self.update_pax_tick();
self.update_cargo_tick();
}
self.update_boarding_sounds();
if self.is_fully_loaded() {
self.emit_stop_boarding();
let ms_delay = if self.board_rate() == BoardingRate::Instant {
0
} else if self.board_rate() == BoardingRate::Fast {
self.fast_rate.into()
} else {
self.real_rate.into()
};
self.update_time(delta_time);

if self.time().as_millis() > ms_delay {
self.reset_time();
self.update_pax_tick();
self.update_cargo_tick();
}
self.update_boarding_sounds();
if self.is_fully_loaded() {
self.emit_stop_boarding();
}
}
} else {
self.emit_stop_boarding();
Expand All @@ -989,8 +1014,10 @@ impl<const P: usize, const G: usize, const C: usize> PayloadManager<P, G, C> {
&mut self.passenger_deck,
&mut self.cargo_deck,
&mut self.boarding_sounds,
)
);
}

self.boarding_sounds.update_welcome(delta_time);
}
}
impl<const P: usize, const G: usize, const C: usize> SimulationElement for PayloadManager<P, G, C> {
Expand Down
Loading