Skip to content

Commit

Permalink
Automatic merge of T1.5.1-269-g01607fd93 and 34 pull requests
Browse files Browse the repository at this point in the history
- Pull request #570 at 6a2ffed: Experimental glTF 2.0 support with PBR lighting
- Pull request #722 at fb9079e: Fix Windows Forms deprecations in ActivityEditor
- Pull request #732 at 83002d7: Improvements for air brakes
- Pull request #751 at f947f29: Web interface to control cab controls with external hardware
- Pull request #753 at ab8fe32: Extends CabControls for user input
- Pull request #767 at 4cb5c77: Refine sunrise and sunset
- Pull request #769 at 1a99f43: Partial turntables https://blueprints.launchpad.net/or/+spec/partial-turntable
- Pull request #771 at c380043: Action on Hold Signal is no longer invalidated if train is not stoppe…
- Pull request #772 at 36c3662: Update tt train
- Pull request #773 at 4543e4b: Add watchdog ping to Train Processing
- Pull request #774 at d3f8c2e: Use variable OrgAINumber for all train to train references
- Pull request #775 at d84c8d8: Update turntable pools
- Pull request #776 at 7b6af67: Update Receivers in Viewer.cs
- Pull request #777 at 7724f2b: Save and restore ClearMovingTable action (for timetables)
- Pull request #778 at 779a819: Correction for player locomotive on turntable
- Pull request #779 at 87c34a7: Remove forced processed ClearSection actions
- Pull request #780 at 5b3f246: Process passing time
- Pull request #781 at 4d9c3fb: Correct update of pending speed limits for timetable mode
- Pull request #782 at 23c41b5: Nu full physics update is required for trains in state AIStatic
- Pull request #783 at 083bc6c: Move CreateInPool from AI to Pools
- Pull request #784 at 1c37be3: Incorrect distance along track
- Pull request #785 at fd121be: Incorrect calculation of distance to train ahead
- Pull request #786 at f2c5d2d: Improve syntax check on timetable files
- Pull request #787 at e0ad658: Improve debug output for turntable pools
- Pull request #788 at 94a73d5: Improve Debug Outputs for TTTrain.cs
- Pull request #789 at 81b11f7: Avoid error on inserting train without start time
- Pull request #790 at 36a9921: Correct crash in TrainCar.cs
- Pull request #791 at 5bc890b: Correct update for Switchstand signalscript function
- Pull request #792 at f6c16fb: Correct required actions
- Pull request #793 at 8897021: Correct errors in Turntables.cs
- Pull request #794 at 6d2bf04: Use reverse path in TT Pool
- Pull request #795 at 79979e2: Accept SpeedMPS as dimension for Approach Control Speed definition
- Pull request #796 at a67ee61: fix: Resume from Save fails - filenames do not match
- Pull request #797 at 7ced1fe: To use enum for ControlGearBoxType
  • Loading branch information
Showing 1 changed file with 8 additions and 49 deletions.
Expand Up @@ -28,54 +28,40 @@
*
*/

using Microsoft.Xna.Framework;
using Orts.Formats.Msts;
using System.Diagnostics;
using System.IO;
using System.Text;
using Orts.Parsers.Msts;
using Orts.Simulation.Physics;
using Orts.Simulation.RollingStocks.SubSystems.Controllers;
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
using ORTS.Common;
using System.Diagnostics;
using System;
using System.IO;
using System.Text;
using Event = Orts.Common.Event;
using ORTS.Scripting.Api;
using static Orts.Simulation.RollingStocks.MSTSDieselLocomotive;

namespace Orts.Simulation.RollingStocks
{
public class MSTSControlTrailerCar : MSTSLocomotive
{

public int ControllerNumberOfGears = 1;
bool HasGearController = false;
bool ControlGearUp = false;
bool ControlGearDown = false;
int ControlGearIndex;
int ControlGearIndication;
string ControlGearBoxType;

TypesGearBox ControlGearBoxType;

public MSTSControlTrailerCar(Simulator simulator, string wagFile)
: base(simulator, wagFile)
: base(simulator, wagFile)
{

PowerSupply = new ScriptedControlCarPowerSupply(this);

}

public override void LoadFromWagFile(string wagFilePath)
{
base.LoadFromWagFile(wagFilePath);
}


public override void Initialize()
{


// Initialise gearbox controller
if (ControllerNumberOfGears > 0)
{
Expand All @@ -90,7 +76,6 @@ public override void Initialize()
base.Initialize();
}


/// <summary>
/// Parse the wag file parameters required for the simulator and viewer classes
/// </summary>
Expand All @@ -117,11 +102,9 @@ public override void Parse(string lowercasetoken, STFReader stf)
// to setup gearbox controller
case "engine(gearboxcontrollernumberofgears": ControllerNumberOfGears = stf.ReadIntBlock(null); break;


default:
base.Parse(lowercasetoken, stf); break;
}

}

/// <summary>
Expand All @@ -132,14 +115,11 @@ public override void Parse(string lowercasetoken, STFReader stf)
/// </summary>
public override void Copy(MSTSWagon copy)
{

base.Copy(copy); // each derived level initializes its own variables

MSTSControlTrailerCar locoCopy = (MSTSControlTrailerCar)copy;

ControllerNumberOfGears = locoCopy.ControllerNumberOfGears;


}

/// <summary>
Expand All @@ -165,11 +145,9 @@ public override void Restore(BinaryReader inf)
ControlGearIndex = inf.ReadInt32();
}


/// <summary>
/// Set starting conditions when initial speed > 0
///

public override void InitializeMoving()
{
base.InitializeMoving();
Expand All @@ -186,7 +164,6 @@ public override void Update(float elapsedClockSeconds)
base.Update(elapsedClockSeconds);
WheelSpeedMpS = SpeedMpS; // Set wheel speed for control car, required to make wheels go around.


if (ControllerNumberOfGears > 0 && IsLeadLocomotive() && GearBoxController != null)
{
// Pass gearbox command key to other locomotives in train, don't treat the player locomotive in this fashion.
Expand All @@ -198,10 +175,8 @@ public override void Update(float elapsedClockSeconds)

if (locog != null && car != this && !locog.IsLeadLocomotive() && (ControlGearDown || ControlGearUp))
{

if (ControlGearUp)
{

locog.GearBoxController.CurrentNotch = GearBoxController.CurrentNotch;
locog.GearBoxController.SetValue((float)locog.GearBoxController.CurrentNotch);

Expand All @@ -210,7 +185,6 @@ public override void Update(float elapsedClockSeconds)

if (ControlGearDown)
{

locog.GearBoxController.CurrentNotch = GearBoxController.CurrentNotch;
locog.GearBoxController.SetValue((float)locog.GearBoxController.CurrentNotch);

Expand All @@ -225,18 +199,15 @@ public override void Update(float elapsedClockSeconds)
ControlGearIndication = locog.DieselEngines[0].GearBox.GearIndication;
if (locog.DieselEngines[0].GearBox.GearBoxType == TypesGearBox.C)
{
ControlGearBoxType = "C";
ControlGearBoxType = TypesGearBox.C;
}
}
}


// Rest gear flags once all the cars have been processed
ControlGearUp = false;
ControlGearDown = false;

}

}

public override string GetStatus()
Expand All @@ -255,28 +226,18 @@ public override string GetStatus()
/// </summary>
protected override void UpdateTractiveForce(float elapsedClockSeconds, float t, float AbsSpeedMpS, float AbsWheelSpeedMpS)
{




}


/// <summary>
/// This function updates periodically the locomotive's sound variables.
/// </summary>
protected override void UpdateSoundVariables(float elapsedClockSeconds)
{



}


public override void ChangeGearUp()
{

if (ControlGearBoxType == "C")
if (ControlGearBoxType == TypesGearBox.C)
{
if (ThrottlePercent == 0)
{
Expand All @@ -303,12 +264,11 @@ public override void ChangeGearUp()

ControlGearUp = true;
ControlGearDown = false;

}

public override void ChangeGearDown()
{
if (ControlGearBoxType == "C")
if (ControlGearBoxType == TypesGearBox.C)
{
if (ThrottlePercent == 0)
{
Expand All @@ -335,7 +295,6 @@ public override void ChangeGearDown()

ControlGearUp = false;
ControlGearDown = true;

}
}
}

0 comments on commit cf5ee2b

Please sign in to comment.