static void Postfix(PlayerInventory inventory, BuildingUI_CostBox __instance) { if (!CraftFromStorageManager.isUnlimitedResources()) { __instance.SetAmount(__instance.GetAmount() + InventoryManager.getItemCountInInventory(__instance, null)); } }
static void Prefix(Item_Base ___item) { if (___item != null) { CostMultiple[] newCost = ___item.settings_recipe.NewCost; CraftFromStorageManager.RemoveCostMultiple(newCost); } }
static bool Postfix(bool __result, CostMultiple __instance, Inventory inventory) { if (!CraftFromStorageManager.isUnlimitedResources()) { return(CraftFromStorageManager.enoughInStorageInventory(__result, __instance, inventory)); } return(__result); }
static void Prefix(SelectedRecipeBox ___selectedRecipeBox) { Item_Base itemBase = ___selectedRecipeBox.selectedRecipeItem; if (itemBase != null) { CostMultiple[] newCost = itemBase.settings_recipe.NewCost; CraftFromStorageManager.RemoveCostMultiple(newCost); } }
static public bool enoughInStorageInventory(bool enouthInPlayerInventory, CostMultiple costMultiple, Inventory inventoryToCheck) { bool enough = enouthInPlayerInventory; if (!CraftFromStorageManager.isUnlimitedResources()) { if (enough == false && InventoryManager.isStorageInventoryOpened() && !InventoryManager.isInventorySameAsOpenedStorageInventory(inventoryToCheck)) { enough = costMultiple.HasEnoughInInventory(InventoryManager.getStorageInventory()); } } return(enough); }
static public int getItemCountInInventory(BuildingUI_CostBox costBox, Inventory inventory) { Inventory actualInventory = inventory != null ? inventory : InventoryManager.getStorageInventory(); List <Item_Base> items = CraftFromStorageManager.getItemsFromCostBox(costBox); int itemCount = 0; if (actualInventory != null) { for (int i = 0; i < items.Count; i++) { if (items[i] != null) { itemCount += actualInventory.GetItemCount(items[i].UniqueName); } } } return(itemCount); }
static public void RemoveCostMultiple(CostMultiple[] costMultipleArray) { if (!CraftFromStorageManager.isUnlimitedResources()) { Inventory storageInventory = InventoryManager.getStorageInventory(); Inventory playerInventory = InventoryManager.getPlayerInventory(); if (storageInventory != null) { for (int i = 0; i < (int)costMultipleArray.Length; i++) { CostMultiple costMultiple = costMultipleArray[i]; int num = costMultiple.amount - InventoryManager.getItemCountInInventory(costMultiple, playerInventory); for (int j = 0; j < (int)costMultiple.items.Length; j++) { int itemCount = storageInventory.GetItemCount(costMultiple.items[j].UniqueName); if (itemCount < num) { storageInventory.RemoveItem(costMultiple.items[j].UniqueName, itemCount); num -= itemCount; } else { storageInventory.RemoveItem(costMultiple.items[j].UniqueName, num); num = 0; } if (num <= 0) { break; } } } } } }