public bool make(RecipeInfo recipe) { if (!can_make(recipe)) { return(false); } foreach (var entry in recipe.inputs) { this.try_remove(entry.info, entry.amount, out _); } this.add(recipe.output.info, recipe.output.amount); return(true); }
public bool can_make(RecipeInfo recipe) { if (recipe.output.info == null) { return(false); } foreach (var entry in recipe.inputs) { if (this.item_map.TryGetValue(entry.info, out int value)) { if (value < entry.amount) { return(false); } } else if (entry.amount > 0) { return(false); } } return(true); }