Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 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));
         }
     }
 }
Ejemplo n.º 4
0
 private void CheckDark(int x, int y, int z, byte intensity)
 {
     intensity = (byte)(intensity - 1);
     if (_world.InWorldBounds(x, y, z))
     {
         if (intensity > WorldSettings.MINLIGHT && _lighting[x, y, z] != WorldSettings.MINLIGHT)
         {
             _lighting[x, y, z] = WorldSettings.MINLIGHT;
             // If we're in sunlight on a light emitter we need to requeue
             if (y >= _lightHeight[x, z] || BlockInformation.IsLightEmittingBlock(_world.BlockAt(x, y, z)))
             {
                 // We darked a light so schedule it to be relit
                 toLight.Enqueue(new Light(x, y, z, WorldSettings.MAXLIGHT + 1));
             }
             _world.MakeDirty(x, y, z);
             toDark.Enqueue(new Light(x, y, z, intensity));
         }
     }
 }