-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(sound): boarding complete and welcome onboard announcements playing simultaneously #10598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this function is ultimately called in the |
||
|
|
||
| pub fn stop_boarding_sounds(&mut self) { | ||
| self.pax_boarding = false; | ||
| self.pax_deboarding = false; | ||
|
|
@@ -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); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -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(); | ||
|
|
@@ -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> { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.