Exemplo n.º 1
0
        /// <summary>
        /// Loads prop data from given XML file.
        /// </summary>
        /// <param name="filePath"></param>
        public static void Load(Stream stream)
        {
            using (var sr = new StreamReader(stream, true))
                using (var xmlReader = new XmlTextReader(sr))
                {
                    xmlReader.ReadToFollowing("FieldMapInfoList");

                    while (xmlReader.ReadToFollowing("MinimapInfo"))
                    {
                        var regionId    = int.Parse(xmlReader.GetAttribute("RegionID"));
                        var featureName = xmlReader.GetAttribute("feature");

                        // Ignore featureless entries when we already have one
                        var isFeatureEmpty = string.IsNullOrWhiteSpace(featureName);
                        if (_entries.ContainsKey(regionId) && isFeatureEmpty)
                        {
                            continue;
                        }

                        // Ignore entry if feature is not enabled
                        if (!isFeatureEmpty && !Features.IsEnabled(featureName))
                        {
                            continue;
                        }

                        // There is at least one mini map entry without heights
                        // and widths, so we need to check for null on those,
                        // or we'll get an exception. Still want to include the
                        // data though, just in case.

                        var entry = new MiniMapInfoEntry();

                        entry.RegionID       = regionId;
                        entry.feature        = featureName;
                        entry.MapName        = xmlReader.GetAttribute("MapName");
                        entry.MapLocalName   = xmlReader.GetAttribute("MapLocalName");
                        entry.MapWidth       = int.Parse(xmlReader.GetAttribute("MapWidth") ?? "0");
                        entry.MapHeight      = int.Parse(xmlReader.GetAttribute("MapHeight") ?? "0");
                        entry.MapFile        = xmlReader.GetAttribute("MapFile");
                        entry.MapImageWidth  = int.Parse(xmlReader.GetAttribute("MapImageWidth") ?? "0");
                        entry.MapImageHeight = int.Parse(xmlReader.GetAttribute("MapImageHeight") ?? "0");
                        entry.MapOffsetX     = int.Parse(xmlReader.GetAttribute("MapOffsetX") ?? "0");
                        entry.MapOffsetY     = int.Parse(xmlReader.GetAttribute("MapOffsetY") ?? "0");

                        entry.MapName      = Local.GetString(entry.MapName);
                        entry.MapLocalName = Local.GetString(entry.MapLocalName);
                        entry.MapFile      = Local.GetString(entry.MapFile);

                        _entries[entry.RegionID] = entry;
                    }
                }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads prop data from given XML file.
        /// </summary>
        /// <param name="filePath"></param>
        public static void Load(Stream stream)
        {
            using (var sr = new StreamReader(stream, true))
                using (var xmlReader = new XmlTextReader(sr))
                {
                    xmlReader.ReadToFollowing("FieldMapInfoList");

                    while (xmlReader.ReadToFollowing("MinimapInfo"))
                    {
                        var regionId    = int.Parse(xmlReader.GetAttribute("RegionID"));
                        var featureName = xmlReader.GetAttribute("feature");

                        // Ignore featureless entries when we already have one
                        var isFeatureEmpty = string.IsNullOrWhiteSpace(featureName);
                        if (_entries.ContainsKey(regionId) && isFeatureEmpty)
                        {
                            continue;
                        }

                        // Ignore entry if feature is not enabled
                        if (!isFeatureEmpty && !Features.IsEnabled(featureName))
                        {
                            continue;
                        }

                        var entry = new MiniMapInfoEntry();

                        entry.RegionID       = regionId;
                        entry.feature        = featureName;
                        entry.MapName        = xmlReader.GetAttribute("MapName");
                        entry.MapLocalName   = xmlReader.GetAttribute("MapLocalName");
                        entry.MapWidth       = int.Parse(xmlReader.GetAttribute("MapWidth"));
                        entry.MapHeight      = int.Parse(xmlReader.GetAttribute("MapHeight"));
                        entry.MapFile        = xmlReader.GetAttribute("MapFile");
                        entry.MapImageWidth  = int.Parse(xmlReader.GetAttribute("MapImageWidth"));
                        entry.MapImageHeight = int.Parse(xmlReader.GetAttribute("MapImageHeight"));
                        entry.MapOffsetX     = int.Parse(xmlReader.GetAttribute("MapOffsetX"));
                        entry.MapOffsetY     = int.Parse(xmlReader.GetAttribute("MapOffsetY"));

                        entry.MapName      = Local.GetString(entry.MapName);
                        entry.MapLocalName = Local.GetString(entry.MapLocalName);
                        entry.MapFile      = Local.GetString(entry.MapFile);

                        _entries[entry.RegionID] = entry;
                    }
                }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns entry with given region id via out if it exists.
 /// Returns true if entry was found.
 /// </summary>
 /// <param name="regionId"></param>
 /// <param name="entry"></param>
 /// <returns></returns>
 public static bool TryGetEntry(int regionId, out MiniMapInfoEntry entry)
 {
     return(_entries.TryGetValue(regionId, out entry));
 }