示例#1
0
        /// <summary>1フレームごとに呼び出される関数</summary>
        /// <param name="data">The data.</param>
        internal void Elapse(ElapseData data)
        {
            this.PluginInitializing = false;
            if (data.ElapsedTime.Seconds > 0.0 && data.ElapsedTime.Seconds < 1.0)
            {
                // --- パネル初期化 ---
                for (int i = 0; i < this.Panel.Length; i++)
                {
                    this.Panel[i] = 0;
                }

                // --- 保安装置 ---
                this.State   = data.Vehicle;
                this.Handles = new ReadOnlyHandles(data.Handles);
                bool blocking = false;
                foreach (Device device in this.Devices)
                {
                    device.Elapse(data, ref blocking);
                }

                // For Safety
                if (this.Doors != DoorStates.None)
                {
                    data.Handles.PowerNotch = 0;
                }

                // --- パネル ---

                // --- サウンド ---
                this.Sounds.Elapse(data);
            }
        }
示例#2
0
 // --- constructors ---
 /// <summary>Creates a new train without any devices installed.</summary>
 /// <param name="panel">The array of panel variables.</param>
 /// <param name="playSound">The delegate to play sounds.</param>
 internal Train(int[] panel, PlaySoundDelegate playSound)
 {
     this.PluginInitializing = false;
     this.Specs   = new VehicleSpecs(0, BrakeTypes.ElectromagneticStraightAirBrake, 0, false, 0);
     this.State   = new VehicleState(0.0, new Speed(0.0), 0.0, 0.0, 0.0, 0.0, 0.0);
     this.Handles = new ReadOnlyHandles(new Handles(0, 0, 0, false));
     this.Doors   = DoorStates.None;
     this.Panel   = panel;
     this.Sounds  = new Sounds(playSound);
     this.AI      = new AI(this);
 }
示例#3
0
文件: Train.cs 项目: sladen/openbve
 // --- constructors ---
 /// <summary>Creates a new train without any devices installed.</summary>
 /// <param name="panel">The array of panel variables.</param>
 /// <param name="playSound">The delegate to play sounds.</param>
 internal Train(int[] panel, PlaySoundDelegate playSound)
 {
     this.PluginInitializing = false;
     this.Specs = new VehicleSpecs(0, BrakeTypes.ElectromagneticStraightAirBrake, 0, false, 0);
     this.State = new VehicleState(0.0, new Speed(0.0), 0.0, 0.0, 0.0, 0.0, 0.0);
     this.Handles = new ReadOnlyHandles(new Handles(0, 0, 0, false));
     this.Doors = DoorStates.None;
     this.Panel = panel;
     this.Sounds = new Sounds(playSound);
     this.AI = new AI(this);
 }
示例#4
0
 // --- コンストラクタ ---
 /// <summary>新しいインスタンスを作成する</summary>
 /// <param name="panel">パネルに渡す値</param>
 /// <param name="playSound">サウンドを再生するためのデリゲート</param>
 internal Train(int[] panel, PlaySoundDelegate playSound)
 {
     this.PluginInitializing = false;
     this.Specs   = new VehicleSpecs(0, BrakeTypes.ElectromagneticStraightAirBrake, 0, false, 0);
     this.State   = new VehicleState(0.0, new Speed(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
     this.Handles = new ReadOnlyHandles(new Handles(0, 0, 0, false));
     this.Doors   = DoorStates.None;
     this.Panel   = panel;
     this.Sounds  = new Sounds(playSound);
     this.Accel   = new Accel();
     this.Atc     = new Atc(this);
     this.AtsP    = new AtsP(this);
     this.Wiper   = new Wiper(this);
     this.Sub     = new Sub(this);
     this.Devices = new Device[] { this.Accel, this.Atc, this.AtsP, this.Wiper, this.Sub };
 }
示例#5
0
        /// <summary>1フレームごとに呼び出される関数</summary>
        /// <param name="data">The data.</param>
        internal void Elapse(ElapseData data)
        {
            this.PluginInitializing = false;
            if (data.ElapsedTime.Seconds > 0.0 && data.ElapsedTime.Seconds < 1.0)
            {
                // --- パネル初期化 ---
                for (int i = 0; i < this.Panel.Length; i++)
                {
                    this.Panel[i] = 0;
                }

                // --- 保安装置 ---
                this.State   = data.Vehicle;
                this.Handles = new ReadOnlyHandles(data.Handles);
                bool blocking = false;
                foreach (Device device in this.Devices)
                {
                    device.Elapse(data, ref blocking);
                }

                // For Safety
                if (this.Doors != DoorStates.None)
                {
                    data.Handles.PowerNotch = 0;
                }

                // --- パネル ---
                int seconds = (int)Math.Floor(data.TotalTime.Seconds);
                this.Panel[10]  = (seconds / 3600) % 24;
                this.Panel[11]  = (seconds / 60) % 60;
                this.Panel[12]  = seconds % 60;
                this.Panel[194] = (((int)data.Vehicle.Location + this.Sub.adj_loc_) % 1000000) / 100000;
                this.Panel[195] = (((int)data.Vehicle.Location + this.Sub.adj_loc_) % 100000) / 10000;
                this.Panel[196] = (((int)data.Vehicle.Location + this.Sub.adj_loc_) % 10000) / 1000;
                this.Panel[197] = (((int)data.Vehicle.Location + this.Sub.adj_loc_) % 1000) / 100;
                this.Panel[198] = (((int)data.Vehicle.Location + this.Sub.adj_loc_) % 100) / 10;
                this.Panel[199] = ((int)data.Vehicle.Location + this.Sub.adj_loc_) % 10;
                this.Panel[216] = (int)(data.Vehicle.BcPressure / 98.0665 * 100.0);
                this.Panel[217] = (int)(data.Vehicle.SapPressure / 98.0665 * 100.0);
                this.Panel[218] = (int)(data.Vehicle.MrPressure / 98.0665 * 100.0);
                this.Panel[219] = (data.Vehicle.Speed.KilometersPerHour >= 30.0 && data.Handles.BrakeNotch != 0) ? 1 : 0;

                // --- サウンド ---
                this.Sounds.Elapse(data);
            }
        }
示例#6
0
 /// <summary>Is called every frame.</summary>
 /// <param name="data">The data.</param>
 internal void Elapse(ElapseData data)
 {
     this.PluginInitializing = false;
     if (data.ElapsedTime.Seconds > 0.0 & data.ElapsedTime.Seconds < 1.0)
     {
         // --- panel ---
         for (int i = 0; i < this.Panel.Length; i++)
         {
             this.Panel[i] = 0;
         }
         // --- devices ---
         this.State   = data.Vehicle;
         this.Handles = new ReadOnlyHandles(data.Handles);
         bool blocking = false;
         foreach (Device device in this.Devices)
         {
             device.Elapse(data, ref blocking);
         }
         // --- panel ---
         int seconds = (int)Math.Floor(data.TotalTime.Seconds);
         this.Panel[10]  = (seconds / 3600) % 24;
         this.Panel[11]  = (seconds / 60) % 60;
         this.Panel[12]  = seconds % 60;
         this.Panel[269] = data.Handles.ConstSpeed ? 1 : 0;
         if (data.Handles.Reverser != 0 & (this.Handles.PowerNotch > 0 & this.Handles.BrakeNotch == 0 | this.Handles.PowerNotch == 0 & this.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake))
         {
             this.Panel[100] = 1;
         }
         if (data.Handles.BrakeNotch >= this.Specs.AtsNotch & data.Handles.BrakeNotch <= this.Specs.BrakeNotches | data.Handles.Reverser != 0 & data.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake)
         {
             this.Panel[101] = 1;
         }
         // --- sound ---
         this.Sounds.Elapse(data);
     }
 }
示例#7
0
		/// <summary>Is called every frame.</summary>
		/// <param name="data">The data.</param>
		internal void Elapse(ElapseData data) {
			this.PluginInitializing = false;
			if (data.ElapsedTime.Seconds > 0.0 & data.ElapsedTime.Seconds < 1.0) {
				// --- panel ---
				for (int i = 0; i < this.Panel.Length; i++) {
					this.Panel[i] = 0;
				}
				// --- devices ---
				this.State = data.Vehicle;
				this.Handles = new ReadOnlyHandles(data.Handles);
				bool blocking = false;
				foreach (Device device in this.Devices) {
					device.Elapse(data, ref blocking);
				}
				// --- panel ---
				int seconds = (int)Math.Floor(data.TotalTime.Seconds);
				this.Panel[10] = (seconds / 3600) % 24;
				this.Panel[11] = (seconds / 60) % 60;
				this.Panel[12] = seconds % 60;
				this.Panel[269] = data.Handles.ConstSpeed ? 1 : 0;
				if (data.Handles.Reverser != 0 & (this.Handles.PowerNotch > 0 & this.Handles.BrakeNotch == 0 | this.Handles.PowerNotch == 0 & this.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake)) {
					this.Panel[100] = 1;
				}
				if (data.Handles.BrakeNotch >= this.Specs.AtsNotch & data.Handles.BrakeNotch <= this.Specs.BrakeNotches | data.Handles.Reverser != 0 & data.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake) {
					this.Panel[101] = 1;
				}
				// --- sound ---
				this.Sounds.Elapse(data);
			}
		}
示例#8
0
 /// <summary>Is called every frame.</summary>
 /// <param name="data">The data.</param>
 internal void Elapse(ElapseData data)
 {
     this.PluginInitializing = false;
     if (data.ElapsedTime.Seconds > 0.0 & data.ElapsedTime.Seconds < 1.0)
     {
         // --- panel ---
         for (int i = 0; i < this.Panel.Length; i++)
         {
             this.Panel[i] = 0;
         }
         // --- devices ---
         this.State   = data.Vehicle;
         this.Handles = new ReadOnlyHandles(data.Handles);
         bool blocking = false;
         foreach (var device in this.Devices)
         {
             device.Elapse(data, ref blocking);
         }
         if (data.Handles.BrakeNotch != 0)
         {
             data.Handles.PowerNotch = 0;
         }
         // --- panel ---
         this.Panel[255] = 1;
         int seconds = (int)Math.Floor(data.TotalTime.Seconds);
         this.Panel[10]  = (seconds / 3600) % 24;
         this.Panel[11]  = (seconds / 60) % 60;
         this.Panel[12]  = seconds % 60;
         this.Panel[269] = data.Handles.ConstSpeed ? 1 : 0;
         if (data.Handles.Reverser != 0 & (this.Handles.PowerNotch > 0 & this.Handles.BrakeNotch == 0 | this.Handles.PowerNotch == 0 & this.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake))
         {
             this.Panel[100] = 1;
         }
         if (data.Handles.BrakeNotch >= this.Specs.AtsNotch & data.Handles.BrakeNotch <= this.Specs.BrakeNotches | data.Handles.Reverser != 0 & data.Handles.BrakeNotch == 1 & this.Specs.HasHoldBrake)
         {
             this.Panel[101] = 1;
         }
         for (int i = (int)VirtualKeys.S; i <= (int)VirtualKeys.C2; i++)
         {
             if (KeysPressed[i])
             {
                 this.Panel[93 + i] = 1;
             }
         }
         if (PanelIllumination)
         {
             this.Panel[161] = 1;
         }
         // --- accelerometer ---
         this.AccelerometerTimer += data.ElapsedTime.Seconds;
         if (this.AccelerometerTimer > AccelerometerMaximumTimer)
         {
             this.Acceleration       = (data.Vehicle.Speed.MetersPerSecond - AccelerometerSpeed) / this.AccelerometerTimer;
             this.AccelerometerSpeed = data.Vehicle.Speed.MetersPerSecond;
             this.AccelerometerTimer = 0.0;
         }
         if (this.Acceleration < 0.0)
         {
             double value = -3.6 * this.Acceleration;
             if (value >= 10.0)
             {
                 this.Panel[74] = 9;
                 this.Panel[75] = 9;
             }
             else
             {
                 this.Panel[74] = (int)Math.Floor(value) % 10;
                 this.Panel[75] = (int)Math.Floor(10.0 * value) % 10;
             }
         }
         // --- sound ---
         this.Sounds.Elapse(data);
         // --- AI ---
         this.Calling.Elapse(data);
     }
 }