private LightChunk GetLightChunkInstance(Vector3i pos) { LightChunk chunk = GetLightChunk(pos); if (chunk == null) { chunk = new LightChunk(); chunks.AddOrReplace(chunk, pos); } return(chunk); }
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); }
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())); } } }
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)); }
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); }