/// <inheritdoc/> public override void Update(AbstractTrain NearestTrain, double TimeElapsed, bool ForceUpdate, bool CurrentlyVisible) { if (CurrentlyVisible | ForceUpdate) { if (Object.SecondsSinceLastUpdate >= Object.RefreshRate | ForceUpdate) { double timeDelta = Object.SecondsSinceLastUpdate + TimeElapsed; Object.SecondsSinceLastUpdate = 0.0; Object.Update(false, NearestTrain, NearestTrain == null ? 0 : NearestTrain.DriverCar, SectionIndex, TrackPosition, Position, Direction, Up, Side, true, true, timeDelta, true); } else { Object.SecondsSinceLastUpdate += TimeElapsed; } if (!base.Visible) { currentHost.ShowObject(Object.internalObject, ObjectType.Dynamic); base.Visible = true; } } else { Object.SecondsSinceLastUpdate += TimeElapsed; if (base.Visible) { currentHost.HideObject(Object.internalObject); base.Visible = false; } } }
/// <inheritdoc/> public override void Update(AbstractTrain NearestTrain, double TimeElapsed, bool ForceUpdate, bool CurrentlyVisible) { if (CurrentlyVisible | ForceUpdate) { if (Object.SecondsSinceLastUpdate >= Object.RefreshRate | ForceUpdate) { double timeDelta = Object.SecondsSinceLastUpdate + TimeElapsed; Object.SecondsSinceLastUpdate = 0.0; Object.Update(false, NearestTrain, NearestTrain == null ? 0 : NearestTrain.DriverCar, SectionIndex, TrackPosition, Position, Direction, Up, Side, true, true, timeDelta, true); if (this.Object.CurrentState != this.lastState && currentHost.SimulationSetup) { if (this.SingleBuffer && this.Buffers[0] != null) { switch (this.Object.CurrentState) { case -1: if (this.PlayOnHide) { Source = currentHost.PlaySound(Buffers[0], currentPitch, currentVolume, Position, null, false); } break; case 0: if (this.PlayOnShow || this.lastState != -1) { Source = currentHost.PlaySound(Buffers[0], currentPitch, currentVolume, Position, null, false); } break; default: Source = currentHost.PlaySound(Buffers[0], currentPitch, currentVolume, Position, null, false); break; } } else { int bufferIndex = this.Object.CurrentState; switch (bufferIndex) { case -1: //Do not play sound when completely hiding the object from view break; default: if (this.Buffers.Length >= bufferIndex && this.Buffers[bufferIndex] != null) { Source = currentHost.PlaySound(Buffers[bufferIndex], currentPitch, currentVolume, Position, null, false); } break; } } } } else { Object.SecondsSinceLastUpdate += TimeElapsed; } if (!base.Visible) { currentHost.ShowObject(Object.internalObject, ObjectType.Dynamic); base.Visible = true; } } else { Object.SecondsSinceLastUpdate += TimeElapsed; if (base.Visible) { currentHost.HideObject(Object.internalObject); base.Visible = false; } } this.lastState = this.Object.CurrentState; }