Skip to content

Commit e30853e

Browse files

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

Source/Orts.Simulation/MultiPlayer/Message.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,8 +2093,9 @@ public override void HandleMsg()
20932093
}
20942094
else if (EventName == "BELL")
20952095
{
2096-
if (t.LeadLocomotive != null)
2096+
if (t.LeadLocomotive != null && t.LeadLocomotive is MSTSLocomotive)
20972097
{
2098+
(t.LeadLocomotive as MSTSLocomotive).Bell = (EventState == 0 ? false : true);
20982099
t.LeadLocomotive.SignalEvent(EventState == 0 ? Event.BellOff : Event.BellOn);
20992100
MPManager.BroadCast(this.ToString()); //if the server, will broadcast
21002101
}

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,12 +1895,12 @@ protected virtual void UpdateHornAndBell(float elapsedClockSeconds)
18951895
if (Bell && !PreviousBell)
18961896
{
18971897
SignalEvent(Event.BellOn);
1898-
if (MPManager.IsMultiPlayer()) MPManager.Notify((new MSGEvent(MPManager.GetUserName(), "BELL", 1)).ToString());
1898+
if (Train.TrainType != Train.TRAINTYPE.REMOTE && MPManager.IsMultiPlayer()) MPManager.Notify((new MSGEvent(MPManager.GetUserName(), "BELL", 1)).ToString());
18991899
}
19001900
else if (!Bell && PreviousBell)
19011901
{
19021902
SignalEvent(Event.BellOff);
1903-
if (MPManager.IsMultiPlayer()) MPManager.Notify((new MSGEvent(MPManager.GetUserName(), "BELL", 0)).ToString());
1903+
if (Train.TrainType != Train.TRAINTYPE.REMOTE && MPManager.IsMultiPlayer()) MPManager.Notify((new MSGEvent(MPManager.GetUserName(), "BELL", 0)).ToString());
19041904
}
19051905

19061906
PreviousHorn = Horn;

Source/RunActivity/Viewer3D/AnimatedPart.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ public void UpdateLoop(float change)
156156
/// <summary>
157157
/// Updates an animated part that loops only when enabled (e.g. wipers).
158158
/// </summary>
159-
public void UpdateLoop(bool running, ElapsedTime elapsedTime)
159+
public void UpdateLoop(bool running, ElapsedTime elapsedTime, float frameRateMultiplier = 1.5f)
160160
{
161161
if (PoseableShape.SharedShape.Animations == null || PoseableShape.SharedShape.Animations.Count == 0 || FrameCount == 0)
162162
return;
163163

164-
// The speed of cycling is set at 1.5 frames of animation per second at 30 FPS.
165-
var frameRate = PoseableShape.SharedShape.Animations[0].FrameRate * 1.5f / 30f;
166-
if (running || (AnimationKey > 0 && AnimationKey + elapsedTime.ClockSeconds < FrameCount))
164+
// The speed of cycling is as default 1.5 frames of animation per second at 30 FPS.
165+
var frameRate = PoseableShape.SharedShape.Animations[0].FrameRate * frameRateMultiplier / 30f;
166+
if (running || (AnimationKey > 0 && AnimationKey + elapsedTime.ClockSeconds * frameRate < FrameCount))
167167
SetFrameWrap(AnimationKey + elapsedTime.ClockSeconds * frameRate);
168168
else
169169
SetFrame(0);

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,9 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
266266
return;
267267
}
268268

269-
// Wiper animation
269+
// Wipers and bell animation
270270
Wipers.UpdateLoop(Locomotive.Wiper, elapsedTime);
271+
Bell.UpdateLoop(Locomotive.Bell, elapsedTime, 8.0f);
271272

272273
// Draw 2D CAB View - by GeorgeS
273274
if (Viewer.Camera.AttachedCar == this.MSTSWagon &&

Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class MSTSWagonViewer : TrainCarViewer
6060
AnimatedPart RightDoor;
6161
AnimatedPart Mirrors;
6262
protected AnimatedPart Wipers;
63+
protected AnimatedPart Bell;
6364
AnimatedPart UnloadingParts;
6465

6566
public Dictionary<string, List<ParticleEmitterViewer>> ParticleDrawers = new Dictionary<string, List<ParticleEmitterViewer>>();
@@ -182,6 +183,7 @@ from data in effect.Value
182183
Mirrors = new AnimatedPart(TrainCarShape);
183184
Wipers = new AnimatedPart(TrainCarShape);
184185
UnloadingParts = new AnimatedPart(TrainCarShape);
186+
Bell = new AnimatedPart(TrainCarShape);
185187

186188
if (car.FreightAnimations != null)
187189
FreightAnimations = new FreightAnimationsViewer(viewer, car, wagonFolderSlash);
@@ -407,6 +409,10 @@ void MatchMatrixToPart(MSTSWagon car, int matrix, int bogieMatrix)
407409
else Pantograph2.AddMatrix(matrix);
408410
}
409411
}
412+
else if (matrixName.StartsWith("ORTSBELL")) // wipers
413+
{
414+
Bell.AddMatrix(matrix);
415+
}
410416
else
411417
{
412418
if (matrixAnimated && matrix != 0)

0 commit comments

Comments
 (0)