AddBlackBoxEntry() static private method

static private AddBlackBoxEntry ( BlackBoxEventToken EventToken ) : void
EventToken BlackBoxEventToken
return void
Beispiel #1
0
            /// <summary>Moves the air brake handle</summary>
            /// <param name="RelativeDirection">The direction: -1 for decrease, 1 for increase</param>
            internal void ApplyAirBrakeHandle(int RelativeDirection)
            {
                if (Handles.Brake is AirBrakeHandle)
                {
                    if (RelativeDirection == -1)
                    {
                        if (Handles.Brake.Driver == (int)AirBrakeHandleState.Service)
                        {
                            ApplyAirBrakeHandle(AirBrakeHandleState.Lap);
                        }
                        else
                        {
                            ApplyAirBrakeHandle(AirBrakeHandleState.Release);
                        }
                    }
                    else if (RelativeDirection == 1)
                    {
                        if (Handles.Brake.Driver == (int)AirBrakeHandleState.Release)
                        {
                            ApplyAirBrakeHandle(AirBrakeHandleState.Lap);
                        }
                        else
                        {
                            ApplyAirBrakeHandle(AirBrakeHandleState.Service);
                        }
                    }

                    Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                }
            }
Beispiel #2
0
            /// <summary>Applies a reverser notch</summary>
            /// <param name="Value">The notch to apply</param>
            /// <param name="Relative">Whether this is an absolute value or relative to the previous</param>
            internal void ApplyReverser(int Value, bool Relative)
            {
                int a = (int)Handles.Reverser.Driver;
                int r = Relative ? a + Value : Value;

                if (r < -1)
                {
                    r = -1;
                }

                if (r > 1)
                {
                    r = 1;
                }

                if (a != r)
                {
                    Handles.Reverser.Driver = (ReverserPosition)r;
                    if (Plugin != null)
                    {
                        Plugin.UpdateReverser();
                    }
                    Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                    // sound
                    if (a == 0 & r != 0)
                    {
                        Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.ReverserOn.Buffer;
                        if (buffer == null)
                        {
                            return;
                        }

                        Vector3 pos = Cars[DriverCar].Sounds.ReverserOn.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                    }
                    else if (a != 0 & r == 0)
                    {
                        Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.ReverserOff.Buffer;
                        if (buffer == null)
                        {
                            return;
                        }

                        Vector3 pos = Cars[DriverCar].Sounds.ReverserOff.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                    }
                }
            }
Beispiel #3
0
            /// <summary>Moves the air brake handle to the specified state</summary>
            /// <param name="newState">The state</param>
            internal void ApplyLocoAirBrakeHandle(AirBrakeHandleState newState)
            {
                if (Handles.LocoBrake is LocoAirBrakeHandle)
                {
                    if ((int)newState != Handles.LocoBrake.Driver)
                    {
                        // sound when moved to service
                        if (newState == AirBrakeHandleState.Service)
                        {
                            SoundBuffer buffer = Cars[DriverCar].Sounds.Brake.Buffer;
                            if (buffer != null)
                            {
                                Vector3 pos = Cars[DriverCar].Sounds.Brake.Position;
                                Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                            }
                        }

                        // sound
                        if ((int)newState < (int)Handles.Brake.Driver)
                        {
                            // brake release
                            if ((int)newState > 0)
                            {
                                // brake release (not min)
                                SoundBuffer buffer;
                                if ((Handles.Brake.Driver - (int)newState > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer != null)
                                {
                                    buffer = Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer;
                                }
                                else
                                {
                                    buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                                }
                                if (buffer != null)
                                {
                                    Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                                    Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                                }
                            }
                            else
                            {
                                // brake min
                                SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleMin.Buffer;
                                if (buffer != null)
                                {
                                    Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleMin.Position;
                                    Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                                }
                            }
                        }
                        else if ((int)newState > (int)Handles.LocoBrake.Driver)
                        {
                            // brake
                            SoundBuffer buffer;
                            if (((int)newState - (int)Handles.LocoBrake.Driver > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer != null)
                            {
                                buffer = Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer;
                            }
                            else
                            {
                                buffer = Cars[DriverCar].Sounds.BrakeHandleApply.Buffer;
                            }
                            if (buffer != null)
                            {
                                Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleApply.Position;
                                Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                            }
                        }

                        // apply
                        Handles.LocoBrake.Driver = (int)newState;
                        Handles.LocoBrake.Actual = (int)newState;                          //TODO: FIXME
                        Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                        // plugin
                        if (Plugin != null)
                        {
                            Plugin.UpdatePower();
                            Plugin.UpdateBrake();
                        }
                    }
                }
            }
Beispiel #4
0
            /// <summary>Applies a power and / or brake notch to this train</summary>
            /// <param name="PowerValue">The power notch value</param>
            /// <param name="PowerRelative">Whether this is relative to the current notch</param>
            /// <param name="BrakeValue">The brake notch value</param>
            /// <param name="BrakeRelative">Whether this is relative to the current notch</param>
            /// <param name="IsOverMaxDriverNotch"></param>
            internal void ApplyNotch(int PowerValue, bool PowerRelative, int BrakeValue, bool BrakeRelative, bool IsOverMaxDriverNotch = false)
            {
                // determine notch
                int p = PowerRelative ? PowerValue + Handles.Power.Driver : PowerValue;

                if (p < 0)
                {
                    p = 0;
                }
                else if (p > Handles.Power.MaximumNotch)
                {
                    p = Handles.Power.MaximumNotch;
                }
                if (!IsOverMaxDriverNotch && p > Handles.Power.MaximumDriverNotch)
                {
                    p = Handles.Power.MaximumDriverNotch;
                }

                int b = BrakeRelative ? BrakeValue + Handles.Brake.Driver : BrakeValue;

                if (b < 0)
                {
                    b = 0;
                }
                else if (b > Handles.Brake.MaximumNotch)
                {
                    b = Handles.Brake.MaximumNotch;
                }
                if (!IsOverMaxDriverNotch && b > Handles.Brake.MaximumDriverNotch)
                {
                    b = Handles.Brake.MaximumDriverNotch;
                }

                // power sound
                if (p < Handles.Power.Driver)
                {
                    if (p > 0)
                    {
                        // down (not min)
                        SoundBuffer buffer;
                        if ((Handles.Power.Driver - p > 2 | Cars[DriverCar].Sounds.PowerHandleFast) && Cars[DriverCar].Sounds.MasterControllerDownFast.Buffer != null)
                        {
                            buffer = Cars[DriverCar].Sounds.MasterControllerDownFast.Buffer;
                        }
                        else
                        {
                            buffer = Cars[DriverCar].Sounds.MasterControllerDown.Buffer;
                        }
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.MasterControllerDown.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                    else
                    {
                        // min
                        SoundBuffer buffer = Cars[DriverCar].Sounds.MasterControllerMin.Buffer;
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.MasterControllerMin.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                }
                else if (p > Handles.Power.Driver)
                {
                    if (p < Handles.Power.MaximumDriverNotch)
                    {
                        // up (not max)
                        SoundBuffer buffer;
                        if ((Handles.Power.Driver - p > 2 | Cars[DriverCar].Sounds.PowerHandleFast) && Cars[DriverCar].Sounds.MasterControllerUpFast.Buffer != null)
                        {
                            buffer = Cars[DriverCar].Sounds.MasterControllerUpFast.Buffer;
                        }
                        else
                        {
                            buffer = Cars[DriverCar].Sounds.MasterControllerUp.Buffer;
                        }
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.MasterControllerUp.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                    else
                    {
                        // max
                        SoundBuffer buffer = Cars[DriverCar].Sounds.MasterControllerMax.Buffer;
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.MasterControllerMax.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                }

                // brake sound
                if (b < Handles.Brake.Driver)
                {
                    // brake release
                    SoundBuffer buffer = Cars[DriverCar].Sounds.Brake.Buffer;
                    if (buffer != null)
                    {
                        Vector3 pos = Cars[DriverCar].Sounds.Brake.Position;
                        Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                    }

                    if (b > 0)
                    {
                        // brake release (not min)
                        if ((Handles.Brake.Driver - b > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer != null)
                        {
                            buffer = Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer;
                        }
                        else
                        {
                            buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                        }
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                    else
                    {
                        // brake min
                        buffer = Cars[DriverCar].Sounds.BrakeHandleMin.Buffer;
                        if (buffer != null)
                        {
                            Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleMin.Position;
                            Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                        }
                    }
                }
                else if (b > Handles.Brake.Driver)
                {
                    // brake
                    SoundBuffer buffer;
                    if ((b - Handles.Brake.Driver > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer != null)
                    {
                        buffer = Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer;
                    }
                    else
                    {
                        buffer = Cars[DriverCar].Sounds.BrakeHandleApply.Buffer;
                    }

                    if (buffer != null)
                    {
                        Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleApply.Position;
                        Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                    }
                }

                // apply notch
                if (Handles.SingleHandle)
                {
                    if (b != 0)
                    {
                        p = 0;
                    }
                }

                Handles.Power.Driver = p;
                Handles.Brake.Driver = b;
                Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                // plugin
                if (Plugin != null)
                {
                    Plugin.UpdatePower();
                    Plugin.UpdateBrake();
                }
            }
Beispiel #5
0
 public override void AddBlackBoxEntry()
 {
     Game.AddBlackBoxEntry();
 }
Beispiel #6
0
            /// <summary>Moves the air brake handle to the specified state</summary>
            /// <param name="State">The state</param>
            internal void ApplyAirBrakeHandle(AirBrakeHandleState State)
            {
                if (Handles.Brake is AirBrakeHandle)
                {
                    if ((int)State != Handles.Brake.Driver)
                    {
                        // sound when moved to service
                        if (State == AirBrakeHandleState.Service)
                        {
                            Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.Brake.Buffer;
                            if (buffer != null)
                            {
                                OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.Brake.Position;
                                Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                            }
                        }

                        // sound
                        if ((int)State < (int)Handles.Brake.Driver)
                        {
                            // brake release
                            if ((int)State > 0)
                            {
                                // brake release (not min)
                                Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                                if (buffer != null)
                                {
                                    OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                                }
                            }
                            else
                            {
                                // brake min
                                Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleMin.Buffer;
                                if (buffer != null)
                                {
                                    OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleMin.Position;
                                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                                }
                            }
                        }
                        else if ((int)State > (int)Handles.Brake.Driver)
                        {
                            // brake
                            Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleApply.Buffer;
                            if (buffer != null)
                            {
                                OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleApply.Position;
                                Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                            }
                        }

                        // apply
                        Handles.Brake.Driver = (int)State;
                        Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                        // plugin
                        if (Plugin != null)
                        {
                            Plugin.UpdatePower();
                            Plugin.UpdateBrake();
                        }
                    }
                }
            }
Beispiel #7
0
        // apply notch
        internal static void ApplyNotch(Train Train, int PowerValue, bool PowerRelative, int BrakeValue, bool BrakeRelative)
        {
            // determine notch
            int p = PowerRelative ? PowerValue + Train.Specs.CurrentPowerNotch.Driver : PowerValue;

            if (p < 0)
            {
                p = 0;
            }
            else if (p > Train.Specs.MaximumPowerNotch)
            {
                p = Train.Specs.MaximumPowerNotch;
            }
            int b = BrakeRelative ? BrakeValue + Train.Specs.CurrentBrakeNotch.Driver : BrakeValue;

            if (b < 0)
            {
                b = 0;
            }
            else if (b > Train.Specs.MaximumBrakeNotch)
            {
                b = Train.Specs.MaximumBrakeNotch;
            }
            // power sound
            if (p < Train.Specs.CurrentPowerNotch.Driver)
            {
                if (p > 0)
                {
                    // down (not min)
                    Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.MasterControllerDown.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.MasterControllerDown.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
                else
                {
                    // min
                    Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.MasterControllerMin.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.MasterControllerMin.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
            }
            else if (p > Train.Specs.CurrentPowerNotch.Driver)
            {
                if (p < Train.Specs.MaximumPowerNotch)
                {
                    // up (not max)
                    Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.MasterControllerUp.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.MasterControllerUp.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
                else
                {
                    // max
                    Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.MasterControllerMax.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.MasterControllerMax.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
            }
            // brake sound
            if (b < Train.Specs.CurrentBrakeNotch.Driver)
            {
                // brake release
                Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.Brake.Buffer;
                if (buffer != null)
                {
                    OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.Brake.Position;
                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                }
                if (b > 0)
                {
                    // brake release (not min)
                    buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
                else
                {
                    // brake min
                    buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Buffer;
                    if (buffer != null)
                    {
                        OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                    }
                }
            }
            else if (b > Train.Specs.CurrentBrakeNotch.Driver)
            {
                // brake
                Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Buffer;
                if (buffer != null)
                {
                    OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Position;
                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                }
            }
            // apply notch
            if (Train.Specs.SingleHandle)
            {
                if (b != 0)
                {
                    p = 0;
                }
            }
            Train.Specs.CurrentPowerNotch.Driver = p;
            Train.Specs.CurrentBrakeNotch.Driver = b;
            Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
            // plugin
            if (Train.Plugin != null)
            {
                Train.Plugin.UpdatePower();
                Train.Plugin.UpdateBrake();
            }
        }