Fix in managers

This commit is contained in:
Marc Riera 2024-11-03 18:01:18 +01:00
parent 7574de93ab
commit bcebb8599c
3 changed files with 11 additions and 6 deletions

View file

@ -22,7 +22,7 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>Shows a message to the player.</summary>
/// <param name="message">The message to be shown.</param>
/// <param name="color">The color of the message.</param>
/// <param name="time">The time to show the message.</param>
/// <param name="time">The time to show the message, in seconds.</param>
internal static void ShowMessage(string message, OpenBveApi.Colors.MessageColor color, double time)
{
MessageDelegate(message, color, time);
@ -31,7 +31,7 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>Shows a message to the player.</summary>
/// <param name="message">The message to be shown.</param>
/// <param name="color">The color of the message.</param>
/// <param name="time">The time to show the message.</param>
/// <param name="time">The time to show the message, in seconds.</param>
/// <param name="score">The score for the player.</param>
internal static void ShowMessage( string message, OpenBveApi.Colors.MessageColor color, double time, int score)
{

View file

@ -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
/// <param name="soundIndex">The index of the sound to be stopped.</param>
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();

View file

@ -28,6 +28,9 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>The next station in the route.</summary>
internal Station NextStation;
/// <summary>The current time in the route.</summary>
internal Time CurrentTime { get; private set; } = new Time(0);
/// <summary>The current state of the train doors.</summary>
private DoorStates DoorState;
@ -38,6 +41,9 @@ namespace OpenbveFcmbTrainPlugin
/// <param name="data">The data passed to the plugin.</param>
internal void Elapse(ElapseData data)
{
// Update current time
CurrentTime = data.TotalTime;
if (OpenbveFcmbTrainPlugin.Initializing)
{
// Get the list of stations and set the current station