Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     myNavMeshAgent        = GetComponent <NavMeshAgent>();
     mySelectionController = FindObjectOfType <SelectionController>();
     myRend = GetComponent <MeshRenderer>();
     brake  = GetComponent <BrakeController>();
 }
Esempio n. 2
0
        public void Initialize()
        {
            if (!Activated)
            {
                if (ScriptName != null && ScriptName != "MSTS")
                {
                    var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") };
                    Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as BrakeController;
                }
                if (Script == null)
                {
                    Script = new MSTSBrakeController() as BrakeController;
                    (Script as MSTSBrakeController).ForceControllerReleaseGraduated = Simulator.Settings.GraduatedRelease;
                }

                // AbstractScriptClass
                Script.ClockTime = () => (float)Simulator.ClockTime;
                Script.GameTime  = () => (float)Simulator.GameTime;
                Script.DistanceM = () => Locomotive.DistanceM;

                // BrakeController
                Script.EmergencyBrakingPushButton = () => EmergencyBrakingPushButton;
                Script.TCSEmergencyBraking        = () => TCSEmergencyBraking;
                Script.TCSFullServiceBraking      = () => TCSFullServiceBraking;

                Script.MainReservoirPressureBar = () =>
                {
                    if (Locomotive.Train != null)
                    {
                        return(Bar.FromPSI(Locomotive.Train.BrakeLine2PressurePSI));
                    }
                    else
                    {
                        return(float.MaxValue);
                    }
                };
                Script.MaxPressureBar        = () => Bar.FromPSI(MaxPressurePSI);
                Script.ReleaseRateBarpS      = () => BarpS.FromPSIpS(ReleaseRatePSIpS);
                Script.QuickReleaseRateBarpS = () => BarpS.FromPSIpS(QuickReleaseRatePSIpS);
                Script.ApplyRateBarpS        = () => BarpS.FromPSIpS(ApplyRatePSIpS);
                Script.EmergencyRateBarpS    = () => BarpS.FromPSIpS(EmergencyRatePSIpS);
                Script.FullServReductionBar  = () => Bar.FromPSI(FullServReductionPSI);
                Script.MinReductionBar       = () => Bar.FromPSI(MinReductionPSI);
                Script.CurrentValue          = () => CurrentValue;
                Script.MinimumValue          = () => MinimumValue;
                Script.MaximumValue          = () => MaximumValue;
                Script.StepSize    = () => StepSize;
                Script.UpdateValue = () => UpdateValue;
                Script.Notches     = () => Notches;

                Script.SetCurrentValue = (value) => CurrentValue = value;
                Script.SetUpdateValue  = (value) => UpdateValue = value;

                Script.Initialize();
            }
        }
Esempio n. 3
0
    private void Awake()
    {
        brakes = GetComponent <BrakeController> ();
        rb     = GetComponent <Rigidbody> ();

        //once the ball is moving very slowly bring it to a complete stop
        rb.sleepThreshold = 0.2f;
        // Set the maximum angular velocity so that the ball doesn't spin too wildly
        rb.maxAngularVelocity = maxAngularVelocity;

        movementModifiers = defaultMovementModifiers;
    }
Esempio n. 4
0
 private IEnumerator UnlockBrakesIfRequired(BrakeController brakes)
 {
     for (int i = 1; i <= 2; i++)
     {
         if (brakes.IsBrakeLocked())
         {
             brakes.UnlockBrakes();
         }
         yield return(new WaitForEndOfFrame());
     }
     RemoveWormhole();
 }
Esempio n. 5
0
        public void Initialize()
        {
            if (!Activated)
            {
                if (ScriptName != null && ScriptName != "MSTS")
                {
                    var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") };
                    Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as BrakeController;
                }
                if (Script == null)
                {
                    Script = new MSTSBrakeController() as BrakeController;
                    (Script as MSTSBrakeController).ForceControllerReleaseGraduated = Simulator.Settings.GraduatedRelease;
                }

                // AbstractScriptClass
                Script.ClockTime          = () => (float)Simulator.ClockTime;
                Script.GameTime           = () => (float)Simulator.GameTime;
                Script.DistanceM          = () => Locomotive.DistanceM;
                Script.SpeedMpS           = () => Math.Abs(Locomotive.SpeedMpS);
                Script.Confirm            = Locomotive.Simulator.Confirmer.Confirm;
                Script.Message            = Locomotive.Simulator.Confirmer.Message;
                Script.SignalEvent        = Locomotive.SignalEvent;
                Script.SignalEventToTrain = (evt) =>
                {
                    if (Locomotive.Train != null)
                    {
                        Locomotive.Train.SignalEvent(evt);
                    }
                };

                // BrakeController
                Script.EmergencyBrakingPushButton = () => EmergencyBrakingPushButton;
                Script.TCSEmergencyBraking        = () => TCSEmergencyBraking;
                Script.TCSFullServiceBraking      = () => TCSFullServiceBraking;
                Script.QuickReleaseButtonPressed  = () => QuickReleaseButtonPressed;
                Script.OverchargeButtonPressed    = () => OverchargeButtonPressed;
                Script.IsLowVoltagePowerSupplyOn  = () => Locomotive.LocomotivePowerSupply.LowVoltagePowerSupplyOn;
                Script.IsCabPowerSupplyOn         = () => Locomotive.LocomotivePowerSupply.CabPowerSupplyOn;

                Script.MainReservoirPressureBar = () =>
                {
                    if (Locomotive.Train != null)
                    {
                        return(Bar.FromPSI(Locomotive.Train.BrakeLine2PressurePSI));
                    }
                    else
                    {
                        return(float.MaxValue);
                    }
                };
                Script.MaxPressureBar                 = () => Bar.FromPSI(MaxPressurePSI);
                Script.MaxOverchargePressureBar       = () => Bar.FromPSI(MaxOverchargePressurePSI);
                Script.ReleaseRateBarpS               = () => BarpS.FromPSIpS(ReleaseRatePSIpS);
                Script.QuickReleaseRateBarpS          = () => BarpS.FromPSIpS(QuickReleaseRatePSIpS);
                Script.OverchargeEliminationRateBarpS = () => BarpS.FromPSIpS(OverchargeEliminationRatePSIpS);
                Script.SlowApplicationRateBarpS       = () => BarpS.FromPSIpS(SlowApplicationRatePSIpS);
                Script.ApplyRateBarpS                 = () => BarpS.FromPSIpS(ApplyRatePSIpS);
                Script.EmergencyRateBarpS             = () => BarpS.FromPSIpS(EmergencyRatePSIpS);
                Script.FullServReductionBar           = () => Bar.FromPSI(FullServReductionPSI);
                Script.MinReductionBar                = () => Bar.FromPSI(MinReductionPSI);
                Script.CurrentValue = () => CurrentValue;
                Script.MinimumValue = () => MinimumValue;
                Script.MaximumValue = () => MaximumValue;
                Script.StepSize     = () => StepSize;
                Script.UpdateValue  = () => UpdateValue;
                Script.Notches      = () => Notches;

                Script.SetCurrentValue = (value) => CurrentValue = value;
                Script.SetUpdateValue  = (value) => UpdateValue = value;

                Script.SetDynamicBrakeIntervention = (value) =>
                {
                    // TODO: Set dynamic brake intervention instead of controller position
                    // There are some issues that need to be identified and fixed before setting the intervention directly
                    if (Locomotive.DynamicBrakeController == null)
                    {
                        return;
                    }
                    Locomotive.DynamicBrakeChangeActiveState(value > 0);
                    Locomotive.DynamicBrakeController.SetValue(value);
                };

                Script.Initialize();
            }
        }
Esempio n. 6
0
        private void LoadMetadata(SpecDB db)
        {
            if (TableName.StartsWith("CAR_NAME_"))
            {
                string locale = TableName.Split('_')[2];
                if (locale.Equals("ALPHABET") || locale.Equals("JAPAN"))
                {
                    locale = "UnistrDB.sdb";
                }
                else
                {
                    locale += "_StrDB.sdb";
                }

                TableMetadata = new CarName(db.SpecDBFolderType, locale);
            }
            else if (TableName.StartsWith("CAR_VARIATION_"))
            {
                string locale = TableName.Split('_')[2];
                if (locale.Equals("ALPHABET") || locale.Equals("JAPAN"))
                {
                    locale = "UnistrDB.sdb";
                }
                else
                {
                    locale += "_StrDB.sdb";
                }
                TableMetadata = new CarVariation(db.SpecDBFolderType, locale);
            }
            else if (TableName.StartsWith("COURSE_NAME_"))
            {
                string locale = TableName.Split('_')[2];
                if (locale.Equals("ALPHABET") || locale.Equals("JAPAN"))
                {
                    locale = "UnistrDB.sdb";
                }
                else
                {
                    locale += "_StrDB.sdb";
                }
                TableMetadata = new CourseName(db.SpecDBFolderType, locale);
            }
            else if (TableName.StartsWith("VARIATION"))
            {
                string locale = "UnistrDB.sdb";
                if (TableName.Length > 9)
                {
                    locale = TableName.Substring(9);
                    if (!locale.Equals("ALPHABET") && !locale.Equals("JAPAN"))
                    {
                        locale += "_StrDB.sdb";
                    }
                }
                TableMetadata = new Variation(db.SpecDBFolderType, locale);
            }
            else if (TableName.StartsWith("RIDER_EQUIPMENT"))
            {
                string locale = "UnistrDB.sdb";
                if (TableName.Length > 15)
                {
                    locale = TableName.Substring(15);
                    if (!locale.Equals("ALPHABET") && !locale.Equals("JAPAN"))
                    {
                        locale += "_StrDB.sdb";
                    }
                }
                TableMetadata = new RiderEquipment(db.SpecDBFolderType, locale);
            }
            else
            {
                switch (TableName)
                {
                case "AIR_CLEANER":
                    TableMetadata = new AirCleaner(db.SpecDBFolderType); break;

                case "ALLOW_ENTRY":
                    TableMetadata = new AllowEntry(db.SpecDBFolderType); break;

                case "ARCADEINFO_NORMAL":
                case "ARCADEINFO_TUNED":
                    TableMetadata = new ArcadeInfoNormal(db.SpecDBFolderType); break;

                case "ASCC":
                    TableMetadata = new ASCC(db.SpecDBFolderType); break;

                case "BRAKE":
                    TableMetadata = new Brake(db.SpecDBFolderType); break;

                case "BRAKECONTROLLER":
                    TableMetadata = new BrakeController(db.SpecDBFolderType); break;

                case "CATALYST":
                    TableMetadata = new Catalyst(db.SpecDBFolderType); break;

                case "CLUTCH":
                    TableMetadata = new Clutch(db.SpecDBFolderType); break;

                case "COMPUTER":
                    TableMetadata = new Computer(db.SpecDBFolderType); break;

                case "COURSE":
                    TableMetadata = new Course(db.SpecDBFolderType); break;

                case "CAR_CUSTOM_INFO":
                    TableMetadata = new CarCustomInfo(db.SpecDBFolderType); break;

                case "DEFAULT_PARAM":
                    TableMetadata = new DefaultParam(db.SpecDBFolderType); break;

                case "DEFAULT_PARTS":
                    TableMetadata = new DefaultParts(db.SpecDBFolderType); break;

                case "DISPLACEMENT":
                    TableMetadata = new Displacement(db.SpecDBFolderType); break;

                case "DRIVETRAIN":
                    TableMetadata = new Drivetrain(db.SpecDBFolderType); break;

                case "ENGINE":
                    TableMetadata = new Engine(db.SpecDBFolderType); break;

                case "EXHAUST_MANIFOLD":
                    TableMetadata = new ExhaustManifold(db.SpecDBFolderType); break;

                case "FLYWHEEL":
                    TableMetadata = new Flywheel(db.SpecDBFolderType); break;

                case "GEAR":
                    TableMetadata = new Gear(db.SpecDBFolderType); break;

                case "MAKER":
                    TableMetadata = new Maker(db.SpecDBFolderType); break;

                case "MODEL_INFO":
                    TableMetadata = new ModelInfo(db.SpecDBFolderType); break;

                case "PAINT_COLOR_INFO":
                    TableMetadata = new PaintColorInfo(db.SpecDBFolderType); break;

                case "GENERIC_CAR":
                    TableMetadata = new GenericCar(db.SpecDBFolderType); break;

                case "FRONTTIRE":
                    TableMetadata = new FrontTire(db.SpecDBFolderType); break;

                case "REARTIRE":
                    TableMetadata = new RearTire(db.SpecDBFolderType); break;

                case "RACINGMODIFY":
                    TableMetadata = new RacingModify(db.SpecDBFolderType); break;

                case "CHASSIS":
                    TableMetadata = new Chassis(db.SpecDBFolderType); break;

                case "INTAKE_MANIFOLD":
                    TableMetadata = new IntakeManifold(db.SpecDBFolderType); break;

                case "LIGHTWEIGHT":
                    TableMetadata = new Lightweight(db.SpecDBFolderType); break;

                case "LSD":
                    TableMetadata = new Lsd(db.SpecDBFolderType); break;

                case "MUFFLER":
                    TableMetadata = new Muffler(db.SpecDBFolderType); break;

                case "NATUNE":
                    TableMetadata = new Natune(db.SpecDBFolderType); break;

                case "NOS":
                    TableMetadata = new NOS(db.SpecDBFolderType); break;

                case "PROPELLERSHAFT":
                    TableMetadata = new PropellerShaft(db.SpecDBFolderType); break;

                case "RACE":
                    TableMetadata = new Race(db.SpecDBFolderType); break;

                case "STEER":
                    TableMetadata = new Steer(db.SpecDBFolderType); break;

                case "SUPERCHARGER":
                    TableMetadata = new Supercharger(db.SpecDBFolderType); break;

                case "SUSPENSION":
                    TableMetadata = new Suspension(db.SpecDBFolderType); break;

                case "TIRECOMPOUND":
                    TableMetadata = new TireCompound(db.SpecDBFolderType); break;

                case "TURBINEKIT":
                    TableMetadata = new TurbineKit(db.SpecDBFolderType); break;

                case "GENERIC_ITEMS":
                    TableMetadata = new GenericItems(db.SpecDBFolderType); break;

                case "TUNED_CARS":
                    TableMetadata = new TunedCars(db.SpecDBFolderType); break;

                case "TUNER":
                    TableMetadata = new Tuner(db.SpecDBFolderType); break;

                case "WHEEL":
                    TableMetadata = new Wheel(db.SpecDBFolderType); break;

                // Unmapped, but havent seen having rows
                case "TCSC":
                    TableMetadata = new TCSC(db.SpecDBFolderType); break;

                case "TIREFORCEVOL":
                    TableMetadata = new TireForceVol(db.SpecDBFolderType); break;

                case "GENERIC_CAR_INFO":
                    TableMetadata = new GenericCarInfo(db.SpecDBFolderType); break;

                case "INDEP_THROTTLE":
                    TableMetadata = new IndepThrottle(db.SpecDBFolderType); break;

                case "INTERCOOLER":
                    TableMetadata = new Intercooler(db.SpecDBFolderType); break;

                case "PORTPOLISH":
                    TableMetadata = new PortPolish(db.SpecDBFolderType); break;

                case "WING":
                    TableMetadata = new Wing(db.SpecDBFolderType); break;

                case "TUNER_LIST":
                    TableMetadata = new TunerList(db.SpecDBFolderType); break;

                case "TIRESIZE":
                    TableMetadata = new TireSize(db.SpecDBFolderType); break;

                case "ENEMY_CARS":
                    TableMetadata = new EnemyCars(db.SpecDBFolderType); break;

                case "ENGINEBALANCE":
                    TableMetadata = new EngineBalance(db.SpecDBFolderType); break;

                case "RIDER_SET_ASSIGN":
                    TableMetadata = new RiderSetAssign(db.SpecDBFolderType); break;

                case "RIDER_SET":
                    TableMetadata = new RiderSet(db.SpecDBFolderType); break;

                default:
                    throw new NotSupportedException($"This table ({TableName}) is not yet mapped.");
                }

                for (int i = 0; i < TableMetadata.Columns.Count; i++)
                {
                    TableMetadata.Columns[i].ColumnIndex = i;
                }
            }
        }