示例#1
0
 static void Postfix(PlayerInventory inventory, BuildingUI_CostBox __instance)
 {
     if (!CraftFromStorageManager.isUnlimitedResources())
     {
         __instance.SetAmount(__instance.GetAmount() + InventoryManager.getItemCountInInventory(__instance, null));
     }
 }
示例#2
0
 static void Prefix(Item_Base ___item)
 {
     if (___item != null)
     {
         CostMultiple[] newCost = ___item.settings_recipe.NewCost;
         CraftFromStorageManager.RemoveCostMultiple(newCost);
     }
 }
示例#3
0
 static bool Postfix(bool __result, CostMultiple __instance, Inventory inventory)
 {
     if (!CraftFromStorageManager.isUnlimitedResources())
     {
         return(CraftFromStorageManager.enoughInStorageInventory(__result, __instance, inventory));
     }
     return(__result);
 }
示例#4
0
        static void Prefix(SelectedRecipeBox ___selectedRecipeBox)
        {
            Item_Base itemBase = ___selectedRecipeBox.selectedRecipeItem;

            if (itemBase != null)
            {
                CostMultiple[] newCost = itemBase.settings_recipe.NewCost;
                CraftFromStorageManager.RemoveCostMultiple(newCost);
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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;
                            }
                        }
                    }
                }
            }
        }