Beispiel #1
0
 static void Postfix(PlayerInventory inventory, BuildingUI_CostBox __instance)
 {
     if (!CraftFromStorageManager.isUnlimitedResources())
     {
         __instance.SetAmount(__instance.GetAmount() + InventoryManager.getItemCountInInventory(__instance, null));
     }
 }
Beispiel #2
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);
        }
Beispiel #3
0
 static public List <Item_Base> getItemsFromCostBox(BuildingUI_CostBox costBox)
 {
     return(Traverse.Create(costBox).Field("items").GetValue <List <Item_Base> >());
 }