예제 #1
0
 public void BlockRemoved(BlockType blockType, int x, int y, int z)
 {
     if (!BlockInformation.IsLightTransparentBlock(blockType) && !BlockInformation.IsLightEmittingBlock(blockType))
     {
         toLight.Enqueue(new Light(x, y, z, _lighting[x, y, z]));
     }
     if (BlockInformation.IsLightEmittingBlock(blockType))
     {
         LightRemoved(x, y, z);
     }
 }
예제 #2
0
        private void LightRegion(int sx, int ex, int sz, int ez)
        {
            if (sx < 0)
            {
                sx = 0;
            }
            if (sz < 0)
            {
                sz = 0;
            }
            if (ex > WorldSettings.MAPWIDTH)
            {
                ex = WorldSettings.MAPWIDTH;
            }
            if (ez > WorldSettings.MAPLENGTH)
            {
                ex = WorldSettings.MAPLENGTH;
            }

            for (int x = sx; x < ex; x++)
            {
                for (int z = sz; z < ez; z++)
                {
                    bool inShadow = false;
                    for (int y = WorldSettings.MAPHEIGHT - 1; y > 0; y--)
                    {
                        BlockType blockType = _world.BlockAt(x, y, z);
                        if (!BlockInformation.IsLightTransparentBlock(blockType) && !inShadow)
                        {
                            inShadow           = true;
                            _lightHeight[x, z] = y + 1;
                        }
                        if (!inShadow)
                        {
                            _lighting[x, y, z] = WorldSettings.MAXLIGHT;
                            toLight.Enqueue(new Light(x, y, z, WorldSettings.MAXLIGHT));
                        }
                        else
                        {
                            _lighting[x, y, z] = WorldSettings.MINLIGHT;
                            if (BlockInformation.IsLightEmittingBlock(blockType))
                            {
                                toLight.Enqueue(new Light(x, y, z, WorldSettings.MAXLIGHT));
                            }
                        }
                        _world.MakeDirty(x, y, z);
                    }
                }
            }
        }
예제 #3
0
 public void BlockAdded(BlockType blockType, int x, int y, int z)
 {
     // Don't want to call this during initial map loading
     if (_lighting != null)
     {
         if (BlockInformation.IsLightEmittingBlock(blockType))
         {
             toLight.Enqueue(new Light(x, y, z, WorldSettings.MAXLIGHT));
         }
         if (!BlockInformation.IsLightTransparentBlock(blockType))
         {
             toDark.Enqueue(new Light(x, y, z, WorldSettings.MAXLIGHT * 2));
         }
     }
 }
예제 #4
0
 private void CheckLight(int x, int y, int z, byte intensity)
 {
     intensity = (byte)(intensity - 1);
     if (_world.InWorldBounds(x, y, z))
     {
         if (_lighting[x, y, z] < intensity)
         {
             _lighting[x, y, z] = intensity;
             _world.MakeDirty(x, y, z);
             if (BlockInformation.IsLightTransparentBlock(_world.BlockAt(x, y, z)))
             {
                 toLight.Enqueue(new Light(x, y, z, intensity));
             }
         }
     }
 }