/// <summary> /// Deletes a chunk from the underlying data store at the given local coordinates relative to this region. /// </summary> /// <param name="lcx">The local X-coordinate of a chunk relative to this region.</param> /// <param name="lcz">The local Z-coordinate of a chunk relative to this region.</param> /// <returns>True if there is a chunk was deleted; false otherwise.</returns> /// <remarks>If the local coordinates are out of bounds for this region, the action will be forwarded to the correct region /// transparently.</remarks> public bool DeleteChunk(int lcx, int lcz) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); return((alt == null) ? false : alt.DeleteChunk(ForeignX(lcx), ForeignZ(lcz))); } RegionFile rf = GetRegionFile(); if (!rf.HasChunk(lcx, lcz)) { return(false); } rf.DeleteChunk(lcx, lcz); ChunkKey k = new ChunkKey(ChunkGlobalX(lcx), ChunkGlobalZ(lcz)); _cache.Remove(k); if (ChunkCount() == 0) { _regionMan.DeleteRegion(X, Z); _regionFile.Target = null; } return(true); }
/// <inheritdoc/> public bool DeleteChunk(int cx, int cz) { IRegion r = GetRegion(cx, cz); if (r == null) { return(false); } if (!r.DeleteChunk(cx & REGION_XMASK, cz & REGION_ZMASK)) { return(false); } if (r.ChunkCount() == 0) { _regionMan.DeleteRegion(r.X, r.Z); } return(true); }