Пример #1
0
			/// <summary>Called every frame to update the plugin.</summary>
			internal void UpdatePlugin() {
				/*
				 * Prepare the vehicle state.
				 * */
				double location = this.Train.Cars[0].FrontAxle.Follower.TrackPosition - this.Train.Cars[0].FrontAxlePosition + 0.5 * this.Train.Cars[0].Length;
			    //Curve Radius, Cant and Pitch Added
                double CurrentRadius = this.Train.Cars[0].FrontAxle.Follower.CurveRadius;
                double CurrentCant = this.Train.Cars[0].FrontAxle.Follower.CurveCant;
			    double CurrentPitch = this.Train.Cars[0].FrontAxle.Follower.Pitch;
                //If the list of stations has not been loaded, do so
			    if (!StationsLoaded)
			    {
                    currentRouteStations = new List<Station>();
			        foreach (Game.Station selectedStation in Game.Stations)
			        {
				        Station i = new Station
				        {
					        Name = selectedStation.Name,
					        ArrivalTime = selectedStation.ArrivalTime,
					        DepartureTime = selectedStation.DepartureTime,
					        StopTime = selectedStation.StopTime,
					        OpenLeftDoors = selectedStation.OpenLeftDoors,
					        OpenRightDoors = selectedStation.OpenRightDoors,
					        ForceStopSignal = selectedStation.ForceStopSignal,
					        DefaultTrackPosition = selectedStation.DefaultTrackPosition
				        };
				        currentRouteStations.Add(i);
			        }
			        StationsLoaded = true;
			    }
			    //End of additions
				double speed = this.Train.Cars[this.Train.DriverCar].Specs.CurrentPerceivedSpeed;
				double bcPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.BrakeCylinderCurrentPressure;
				double mrPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.MainReservoirCurrentPressure;
				double erPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.EqualizingReservoirCurrentPressure;
				double bpPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.BrakePipeCurrentPressure;
				double sapPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.StraightAirPipeCurrentPressure;
				VehicleState vehicle = new VehicleState(location, new Speed(speed), bcPressure, mrPressure, erPressure, bpPressure, sapPressure, CurrentRadius, CurrentCant, CurrentPitch);
				/*
				 * Prepare the preceding vehicle state.
				 * */
				double bestLocation = double.MaxValue;
				double bestSpeed = 0.0;
				for (int i = 0; i < TrainManager.Trains.Length; i++) {
					if (TrainManager.Trains[i] != this.Train & TrainManager.Trains[i].State == TrainManager.TrainState.Available) {
						int c = TrainManager.Trains[i].Cars.Length - 1;
						double z = TrainManager.Trains[i].Cars[c].RearAxle.Follower.TrackPosition - TrainManager.Trains[i].Cars[c].RearAxlePosition - 0.5 * TrainManager.Trains[i].Cars[c].Length;
						if (z >= location & z < bestLocation) {
							bestLocation = z;
							bestSpeed = TrainManager.Trains[i].Specs.CurrentAverageSpeed;
						}
					}
				}
				var precedingVehicle = bestLocation != double.MaxValue ? new PrecedingVehicleState(bestLocation, bestLocation - location, new Speed(bestSpeed)) : null;
				/*
				 * Get the driver handles.
				 * */
				Handles handles = GetHandles();
				/*
				 * Update the plugin.
				 * */
				double totalTime = Game.SecondsSinceMidnight;
				double elapsedTime = Game.SecondsSinceMidnight - LastTime;
                /* 
                 * Set the current camera view mode
                 * Could probably do away with the CurrentCameraViewMode and use a direct cast??
                 * 
                 */
			    CurrentCameraViewMode = (OpenBveApi.Runtime.CameraViewMode)World.CameraMode;
				ElapseData data = new ElapseData(vehicle, precedingVehicle, handles, new Time(totalTime), new Time(elapsedTime), currentRouteStations, CurrentCameraViewMode, Interface.CurrentLanguageCode);
				LastTime = Game.SecondsSinceMidnight;
				Elapse(data);
				this.PluginMessage = data.DebugMessage;
			    DisableTimeAcceleration = data.DisableTimeAcceleration;
				/*
				 * Set the virtual handles.
				 * */
				this.PluginValid = true;
				SetHandles(data.Handles, true);
			}
Пример #2
0
            /// <summary>Called every frame to update the plugin.</summary>
            internal void UpdatePlugin()
            {
                /*
                 * Prepare the vehicle state.
                 * */
                double location = this.Train.Cars[0].FrontAxle.Follower.TrackPosition - this.Train.Cars[0].FrontAxle.Position + 0.5 * this.Train.Cars[0].Length;
                //Curve Radius, Cant and Pitch Added
                double CurrentRadius = this.Train.Cars[0].FrontAxle.Follower.CurveRadius;
                double CurrentCant   = this.Train.Cars[0].FrontAxle.Follower.CurveCant;
                double CurrentPitch  = this.Train.Cars[0].FrontAxle.Follower.Pitch;

                //If the list of stations has not been loaded, do so
                if (!StationsLoaded)
                {
                    currentRouteStations = new List <Station>();
                    foreach (Game.Station selectedStation in Game.Stations)
                    {
                        Station i = new Station
                        {
                            Name                 = selectedStation.Name,
                            ArrivalTime          = selectedStation.ArrivalTime,
                            DepartureTime        = selectedStation.DepartureTime,
                            StopTime             = selectedStation.StopTime,
                            OpenLeftDoors        = selectedStation.OpenLeftDoors,
                            OpenRightDoors       = selectedStation.OpenRightDoors,
                            ForceStopSignal      = selectedStation.ForceStopSignal,
                            DefaultTrackPosition = selectedStation.DefaultTrackPosition
                        };
                        currentRouteStations.Add(i);
                    }
                    StationsLoaded = true;
                }
                //End of additions
                double       speed       = this.Train.Cars[this.Train.DriverCar].Specs.CurrentPerceivedSpeed;
                double       bcPressure  = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.BrakeCylinderCurrentPressure;
                double       mrPressure  = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.MainReservoirCurrentPressure;
                double       erPressure  = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.EqualizingReservoirCurrentPressure;
                double       bpPressure  = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.BrakePipeCurrentPressure;
                double       sapPressure = this.Train.Cars[this.Train.DriverCar].Specs.AirBrake.StraightAirPipeCurrentPressure;
                VehicleState vehicle     = new VehicleState(location, new Speed(speed), bcPressure, mrPressure, erPressure, bpPressure, sapPressure, CurrentRadius, CurrentCant, CurrentPitch);

                /*
                 * Prepare the preceding vehicle state.
                 * */
                double bestLocation = double.MaxValue;
                double bestSpeed    = 0.0;

                for (int i = 0; i < TrainManager.Trains.Length; i++)
                {
                    if (TrainManager.Trains[i] != this.Train & TrainManager.Trains[i].State == TrainManager.TrainState.Available)
                    {
                        int    c = TrainManager.Trains[i].Cars.Length - 1;
                        double z = TrainManager.Trains[i].Cars[c].RearAxle.Follower.TrackPosition - TrainManager.Trains[i].Cars[c].RearAxle.Position - 0.5 * TrainManager.Trains[i].Cars[c].Length;
                        if (z >= location & z < bestLocation)
                        {
                            bestLocation = z;
                            bestSpeed    = TrainManager.Trains[i].Specs.CurrentAverageSpeed;
                        }
                    }
                }
                var precedingVehicle = bestLocation != double.MaxValue ? new PrecedingVehicleState(bestLocation, bestLocation - location, new Speed(bestSpeed)) : null;

                /*
                 * Get the driver handles.
                 * */
                Handles handles = GetHandles();

                /*
                 * Update the plugin.
                 * */
                double totalTime   = Game.SecondsSinceMidnight;
                double elapsedTime = Game.SecondsSinceMidnight - LastTime;

                /*
                 * Set the current camera view mode
                 * Could probably do away with the CurrentCameraViewMode and use a direct cast??
                 *
                 */
                CurrentCameraViewMode = (OpenBveApi.Runtime.CameraViewMode)World.CameraMode;
                ElapseData data = new ElapseData(vehicle, precedingVehicle, handles, (DoorInterlockStates)this.Train.Specs.DoorInterlockState, new Time(totalTime), new Time(elapsedTime), currentRouteStations, CurrentCameraViewMode, Interface.CurrentLanguageCode);

                LastTime = Game.SecondsSinceMidnight;
                Elapse(data);
                this.PluginMessage = data.DebugMessage;
                this.Train.Specs.DoorInterlockState = (TrainManager.DoorInterlockStates)data.DoorInterlockState;
                DisableTimeAcceleration             = data.DisableTimeAcceleration;

                /*
                 * Set the virtual handles.
                 * */
                this.PluginValid = true;
                SetHandles(data.Handles, true);
            }