public void Deserialize(T obj, Stream strm) { var type = typeof(T); var rootNode = TWXmlNode.GetRootNodeFromStream(strm); deserializeObject(type, rootNode, obj); }
public TileData DeserializeTileData(Stream stream) { var node = TWXmlNode.GetRootNodeFromStream(stream); var data = new TileData(XMLSerializer.ReadGuid(node.FindChildNode("Guid"))) { Mesh = meshFactory.GetMesh(XMLSerializer.ReadGuid(node.FindChildNode("Mesh"))), Dimensions = XMLSerializer.ReadVector3(node.FindChildNode("Dimensions")) }; var faces = node.FindChildNode("Faces").GetChildNodes(); for (int i = 0; i < faces.Length; i++) { var cFace = faces[i]; var face = (TileFace)Enum.Parse(typeof(TileFace), cFace.GetAttribute("Face")); data.SetFaceType(face, tileFaceTypeFactory.GetTileFaceType(XMLSerializer.ReadGuid(cFace.FindChildNode("Type")))); data.SetLocalWinding(face, XMLSerializer.ReadBoolean(cFace.FindChildNode("Winding"))); } return(data); }
public void DeserializeWorld(World world, Stream stream) { var rootNode = TWXmlNode.GetRootNodeFromStream(stream); var typesNodes = rootNode.FindChildNode("WorldObjectTypes").GetChildNodes(); for (int i = 0; i < typesNodes.Length; i++) { var nType = typesNodes[i]; worldObjectTypeFactory.AddWorldObjectType(DeserializeWorldObjectType(nType)); } var objectNodes = rootNode.FindChildNode("WorldObjects").GetChildNodes(); for (int i = 0; i < objectNodes.Length; i++) { var nObj = objectNodes[i]; // Auto-adds it to the world DeserializeWorldObject(world, nObj); } }