Example #1
0
        public void WriteWalkmesh(Walkmesh walkmesh)
        {
            XmlElement node = _root.EnsureChildElement("Walkmesh");

            node.RemoveAll();

            bool isExists = walkmesh != null;

            node.SetBoolean("IsExists", isExists);

            if (!isExists)
            {
                return;
            }

            string wlkPath = Path.ChangeExtension(_xmlPath, ".wlk.xml");

            node = XmlHelper.CreateDocument("Walkmesh");

            XmlElement triangles = node.EnsureChildElement("Triangles");

            foreach (WalkmeshTriangle triangle in walkmesh.Triangles)
            {
                Write(triangle, triangles.CreateChildElement("Triangle"));
            }

            XmlElement passability = node.EnsureChildElement("Passability");

            foreach (WalkmeshPassability pass in walkmesh.Passability)
            {
                Write(pass, passability.CreateChildElement("Pass"));
            }

            node.GetOwnerDocument().Save(wlkPath);
        }
Example #2
0
        public bool ReadWalkmesh(Location location)
        {
            if (_root == null)
            {
                return(false);
            }

            XmlElement node = _root["Walkmesh"];

            if (node == null)
            {
                return(false);
            }

            if (!node.GetBoolean("IsExists"))
            {
                return(true);
            }

            string      wlkPath = Path.ChangeExtension(_xmlPath, ".wlk.xml");
            XmlDocument wlkDoc  = new XmlDocument();

            wlkDoc.Load(wlkPath);

            node = wlkDoc.GetDocumentElement();

            XmlElement trianglesNode = node.GetChildElement("Triangles");

            WalkmeshTriangle[] triangles = new WalkmeshTriangle[trianglesNode.ChildNodes.Count];
            for (int i = 0; i < triangles.Length; i++)
            {
                triangles[i] = ReadWalkmeshTriangle((XmlElement)trianglesNode.ChildNodes[i]);
            }

            XmlElement passabilityNode = node.GetChildElement("Passability");

            WalkmeshPassability[] passability = new WalkmeshPassability[passabilityNode.ChildNodes.Count];
            for (int i = 0; i < passability.Length; i++)
            {
                passability[i] = ReadWalkmeshPassability((XmlElement)passabilityNode.ChildNodes[i]);
            }

            Walkmesh result = new Walkmesh(triangles, passability);

            location.Walkmesh = result;

            location.SaveRequest &= ~LocationProperty.Walkmesh;
            location.Importable  |= LocationProperty.Walkmesh;
            return(true);
        }
Example #3
0
        public bool ReadWalkmesh(Location location)
        {
            ArchiveFileEntry idEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".id");

            if (idEntry == null)
            {
                return(true);
            }

            using (IdFileReader idReader = new IdFileReader(idEntry.OpenReadableContentStream()))
            {
                WalkmeshTriangle[]    triangles   = idReader.Triangles.Select(t => new WalkmeshTriangle(t.Vertices.Select(v => v.Point).ToArray())).ToArray();
                WalkmeshPassability[] passability = idReader.Accesses.Select(a => new WalkmeshPassability(a.Accesses)).ToArray();
                Walkmesh result = new Walkmesh(triangles, passability);
                location.Walkmesh = result;
            }

            location.SaveRequest &= ~LocationProperty.Walkmesh;
            location.Importable  &= ~LocationProperty.Walkmesh;
            return(true);
        }
Example #4
0
 public void WriteWalkmesh(Walkmesh walkmesh)
 {
     throw new NotImplementedException();
 }