Пример #1
0
        private void LoadAvailableRegions()
        {
            string path = Path.Combine(BasePath, "region");

            //Debug.WriteLine($"Loading all regions from {path}");

            if (!Directory.Exists(path))
            {
                return;
            }

            string[] files = Directory.GetFiles(path);

            foreach (string regionFilePath in files)
            {
                string regionFile = regionFilePath.Replace(path + Path.DirectorySeparatorChar, "");
                try
                {
                    Match match = RegionFilenameRegex.Match(regionFile);
                    if (match.Success)
                    {
                        int x = int.Parse(match.Groups["x"].Value);
                        int z = int.Parse(match.Groups["z"].Value);

                        var region = new AnvilRegion(this, x, z);
                        _regionCache.TryAdd(new ChunkCoordinates(x, z), region);
                    }
                }
                catch (Exception ex) {}
            }
        }
Пример #2
0
        private AnvilRegion GenerateRegion(ChunkCoordinates coords)
        {
            int x            = coords.X >> 5;
            int z            = coords.Z >> 5;
            var regionCoords = new ChunkCoordinates(x, z);

            //Debug.WriteLine($"Generating AnvilRegion {x},{z}");

            var region = new AnvilRegion(this, x, z);

            _regionCache[regionCoords] = region;
            return(region);
        }
Пример #3
0
        private void DeleteChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            AnvilRegion region = GetRegion(chunkCoordinates);

            region?.DeleteChunk(chunkCoordinates);
        }
Пример #4
0
        private ChunkColumn GetChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            AnvilRegion region = GetRegion(chunkCoordinates);

            return(region?.GetChunk(chunkCoordinates, false));
        }
Пример #5
0
        public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates, bool cacheOnly = false)
        {
            AnvilRegion region = GetRegion(chunkCoordinates);

            return(region.GetChunk(chunkCoordinates));
        }