예제 #1
0
 public override void GetState([NotNull] BaseLocoState state)
 {
     state.Reverser       = _inner.reverser;
     state.ReverserSymbol = _inner.GetReverserSymbol();
     state.Throttle       = (float)Math.Round(_inner.throttle, 2);
     state.TargetThrottle = (float)Math.Round(_inner.targetThrottle, 2);
     state.Break          = (float)Math.Round(_inner.brake, 2);
     state.TargetBreak    = (float)Math.Round(_inner.targetBrake, 2);
     state.Derailed       = _inner.IsDerailed();
     state.WheelSlip      = _inner.IsWheelslipping();
     state.Speed          = (float)Math.Round(_inner.GetSpeedKmH(), 2);
     state.CanCouple      = _inner.IsCouplerInRange();
     state.MinCouplePos   = -_inner.GetNumberOfCarsInRear() - 1;
     state.MaxCouplePos   = _inner.GetNumberOfCarsInFront() + 1;
     state.LocoType       = "base";
 }
예제 #2
0
        /// <summary>
        /// Determines whether this locomotive is eligible for automatic shutdown on player exit
        /// </summary>
        /// <param name="Loco">Locomotive</param>
        /// <returns>true, if should be shut down</returns>
        private static bool ShouldPerformAutoShutdown(LocoControllerBase Loco)
        {
            var s = Main.settings.ShutdownOptions;

            if (s == null)
            {
                s = new AutomaticShutdownOptions();
            }
            //Don't do anything if this object is not present
            if (Loco == null)
            {
                WarnMessage("ShouldPerformAutoShutdown argument is <null> but should not be");
                return(false);
            }
            //Don't shut down if cars are coupled
            if (s.NoCarsCoupled && (Loco.GetNumberOfCarsInFront() > 0 || Loco.GetNumberOfCarsInRear() > 0))
            {
                return(false);
            }
            //Don't shut down if a coupler is in range
            if (s.NoCarsInCouplingRange && Loco.IsCouplerInRange(LocoControllerBase.COUPLING_RANGE))
            {
                return(false);
            }
            //Don't shut down if rolling
            if (s.MustBeStationary && Math.Abs(Loco.GetSpeedKmH()) >= 1.0f)
            {
                return(false);
            }
            //Don't shut down if the reverser is not centered
            if (s.ReverserCentered && Math.Abs(Loco.reverser) >= 0.1f)
            {
                return(false);
            }
            //Don't shut down if independent brake not at least 90% applied
            if (s.IndependentBrakesApplied && Loco.independentBrake < 0.9f)
            {
                return(false);
            }
            //Don't shut down if remote controlled
            if (s.RemoteControlDisconnected && Loco.IsRemoteControlled())
            {
                return(false);
            }
            //All checks passed
            return(true);
        }