示例#1
0
    public static void ComputeRays(Map map, int cx, int cz)
    {
        int x1 = cx * Chunk.SIZE_X - 1;
        int z1 = cz * Chunk.SIZE_Z - 1;

        int x2 = x1 + Chunk.SIZE_X + 2;
        int z2 = z1 + Chunk.SIZE_Z + 2;

        for (int z = z1; z < z2; z++)
        {
            for (int x = x1; x < x2; x++)
            {
                SunLightComputer.ComputeRayAtPosition(map, x, z);
            }
        }
    }
示例#2
0
    public void SetBlockAndRecompute(BlockData block, Vector3i pos)
    {
        SetBlock(block, pos);

        Vector3i chunkPos = Chunk.ToChunkPosition(pos);
        Vector3i localPos = Chunk.ToLocalPosition(pos);

        SetDirty(chunkPos);

        if (localPos.x == 0)
        {
            SetDirty(chunkPos - Vector3i.right);
        }
        if (localPos.y == 0)
        {
            SetDirty(chunkPos - Vector3i.up);
        }
        if (localPos.z == 0)
        {
            SetDirty(chunkPos - Vector3i.forward);
        }

        if (localPos.x == Chunk.SIZE_X - 1)
        {
            SetDirty(chunkPos + Vector3i.right);
        }
        if (localPos.y == Chunk.SIZE_Y - 1)
        {
            SetDirty(chunkPos + Vector3i.up);
        }
        if (localPos.z == Chunk.SIZE_Z - 1)
        {
            SetDirty(chunkPos + Vector3i.forward);
        }

        SunLightComputer.RecomputeLightAtPosition(this, pos);
        LightComputer.RecomputeLightAtPosition(this, pos);

        UpdateMeshColliderAfterBlockChange();
    }