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) {} } }
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); }
private void DeleteChunkColumn(ChunkCoordinates chunkCoordinates) { AnvilRegion region = GetRegion(chunkCoordinates); region?.DeleteChunk(chunkCoordinates); }
private ChunkColumn GetChunkColumn(ChunkCoordinates chunkCoordinates) { AnvilRegion region = GetRegion(chunkCoordinates); return(region?.GetChunk(chunkCoordinates, false)); }
public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates, bool cacheOnly = false) { AnvilRegion region = GetRegion(chunkCoordinates); return(region.GetChunk(chunkCoordinates)); }