コード例 #1
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the driver's selected brake notch for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The driver's selected power notch</returns>
 public static int brakeNotch(TrainBase Train)
 {
     if (Train == null)
     {
         return(0);
     }
     return(Train.Handles.Brake.Driver);
 }
コード例 #2
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the maximum brake notch for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The maximum power notch</returns>
 public static int brakeNotches(TrainBase Train)
 {
     if (Train == null)
     {
         return(0);
     }
     return(Train.Handles.Brake.MaximumNotch);
 }
コード例 #3
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the maximum power notch for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The maximum power notch</returns>
 public static int powerNotches(TrainBase Train)
 {
     if (Train == null)
     {
         return(0);
     }
     return(Train.Handles.Power.MaximumNotch);
 }
コード例 #4
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the number of cars in this train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The number of cars</returns>
 public static int numberOfCars(TrainBase Train)
 {
     if (Train != null)
     {
         return(Train.Cars.Length);
     }
     return(0);
 }
コード例 #5
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the driver's selected reverser position for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>-1 for backwards, 0 for neutral, 1 for forwards</returns>
 public static int reverserNotch(TrainBase Train)
 {
     if (Train == null)
     {
         return(0);
     }
     return((int)Train.Handles.Reverser.Driver);
 }
コード例 #6
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the driver's selected power notch for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The driver's selected power notch</returns>
 public static int powerNotch(TrainBase Train)
 {
     if (Train == null)
     {
         return(0);
     }
     return(Train.Handles.Power.Driver);
 }
コード例 #7
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Whether the constant speed devicee is currently active for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>Whether the constant speed device is currently active</returns>
 public static bool constantSpeed(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     return(Train.Specs.CurrentConstSpeed);
 }
コード例 #8
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Whether the selected train has an automatic air brake</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>Whether the selected train has an automatic air brake</returns>
 public static bool hasAirBrake(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     return(Train.Handles.Brake is AirBrakeHandle);
 }
コード例 #9
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Whether the selected train has a constant speed device</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>Whether the selected train has a constant speed device</returns>
 public static bool hasConstantSpeed(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     return(Train.Specs.HasConstSpeed);
 }
コード例 #10
0
ファイル: Handles.Reverser.cs プロジェクト: zbx1425/OpenBVE
 public ReverserHandle(TrainBase train)
 {
     Driver       = ReverserPosition.Neutral;
     Actual       = ReverserPosition.Neutral;
     EngageSound  = new CarSound();
     ReleaseSound = new CarSound();
     baseTrain    = train;
 }
コード例 #11
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns whether EB is active for the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>Whether EB is active</returns>
 public static bool emergencyBrake(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     return(Train.Handles.EmergencyBrake.Driver);
 }
コード例 #12
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Whether the selected train has a hold brake</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>Whether the selected train has a hold brake</returns>
 public static bool hasHoldBrake(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     return(Train.Handles.HasHoldBrake);
 }
コード例 #13
0
ファイル: TrainManager.cs プロジェクト: s520/OpenBVE
 /// <summary>Un-derails a train</summary>
 /// <param name="Train">The train</param>
 public static void UnderailTrain(TrainBase Train)
 {
     Train.Derailed = false;
     for (int i = 0; i < Train.Cars.Length; i++)
     {
         Train.Cars[i].Specs.RollDueToTopplingAngle = 0.0;
         Train.Cars[i].Derailed = false;
     }
 }
コード例 #14
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the acceleration of the selected car</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The car for which to get the acceleration</param>
 /// <returns>The acceleration in m/s</returns>
 public static double acceleration(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0);
     }
     return(CarIndex > Train.Cars.Length
         ? Train.Cars[0].Specs.Acceleration
         : Train.Cars[CarIndex].Specs.Acceleration);
 }
コード例 #15
0
 protected AbstractHandle(TrainBase Train)
 {
     baseTrain    = Train;
     Increase     = new CarSound();
     IncreaseFast = new CarSound();
     Decrease     = new CarSound();
     DecreaseFast = new CarSound();
     Min          = new CarSound();
     Max          = new CarSound();
 }
コード例 #16
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the speed of the selected car, accounting for wheelslip and wheel lock</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The car for which to get the speed</param>
 /// <returns>The speed in m/s</returns>
 public static double speedometer(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0);
     }
     return(CarIndex > Train.Cars.Length
         ? Train.Cars[0].Specs.PerceivedSpeed
         : Train.Cars[CarIndex].Specs.PerceivedSpeed);
 }
コード例 #17
0
        /// <summary>
        /// Applies the status to the specified train
        /// </summary>
        /// <param name="train">The train loaded from extensions.cfg or dummy train</param>
        internal void Apply(TrainBase train)
        {
            foreach (CarBase car in train.Cars)
            {
                car.CurrentSpeed         = Speed / 3.6;
                car.Specs.PerceivedSpeed = Speed / 3.6;
                car.Specs.Acceleration   = Acceleration / 3.6;

                if (!NearestTrain.IsExtensionsCfg)
                {
                    car.CarBrake.mainReservoir.CurrentPressure       = MainReservoirPressure * 1000.0;
                    car.CarBrake.equalizingReservoir.CurrentPressure = EqualizingReservoirPressure * 1000.0;
                    car.CarBrake.brakePipe.CurrentPressure           = BrakePipePressure * 1000.0;
                    car.CarBrake.brakeCylinder.CurrentPressure       = BrakeCylinderPressure * 1000.0;
                    car.CarBrake.straightAirPipe.CurrentPressure     = StraightAirPipePressure * 1000.0;
                }

                car.Doors[0].State           = LeftDoorState;
                car.Doors[0].AnticipatedOpen = LeftDoorAnticipatedOpen;
                car.Doors[1].State           = RightDoorState;
                car.Doors[1].AnticipatedOpen = RightDoorAnticipatedOpen;
            }

            train.Handles.Reverser.Driver = (ReverserPosition)Reverser;
            train.Handles.Reverser.Actual = (ReverserPosition)Reverser;
            train.Handles.Power.Driver    = PowerNotch;
            train.Handles.Power.Actual    = PowerNotch;
            train.Handles.Brake.Driver    = BrakeNotch;
            train.Handles.Brake.Actual    = BrakeNotch;
            if (train.Handles.HasHoldBrake)
            {
                train.Handles.HoldBrake.Driver = HoldBrake;
                train.Handles.HoldBrake.Actual = HoldBrake;
            }
            train.Handles.EmergencyBrake.Driver = EmergencyBrake;
            train.Handles.EmergencyBrake.Actual = EmergencyBrake;
            if (train.Specs.HasConstSpeed)
            {
                train.Specs.CurrentConstSpeed = ConstSpeed;
            }

            if (NearestTrain.EnablePluginSimulation && PluginStates.Length != 0)
            {
                PluginManager.CurrentPlugin.Panel = new int[PluginStates.Max(x => x.Index) + 1];
                foreach (PluginState pluginState in PluginStates)
                {
                    PluginManager.CurrentPlugin.Panel[pluginState.Index] = pluginState.Value;
                }
            }
            else
            {
                PluginManager.CurrentPlugin.Panel = new int[0];
            }
        }
コード例 #18
0
ファイル: ProxyPlugin.cs プロジェクト: s520/OpenBVE
        internal ProxyPlugin(string pluginFile, TrainBase train)
        {
            externalCrashed = false;
            PluginTitle     = System.IO.Path.GetFileName(pluginFile);
            //Load the plugin via the proxy callback
            var handle = Process.GetCurrentProcess().MainWindowHandle;

            try
            {
                var hostProcess = new Process();
                hostProcess.StartInfo.FileName = @"Win32PluginProxy.exe";
                hostProcess.Start();
                HostInterface.Win32PluginHostReady.WaitOne();
                pipeProxy = new DuplexChannelFactory <IAtsPluginProxy>(new InstanceContext(this), new NetNamedPipeBinding(), new EndpointAddress(HostInterface.Win32PluginHostEndpointAddress)).CreateChannel();
                pipeProxy.SetPluginFile(pluginFile, Process.GetCurrentProcess().Id);
                SetForegroundWindow(handle.ToInt32());
            }
            catch
            {
                //That didn't work
                externalCrashed = true;
            }
            PluginValid   = true;
            PluginMessage = null;
            Train         = train;
            Panel         = new int[256];
            SupportsAI    = AISupport.None;
            switch (PluginTitle.ToLowerInvariant())
            {
            case "ukdt.dll":
                base.SupportsAI = AISupport.Program;
                AI = new UKDtAI(this);
                break;

            case "ukspt.dll":
                base.SupportsAI = AISupport.Program;
                AI = new UKSptAI(this);
                break;

            case "ukmut.dll":
                base.SupportsAI = AISupport.Program;
                base.AI         = new UKMUtAI(this);
                break;
            }
            LastTime       = 0.0;
            LastReverser   = -2;
            LastPowerNotch = -1;
            LastBrakeNotch = -1;
            LastAspects    = new int[] { };
            LastSection    = -1;
            LastException  = null;
            Sound          = new int[256];
            LastSound      = new int[256];
        }
コード例 #19
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
            /// <summary>Returns the track distance to the nearest car of the selected train</summary>
            /// <param name="Train">The selected train</param>
            /// <param name="TrackPosition">The object's track position</param>
            /// <returns>The distance to the object</returns>
            public static double trackDistance(TrainBase Train, double TrackPosition)
            {
                if (Train == null)
                {
                    return(0.0);
                }
                double t0 = Train.FrontCarTrackPosition();
                double t1 = Train.RearCarTrackPosition();

                return(TrackPosition > t0 ? TrackPosition - t0 : TrackPosition < t1 ? TrackPosition - t1 : 0.0);
            }
コード例 #20
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the main brake reservoir pressure of the selected car of the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The selected car</param>
 /// <returns>The main brake reservoir pressure in Pa</returns>
 public static double mainReservoir(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0.0);
     }
     if (Train.Cars.Length > CarIndex)
     {
         return(0.0);
     }
     return(Train.Cars[CarIndex].CarBrake.mainReservoir.CurrentPressure);
 }
コード例 #21
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Whether the selected train uses a custom plugin</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>True if the train uses a custom plugin, false otherwise</returns>
 public static bool hasPlugin(TrainBase Train)
 {
     if (Train == null)
     {
         return(false);
     }
     if (Train.IsPlayerTrain && Train.Plugin != null)
     {
         return(TrainManager.PlayerTrain.Plugin.IsDefault);
     }
     return(false);
 }
コード例 #22
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the brake cylinder pressure of the selected car of the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The selected car</param>
 /// <returns>The brake cylinder pressure in Pa</returns>
 public static double brakeCylinder(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0.0);
     }
     if (Train.Cars.Length > CarIndex)
     {
         return(0.0);
     }
     return(Train.Cars[CarIndex].CarBrake.brakeCylinder.CurrentPressure);
 }
コード例 #23
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the brake pipe pressure of the selected car of the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The selected car</param>
 /// <returns>The brake pipe pressure in Pa</returns>
 public static double straightAirPipe(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0.0);
     }
     if (Train.Cars.Length > CarIndex)
     {
         return(0.0);
     }
     return(Train.Cars[CarIndex].CarBrake.straightAirPipe.CurrentPressure);
 }
コード例 #24
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns the speed of the selected car </summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The car for which to get the speed</param>
 /// <returns>The speed in m/s</returns>
 public static double speed(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(0);
     }
     if (CarIndex > Train.Cars.Length)
     {
         return(Train.Cars[0].CurrentSpeed);
     }
     return(Train.Cars[CarIndex].CurrentSpeed);
 }
コード例 #25
0
ファイル: TrainManager.cs プロジェクト: s520/OpenBVE
 /// <summary>Called after passengers have finished boarding, in order to update the train's mass from the new passenger ratio</summary>
 /// <param name="Train">The train</param>
 internal static void UpdateTrainMassFromPassengerRatio(TrainBase Train)
 {
     for (int i = 0; i < Train.Cars.Length; i++)
     {
         double       area = Train.Cars[i].Width * Train.Cars[i].Length;
         const double passengersPerArea = 1.0;
         double       randomFactor      = 0.9 + 0.2 * RandomNumberGenerator.NextDouble();
         double       passengers        = Math.Round(randomFactor * Train.Passengers.PassengerRatio * passengersPerArea * area);
         const double massPerPassenger  = 70.0;
         double       passengerMass     = passengers * massPerPassenger;
         Train.Cars[i].CargoMass = passengerMass;
     }
 }
コード例 #26
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
            /// <summary>Whether the selected train has a hold brake</summary>
            /// <param name="Train">The selected train</param>
            /// <param name="pluginState">The plugin state to query</param>
            /// <returns>The plugin state value</returns>
            public static int pluginState(TrainBase Train, int pluginState)
            {
                if (Train == null || Train.Plugin == null)
                {
                    return(0);
                }

                if (pluginState >= 0 & pluginState < Train.Plugin.Panel.Length)
                {
                    return(Train.Plugin.Panel[pluginState]);
                }
                return(0);
            }
コード例 #27
0
ファイル: SoundCfg.Ats.cs プロジェクト: zbx1425/OpenBVE
        /// <summary>Loads the default ATS plugin sound set</summary>
        /// <param name="train">The train</param>
        private void LoadDefaultATSSounds(TrainBase train)
        {
            Vector3      position = new Vector3(train.Cars[train.DriverCar].Driver.X, train.Cars[train.DriverCar].Driver.Y, train.Cars[train.DriverCar].Driver.Z + 1.0);
            const double radius   = 2.0;

            train.Cars[train.DriverCar].Sounds.Plugin = new[] {
                new CarSound(Plugin.currentHost, train.TrainFolder, "ats.wav", radius, position),
                new CarSound(Plugin.currentHost, train.TrainFolder, "atscnt.wav", radius, position),
                new CarSound(Plugin.currentHost, train.TrainFolder, "ding.wav", radius, position),
                new CarSound(Plugin.currentHost, train.TrainFolder, "toats.wav", radius, position),
                new CarSound(Plugin.currentHost, train.TrainFolder, "toatc.wav", radius, position),
                new CarSound(Plugin.currentHost, train.TrainFolder, "eb.wav", radius, position)
            };
        }
コード例 #28
0
 internal bool ParseTrain(string fileName, TrainBase train)
 {
     for (int i = 0; i < train.Cars.Length; i++)
     {
         try
         {
             Parse(fileName, ref train, ref train.Cars[i], i == train.DriverCar);
         }
         catch
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #29
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
            /// <summary>Returns the track distance to the nearest car of the selected train</summary>
            /// <param name="Train">The selected train</param>
            /// <param name="CarIndex">The selected car</param>
            /// <param name="TrackPosition">The object's track position</param>
            /// <returns>The distance to the object</returns>
            public static double trackDistance(TrainBase Train, int CarIndex, double TrackPosition)
            {
                if (Train == null)
                {
                    return(0.0);
                }
                if (Train.Cars.Length > CarIndex)
                {
                    CarIndex = Train.Cars.Length - 1;
                }
                double t1 = Train.Cars[CarIndex].RearAxle.Follower.TrackPosition - Train.Cars[CarIndex].RearAxle.Position -
                            0.5 * Train.Cars[CarIndex].Length;

                return(TrackPosition < t1 ? TrackPosition - t1 : 0.0);
            }
コード例 #30
0
ファイル: Scripting.cs プロジェクト: zbx1425/OpenBVE
 /// <summary>Returns whether the left doors are opening for the selected car of the selected train</summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The selected car</param>
 /// <returns>True if the doors are opening, false otherwise</returns>
 public static bool rightDoorsTarget(TrainBase Train, int CarIndex)
 {
     if (Train == null)
     {
         return(false);
     }
     if (Train.Cars.Length <= CarIndex)
     {
         if (Train.Cars[CarIndex].Doors[1].AnticipatedOpen)
         {
             return(true);
         }
     }
     return(false);
 }