示例#1
0
        private static void ExportRecipes(XmlWriterSettings saveSettings, string outputPath)
        {
            var recipeFile = new RecipeTemplates();
            recipeFile.RecipeList = new List<RecipeTemplate>();

            var utility = Utility<CombineRecipe>.Instance;

            foreach (var recipe in Utility.RecipeIndex.RecipeList) {
                var template = new RecipeTemplate();
                template.id = recipe.id;
                template.nameid = Utility.StringIndex["str_" + recipe.name] * 2 + 1;
                template.skillid = Utility.GetSkillIdFromName(recipe.combineskill.ToString());
                template.race = (skillRace)Enum.Parse(typeof(skillRace),
                                                      recipe.qualification_race.ToString().ToUpper());
                template.skillpoint = recipe.required_skillpoint;
                template.dp = recipe.require_dp;
                template.autolearn = recipe.auto_learn;
                Item item = Utility.ItemIndex.GetItem(recipe.product);
                if (item == null)
                    Debug.Print("Missing product for recipe {0}", recipe.id);
                else
                    template.productid = item.id;
                template.quantity = recipe.product_quantity;
                template.componentquantity = recipe.component_quantity;
                template.tasktype = recipe.task_type;
                template.maxcount = recipe.max_production_count;
                template.delayid = recipe.craft_delay_id;
                template.delaytime = recipe.craft_delay_time;

                List<string> components = new List<string>();
                List<int> quantities = new List<int>();
                List<string> comboproducts = new List<string>();
                utility.Export(recipe, "component", components);
                utility.Export(recipe, "compo", quantities);

                // remove "component_quantity" which is the last in the list
                quantities.RemoveAt(quantities.Count - 1);
                for (int i = 0; i < components.Count; i++) {
                    string nameId = components[i];
                    item = Utility.ItemIndex.GetItem(nameId);
                    if (item == null) {
                        Debug.Print("Missing component for recipe {0}", recipe.id);
                        continue;
                    }
                    if (template.components == null)
                        template.components = new List<Component>();
                    var comp = new Component();
                    template.components.Add(comp);
                    comp.itemid = item.id;
                    comp.quantity = quantities[i];
                }

                utility.Export(recipe, "combo", comboproducts);

                for (int i = 0; i < comboproducts.Count; i++) {
                    string nameId = comboproducts[i];
                    item = Utility.ItemIndex.GetItem(nameId);
                    if (item == null) {
                        Debug.Print("Missing combo product for recipe {0}", recipe.id);
                        continue;
                    }
                    if (template.comboproducts == null)
                        template.comboproducts = new List<ComboProduct>();
                    var combo = new ComboProduct();
                    template.comboproducts.Add(combo);
                    combo.itemid = item.id;
                }
                recipeFile.RecipeList.Add(template);
            }

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "recipe_templates.xml"),
                                                      FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(RecipeTemplates));
                    ser.Serialize(wr, recipeFile);
                }
            }
        }
示例#2
0
        private static void ExportRecipes(XmlWriterSettings saveSettings, string outputPath)
        {
            var recipeFile = new RecipeTemplates();
            recipeFile.RecipeList = new List<RecipeTemplate>();

            var utility = Utility<CombineRecipe>.Instance;

            int descriptionID;
            foreach (var recipe in Utility.RecipeIndex.RecipeList) {
                var template = new RecipeTemplate();
                template.id = recipe.id;

                // zp
                template.autolearn = recipe.auto_learn;
                template.name = Regex.Replace(Utility.StringIndex.GetString(recipe.desc), @"[^\u0030-\u007A\u0020]", string.Empty);

                // zp - return substring of parent item for matching test items
                string recipeName = "STR_" + recipe.name.ToUpper();
                if(recipeName.Substring(recipeName.Length - 5, 5) == "_TEST")
                    recipeName = recipeName.Substring(0, recipeName.Length - 5);

                int stringIndex = Utility.StringIndex[recipeName];

                descriptionID = stringIndex * 2 + 1;

                // zp - hard code 1 name ID, need to investigate why string is not in strings
                if (template.id == 155100341) descriptionID = 1590723;

                if (descriptionID < 1) {
                    Console.Write("Pausing (Press Enter): Bad DescriptionID!" + descriptionID + " recipeID: " + template.id);
                    Console.ReadLine(); //Pause
                }

                template.nameid = descriptionID;

                template.skillid = Utility.GetSkillIdFromName(recipe.combineskill.ToString());
                if (template.skillid < 1) {
                    Console.Write("Pausing (Press Enter): Unknown recipe SkillID - recipeId: " + recipe.id);
                    Console.ReadLine(); //Pause
                }

                //template.race = (skillRace)Enum.Parse(typeof(skillRace), recipe.qualification_race.ToString().ToUpper());
                // zp
                template.race = recipe.race;

                template.skillpoint = recipe.required_skillpoint;
                template.dp = recipe.require_dp;
                template.autolearn = recipe.auto_learn;
                Item item = Utility.ItemIndex.GetItem(recipe.product);
                if (item == null)
                    Debug.Print("Missing product for recipe {0}", recipe.id);
                else
                    template.productid = item.id;
                template.quantity = recipe.product_quantity;
                template.max_production_count = recipe.max_production_count;
                template.craft_delay_id = recipe.craft_delay_id;
                template.craft_delay_time = recipe.craft_delay_time;

                List<string> components = new List<string>();
                List<int> quantities = new List<int>();
                List<string> comboproducts = new List<string>();
                utility.Export(recipe, "component", components);
                utility.Export(recipe, "compo", quantities);

                // remove "component_quantity" which is the last in the list
                quantities.RemoveAt(quantities.Count - 1);
                for (int i = 0; i < components.Count; i++) {
                    string nameId = components[i];
                    item = Utility.ItemIndex.GetItem(nameId);
                    if (item == null) {
                        Debug.Print("Missing component for recipe {0}", recipe.id);
                        continue;
                    }
                    if (template.components == null)
                        template.components = new List<Component>();
                    var comp = new Component();
                    template.components.Add(comp);
                    comp.itemid = item.id;
                    comp.quantity = quantities[i];
                }

                utility.Export(recipe, "combo", comboproducts);

                for (int i = 0; i < comboproducts.Count; i++) {
                    string nameId = comboproducts[i];
                    item = Utility.ItemIndex.GetItem(nameId);
                    if (item == null) {
                        Debug.Print("Missing combo product for recipe {0}", recipe.id);
                        continue;
                    }
                    if (template.comboproducts == null)
                        template.comboproducts = new List<ComboProduct>();
                    var combo = new ComboProduct();
                    template.comboproducts.Add(combo);
                    combo.itemid = item.id;
                }
                recipeFile.RecipeList.Add(template);
            }

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "recipe_templates.xml"),
                                              FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(RecipeTemplates));
                    ser.Serialize(wr, recipeFile);
                }
            }
        }