Ejemplo n.º 1
0
 BlockInternal GetLODRelative(Chunk c, int x, int y, int z)
 {
     if (c.PosMultiplier == PosMultiplier)
     {
         return(c.GetBlockAt(x, y, z));
     }
     if (c.PosMultiplier > PosMultiplier)
     {
         return(new BlockInternal((ushort)Material.STONE, 0, 0, 0));
     }
     for (int bx = 0; bx < PosMultiplier; bx++)
     {
         for (int by = 0; by < PosMultiplier; by++)
         {
             for (int bz = 0; bz < PosMultiplier; bz++)
             {
                 if (!c.GetBlockAt(x * PosMultiplier + bx, y * PosMultiplier + bx, z * PosMultiplier + bz).IsOpaque())
                 {
                     return(BlockInternal.AIR);
                 }
             }
         }
     }
     return(new BlockInternal((ushort)Material.STONE, 0, 0, 0));
 }
Ejemplo n.º 2
0
        public BlockInternal GetBlockInternal(Location pos)
        {
            Chunk ch = GetChunk(ChunkLocFor(pos));

            if (ch == null)
            {
                return(new BlockInternal((ushort)Material.AIR, 0, 0, 255));
            }
            int x = (int)Math.Floor(((int)Math.Floor(pos.X) - (int)ch.WorldPosition.X * Chunk.CHUNK_SIZE) / (float)ch.PosMultiplier);
            int y = (int)Math.Floor(((int)Math.Floor(pos.Y) - (int)ch.WorldPosition.Y * Chunk.CHUNK_SIZE) / (float)ch.PosMultiplier);
            int z = (int)Math.Floor(((int)Math.Floor(pos.Z) - (int)ch.WorldPosition.Z * Chunk.CHUNK_SIZE) / (float)ch.PosMultiplier);

            return(ch.GetBlockAt(x, y, z));
        }
Ejemplo n.º 3
0
 public void CalcSkyLight(Chunk above)
 {
     if (CSize != CHUNK_SIZE)
     {
         for (int x = 0; x < CSize; x++)
         {
             for (int y = 0; y < CSize; y++)
             {
                 for (int z = 0; z < CSize; z++)
                 {
                     BlocksInternal[BlockIndex(x, y, z)].BlockLocalData = 255;
                 }
             }
         }
         return;
     }
     for (int x = 0; x < CHUNK_SIZE; x++)
     {
         for (int y = 0; y < CHUNK_SIZE; y++)
         {
             byte light = (above != null && above.CSize == CHUNK_SIZE) ? above.GetBlockAt(x, y, 0).BlockLocalData : (byte)255;
             for (int z = CHUNK_SIZE - 1; z >= 0; z--)
             {
                 if (light > 0)
                 {
                     BlockInternal bi = GetBlockAt(x, y, z);
                     double transc = Colors.AlphaForByte(bi.BlockPaint);
                     if (bi.Material.IsOpaque())
                     {
                         light = (byte)(light * (1.0 - (BlockShapeRegistry.BSD[bi.BlockData].LightDamage * transc)));
                     }
                     else
                     {
                         light = (byte)(light * (1.0 - (bi.Material.GetLightDamage() * transc)));
                     }
                 }
                 BlocksInternal[BlockIndex(x, y, z)].BlockLocalData = light;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void CalcSkyLight(Chunk above)
 {
     if (CSize != CHUNK_SIZE)
     {
         for (int x = 0; x < CSize; x++)
         {
             for (int y = 0; y < CSize; y++)
             {
                 for (int z = 0; z < CSize; z++)
                 {
                     BlocksInternal[BlockIndex(x, y, z)].BlockLocalData = 255;
                 }
             }
         }
         return;
     }
     for (int x = 0; x < CHUNK_SIZE; x++)
     {
         for (int y = 0; y < CHUNK_SIZE; y++)
         {
             byte light = (above != null && above.CSize == CHUNK_SIZE) ? above.GetBlockAt(x, y, 0).BlockLocalData : (byte)255;
             for (int z = CHUNK_SIZE - 1; z >= 0; z--)
             {
                 if (light > 0)
                 {
                     BlockInternal bi     = GetBlockAt(x, y, z);
                     double        transc = Colors.AlphaForByte(bi.BlockPaint);
                     if (bi.Material.IsOpaque())
                     {
                         light = (byte)(light * (1.0 - (BlockShapeRegistry.BSD[bi.BlockData].LightDamage * transc)));
                     }
                     else
                     {
                         light = (byte)(light * (1.0 - (bi.Material.GetLightDamage() * transc)));
                     }
                 }
                 BlocksInternal[BlockIndex(x, y, z)].BlockLocalData = light;
             }
         }
     }
 }
Ejemplo n.º 5
0
 BlockInternal GetLODRelative(Chunk c, int x, int y, int z)
 {
     if (c.PosMultiplier == PosMultiplier)
     {
         return c.GetBlockAt(x, y, z);
     }
     if (c.PosMultiplier > PosMultiplier)
     {
         return new BlockInternal((ushort)Material.STONE, 0, 0, 0);
     }
     for (int bx = 0; bx < PosMultiplier; bx++)
     {
         for (int by = 0; by < PosMultiplier; by++)
         {
             for (int bz = 0; bz < PosMultiplier; bz++)
             {
                 if (!c.GetBlockAt(x * PosMultiplier + bx, y * PosMultiplier + bx, z * PosMultiplier + bz).IsOpaque())
                 {
                     return BlockInternal.AIR;
                 }
             }
         }
     }
     return new BlockInternal((ushort)Material.STONE, 0, 0, 0);
 }