Beispiel #1
0
        /// <summary>
        /// Generate the skills datafile.
        /// </summary>
        internal static void GenerateDatafile()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Util.ResetCounters();

            Console.WriteLine();
            Console.Write(@"Generating blueprints datafile... ");

            // Configure blueprints with Null market group
            ConfigureNullMarketBlueprint();

            Dictionary<int, SerializableBlueprintMarketGroup> groups = new Dictionary<int, SerializableBlueprintMarketGroup>();

            // Export blueprint groups
            CreateMarketGroups(groups);

            // Create the parent-children groups relations
            foreach (SerializableBlueprintMarketGroup group in groups.Values)
            {
                IEnumerable<SerializableBlueprintMarketGroup> children = Database.InvMarketGroupsTable.Concat(
                    s_injectedMarketGroups).Where(x => x.ParentID == group.ID).Select(
                        x => groups[x.ID]).OrderBy(x => x.Name);

                group.SubGroups.AddRange(children);
            }

            // Sort groups
            IEnumerable<SerializableBlueprintMarketGroup> blueprintGroups = Database.InvMarketGroupsTable.Concat(
                s_injectedMarketGroups).Where(x => x.ParentID == DBConstants.BlueprintsMarketGroupID).Select(
                    x => groups[x.ID]).OrderBy(x => x.Name);

            // Reset the custom market groups
            s_nullMarketBlueprints.ForEach(srcItem => srcItem.MarketGroupID = null);
            Database.InvTypesTable
                .Where(item => Database.InvGroupsTable[item.GroupID].CategoryID == DBConstants.AncientRelicsCategoryID)
                .ToList()
                .ForEach(x => x.MarketGroupID = DBConstants.AncientRelicsMarketGroupID);

            // Serialize
            BlueprintsDatafile datafile = new BlueprintsDatafile();
            datafile.MarketGroups.AddRange(blueprintGroups);

            Util.DisplayEndTime(stopwatch);

            // DEBUG: Find which blueprints have not been generated
            if (Debugger.IsAttached)
            {
                var blueprintIds = groups.Values.SelectMany(x => x.Blueprints).Select(y => y.ID).ToList();
                var diff = Database.InvBlueprintTypesTable.Where(blueprint => !blueprintIds.Contains(blueprint.ID)).ToList();

                if (diff.Any())
                    Console.WriteLine("{0} blueprints were not generated.", diff.Count);
            }

            Util.SerializeXml(datafile, DatafileConstants.BlueprintsDatafile);
        }
Beispiel #2
0
        /// <summary>
        /// Generate the skills datafile.
        /// </summary>
        private static void GenerateBlueprints()
        {
            Console.WriteLine();
            Console.Write(@"Generated blueprints datafile... ");

            s_counter = 0;
            s_percentOld = 0;
            s_text = String.Empty;
            s_startTime = DateTime.Now;

            // Configure blueprints with Null market group
            ConfigureNullMarketBlueprint();

            var groups = new Dictionary<int, SerializableBlueprintGroup>();

            // Export blueprint groups
            foreach (InvMarketGroup marketGroup in s_marketGroups.Concat(s_injectedMarketGroups))
            {
                var group = new SerializableBlueprintGroup
                                {
                                    ID = marketGroup.ID,
                                    Name = marketGroup.Name,
                                };

                groups[marketGroup.ID] = group;

                // Add the items in this group
                var blueprints = new List<SerializableBlueprint>();
                foreach (InvType item in s_types.Where(x => x.MarketGroupID == marketGroup.ID
                                       && s_groups[x.GroupID].CategoryID == DBConstants.BlueprintCategoryID
                                       && s_groups[x.GroupID].Published))
                {
                    CreateBlueprint(item, blueprints);
                }

                // Store the items
                group.Blueprints = blueprints.OrderBy(x => x.Name).ToArray();
            }

            // Create the parent-children groups relations
            foreach (SerializableBlueprintGroup group in groups.Values)
            {
                IEnumerable<SerializableBlueprintGroup> children = s_marketGroups.Concat(
                    s_injectedMarketGroups).Where(x => x.ParentID == group.ID).Select(x => groups[x.ID]);

                group.SubGroups = children.OrderBy(x => x.Name).ToArray();
            }

            // Sort groups
            IOrderedEnumerable<SerializableBlueprintGroup> blueprintGroups = s_marketGroups.Concat(
                s_injectedMarketGroups).Where(x => x.ParentID == DBConstants.BlueprintsGroupID)
                .Select(x => groups[x.ID]).OrderBy(x => x.Name);

            s_endTime = DateTime.Now;
            Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0'));

            // Serialize
            var datafile = new BlueprintsDatafile();
            datafile.Groups = blueprintGroups.ToArray();
            Util.SerializeXML(datafile, DatafileConstants.BlueprintsDatafile);
        }