Exemplo n.º 1
0
        static void Postfix(LocoControllerSteam __instance, float position)
        {
            TrainCar currentCar = __instance.GetComponent <TrainCar>();
            TrainCar targetCar  = null;
            Trainset trainset   = null;

            if (PlayerManager.Car != null && PlayerManager.Car.trainset != null)
            {
                targetCar = PlayerManager.Car;
                trainset  = PlayerManager.Car.trainset;
            }

            if (currentCar == null || targetCar == null || !targetCar.Equals(currentCar) || trainset == null || trainset.cars.Count < 2)
            {
                return;
            }

            List <TrainCar> trainsetCars = trainset.cars;

            for (int i = 0; i < trainsetCars.Count; i++)
            {
                TrainCar car = trainsetCars[i];

                if (targetCar.Equals(car))
                {
                    continue;
                }

                if (car.carType == TrainCarType.LocoSteamHeavy)
                {
                    LocoControllerSteam steamController = car.GetComponent <LocoControllerSteam>();

                    if (steamController)
                    {
                        if (GetCarsBehind(PlayerManager.Car).Contains(car))
                        {
                            if (GetCarsInFrontOf(car).Contains(PlayerManager.Car))
                            {
                                steamController.SetReverser(position);
                            }
                            else
                            {
                                steamController.SetReverser(position * -1f);
                            }
                        }
                        else if (GetCarsInFrontOf(PlayerManager.Car).Contains(car))
                        {
                            if (GetCarsBehind(car).Contains(PlayerManager.Car))
                            {
                                steamController.SetReverser(position);
                            }
                            else
                            {
                                steamController.SetReverser(position * -1f);
                            }
                        }
                    }
                }
            }
        }
        static void Postfix(LocoControllerBase __instance, float nextTargetIndependentBrake)
        {
            TrainCar currentCar = __instance.GetComponent <TrainCar>();
            TrainCar targetCar  = null;
            Trainset trainset   = null;

            if (Main.remoteCar)
            {
                targetCar = Main.remoteCar;
                trainset  = targetCar.trainset;
            }
            else if (PlayerManager.Car != null)
            {
                targetCar = PlayerManager.Car;
                trainset  = PlayerManager.Car.trainset;
            }

            if (currentCar == null || targetCar == null || !targetCar.Equals(currentCar) || trainset == null || trainset.cars.Count < 2)
            {
                return;
            }

            for (int i = 0; i < trainset.cars.Count; i++)
            {
                TrainCar car = trainset.cars[i];

                if (targetCar.Equals(car))
                {
                    continue;
                }

                if (car.carType == TrainCarType.LocoShunter)
                {
                    LocoControllerShunter locoController = car.GetComponent <LocoControllerShunter>();

                    if (locoController)
                    {
                        locoController.SetIndependentBrake(nextTargetIndependentBrake);
                    }
                }
                else if (car.carType == TrainCarType.LocoDiesel)
                {
                    LocoControllerDiesel locoController = car.GetComponent <LocoControllerDiesel>();

                    if (locoController)
                    {
                        locoController.SetIndependentBrake(nextTargetIndependentBrake);
                    }
                }
            }
        }
Exemplo n.º 3
0
        static void Postfix(LocoControllerSteam __instance, float throttle)
        {
            TrainCar currentCar = __instance.GetComponent <TrainCar>();
            TrainCar targetCar  = null;
            Trainset trainset   = null;

            if (PlayerManager.Car != null && PlayerManager.Car.trainset != null)
            {
                targetCar = PlayerManager.Car;
                trainset  = PlayerManager.Car.trainset;
            }

            if (currentCar == null || targetCar == null || !targetCar.Equals(currentCar) || trainset == null || trainset.cars.Count < 2)
            {
                return;
            }

            List <TrainCar> trainsetCars = trainset.cars;

            for (int i = 0; i < trainsetCars.Count; i++)
            {
                TrainCar car = trainsetCars[i];

                if (targetCar.Equals(car))
                {
                    continue;
                }

                if (car.carType == TrainCarType.LocoSteamHeavy)
                {
                    LocoControllerSteam steamController = car.GetComponent <LocoControllerSteam>();

                    if (steamController)
                    {
                        steamController.SetThrottle(throttle);
                    }
                }
            }
        }
        static void Prefix(LocoControllerDiesel __instance, ToggleDirection toggle)
        {
            TrainCar targetCar = __instance.GetComponent <TrainCar>();
            Trainset trainset  = targetCar.trainset;

            if (trainset == null)
            {
                return;
            }

            for (int i = 0; i < trainset.cars.Count; i++)
            {
                TrainCar car = trainset.cars[i];

                if (targetCar.Equals(car))
                {
                    continue;
                }

                if (car.carType == TrainCarType.LocoShunter)
                {
                    LocoControllerShunter locoController = car.GetComponent <LocoControllerShunter>();

                    if (locoController != null)
                    {
                        locoController.SetSandersOn(toggle == ToggleDirection.UP);
                    }
                }
                else if (car.carType == TrainCarType.LocoDiesel)
                {
                    LocoControllerDiesel locoController = car.GetComponent <LocoControllerDiesel>();

                    if (locoController != null)
                    {
                        locoController.SetSandersOn(toggle == ToggleDirection.UP);
                    }
                }
            }
        }
        static void Postfix(LocoControllerDiesel __instance, float position)
        {
            TrainCar currentCar = __instance.GetComponent <TrainCar>();
            TrainCar targetCar  = null;
            Trainset trainset   = null;

            if (Main.remoteCar)
            {
                targetCar = Main.remoteCar;
                trainset  = targetCar.trainset;
            }
            else if (PlayerManager.Car != null)
            {
                targetCar = PlayerManager.Car;
                trainset  = PlayerManager.Car.trainset;
            }

            if (currentCar == null || targetCar == null || !targetCar.Equals(currentCar) || trainset == null || trainset.cars.Count < 2)
            {
                return;
            }

            List <TrainCar> trainsetCars = trainset.cars;

            for (int i = 0; i < trainsetCars.Count; i++)
            {
                TrainCar car = trainsetCars[i];

                if (targetCar.Equals(car))
                {
                    continue;
                }

                LocoControllerBase locoController = null;

                if (car.carType == TrainCarType.LocoShunter)
                {
                    locoController = car.GetComponent <LocoControllerShunter>();
                }
                else if (car.carType == TrainCarType.LocoDiesel)
                {
                    locoController = car.GetComponent <LocoControllerDiesel>();
                }

                if (locoController != null)
                {
                    if (GetCarsBehind(targetCar).Contains(car))
                    {
                        if (GetCarsInFrontOf(car).Contains(targetCar))
                        {
                            locoController.SetReverser(position);
                        }
                        else
                        {
                            locoController.SetReverser(position * -1f);
                        }
                    }
                    else if (GetCarsInFrontOf(targetCar).Contains(car))
                    {
                        if (GetCarsBehind(car).Contains(targetCar))
                        {
                            locoController.SetReverser(position);
                        }
                        else
                        {
                            locoController.SetReverser(position * -1f);
                        }
                    }
                }
            }
        }