/** * Simulate refit task on provided storages. * Returns false when the refit task has no item to refit (=Auto refit) */ private bool Refit(RefitTask refitTask, Dictionary <VehicleUnit, StorageState> storages) { Item item = refitTask.Item; if (item == null) { //refit to auto = cannot determine begin state return(false); } ImmutableUniqueList <VehicleUnit> targetUnits = refitTask.GetTargetUnits(); int targetUnitsCount = targetUnits.Count; StorageManager storageManager = LazyManager <StorageManager> .Current; for (var k = 0; k < targetUnitsCount; k++) { VehicleUnit targetUnit = targetUnits[k]; storageManager.TryGetStorage(targetUnit.SharedData.AssetId, item, out Storage newStorage); if (newStorage != null && storages.ContainsKey(targetUnit) && (storages[targetUnit].storage == null || storages[targetUnit].storage.Item != newStorage.Item)) { storages[targetUnit] = new StorageState(newStorage); } } return(true); }
static private void VehicleWindowScheduleTabRefitPropertyView_Initialize_pof(VehicleWindowScheduleTabRefitPropertyView __instance, RefitTask task, bool editMode, ref GridPickerEx ____gridPicker) { _itemChangeRefitTask = null; if (editMode && task != null) { Button component = __instance.transform.GetComponent <Button>(); component.onClick.AddListener(delegate() { _itemChangeRefitTask = task; }); } }
static private void GridPickerHelper_PickItemToRefitVehicleUnits_prf(ref Action <Item> callback) { RefitTask task = _itemChangeRefitTask; if (task != null && task.Vehicle != null) { Item origItem = task.Item; callback += delegate(Item item) { if (origItem != item) { Current.OnSubtaskChanged(task, notifyRoute: true); } }; } _itemChangeRefitTask = null; }