/// <summary> /// Initialize static items. /// </summary> internal static void Load() { if (MarketGroups != null) { return; } // Create the implants slots for (int i = 0; i < s_implantSlots.Length; i++) { s_implantSlots[i] = new ImplantCollection((ImplantSlots)i); } // Deserialize the items datafile ItemsDatafile datafile = Util.DeserializeDatafile <ItemsDatafile>(DatafileConstants.ItemsDatafile, Util.LoadXslt(Properties.Resources.DatafilesXSLT)); MarketGroups = new MarketGroupCollection(null, datafile.MarketGroups); // Gather the items into a by-ID dictionary foreach (MarketGroup marketGroup in MarketGroups) { InitializeDictionaries(marketGroup); } GlobalDatafileCollection.OnDatafileLoaded(); }
/// <summary> /// Generate the items datafile. /// </summary> internal static void GenerateDatafile() { Stopwatch stopwatch = Stopwatch.StartNew(); Util.ResetCounters(); Console.WriteLine(); Console.Write(@"Generating items datafile... "); // Move non existing makret group to custom market group ConfigureNonExistingMarketGroupItems(); // Create custom market groups that don't exist in EVE ConfigureNullMarketItems(); Dictionary <int, SerializableMarketGroup> groups = new Dictionary <int, SerializableMarketGroup>(); // Create the market groups CreateMarketGroups(groups); // Create the parent-children groups relations foreach (SerializableMarketGroup group in groups.Values) { IEnumerable <SerializableMarketGroup> children = Database.InvMarketGroupsTable.Concat( s_injectedMarketGroups).Where(x => x.ParentID.GetValueOrDefault() == group.ID).Select( x => groups[x.ID]).OrderBy(x => x.Name); group.SubGroups.AddRange(children); } // Pick the family SetItemFamilyByMarketGroup(groups[DBConstants.BlueprintsMarketGroupID], ItemFamily.Blueprint); SetItemFamilyByMarketGroup(groups[DBConstants.ShipsMarketGroupID], ItemFamily.Ship); SetItemFamilyByMarketGroup(groups[DBConstants.ImplantsMarketGroupID], ItemFamily.Implant); SetItemFamilyByMarketGroup(groups[DBConstants.DronesMarketGroupID], ItemFamily.Drone); SetItemFamilyByMarketGroup(groups[DBConstants.StarbaseStructuresMarketGroupID], ItemFamily.StarbaseStructure); // Sort groups IEnumerable <SerializableMarketGroup> rootGroups = Database.InvMarketGroupsTable.Concat(s_injectedMarketGroups).Where( x => !x.ParentID.HasValue).Select(x => groups[x.ID]).OrderBy(x => x.Name); // Reset the custom market groups s_nullMarketItems.ForEach(srcItem => srcItem.MarketGroupID = null); // Serialize ItemsDatafile datafile = new ItemsDatafile(); datafile.MarketGroups.AddRange(rootGroups); Util.DisplayEndTime(stopwatch); // DEBUG: Find which items have not been generated if (Debugger.IsAttached) { var itemids = groups.Values.SelectMany(x => x.Items).Select(y => y.ID).ToList(); var diff = Database.InvTypesTable.Where(item => !itemids.Contains(item.ID)).ToList(); if (diff.Any()) { Console.WriteLine("{0} items were not generated.", diff.Count); } } Util.SerializeXml(datafile, DatafileConstants.ItemsDatafile); }