Exemple #1
0
        private static void Demolish(GameLocation location, Object machine)
        {
            string craftingRecipeRaw;

            if (!CraftingRecipe.craftingRecipes.TryGetValue(machine.Name, out craftingRecipeRaw))
            {
                return;
            }

            var craftingRecipe = CraftingRecipeInformation.Parse(craftingRecipeRaw);
            var debrisLocation = machine.TileLocation * Game1.tileSize + new Vector2(Game1.tileSize / 2f, Game1.tileSize / 2f);

            foreach (var ingredient in craftingRecipe.Materials)
            {
                location.debris.Add(new Debris(new SmartObject(ingredient.ID, ingredient.Count), debrisLocation));
            }
            if (machine.heldObject != null && machine.readyForHarvest)
            {
                location.debris.Add(new Debris(machine.heldObject, debrisLocation));
            }
            location.removeObject(machine.TileLocation, false);
        }
 /// <summary>
 /// Register a custom crafting recipe.
 /// </summary>
 public void Register(CraftingRecipeInformation craftingRecipeInformation)
 {
     _craftingRecipeInformations.Add(craftingRecipeInformation);
 }
Exemple #3
0
        private static void TestParsing(string value)
        {
            var craftingRecipeInformation = CraftingRecipeInformation.Parse(value);

            Assert.AreEqual(value, craftingRecipeInformation.ToString());
        }