public void SetLightLocal(int x, int y, int z, byte light) { int index = ArrayUtil.Convert3DTo1D(x, y, z, _length, _height); GridPoint gp = _points[index]; gp.Metadata[0] = light; }
public Chunk Get(int x, int y, int z) { if (x < 0 || x >= _worldWidth || y < 0 || y >= _worldHeight || z < 0 || z >= _worldLength) { return(null); } int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight); return(_chunks[index]); }
public void BuildAllChunks() { for (int x = 0; x < _worldWidth; x++) { for (int z = 0; z < _worldLength; z++) { if (_config.CPULightingEnabled) { _lightManager.LightChunkColumn(x, z); } else { for (int y = 0; y < _worldHeight; y++) { int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight); _chunks[index].MarkChunkAwaitingBuild(); } } } } for (int x = 0; x < _worldWidth; x++) { for (int y = 0; y < _worldHeight; y++) { for (int z = 0; z < _worldLength; z++) { int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight); _chunkSystem.Builder.Build(_chunks[index]); } } } if (_chunkSystem.Builder.RequiresPostProcess) { for (int x = 0; x < _worldWidth; x++) { for (int y = 0; y < _worldHeight; y++) { for (int z = 0; z < _worldLength; z++) { int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight); _chunkSystem.Builder.PostProcess(_chunks[index]); } } } } }
public GridPoint PointAt(int x, int y, int z) { int cx = x / _config.ChunkWidth; int cy = y / _config.ChunkHeight; int cz = z / _config.ChunkLength; int lx = x % _config.ChunkWidth; int ly = y % _config.ChunkHeight; int lz = z % _config.ChunkLength; Chunk c = _chunkManager[cx, cy, cz]; if (c == null || lx < 0 || ly < 0 || lz < 0) { return(new GridPoint(GridPoint.Empty)); } return(c.Points[ArrayUtil.Convert3DTo1D(lx, ly, lz, _config.ChunkLength, _config.ChunkHeight)]); }
public void GenerateChunks() { int chunkWidth = _world.EngineConfiguration.ChunkWidth; int chunkHeight = _world.EngineConfiguration.ChunkHeight; int chunkLength = _world.EngineConfiguration.ChunkLength; for (int x = 0; x < _worldWidth; x++) { for (int y = 0; y < _worldHeight; y++) { for (int z = 0; z < _worldLength; z++) { int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight); Chunk c = new Chunk(_world, new Vector3I(x * chunkWidth, y * chunkHeight, z * chunkLength), chunkWidth, chunkHeight, chunkLength); _chunkGenerator.Generate(c); _chunks[index] = c; } } } }
public void SetPointLocal(int x, int y, int z, GridPoint gp, bool suppressRebuild = false) { _points[ArrayUtil.Convert3DTo1D(x, y, z, _length, _height)] = gp; if (!suppressRebuild) { MarkDataOutOfSync(false); List <Chunk> rebuildChunks = new List <Chunk>(1); rebuildChunks.Add(this); Chunk xNegative = XNegative; Chunk xPositive = XPositive; Chunk yNegative = YNegative; Chunk yPositive = YPositive; Chunk zNegative = ZNegative; Chunk zPositive = ZPositive; Chunk xNegativezNegative = _world.ChunkManager[ChunkSpaceX - 1, ChunkSpaceY, ChunkSpaceZ - 1]; Chunk xNegativeyNegative = _world.ChunkManager[ChunkSpaceX - 1, ChunkSpaceY - 1, ChunkSpaceZ]; Chunk yNegativezNegative = _world.ChunkManager[ChunkSpaceX, ChunkSpaceY - 1, ChunkSpaceZ - 1]; bool minx = false; bool miny = false; bool minz = false; if ((x == 0 || x == 1) && xNegative != null) { rebuildChunks.Add(xNegative); minx = true; } if (x == _width - 1 && xPositive != null) { rebuildChunks.Add(xPositive); } if ((y == 0 || y == 1) && yNegative != null) { rebuildChunks.Add(yNegative); miny = true; } if (y == _height - 1 && yPositive != null) { rebuildChunks.Add(yPositive); } if ((z == 0 || z == 1) && zNegative != null) { rebuildChunks.Add(zNegative); minz = true; } if (z == _length - 1 && zPositive != null) { rebuildChunks.Add(zPositive); } if (minx && minz && xNegativezNegative != null) { rebuildChunks.Add(xNegativezNegative); } if (minx && miny && xNegativeyNegative != null) { rebuildChunks.Add(xNegativeyNegative); } if (miny && minz && yNegativezNegative != null) { rebuildChunks.Add(yNegativezNegative); } _world.ChunkManager.EnqueueChunkForBuild(rebuildChunks.ToArray()); } }