Пример #1
0
    private static void Scatter(Map map, ColumnMap columnMap, List <Vector3i> list)      // рассеивание
    {
        SunLightMap lightmap = map.GetSunLightmap();

        for (int i = 0; i < list.Count; i++)
        {
            Vector3i pos = list[i];
            if (pos.y < 0)
            {
                continue;
            }

            BlockData block = map.GetBlock(pos);
            int       light = lightmap.GetLight(pos) - LightComputerUtils.GetLightStep(block);
            if (light <= MIN_LIGHT)
            {
                continue;
            }

            Vector3i chunkPos = Chunk.ToChunkPosition(pos);
            if (!columnMap.IsBuilt(chunkPos.x, chunkPos.z))
            {
                continue;
            }

            foreach (Vector3i dir in Vector3i.directions)
            {
                Vector3i nextPos = pos + dir;
                block = map.GetBlock(nextPos);
                if (block.IsAlpha() && lightmap.SetMaxLight((byte)light, nextPos))
                {
                    list.Add(nextPos);
                }
                if (!block.IsEmpty())
                {
                    LightComputerUtils.SetLightDirty(map, nextPos);
                }
            }
        }
    }