//! Load cloth with given name and for given group. public ClothItemGroup load(string Name, CharacterGroup Group) { // Not loaded yet if (!clothes.ContainsKey(Name)) { string full_path = wrkPath + '/' + Name; XmlReader xml = XmlReader.Create(new StringReader(((TextAsset)Resources.Load(full_path, typeof(TextAsset))).text)); // Parse file xml.Read(); // Root node xml.MoveToContent(); // Move to first child if (!xml.ReadToDescendant("item")) { throw new XmlException("Cannot find element 'item' - " + xml.Name); } // Get item name string item_name = xml.GetAttribute("name"); // Make new group dict var group_dict = new Dictionary <CharacterGroup, ClothItemGroup>(); // Get items xml.ReadToDescendant("group"); do { // Get group type CharacterGroup group = (CharacterGroup)Convert.ToUInt16(xml.GetAttribute("id")); // Get prefab name string prefab = xml.GetAttribute("prefab"); // Read all character parts affected var char_items = new List <ClothItem>(); xml.ReadToDescendant("item"); do { char_items.Add(new ClothItem(CharacterPartHelper.FromString(xml.GetAttribute("part")), (CharacterType)Convert.ToUInt16(xml.GetAttribute("type")))); } while (xml.ReadToNextSibling("item")); // Add tuple group_dict[group] = new ClothItemGroup(prefab, char_items.ToArray()); } while (xml.ReadToNextSibling("group")); // Add new group clothes[Name] = group_dict; } return(clothes[Name][Group]); }
//! Load cloth with given name and for given group. public ClothItemGroup load(string Name, CharacterGroup Group) { // Not loaded yet if (!clothes.ContainsKey(Name)) { string full_path = wrkPath + '/' + Name; XmlReader xml = XmlReader.Create(new StringReader(((TextAsset)Resources.Load(full_path, typeof(TextAsset))).text)); // Parse file xml.Read(); // Root node xml.MoveToContent(); // Move to first child if (!xml.ReadToDescendant("item")) throw new XmlException("Cannot find element 'item' - " + xml.Name); // Get item name string item_name = xml.GetAttribute("name"); // Make new group dict var group_dict = new Dictionary<CharacterGroup, ClothItemGroup>(); // Get items xml.ReadToDescendant("group"); do { // Get group type CharacterGroup group = (CharacterGroup)Convert.ToUInt16(xml.GetAttribute("id")); // Get prefab name string prefab = xml.GetAttribute("prefab"); // Read all character parts affected var char_items = new List<ClothItem>(); xml.ReadToDescendant("item"); do { char_items.Add(new ClothItem(CharacterPartHelper.FromString(xml.GetAttribute("part")), (CharacterType)Convert.ToUInt16(xml.GetAttribute("type")))); } while (xml.ReadToNextSibling("item")); // Add tuple group_dict[group] = new ClothItemGroup(prefab, char_items.ToArray()); } while (xml.ReadToNextSibling("group")); // Add new group clothes[Name] = group_dict; } return clothes[Name][Group]; }