ItemInterface FindItemInterface(string name) { ItemInterface retintr = new ItemInterface(); retintr.name = ""; retintr.geometry = ""; foreach (ItemInterface intr in itemIterfaces) { if (intr.name == name) { retintr = intr; } } return(retintr); }
public void LoadItemIterfaces(string path) { if (Directory.Exists(path)) { foreach (var file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories)) { //Console.WriteLine(file); XDocument xml = XDocumentHelper.Load(file); IEnumerable <XElement> elements = xml.Elements(); foreach (var el in elements) { if (el.Name == "interface") { ItemInterface itemInterface = new ItemInterface(); itemInterface.name = el.Attribute("name").Value; //Console.WriteLine(el.Name); //Console.WriteLine(el.Element("geometry").Element("thirdperson")); //Console.WriteLine(el.Descendants("geometry").Descendants("thirdperson")); //foreach (XElement ell in el.Descendants("geometry").Descendants("thirdperson")) //{ // Console.WriteLine(ell); //} if (el.Element("geometry") != null) { if (el.Element("geometry").Element("thirdperson") != null) { itemInterface.geometry = el.Element("geometry").Element("thirdperson").Attribute("name").Value; //Console.WriteLine(itemInterface.geometry); //Console.WriteLine(el.Element("geometry").Element("thirdperson").Attribute("name").Value); } } //Console.WriteLine(itemInterface.name); itemIterfaces.Add(itemInterface); } } } } else { Console.WriteLine("[ERROR] NOT FOUND: {0}", path); SuccessfullyLoaded = false; } }
public void LoadItems(string path) { if (Directory.Exists(path)) { foreach (var file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories)) { //Console.WriteLine(file); XDocument xml = XDocumentHelper.Load(file); IEnumerable <XElement> elements = xml.Elements(); foreach (var el in elements) { if (el.Name == "item") { Item item = new Item(); item.name = el.Attribute("name").Value; item.itemclass = el.Attribute("class").Value; //Console.WriteLine(el.Name); //Console.WriteLine(el.Element("geometry").Element("thirdperson")); //Console.WriteLine(el.Descendants("geometry").Descendants("thirdperson")); //foreach (XElement ell in el.Descendants("geometry").Descendants("thirdperson")) //{ // Console.WriteLine(ell); //} if (el.Element("geometry") != null) { if (el.Element("geometry").Element("thirdperson") != null) { item.geometry = el.Element("geometry").Element("thirdperson").Attribute("name").Value; //Console.WriteLine(item.geometry); //Console.WriteLine(el.Element("geometry").Element("thirdperson").Attribute("name").Value); } } if (el.Attribute("interface") != null) { item.intrface = el.Attribute("interface").Value; ItemInterface iteminterface = FindItemInterface(item.intrface); if (iteminterface.geometry != "") { item.geometry = iteminterface.geometry; } //Console.WriteLine(item.geometry); } if (el.Element("PrefabAttachments") != null) { foreach (XElement ell in el.Element("PrefabAttachments").Descendants("PrefabAttachment")) { PrefabAttachment prefabAtt = new PrefabAttachment(); prefabAtt.attachmentPoint = ell.Attribute("attachmentPoint").Value; prefabAtt.prefabLibrary = ell.Attribute("prefabLibrary").Value; prefabAtt.prefabName = ell.Attribute("prefabName").Value; item.PrefabAttachments.Add(prefabAtt); // Console.WriteLine("prefabatt {0} {1} {2}", prefabAtt.attachmentPoint, prefabAtt.prefabLibrary, prefabAtt.prefabName); } //Console.WriteLine(item.PrefabAttachments.Count); } //Console.WriteLine(item.name); items.Add(item); } } } } else { Console.WriteLine("[ERROR] NOT FOUND: {0}", path); SuccessfullyLoaded = false; } }