Exemplo n.º 1
0
        private void ProcessNode(Level level, BlockCoordinates coordinates, Queue <BlockCoordinates> lightBfsQueue)
        {
            byte currentSkyLight = level.GetSkyLight(coordinates);

            byte maxSkyLight = currentSkyLight;

            if (coordinates.Y < 255)
            {
                var up = coordinates + BlockCoordinates.Up;
                maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, up, currentSkyLight, up: true));
            }

            if (coordinates.Y > 0)
            {
                var down = coordinates + BlockCoordinates.Down;
                maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, down, currentSkyLight, down: true));
            }

            var west = coordinates + BlockCoordinates.West;

            maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, west, currentSkyLight));


            var east = coordinates + BlockCoordinates.East;

            maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, east, currentSkyLight));


            var south = coordinates + BlockCoordinates.South;

            maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, south, currentSkyLight));

            var north = coordinates + BlockCoordinates.North;

            maxSkyLight = Math.Max(maxSkyLight, SetLightLevel(level, lightBfsQueue, north, currentSkyLight));

            if (level.IsNotBlockingSkylight(coordinates) && currentSkyLight != 15)
            {
                maxSkyLight = (byte)Math.Max(currentSkyLight, maxSkyLight - 1);

                if (maxSkyLight > currentSkyLight)
                {
                    level.SetSkyLight(coordinates, maxSkyLight);

                    /*if (!lightBfsQueue.Contains(coordinates)) */
                    lightBfsQueue.Enqueue(coordinates);
                }
            }
        }