public static XBN_RootElement Deserialize(BinaryReader reader, XBN_Header header) { if (reader == null) { throw new Exception("Reader is null"); } if (header == null) { throw new Exception("Header is null"); } var mainTag = header.Tags[reader.ReadInt16()]; var unk1 = reader.ReadInt16(); var unk2 = reader.ReadInt16(); var totalElements = reader.ReadInt16(); List <XBN_Element> elements = new List <XBN_Element>(); List <XBN_Property> properties = new List <XBN_Property>(); List <XBN_RootElement> childs = new List <XBN_RootElement>(); if (unk1 > 0) { for (int i = 0; i < totalElements; i++) { properties.Add(XBN_Property.Deserialize(reader, header)); } //Testing for (int i = 0; i < unk1; i++) { childs.Add(Deserialize(reader, header)); } } else { for (int i = 0; i < totalElements; i++) { elements.Add(XBN_Element.Deserialize(reader, header)); } } return(new XBN_RootElement(header) { Name = mainTag, Unk1 = unk1, Unk2 = unk2, Childs = childs, Elements = elements, Properties = properties }); }
public static XBN_RootElement Deserialize(BinaryReader reader, XBN_Header header) { if (reader == null) { throw new Exception("Reader is null"); } if (header == null) { throw new Exception("Header is null"); } string mainTag = header.Tags[reader.ReadInt16()]; short unk1 = reader.ReadInt16(); short unk2 = reader.ReadInt16(); short totalElements = reader.ReadInt16(); var elements = new List <XBN_Element>(); var properties = new List <XBN_Property>(); var childs = new List <XBN_RootElement>(); if (unk1 > 0) { for (int i = 0; i < totalElements; i++) { var element = XBN_Property.Deserialize(reader, header); properties.Add(element); } childs.Add(XBN_RootElement.Deserialize(reader, header)); } else { for (int i = 0; i < totalElements; i++) { var element = XBN_Element.Deserialize(reader, header); elements.Add(element); } } return(new XBN_RootElement(header) { Name = mainTag, Unk1 = unk1, Unk2 = unk2, Childs = childs, Elements = elements, Properties = properties }); }
public static XBN_Element Deserialize(BinaryReader reader, XBN_Header header) { if (reader == null) { throw new Exception("Reader is null"); } if (header == null) { throw new Exception("Header is null"); } string name = header.Tags[reader.ReadInt16()]; short propertyCount = reader.ReadInt16(); short unk3 = reader.ReadInt16(); short tagCount = reader.ReadInt16(); var properties = new List <XBN_Property>(); for (int i = 0; i < propertyCount; i++) { properties.Add(XBN_Property.Deserialize(reader, header)); } var elements = new List <XBN_Element>(); for (int i = 0; i < tagCount; i++) { elements.Add(XBN_Element.Deserialize(reader, header)); } return(new XBN_Element(header) { Name = name, Unk3 = unk3, Properties = properties, Childs = elements }); }