/// <summary> Constructor. </summary> /// <param name="position"> The position of the given chunk. </param> /// <param name="storage"> The storage location of entities belonging to this chunk. </param> public Chunk(ChunkCoordinate position, AspectStorageContainer storage) { Storage = storage; Position = position; _items = new GridItem[NumberOfGridItemsWide * NumberOfGridItemsHigh]; AbsoluteIndex = Position.GetAbsoluteIndex(); }
/// <summary> /// Returns true if the given coordinate is a valid coordinate that can be used in this grid. /// </summary> public bool IsValid(ChunkCoordinate chunkCoordinate) { return(chunkCoordinate.X >= 0 && chunkCoordinate.X < NumberOfChunksWide && chunkCoordinate.Y >= 0 && chunkCoordinate.Y < NumberOfChunksWide); }
/// <summary> /// Gets the chunk at the specified coordinate. /// </summary> public Chunk this[ChunkCoordinate coordinate] { get { return(_chunks[CalculateIndex(coordinate.X, coordinate.Y)]); } set { _chunks[CalculateIndex(coordinate.X, coordinate.Y)] = value; } }
public GridCoordinate(ChunkCoordinate chunkCoordinate, InnerChunkGridCoordinate innerCoordinate) { X = (chunkCoordinate.X << Chunk.XGridCoordinateToChunkCoordinateBitShift) + innerCoordinate.X; Y = (chunkCoordinate.Y << Chunk.YGridCoordinateToChunkCoordinateBitShift) + innerCoordinate.Y; }