Пример #1
0
    public void SetSunHeight(int height, int x, int z)
    {
        Vector3i chunkPos = Chunk.ToChunkPosition(x, 0, z);
        Vector3i localPos = Chunk.ToLocalPosition(x, 0, z);

        SunLightChunk chunk = GetSunChunkInstance(chunkPos.x, chunkPos.z);

        chunk.SetSunHeight(height, localPos.x, localPos.z);
    }
Пример #2
0
    private SunLightChunk GetSunChunkInstance(int x, int z)
    {
        SunLightChunk chunk = GetSunChunk(x, z);

        if (chunk == null)
        {
            chunk = new SunLightChunk();
            sunChunks.AddOrReplace(chunk, x, 0, z);
        }
        return(chunk);
    }
Пример #3
0
    public bool IsSunLight(int x, int y, int z)
    {
        Vector3i      chunkPos = Chunk.ToChunkPosition(x, y, z);
        Vector3i      localPos = Chunk.ToLocalPosition(x, y, z);
        SunLightChunk chunk    = GetSunChunk(chunkPos.x, chunkPos.z);

        if (chunk != null)
        {
            return(chunk.IsLight(localPos.x, y, localPos.z));
        }
        return(false);
    }
Пример #4
0
    public int GetSunHeight(int x, int z)
    {
        Vector3i      chunkPos = Chunk.ToChunkPosition(x, 0, z);
        Vector3i      localPos = Chunk.ToLocalPosition(x, 0, z);
        SunLightChunk chunk    = GetSunChunk(chunkPos.x, chunkPos.z);

        if (chunk != null)
        {
            return(chunk.GetSunHeight(localPos.x, localPos.z));
        }
        return(Map.maxChunkY);
    }
Пример #5
0
    public bool SetMaxLight(byte light, int x, int y, int z)
    {
        Vector3i chunkPos = Chunk.ToChunkPosition(x, y, z);
        Vector3i localPos = Chunk.ToLocalPosition(x, y, z);

        SunLightChunk sunChunk = GetSunChunk(chunkPos.x, chunkPos.z);

        if (sunChunk != null && sunChunk.IsLight(localPos.x, y, localPos.z))
        {
            return(false);
        }

        LightChunk lightChunk = GetLightChunkInstance(chunkPos);

        return(lightChunk.SetMaxLight(light, localPos));
    }
Пример #6
0
    public byte GetLight(Vector3i chunkPos, Vector3i localPos)
    {
        SunLightChunk sunChunk = GetSunChunk(chunkPos.x, chunkPos.z);
        int           worldY   = (chunkPos.y << Chunk.SIZE_Y_BITS) + localPos.y;

        if (sunChunk != null && sunChunk.IsLight(localPos.x, worldY, localPos.z))
        {
            return(LightComputer.MAX_LIGHT);
        }

        LightChunk lightChunk = GetLightChunk(chunkPos);

        if (lightChunk != null)
        {
            return(lightChunk.GetLight(localPos));
        }
        return(LightComputer.MIN_LIGHT);
    }