Пример #1
0
    private LightChunk GetLightChunkInstance(Vector3i pos)
    {
        LightChunk chunk = GetLightChunk(pos);

        if (chunk == null)
        {
            chunk = new LightChunk();
            chunks.AddOrReplace(chunk, pos);
        }
        return(chunk);
    }
Пример #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);
    }
Пример #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()));
         }
     }
 }
Пример #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));
    }
Пример #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);
    }