public TileLocation(int x, int y, int z, Chunk2D chunk, int chunkX, int chunkY) { this.X = x; this.Y = y; this.Z = z; this.World = chunk.World; if (Chunk2D.IsValidChunkCoordinate(World, chunkX, chunkY)) { this.AsLocalized = new Point(chunkX, chunkY); } else { var chunkPoint = World.ChunkPointFromTileLocation(x, y); chunk = World.GetChunk(chunkPoint.X, chunkPoint.Y); this.AsLocalized = new Point(X - chunk.Location.AsTile.X, Y - chunk.Location.AsTile.Y); } this.Chunk = chunk; this.AsPixel = new Point(X * World.Info.TileSize, Y * World.Info.TileSize); }
protected void CreateChunk(int x, int y) { var chunk = new Chunk2D(new ChunkLocation(this, x, y), new ITileObject[Info.ChunkTileSpan, Info.ChunkTileSpan, Info.LayerCount]); chunks[x, y] = chunk; }