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(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); } } } }