public static void RecurseExport(XmlTextWriter xml, CategoryEntry ce) { xml.WriteStartElement("category"); xml.WriteAttributeString("title", ce.Title); List <CategoryEntry> subCats = new List <CategoryEntry>(ce.SubCategories); subCats.Sort(new CategorySorter()); for (int i = 0; i < subCats.Count; ++i) { RecurseExport(xml, subCats[i]); } ce.Matched.Sort(new CategoryTypeSorter()); for (int i = 0; i < ce.Matched.Count; ++i) { CategoryTypeEntry cte = ce.Matched[i]; xml.WriteStartElement("object"); xml.WriteAttributeString("type", cte.Type.ToString()); if (cte.Object is Item item) { int itemID = item.ItemID; if (item is BaseAddon addon && addon.Components.Count == 1) { itemID = addon.Components[0].ItemID; } if (itemID > TileData.MaxItemValue) { itemID = 1; } xml.WriteAttributeString("gfx", XmlConvert.ToString(itemID)); int hue = item.Hue & 0x7FFF; if ((hue & 0x4000) != 0) { hue = 0; } if (hue != 0) { xml.WriteAttributeString("hue", XmlConvert.ToString(hue)); } item.Delete(); } else if (cte.Object is Mobile mob) { int itemID = ShrinkTable.Lookup(mob, 1); xml.WriteAttributeString("gfx", XmlConvert.ToString(itemID)); int hue = mob.Hue & 0x7FFF; if ((hue & 0x4000) != 0) { hue = 0; } if (hue != 0) { xml.WriteAttributeString("hue", XmlConvert.ToString(hue)); } mob.Delete(); } xml.WriteEndElement(); } xml.WriteEndElement(); }
public static void RecurseExport(XmlTextWriter xml, CategoryEntry ce) { xml.WriteStartElement("category"); xml.WriteAttributeString("title", ce.Title); ArrayList subCats = new ArrayList(ce.SubCategories); subCats.Sort(new CategorySorter()); for (int i = 0; i < subCats.Count; ++i) { RecurseExport(xml, (CategoryEntry)subCats[i]); } ce.Matched.Sort(new CategorySorter()); for (int i = 0; i < ce.Matched.Count; ++i) { CategoryTypeEntry cte = (CategoryTypeEntry)ce.Matched[i]; xml.WriteStartElement("object"); xml.WriteAttributeString("type", cte.Type.ToString()); object obj = cte.Object; if (obj is Item) { Item item = (Item)obj; int itemID = item.ItemID; if (item is BaseAddon && ((BaseAddon)item).Components.Count == 1) { itemID = ((AddonComponent)(((BaseAddon)item).Components[0])).ItemID; } if (itemID >= 0x4000) { itemID = 1; } xml.WriteAttributeString("gfx", XmlConvert.ToString(itemID)); int hue = item.Hue & 0x7FFF; if ((hue & 0x4000) != 0) { hue = 0; } if (hue != 0) { xml.WriteAttributeString("hue", XmlConvert.ToString(hue)); } item.Delete(); } else if (obj is Mobile) { Mobile mob = (Mobile)obj; int itemID = ShrinkTable.Lookup(mob, 1); xml.WriteAttributeString("gfx", XmlConvert.ToString(itemID)); int hue = mob.Hue & 0x7FFF; if ((hue & 0x4000) != 0) { hue = 0; } if (hue != 0) { xml.WriteAttributeString("hue", XmlConvert.ToString(hue)); } mob.Delete(); } xml.WriteEndElement(); } xml.WriteEndElement(); }