示例#1
0
        private static void ApplyBrakingForce(BrakeSystem car, ExtraBrakeState state)
        {
            var cylinderBrakingFactor   = Mathf.InverseLerp(Main.settings.returnSpringStrength, Constants.FullApplicationPressure, state.cylinderPressure);
            var mechanicalBrakingFactor = GetMechanicalBrakeFactor(car);

            car.brakingFactor = Mathf.Max(mechanicalBrakingFactor, cylinderBrakingFactor);
        }
示例#2
0
 private static void UpdateBrakePipeGauge(BrakeSystem car, ExtraBrakeState state)
 {
     // AirBrake.DebugLog(car, $"before: BP={ExtraBrakeState.Instance(car).brakePipePressureUnsmoothed}, gauge={car.brakePipePressure}, vel={car.brakePipePressureRef}");
     car.brakePipePressure = Mathf.SmoothDamp(
         car.brakePipePressure,
         state.brakePipePressureUnsmoothed,
         ref car.brakePipePressureRef, 0.2f);
     // AirBrake.DebugLog(car, $"after: BP={ExtraBrakeState.Instance(car).brakePipePressureUnsmoothed}, gauge={car.brakePipePressure}, vel={car.brakePipePressureRef}");
 }
示例#3
0
 private static void UpdateHUD(TrainCar trainCar, ExtraBrakeState state)
 {
     if (CarTypes.IsAnyLocomotiveOrTender(trainCar.carType))
     {
         HeadsUpDisplayBridge.instance?.UpdateEqualizingReservoirPressure(trainCar, state.equalizingReservoirPressure);
     }
     else
     {
         HeadsUpDisplayBridge.instance?.UpdateAuxReservoirPressure(trainCar, state.auxReservoirPressure);
     }
     HeadsUpDisplayBridge.instance?.UpdateBrakeCylinderPressure(trainCar, state.cylinderPressure);
 }
示例#4
0
        private static void Update(BrakeSystem car, float dt)
        {
            var state = ExtraBrakeState.Instance(car);

            foreach (var c**k in new HoseAndCock[] { car.Front, car.Rear })
            {
                float rate = c**k.IsOpenToAtmosphere
                    ? AirFlow.Vent(
                    dt,
                    ref state.brakePipePressureUnsmoothed,
                    Constants.BrakePipeVolume,
                    VentRate)
                    : 0f;
                // AirBrake.DebugLog(car, $"cockOpen={c**k.IsOpenToAtmosphere}, ventRate={rate}");
                c**k.exhaustFlow = Mathf.SmoothDamp(c**k.exhaustFlow, rate, ref c**k.exhaustFlowRef, 0.1f);
            }
        }
示例#5
0
 private static void RechargeMainReservoir(BrakeSystem car, ExtraBrakeState state, float dt)
 {
     if (car.compressorRunning)
     {
         var increase = car.compressorProductionRate * Main.settings.compressorSpeed * dt;
         car.mainReservoirPressureUnsmoothed =
             Mathf.Clamp(car.mainReservoirPressureUnsmoothed + increase, 0f, Constants.MaxMainReservoirPressure);
     }
     AirFlow.OneWayFlow(
         dt,
         ref car.mainReservoirPressureUnsmoothed,
         ref state.brakePipePressureUnsmoothed,
         Constants.MainReservoirVolume,
         Constants.BrakePipeVolume,
         float.PositiveInfinity);
     car.mainReservoirPressure = Mathf.SmoothDamp(car.mainReservoirPressure, car.mainReservoirPressureUnsmoothed, ref car.mainResPressureRef, 0.8f);
 }
示例#6
0
 public static ref float CylinderPressure(this BrakeSystem brakeSystem) =>
 ref ExtraBrakeState.Instance(brakeSystem).cylinderPressure;