Exemplo n.º 1
0
    private LightChunk GetLightChunkInstance(Vector3i pos)
    {
        LightChunk chunk = GetLightChunk(pos);

        if (chunk == null)
        {
            chunk = new LightChunk();
            chunks.AddOrReplace(chunk, pos);
        }
        return(chunk);
    }
Exemplo n.º 2
0
    public void SetLight(byte light, Vector3i chunkPos, Vector3i localPos)
    {
        LightChunk lightChunk = GetLightChunk(chunkPos);

        if (lightChunk == null)
        {
            if (light == LightComputer.MIN_LIGHT)
            {
                return;
            }
            lightChunk = GetLightChunkInstance(chunkPos);
        }
        lightChunk.SetLight(light, localPos);
    }
Exemplo n.º 3
0
 public static void Dump(this LightChunk chunk, ThreeDSModel4ModernOpengl model)
 {
     foreach (var item in chunk.Children)
     {
         if (item is SpotlightChunk)
         {
             (item as SpotlightChunk).Dump(model);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                                                   "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
Exemplo n.º 4
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));
    }
Exemplo n.º 5
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);
    }