static void LoadData(TrainCar car, CarsTOPSaveData data) { if (car.carType == TrainCarType.LocoShunter) { var simulationComponent = car.GetComponent <ShunterLocoSimulation>(); simulationComponent.fuel.SetValue(data.fuel); simulationComponent.oil.SetValue(data.oil); simulationComponent.sand.SetValue(data.sand); } else if (car.carType == TrainCarType.LocoSteamHeavy) { var simulationComponent = car.GetComponent <SteamLocoSimulation>(); simulationComponent.boilerWater.SetValue(data.boilerWater); simulationComponent.sand.SetValue(data.sand); } else if (car.carType == TrainCarType.Tender) { var simulationComponent = car.GetComponent <TenderSimulation>(); simulationComponent.tenderWater.SetValue(data.tenderWater); simulationComponent.tenderCoal.SetValue(data.tenderCoal); } }
static CarsTOPSaveData GetSaveData(TrainCar car) { var topSaveData = new CarsTOPSaveData(); if (car.carType == TrainCarType.LocoShunter) { var simulationComponent = car.GetComponent <ShunterLocoSimulation>(); topSaveData.fuel = simulationComponent.fuel.value; topSaveData.oil = simulationComponent.oil.value; topSaveData.sand = simulationComponent.sand.value; topSaveData.carGuid = car.logicCar.carGuid; } else if (car.carType == TrainCarType.LocoSteamHeavy) { var simulationComponent = car.GetComponent <SteamLocoSimulation>(); topSaveData.boilerWater = simulationComponent.boilerWater.value; topSaveData.sand = simulationComponent.sand.value; topSaveData.carGuid = car.logicCar.carGuid; } else if (car.carType == TrainCarType.Tender) { var simulationComponent = car.GetComponent <TenderSimulation>(); topSaveData.tenderWater = simulationComponent.tenderWater.value; topSaveData.tenderCoal = simulationComponent.tenderCoal.value; topSaveData.carGuid = car.logicCar.carGuid; } return(topSaveData); }