Exemplo n.º 1
0
        public Voxel ReadVoxel(int x, int y, int z)
        {
            int chunkX = x, chunkY = y, chunkZ = z;

            VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ);
            var chunk = GetChunk(chunkX, chunkY, chunkZ);

            if (chunk != null)
            {
                VoxelChunk.ConvertWorldToLocal(ref x, ref y, ref z);
                return(chunk.GetVoxel(x, y, z));
            }

            return(new Voxel());
        }
Exemplo n.º 2
0
        public void ReadBlock(BlockQuery block, int x, int y, int z)
        {
            int chunkX = x, chunkY = y, chunkZ = z;

            VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ);
            var   chunk = GetChunk(chunkX, chunkY, chunkZ);
            Voxel voxel;

            if (chunk != null)
            {
                VoxelChunk.ConvertWorldToLocal(ref x, ref y, ref z);
                voxel = chunk.GetVoxel(x, y, z);
            }
            else
            {
                voxel = new Voxel();
            }

            //TODO: Properly query for core voxel if current voxel.IsPointer
            block.Set(voxel, chunk, x, y, z);
        }
Exemplo n.º 3
0
        private void GetNextChunk(int x, int y, int z, bool createIfMissing)
        {
            int chunkX = x;
            int chunkY = y;
            int chunkZ = z;

            bool shouldGet = false;

            VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ);

            if (LastChunk != null)
            {
                Vector3i lastChunkPosition = LastChunk.ChunkPosition;

                if (chunkX != lastChunkPosition.x || chunkY != lastChunkPosition.y || chunkZ != lastChunkPosition.z)
                {
                    shouldGet = true;
                }
            }
            else
            {
                shouldGet = true;
            }

            if (shouldGet)
            {
                if (createIfMissing)
                {
                    LastChunk = Map.GetOrCreateChunk(chunkX, chunkY, chunkZ);
                }
                else
                {
                    LastChunk = Map.GetChunk(chunkX, chunkY, chunkZ);
                }
            }
        }
Exemplo n.º 4
0
 public VoxelChunk GetOrCreateChunkFromWorldPosition(int worldX, int worldY, int worldZ)
 {
     VoxelChunk.ConvertWorldToChunk(ref worldX, ref worldY, ref worldZ);
     return(GetOrCreateChunk(worldX, worldY, worldZ));
 }