Esempio n. 1
0
        internal void LeaveCheck(Vector2 Point)
        {
            if (!Loading.SimulationSetup)
            {
                return;
            }

            if (renderer.Camera.CurrentMode != CameraViewMode.Interior && renderer.Camera.CurrentMode != CameraViewMode.InteriorLookAhead)
            {
                return;
            }

            TrainManager.Car Car = TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar];
            int add = Car.CarSections[0].CurrentAdditionalGroup + 1;

            if (add >= Car.CarSections[0].Groups.Length)
            {
                return;
            }

            TrainManager.TouchElement[] TouchElements = Car.CarSections[0].Groups[add].TouchElements;

            if (TouchElements == null)
            {
                return;
            }

            ObjectState pickedObject = ParseFBO(Point, 5, 5);

            foreach (TrainManager.TouchElement TouchElement in TouchElements)
            {
                if (TouchElement.Element.internalObject == pickedObject)
                {
                    Car.CarSections[0].CurrentAdditionalGroup = TouchElement.JumpScreenIndex;
                    Car.ChangeCarSection(TrainManager.CarSectionType.Interior);

                    foreach (var index in TouchElement.SoundIndices.Where(x => x >= 0 && x < Car.Sounds.Touch.Length))
                    {
                        SoundBuffer             Buffer   = Car.Sounds.Touch[index].Buffer;
                        OpenBveApi.Math.Vector3 Position = Car.Sounds.Touch[index].Position;
                        Program.Sounds.PlaySound(Buffer, 1.0, 1.0, Position, TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar], false);
                    }
                }

                // HACK: Normally terminate the command issued once.
                if (TouchElement.Element.internalObject == pickedObject || (pickedObject != prePickedObject && TouchElement.Element.internalObject == prePickedObject))
                {
                    foreach (int index in TouchElement.ControlIndices)
                    {
                        Interface.CurrentControls[index].AnalogState  = 0.0;
                        Interface.CurrentControls[index].DigitalState = Interface.DigitalControlState.Released;
                        MainLoop.RemoveControlRepeat(index);
                    }
                }
            }
        }
Esempio n. 2
0
        internal void LeaveCheck(Vector2 Point)
        {
            if (!Loading.SimulationSetup)
            {
                return;
            }

            if (renderer.Camera.CurrentMode != CameraViewMode.Interior && renderer.Camera.CurrentMode != CameraViewMode.InteriorLookAhead)
            {
                return;
            }

            TrainManager.Car Car = TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar];
            int add = Car.CarSections[0].CurrentAdditionalGroup + 1;

            if (add >= Car.CarSections[0].Groups.Length)
            {
                return;
            }

            TrainManager.TouchElement[] TouchElements = Car.CarSections[0].Groups[add].TouchElements;

            if (TouchElements == null)
            {
                return;
            }

            ObjectState pickedObject = ParseFBO(Point, 5, 5);

            foreach (TrainManager.TouchElement TouchElement in TouchElements)
            {
                if (TouchElement.Element.internalObject == pickedObject)
                {
                    Car.CarSections[0].CurrentAdditionalGroup = TouchElement.JumpScreenIndex;
                    Car.ChangeCarSection(TrainManager.CarSectionType.Interior);

                    if (TouchElement.SoundIndex >= 0 && TouchElement.SoundIndex < Car.Sounds.Touch.Length)
                    {
                        SoundBuffer             Buffer   = Car.Sounds.Touch[TouchElement.SoundIndex].Buffer;
                        OpenBveApi.Math.Vector3 Position = Car.Sounds.Touch[TouchElement.SoundIndex].Position;
                        Program.Sounds.PlaySound(Buffer, 1.0, 1.0, Position, TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar], false);
                    }
                }

                // HACK: Normally terminate the command issued once.
                if (TouchElement.Element.internalObject == pickedObject || (pickedObject != prePickedObject && TouchElement.Element.internalObject == prePickedObject))
                {
                    for (int i = 0; i < Interface.CurrentControls.Length; i++)
                    {
                        if (Interface.CurrentControls[i].Method != Interface.ControlMethod.Touch)
                        {
                            continue;
                        }

                        bool EnableOption = false;

                        for (int j = 0; j < Translations.CommandInfos.Length; j++)
                        {
                            if (Interface.CurrentControls[i].Command == Translations.CommandInfos[j].Command)
                            {
                                EnableOption = Translations.CommandInfos[j].EnableOption;
                                break;
                            }
                        }

                        if (TouchElement.Command == Interface.CurrentControls[i].Command)
                        {
                            if (EnableOption && TouchElement.CommandOption != Interface.CurrentControls[i].Option)
                            {
                                continue;
                            }

                            Interface.CurrentControls[i].AnalogState  = 0.0;
                            Interface.CurrentControls[i].DigitalState = Interface.DigitalControlState.Released;
                            MainLoop.RemoveControlRepeat(i);
                        }
                    }
                }
            }
        }