From bcebb8599c99e2961dcc565213a523bd748e7e90 Mon Sep 17 00:00:00 2001 From: Marc Riera Date: Sun, 3 Nov 2024 18:01:18 +0100 Subject: [PATCH] Fix in managers --- src/Managers/MessageManager.cs | 4 ++-- src/Managers/SoundManager.cs | 7 +++---- src/Route/Route.cs | 6 ++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Managers/MessageManager.cs b/src/Managers/MessageManager.cs index 6024b30..ee716a3 100644 --- a/src/Managers/MessageManager.cs +++ b/src/Managers/MessageManager.cs @@ -22,7 +22,7 @@ namespace OpenbveFcmbTrainPlugin /// Shows a message to the player. /// The message to be shown. /// The color of the message. - /// The time to show the message. + /// The time to show the message, in seconds. internal static void ShowMessage(string message, OpenBveApi.Colors.MessageColor color, double time) { MessageDelegate(message, color, time); @@ -31,7 +31,7 @@ namespace OpenbveFcmbTrainPlugin /// Shows a message to the player. /// The message to be shown. /// The color of the message. - /// The time to show the message. + /// The time to show the message, in seconds. /// The score for the player. internal static void ShowMessage( string message, OpenBveApi.Colors.MessageColor color, double time, int score) { diff --git a/src/Managers/SoundManager.cs b/src/Managers/SoundManager.cs index ba1dc03..f1a3a42 100644 --- a/src/Managers/SoundManager.cs +++ b/src/Managers/SoundManager.cs @@ -39,7 +39,7 @@ namespace OpenbveFcmbTrainPlugin // Validate index before doing anything if (soundIndex < Sounds.Length && soundIndex >= 0) { - if (Sounds[soundIndex].Playing) + if (Playing(soundIndex)) { // The sound is still playing, update volume and pitch Sounds[soundIndex].Volume = volume; @@ -64,7 +64,7 @@ namespace OpenbveFcmbTrainPlugin // Validate index before doing anything if (soundIndex < Sounds.Length && soundIndex >= 0) { - if (Sounds[soundIndex].Playing) + if (Playing(soundIndex)) { // The sound is still playing, update volume and pitch Sounds[soundIndex].Volume = volume; @@ -82,8 +82,7 @@ namespace OpenbveFcmbTrainPlugin /// The index of the sound to be stopped. internal static void Stop(int soundIndex) { - // Validate index before doing anything - if (soundIndex < Sounds.Length && soundIndex >= 0 && Sounds[soundIndex] != null) + if (Playing(soundIndex)) { // Stop sound Sounds[soundIndex].Stop(); diff --git a/src/Route/Route.cs b/src/Route/Route.cs index 0602f7c..9db13b2 100644 --- a/src/Route/Route.cs +++ b/src/Route/Route.cs @@ -28,6 +28,9 @@ namespace OpenbveFcmbTrainPlugin /// The next station in the route. internal Station NextStation; + /// The current time in the route. + internal Time CurrentTime { get; private set; } = new Time(0); + /// The current state of the train doors. private DoorStates DoorState; @@ -38,6 +41,9 @@ namespace OpenbveFcmbTrainPlugin /// The data passed to the plugin. internal void Elapse(ElapseData data) { + // Update current time + CurrentTime = data.TotalTime; + if (OpenbveFcmbTrainPlugin.Initializing) { // Get the list of stations and set the current station