// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT using System; using OpenTK; namespace ClassicalSharp.Map { /// Manages lighting for each block in the world. public abstract class IWorldLighting : IGameComponent { protected internal short[] heightmap; public int Outside, OutsideZSide, OutsideXSide, OutsideYBottom; protected int width, height, length; // Equivalent to // for x = startX; x < startX + 18; x++ // for z = startZ; z < startZ + 18; z++ // CalcHeightAt(x, maxY, z) if height == short.MaxValue // Except this function is a lot more optimised and minimises cache misses. public unsafe abstract void LightHint(int startX, int startZ, byte* mapPtr); /// Returns the y coordinate of the highest block that is fully not in sunlight. /// *** Does NOT check that the coordinates are inside the map. ***
/// e.g. if cobblestone was at y = 5, this method would return 4.
public abstract int GetLightHeight(int x, int z); /// Updates the lighting for the block at that position, which may in turn affect other blocks. public abstract void UpdateLight(int x, int y, int z, byte oldBlock, byte newBlock); /// Returns whether the block at the given coordinates is fully in sunlight. /// *** Does NOT check that the coordinates are inside the map. *** public abstract bool IsLit(int x, int y, int z); /// Returns the light colour of the block at the given coordinates. /// *** Does NOT check that the coordinates are inside the map. *** public abstract int LightCol(int x, int y, int z); /// Returns the light colour of the block at the given coordinates. /// *** Does NOT check that the coordinates are inside the map. *** public abstract int LightCol_ZSide(int x, int y, int z); public abstract int LightCol_Sprite_Fast(int x, int y, int z); public abstract int LightCol_YTop_Fast(int x, int y, int z); public abstract int LightCol_YBottom_Fast(int x, int y, int z); public abstract int LightCol_XSide_Fast(int x, int y, int z); public abstract int LightCol_ZSide_Fast(int x, int y, int z); public virtual void Dispose() { } public virtual void Reset(Game game) { } public virtual void OnNewMap(Game game) { } public virtual void OnNewMapLoaded(Game game) { } public virtual void Init(Game game) { } public virtual void Ready(Game game) { } } }