Example #1
0
        public static void ReadFromXmlPack(Stream xmlPackStream, IPackFileSystemContext packContext)
        {
            string xmlPackContents;

            using (var xmlReader = new StreamReader(xmlPackStream)) {
                xmlPackContents = xmlReader.ReadToEnd();
            }

            var    packDocument = new XmlDocument();
            string packSrc      = SanitizeXml(xmlPackContents);
            bool   packLoaded   = false;

            try {
                packDocument.LoadXml(packSrc);
                packLoaded = true;
            } catch (XmlException exception) {
                GameService.Debug.WriteErrorLine($"Could not load tacO overlay file {packContext} from context {xmlPackContents.GetType().Name} due to an XML error.  Error: {exception.Message}");
            } catch (Exception exception) {
                throw;
            }

            if (packLoaded)
            {
                TryLoadCategories(packDocument);
                TryLoadPOIs(packDocument, packContext, Categories);
            }
        }
Example #2
0
        public void RegisterPathContext(IPackFileSystemContext packContext)
        {
            if (packContext == null)
            {
                return;
            }

            this.PackContexts.Add(packContext);
        }
Example #3
0
        private static void TryLoadPOIs(XmlDocument packDocument, IPackFileSystemContext packContext, PathingCategory rootCategory)
        {
            var poiNodes = packDocument.DocumentElement?.SelectSingleNode("/OverlayData/POIs");

            if (poiNodes == null)
            {
                return;
            }

            foreach (XmlNode poiNode in poiNodes)
            {
                PoiBuilder.UnpackPathable(poiNode, packContext, rootCategory);
            }
        }
Example #4
0
        public static void UnpackPathable(XmlNode pathableNode, IPackFileSystemContext packContext, PathingCategory rootCategory)
        {
            switch (pathableNode.Name.ToLower())
            {
            case ELEMENT_POITYPE_POI:
                var newPoiMarker = new TacOMarkerPathable(pathableNode, packContext, rootCategory);

                if (newPoiMarker.SuccessfullyLoaded)
                {
                    GameService.Pathing.RegisterPathable(newPoiMarker);
                }
                else
                {
                    Console.WriteLine("Failed to load marker: ");
                    Console.WriteLine(string.Join("; ", pathableNode.Attributes.Select(s => ((XmlAttribute)s).Name + " = " + ((XmlAttribute)s).Value)));
                }
                break;

            case ELEMENT_POITYPE_TRAIL:
                var newPathTrail = new TacOTrailPathable(pathableNode, packContext, rootCategory);

                if (newPathTrail.SuccessfullyLoaded)
                {
                    GameService.Pathing.RegisterPathable(newPathTrail);
                }
                else
                {
                    Console.WriteLine("Failed to load trail: ");
                    Console.WriteLine(string.Join("; ", pathableNode.Attributes.Select(s => ((XmlAttribute)s).Name + " = " + ((XmlAttribute)s).Value)));
                }

                break;

            case ELEMENT_POITYPE_ROUTE:
                Console.WriteLine("Skipped loading route.");
                //RouteBuilder.UnpackNode(pathableNode);

                break;

            default:
                Console.WriteLine($"Tried to unpack '{pathableNode.Name}' as POI!");
                break;
            }
        }