Пример #1
0
        static void Postfix(LocoControllerSteam __instance, float percentage)
        {
            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.SetFireDoorOpen(percentage);
                    }
                }
            }
        }
Пример #2
0
        static IEnumerator <object> AttachListeners()
        {
            yield return(null);

            DV.CabControls.ControlImplBase sanderCtrl = instance.sanderValveObj.GetComponent <DV.CabControls.ControlImplBase>();

            sanderCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetSanderValve(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase blowerCtrl = instance.blowerValveObj.GetComponent <DV.CabControls.ControlImplBase>();

            blowerCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetBlower(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase injectorCtrl = instance.injectorValveObj.GetComponent <DV.CabControls.ControlImplBase>();

            injectorCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetInjector(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase waterDumpCtrl = instance.waterDumpValveObj.GetComponent <DV.CabControls.ControlImplBase>();

            waterDumpCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetWaterDump(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase steamReleaseCtrl = instance.steamReleaserValveObj.GetComponent <DV.CabControls.ControlImplBase>();

            steamReleaseCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetSteamReleaser(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase draftPullerCtrl = instance.draftPullerObj.GetComponent <DV.CabControls.ControlImplBase>();

            draftPullerCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetDraft(e.newValue);
                        }
                    }
                }
            });

            DV.CabControls.ControlImplBase fireDoorLeverCtrl = instance.fireDoorLeverObj.GetComponent <DV.CabControls.ControlImplBase>();

            fireDoorLeverCtrl.ValueChanged += (e =>
            {
                if (PlayerManager.Car == null || PlayerManager.Car.trainset == null)
                {
                    return;
                }

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

                    if (PlayerManager.Car.Equals(car))
                    {
                        continue;
                    }

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

                        if (steamController)
                        {
                            steamController.SetFireDoorOpen(e.newValue);
                        }
                    }
                }
            });
        }