/// <summary> /// Deserialization constructor for root category only. /// </summary> /// <param name="src">Source Serializable Market Group</param> private MarketGroup(SerializableMarketGroup src) { ID = src.ID; Name = src.Name; SubGroups = new MarketGroupCollection(this, src.SubGroups); Items = new ItemCollection(this, src.Items); }
/// <summary> /// Deserialization constructor for root category only /// </summary> /// <param name="src">Source Serializable Market Group</param> public MarketGroup(SerializableMarketGroup src) { m_id = src.ID; m_name = src.Name; m_subCategories = new MarketGroupCollection(this, src.SubGroups); m_items = new ItemCollection(this, src.Items); }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="parent">The Market Group this Market Group is contained within</param> /// <param name="src">Source Serializable Market Group</param> public MarketGroup(MarketGroup parent, SerializableMarketGroup src) : this(src) { ParentGroup = parent; }
/// <summary> /// Sets the item family according to its market group /// </summary> /// <param name="group"></param> /// <param name="itemFamily"></param> private static void SetItemFamilyByMarketGroup(SerializableMarketGroup group, ItemFamily itemFamily) { foreach (SerializableItem item in group.Items) { item.Family = itemFamily; } foreach (SerializableMarketGroup childGroup in group.SubGroups) { SetItemFamilyByMarketGroup(childGroup, itemFamily); } }
/// <summary> /// Generate the items datafile. /// </summary> private static void GenerateItems() { Console.WriteLine(); Console.Write(@"Generated items datafile... "); s_counter = 0; s_percentOld = 0; s_text = String.Empty; s_startTime = DateTime.Now; // Create custom market groups that don't exist in EVE s_injectedMarketGroups = new List<InvMarketGroup> { new InvMarketGroup { Name = "Various Non-Market", Description = "Non-Market Items", ID = DBConstants.RootNonMarketGroupID, ParentID = null, IconID = null }, new InvMarketGroup { Name = "Unique Designs", Description = "Ships of a unique design", ID = DBConstants.RootUniqueDesignsGroupID, ParentID = DBConstants.ShipsGroupID, IconID = 1443 }, new InvMarketGroup { Name = "Unique Shuttles", Description = "Fast ships of a unique design", ID = DBConstants.UniqueDesignShuttlesGroupID, ParentID = DBConstants.RootUniqueDesignsGroupID, IconID = null }, new InvMarketGroup { Name = "Unique Battleships", Description = "Battleships ships of a unique design", ID = DBConstants.UniqueDesignBattleshipsGroupID, ParentID = DBConstants.RootUniqueDesignsGroupID, IconID = null }, }; // Manually set some items attributes s_types[11].Published = true; s_types[12].Published = true; s_types[13].Published = true; s_types[2014].Published = true; s_types[2015].Published = true; s_types[2016].Published = true; s_types[2017].Published = true; s_types[2063].Published = true; s_types[30889].Published = true; s_types[27029].Published = true; s_types[32077].Published = true; // Set some attributes to items because their MarketGroupID is NULL foreach (InvType srcItem in s_types.Where(x => x.Published && x.MarketGroupID == null)) { // Set some ships market group and race switch (srcItem.ID) { case 13202: // Megathron Federate Issue case 26840: // Raven State Issue case 26842: // Tempest Tribal Issue srcItem.MarketGroupID = DBConstants.UniqueDesignBattleshipsGroupID; srcItem.RaceID = (int)Race.Faction; break; case 21097: // Goru's Shuttle case 21628: // Guristas Shuttle case 30842: // Interbus Shuttle srcItem.MarketGroupID = DBConstants.UniqueDesignShuttlesGroupID; srcItem.RaceID = (int)Race.Faction; break; // Set some items market group to support blueprints case 21815: case 23882: case 24289: case 27029: case 27038: case 29203: case 29226: case 10260: case 19758: case 10257: case 10258: case 32077: case 30424: case 30839: case 30422: case 30342: case 30420: case 30328: case 21054: case 17761: case 23883: case 29202: case 21510: case 22335: case 22333: case 22337: case 22339: case 22923: case 22329: case 22327: case 22325: case 22331: srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID; break; } // Set some items market group to support blueprints if (srcItem.ID > 28685 && srcItem.ID < 28694) srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID; // Adding planets to support attribute browsing for command centers if (srcItem.GroupID == DBConstants.PlanetGroupID) srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID; } var groups = new Dictionary<int, SerializableMarketGroup>(); // Create the market groups foreach (InvMarketGroup srcGroup in s_marketGroups.Concat(s_injectedMarketGroups)) { var group = new SerializableMarketGroup {ID = srcGroup.ID, Name = srcGroup.Name}; groups[srcGroup.ID] = group; // Add the items in this group var items = new List<SerializableItem>(); foreach (InvType srcItem in s_types .Where(x => x.Published && (x.MarketGroupID.GetValueOrDefault() == srcGroup.ID))) { CreateItem(srcItem, items); } // If this is an implant group, we add the implants with no market groups in this one. if (srcGroup.ParentID == DBConstants.SkillHardwiringImplantGroupID || srcGroup.ParentID == DBConstants.AttributeEnhancersImplantsGroupID) { string slotString = srcGroup.Name.Substring("Implant Slot ".Length); int slot = Int32.Parse(slotString); // Enumerate all implants without market groups foreach (InvType srcItem in s_types .Where(x => x.MarketGroupID == null && s_groups[x.GroupID].CategoryID == DBConstants.ImplantCategoryID && x.GroupID != DBConstants.CyberLearningImplantsGroupID) ) { // Check the slot matches DgmTypeAttribute slotAttrib = s_typeAttributes.Get(srcItem.ID, DBConstants.ImplantSlotPropertyID); if (slotAttrib != null && slotAttrib.GetIntValue() == slot) CreateItem(srcItem, items); } } // Store the items group.Items = items.OrderBy(x => x.Name).ToArray(); } // Create the parent-children groups relations foreach (SerializableMarketGroup group in groups.Values) { IEnumerable<SerializableMarketGroup> children = s_marketGroups.Concat(s_injectedMarketGroups).Where(x => x.ParentID.GetValueOrDefault() == group.ID) .Select(x => groups[x.ID]); group.SubGroups = children.OrderBy(x => x.Name).ToArray(); } // Pick the family SetItemFamilyByMarketGroup(groups[DBConstants.BlueprintsGroupID], ItemFamily.Bpo); SetItemFamilyByMarketGroup(groups[DBConstants.ShipsGroupID], ItemFamily.Ship); SetItemFamilyByMarketGroup(groups[DBConstants.ImplantsGroupID], ItemFamily.Implant); SetItemFamilyByMarketGroup(groups[DBConstants.DronesGroupID], ItemFamily.Drone); SetItemFamilyByMarketGroup(groups[DBConstants.StarbaseStructuresGroupID], ItemFamily.StarbaseStructure); // Sort groups IOrderedEnumerable<SerializableMarketGroup> rootGroups = s_marketGroups.Concat(s_injectedMarketGroups).Where(x => !x.ParentID.HasValue).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 ItemsDatafile(); datafile.MarketGroups = rootGroups.ToArray(); Util.SerializeXML(datafile, DatafileConstants.ItemsDatafile); }
/// <summary> /// Creates the market groups. /// </summary> /// <param name="groups">The groups.</param> private static void CreateMarketGroups(IDictionary<int, SerializableMarketGroup> groups) { foreach (InvMarketGroups marketGroup in Database.InvMarketGroupsTable.Concat(s_injectedMarketGroups)) { SerializableMarketGroup group = new SerializableMarketGroup { ID = marketGroup.ID, Name = marketGroup.Name }; groups[marketGroup.ID] = group; // Add the items in this group; excluding the implants we are adding below List<SerializableItem> items = new List<SerializableItem>(); foreach (InvTypes srcItem in Database.InvTypesTable.Where( item => !item.Generated && item.MarketGroupID.GetValueOrDefault() == marketGroup.ID).Where( srcItem => marketGroup.ParentID != DBConstants.RootNonMarketGroupID || Database.InvGroupsTable[srcItem.GroupID].CategoryID != DBConstants.ImplantCategoryID || srcItem.GroupID == DBConstants.CyberLearningImplantsGroupID)) { CreateItem(srcItem, items); } // Store the items group.Items.AddRange(items.OrderBy(x => x.Name)); } }