public static LocoAI GetLocoAI(TrainCar car) { LocoAI locoAI; if (!locosAI.TryGetValue(car.logicCar.ID, out locoAI)) { DieselLocoSimulation dieselSim = car.GetComponent <DieselLocoSimulation>(); if (dieselSim != null) { if (!dieselSim.engineOn) { throw new CommandException("Engine off"); } } else { ShunterLocoSimulation shunterSim = car.GetComponent <ShunterLocoSimulation>(); if (shunterSim != null) { if (!shunterSim.engineOn) { throw new CommandException("Engine off"); } } else { throw new CommandException("Loco not compatible"); } } LocoControllerShunter shunterController = car.GetComponent <LocoControllerShunter>(); ILocomotiveRemoteControl remote = car.GetComponent <ILocomotiveRemoteControl>(); locoAI = new LocoAI(remote); locosAI.Add(car.logicCar.ID, locoAI); } return(locoAI); }
public LocoAI(ILocomotiveRemoteControl remoteControl) : base(remoteControl) { }