ClassiCube/Rendering/EnvRenderer.cs
2015-06-19 20:12:29 +10:00

49 lines
1.2 KiB
C#

using System;
using ClassicalSharp.GraphicsAPI;
namespace ClassicalSharp.Renderers {
public abstract class EnvRenderer : IDisposable {
public Map Map;
public Game Window;
public OpenGLApi Graphics;
public virtual void Init() {
Graphics = Window.Graphics;
Window.OnNewMap += OnNewMap;
Window.OnNewMapLoaded += OnNewMapLoaded;
Window.EnvVariableChanged += EnvVariableChanged;
}
public virtual void OnNewMap( object sender, EventArgs e ) {
}
public virtual void OnNewMapLoaded( object sender, EventArgs e ) {
}
public virtual void Dispose() {
Window.OnNewMap -= OnNewMap;
Window.OnNewMapLoaded -= OnNewMapLoaded;
Window.EnvVariableChanged -= EnvVariableChanged;
}
public abstract void Render( double deltaTime );
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
if( e.Variable == EnvVariable.SkyColour ) {
SkyColourChanged();
} else if( e.Variable == EnvVariable.FogColour ) {
FogColourChanged();
} else if( e.Variable == EnvVariable.CloudsColour ) {
CloudsColourChanged();
}
}
protected abstract void SkyColourChanged();
protected abstract void FogColourChanged();
protected abstract void CloudsColourChanged();
}
}