public Crusher() { timer = new BaseLibrary.Timer(60, Callback); Handler = new ItemHandler(5) { Modes = { [1] = SlotMode.Input, [2] = SlotMode.Input, [3] = SlotMode.Output, [4] = SlotMode.Output } }; Handler.IsItemValid += (slot, item) => { switch (slot) { case 0: return(item.modItem is BaseContainmentUnit); case 1: case 2: return(Recipes.ContainsKey(item.type)); default: return(false); } }; EnergyHandler = new EnergyHandler(10000, 1000); }
private void AddRecipe(Recipe recipe) { if (!Recipes.ContainsKey(recipe.SpellId)) { Recipes.Add(recipe.SpellId, recipe); recipe.InitIngredients(); recipe.InitTools(); } }
public void AddRecipe(Recipe recipe) { if (Recipes.ContainsKey(recipe.ID)) { return; } Recipes.Add(recipe.ID, recipe); recipe.InitIngredients(); recipe.InitTools(); }
public Recipe(int id, CraftSystem system, CraftItem item) { ID = id; CraftSystem = system; CraftItem = item; if (Recipes.ContainsKey(id)) { throw new Exception("Attempting to create recipe with preexisting ID."); } Recipes.Add(id, this); LargestRecipeID = Math.Max(id, LargestRecipeID); }
private void Callback() { if (EnergyHandler.Energy < EnergyPerItem) { return; } int slot = Handler.GetFirstInput(); if (slot != -1) { Item item = Handler.GetItemInSlot(slot); if (Recipes.ContainsKey(item.type) && Handler.OutputSlots.Any((x, i) => x.IsAir || x.type == Recipes[item.type] && x.stack < x.maxStack)) { for (int i = 0; i < Handler.Slots; i++) { if (Handler.Modes[i] != SlotMode.Output) { continue; } if (Handler.Items[i].type == Recipes[item.type] && Handler.Items[i].stack < Handler.Items[i].maxStack) { Handler.Items[i].stack++; break; } if (Handler.Items[i].IsAir) { Handler.Items[i].SetDefaults(Recipes[item.type]); Handler.Items[i].stack = 1; break; } } Handler.Shrink(slot, 1); EnergyHandler.ExtractEnergy(EnergyPerItem); } } }
public Part GetRecipe(string code) { var key = Lookup.ContainsKey(code) ? Lookup[code] : code; return(Recipes.ContainsKey(key) ? Recipes[key] : null); }