static bool Postfix(bool __result, CostMultiple __instance, Inventory inventory) { if (!CraftFromStorageManager.isUnlimitedResources()) { return(CraftFromStorageManager.enoughInStorageInventory(__result, __instance, inventory)); } return(__result); }
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(CostMultiple costMultiple, Inventory inventory) { Inventory actualInventory = inventory != null ? inventory : InventoryManager.getStorageInventory(); Item_Base[] items = costMultiple.items; int itemCount = 0; if (actualInventory != null) { for (int i = 0; i < items.Length; i++) { if (items[i] != null) { itemCount += actualInventory.GetItemCount(items[i].UniqueName); } } } return(itemCount); }
private void allowItems(params string[] validItemNames) { var sandItem = ItemManager.GetItemByName("Sand"); var sandIngredient = new CostMultiple(new Item_Base[] { sandItem }, 4); var clayItem = ItemManager.GetItemByName("Clay"); var clayIngredient = new CostMultiple(new Item_Base[] { clayItem }, 4); var gooItem = ItemManager.GetItemByName("VineGoo"); var gooIngredient = new CostMultiple(new Item_Base[] { gooItem }, 3); var dyeItem = ItemManager.GetItemByName("Flower_Blue"); var dyeIngredient = new CostMultiple(new Item_Base[] { dyeItem }, 4); var validItems = validItemNames.Select(name => ItemManager.GetItemByName(name)).ToArray(); var validIngredients = new CostMultiple(validItems, 2); var goo = ItemManager.GetItemByName("ExplosiveGoo"); goo.settings_recipe.NewCost = new CostMultiple[] { sandIngredient, clayIngredient, gooIngredient, dyeIngredient, validIngredients }; }
public static void SetConfigurationFromINI() { while (!reader.EndOfStream) { Node node = ReadNode(); if (node.Category == "Recipe") { int order = 0; RConsole.Log("Adding recipes"); foreach (KeyValuePair <string, ININodeParams> setting in node.Settings) { RecipeNodeParams recipeParams = setting.Value as RecipeNodeParams; CostMultiple[] costs = new CostMultiple[recipeParams.Count / 2]; for (int i = 0; i < costs.Length; i++) { costs[i] = new CostMultiple(new Item_Base[] { recipeParams.GetValue <Item_Base>(i * 1) }, recipeParams.GetValue <int>(i * 2)); } CreateRecipe(ItemManager.GetItemByName(setting.Key), recipeParams.SubCategory, order, costs); order++; } } } }
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; } } } } } }