public WorldObjectType DeserializeWorldObjectType(TWXmlNode node)
        {
            var type = new WorldObjectType(meshFactory.GetMesh(XMLSerializer.ReadGuid(node.FindChildNode("Mesh"))),
                                           XMLSerializer.ReadGuid(node.FindChildNode("Guid")), builder);

            type.TileData = diskTileDataFactory.GetTileData(XMLSerializer.ReadGuid(node.FindChildNode("TileData")));
            if (type.TileData == null)
            {
                throw new InvalidOperationException("TileData For WorldObjectType not found!!");
            }
            return(type);
        }
Пример #2
0
        public void ApplyUpdatePacket(IStaticWorldObject obj, StaticWorldObjectUpdatePacket p)
        {
            var o = obj as SimpleStaticWorldObject;

            var newMesh = meshFactory.GetMesh(p.MeshGuid);


            if (o.Mesh != newMesh)
            {
                o.ChangeMesh(newMesh);
            }

            o.WorldMatrix = XnaMathExtensions.CreateMatrixFromFloatArray(p.WorldMatrix, 0);
        }
        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);
        }