void MakeRecipe(params object[] r)
 {
     var recipe = new CraftingRecipe();
     for (int i = 0; i < r.Length - 2; i += 2)
     {
         recipe.ingredients.Add(new Ingredient() { Type = Convert.ToInt32(r[i]), Amount = Convert.ToInt32(r[i + 1]) });
     }
     recipe.output = new Ingredient() { Type = Convert.ToInt32(r[r.Length - 2]), Amount = Convert.ToInt32(r[r.Length - 1]) };
     craftingrecipes.Add(recipe);
 }
예제 #2
0
        public void AddCraftingRecipe3(string output, int outputAmount, string Input0, int Input0Amount, string Input1, int Input1Amount, string Input2, int Input2Amount)
        {
            if (GetBlockId(output) == -1)
            {
                Console.WriteLine(recipeError + output); return;
            }
            if (GetBlockId(Input0) == -1)
            {
                Console.WriteLine(recipeError + Input0); return;
            }
            if (GetBlockId(Input1) == -1)
            {
                Console.WriteLine(recipeError + Input1); return;
            }
            if (GetBlockId(Input2) == -1)
            {
                Console.WriteLine(recipeError + Input2); return;
            }
            CraftingRecipe r = new CraftingRecipe();

            r.ingredients = new Ingredient[]
            {
                new Ingredient()
                {
                    Type = GetBlockId(Input0), Amount = Input0Amount
                },
                new Ingredient()
                {
                    Type = GetBlockId(Input1), Amount = Input1Amount
                },
                new Ingredient()
                {
                    Type = GetBlockId(Input2), Amount = Input2Amount
                },
            };
            r.output = new Ingredient()
            {
                Type = GetBlockId(output), Amount = outputAmount
            };
            server.craftingrecipes.Add(r);
        }
예제 #3
0
        public void Load(string[] csvLines)
        {
            this.csv = new Csv();
            this.csv.LoadCsv(csvLines);
            for (int i = 1; i < csv.data.Length; i++)
            {
                CraftingRecipe r = new CraftingRecipe();

                int outputId = GetBlockId(csv.Get(i, "Output"));
                int outputAmount = csv.GetInt(i, "OutputAmount");
                int input0Id = GetBlockId(csv.Get(i, "Input0"));
                int input0Amount = csv.GetInt(i, "Input0Amount");
                int input1Id = GetBlockId(csv.Get(i, "Input1"));
                int input1Amount = csv.GetInt(i, "Input1Amount");
                int input2Id = GetBlockId(csv.Get(i, "Input2"));
                int input2Amount = csv.GetInt(i, "Input2Amount");

                if (input0Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input0Id, Amount = input0Amount });
                }
                if (input1Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input1Id, Amount = input1Amount });
                }
                if (input2Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input2Id, Amount = input2Amount });
                }

                if (outputId == -1) { throw new FormatException(); }
                if (r.ingredients.Count == 0) { throw new FormatException("Invalid ingredients in recipe " + i); }

                r.output = new Ingredient() { Type = outputId, Amount = outputAmount };
                craftingrecipes.Add(r);
            }
        }
예제 #4
0
파일: Mod.cs 프로젝트: torial/manicdigger
 public void AddCraftingRecipe(string output, int outputAmount, string Input0, int Input0Amount)
 {
     if (GetBlockId(output) == -1) { Console.WriteLine(recipeError + output); return; }
     if (GetBlockId(Input0) == -1) { Console.WriteLine(recipeError + Input0); return; }
     CraftingRecipe r = new CraftingRecipe();
     r.ingredients = new Ingredient[]
     {
         new Ingredient(){Type=GetBlockId(Input0), Amount=Input0Amount},
     };
     r.output = new Ingredient() { Type = GetBlockId(output), Amount = outputAmount };
     server.craftingrecipes.Add(r);
 }