Beispiel #1
0
        private void CalculateSkyLight(Chunk chunk, int x, int y, int z)
        {
            byte self = chunk.GetSkyLight(x, y, z);
            // We use sbytes here so we can use -1 as the light value of an ungenerated block
            sbyte left      = GetSkyLight(chunk, x - 1, y, z);
            sbyte right     = GetSkyLight(chunk, x + 1, y, z);
            sbyte forwards  = GetSkyLight(chunk, x, y, z + 1);
            sbyte backwards = GetSkyLight(chunk, z, y, z - 1);

            if (left > self)
            {
                self = (byte)(left - 1);
            }
            if (right > self)
            {
                self = (byte)(right - 1);
            }
            if (forwards > self)
            {
                self = (byte)(forwards - 1);
            }
            if (backwards > self)
            {
                self = (byte)(backwards - 1);
            }
            chunk.SetSkyLight(x, y, z, self);
        }
Beispiel #2
0
 private void CalculateSkyLight(Chunk chunk, int x, int y, int z)
 {
     byte self = chunk.GetSkyLight(x, y, z);
     // We use sbytes here so we can use -1 as the light value of an ungenerated block
     sbyte left = GetSkyLight(chunk, x - 1, y, z);
     sbyte right = GetSkyLight(chunk, x + 1, y, z);
     sbyte forwards = GetSkyLight(chunk, x, y, z + 1);
     sbyte backwards = GetSkyLight(chunk, z, y, z - 1);
     if (left > self)
         self = (byte)(left - 1);
     if (right > self)
         self = (byte)(right - 1);
     if (forwards > self)
         self = (byte)(forwards - 1);
     if (backwards > self)
         self = (byte)(backwards - 1);
     chunk.SetSkyLight(x, y, z, self);
 }
Beispiel #3
0
 private sbyte GetSkyLight(Chunk chunk, int x, int y, int z)
 {
     if (x < 0)
     {
         x     = Chunk.Width + x;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Left);
         if (chunk == null)
         {
             return(-1);
         }
     }
     if (x >= Chunk.Width)
     {
         x    -= Chunk.Width;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Right);
         if (chunk == null)
         {
             return(-1);
         }
     }
     if (z < 0)
     {
         z     = Chunk.Depth + z;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Backwards);
         if (chunk == null)
         {
             return(-1);
         }
     }
     if (z >= Chunk.Depth)
     {
         z    -= Chunk.Depth;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Forwards);
         if (chunk == null)
         {
             return(-1);
         }
     }
     return((sbyte)chunk.GetSkyLight(x, y, z));
 }
Beispiel #4
0
 private sbyte GetSkyLight(Chunk chunk, int x, int y, int z)
 {
     if (x < 0)
     {
         x = Chunk.Width + x;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Left);
         if (chunk == null) return -1;
     }
     if (x >= Chunk.Width)
     {
         x -= Chunk.Width;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Right);
         if (chunk == null) return -1;
     }
     if (z < 0)
     {
         z = Chunk.Depth + z;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Backwards);
         if (chunk == null) return -1;
     }
     if (z >= Chunk.Depth)
     {
         z -= Chunk.Depth;
         chunk = GetChunkWithoutGeneration(chunk.AbsolutePosition + Vector3.Forwards);
         if (chunk == null) return -1;
     }
     return (sbyte)chunk.GetSkyLight(x, y, z);
 }