Beispiel #1
0
        /// <summary>
        /// Load regions from the RGN file.
        /// </summary>
        private void LoadRgn(string mapPath, MapInstance map)
        {
            var    regions = new List <IMapRegion>();
            string rgn     = Path.Combine(mapPath, $"{map.Name}.rgn");

            using (var rgnFile = new RgnFile(rgn))
            {
                IEnumerable <IMapRespawnRegion> respawnersRgn = rgnFile.GetElements <RgnRespawn7>()
                                                                .Select(x => MapRespawnRegion.FromRgnElement(x));

                regions.AddRange(respawnersRgn);

                foreach (RgnRegion3 region in rgnFile.GetElements <RgnRegion3>())
                {
                    switch (region.Index)
                    {
                    case RegionInfo.RI_REVIVAL:
                        int revivalMapId     = map.MapInformation.RevivalMapId == 0 ? map.Id : map.MapInformation.RevivalMapId;
                        var newRevivalRegion = MapRevivalRegion.FromRgnElement(region, revivalMapId);
                        regions.Add(newRevivalRegion);
                        break;

                    case RegionInfo.RI_TRIGGER:
                        regions.Add(MapTriggerRegion.FromRgnElement(region));
                        break;

                        // TODO: load collector regions
                    }
                }
            }

            map.SetRegions(regions);
        }
Beispiel #2
0
        /// <summary>
        /// Load regions from the RGN file.
        /// </summary>
        private void LoadRgn()
        {
            string rgn = Path.Combine(this._mapPath, $"{this.Name}.rgn");

            using (var rgnFile = new RgnFile(rgn))
            {
                IEnumerable <IMapRespawnRegion> respawnersRgn = rgnFile.GetElements <RgnRespawn7>()
                                                                .Select(x => MapRespawnRegion.FromRgnElement(x));

                this._regions.AddRange(respawnersRgn);

                foreach (RgnRegion3 region in rgnFile.GetElements <RgnRegion3>())
                {
                    switch (region.Index)
                    {
                    case RegionInfo.RI_REVIVAL:
                        int revivalMapId     = this._worldInformations.RevivalMapId == 0 ? this.Id : this._worldInformations.RevivalMapId;
                        var newRevivalRegion = MapRevivalRegion.FromRgnElement(region, revivalMapId);
                        this._regions.Add(newRevivalRegion);
                        break;

                    case RegionInfo.RI_TRIGGER:
                        this._regions.Add(MapTriggerRegion.FromRgnElement(region));
                        break;

                        // TODO: load collector regions
                    }
                }

                if (!this._regions.Any(x => x is IMapRevivalRegion))
                {
                    // Loads the default revival region if no revival region is loaded.
                    this.DefaultRevivalRegion = new MapRevivalRegion(0, 0, 0, 0,
                                                                     this._worldInformations.RevivalMapId, this._worldInformations.RevivalKey, null, false, false);
                }
            }
        }