/// <summary> /// Returns the CacheData at a specific point from the grid array. Does not /// interfere with the savedChunk data (loading or saving). Throws an /// IndexOutOfRangeException if the specified chunk coordinates are out /// of the range of the grid. /// </summary> /// <param name="chunkX"></param> /// <param name="chunkZ"></param> /// <returns></returns> private CacheData this[int chunkX, int chunkZ] { get { lock (CacheLock) { ChunkCoordinate coord = new ChunkCoordinate(chunkX, chunkZ); if (savedChunkData.ContainsKey(coord)) { return(savedChunkData[coord]); } if (!IsInGridRange(chunkX, chunkZ)) { throw new IndexOutOfRangeException(); } int xIndex = Numerical.IntMod(chunkX, Width); int zIndex = Numerical.IntMod(chunkZ, Height); return(cache[xIndex, zIndex]); } } set { lock (CacheLock) { if (!IsInGridRange(chunkX, chunkZ)) { throw new IndexOutOfRangeException(); } int xIndex = Numerical.IntMod(chunkX, Width); int zIndex = Numerical.IntMod(chunkZ, Height); cache[xIndex, zIndex] = value; } } }