Use sides offset instead. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2017-04-16 15:16:34 +10:00
parent e3582a8dff
commit f71d88c699
6 changed files with 12 additions and 10 deletions

View File

@ -54,6 +54,6 @@ namespace ClassicalSharp.Events {
WeatherSpeed, WeatherSpeed,
WeatherFade, WeatherFade,
ExpFog, ExpFog,
SidesLevel, SidesOffset,
} }
} }

View File

@ -60,7 +60,6 @@ namespace ClassicalSharp.Map {
throw new InvalidOperationException("Blocks array length does not match volume of map."); throw new InvalidOperationException("Blocks array length does not match volume of map.");
if (Env.EdgeHeight == -1) Env.EdgeHeight = height / 2; if (Env.EdgeHeight == -1) Env.EdgeHeight = height / 2;
if (Env.SidesHeight == -1) Env.SidesHeight = Env.EdgeHeight - 2;
if (Env.CloudHeight == -1) Env.CloudHeight = height + 2; if (Env.CloudHeight == -1) Env.CloudHeight = height + 2;
} }

View File

@ -64,7 +64,10 @@ namespace ClassicalSharp.Map {
public BlockID SidesBlock = Block.Bedrock; public BlockID SidesBlock = Block.Bedrock;
/// <summary> Maximum height of the various parts of the map sides, in world space. </summary> /// <summary> Maximum height of the various parts of the map sides, in world space. </summary>
public int SidesHeight; public int SidesHeight { get { return EdgeHeight + SidesOffset; } }
/// <summary> Offset of height of map sides from height of map edge. </summary>
public int SidesOffset = -2;
/// <summary> Whether exponential fog mode is used by default. </summary> /// <summary> Whether exponential fog mode is used by default. </summary>
public bool ExpFog; public bool ExpFog;
@ -77,7 +80,7 @@ namespace ClassicalSharp.Map {
/// <summary> Resets all of the environment properties to their defaults. </summary> /// <summary> Resets all of the environment properties to their defaults. </summary>
public void Reset() { public void Reset() {
EdgeHeight = -1; SidesHeight = -1; CloudHeight = -1; EdgeHeight = -1; SidesOffset = -2; CloudHeight = -1;
EdgeBlock = Block.StillWater; SidesBlock = Block.Bedrock; EdgeBlock = Block.StillWater; SidesBlock = Block.Bedrock;
CloudsSpeed = 1; WeatherSpeed = 1; WeatherFade = 1; CloudsSpeed = 1; WeatherSpeed = 1; WeatherFade = 1;
@ -143,11 +146,11 @@ namespace ClassicalSharp.Map {
/// <summary> Sets height of the map edges in world space, and raises /// <summary> Sets height of the map edges in world space, and raises
/// EnvVariableChanged event with variable 'EdgeLevel'. </summary> /// EnvVariableChanged event with variable 'EdgeLevel'. </summary>
public void SetEdgeLevel(int level) { SidesHeight = level - 2; Set(level, ref EdgeHeight, EnvVar.EdgeLevel); } public void SetEdgeLevel(int level) { Set(level, ref EdgeHeight, EnvVar.EdgeLevel); }
/// <summary> Sets height of the map sides in world space, and raises /// <summary> Sets offset of the height of the map sides from map edges in world space, and raises
/// EnvVariableChanged event with variable 'SidesLevel'. </summary> /// EnvVariableChanged event with variable 'SidesLevel'. </summary>
public void SetSidesLevel(int level) { Set(level, ref SidesHeight, EnvVar.SidesLevel); } public void SetSidesOffset(int level) { Set(level, ref SidesOffset, EnvVar.SidesOffset); }
/// <summary> Sets whether exponential fog is used, and raises /// <summary> Sets whether exponential fog is used, and raises
/// EnvVariableChanged event with variable 'ExpFog'. </summary> /// EnvVariableChanged event with variable 'ExpFog'. </summary>

View File

@ -360,7 +360,7 @@ namespace ClassicalSharp.Network.Protocols {
case 8: case 8:
env.SetExpFog(value != 0); break; env.SetExpFog(value != 0); break;
case 9: case 9:
env.SetSidesLevel(value); break; env.SetSidesOffset(value); break;
} }
} }

View File

@ -89,7 +89,7 @@ namespace ClassicalSharp.Renderers {
void EnvVariableChanged(object sender, EnvVarEventArgs e) { void EnvVariableChanged(object sender, EnvVarEventArgs e) {
if (e.Var == EnvVar.SunlightColour || e.Var == EnvVar.ShadowlightColour) { if (e.Var == EnvVar.SunlightColour || e.Var == EnvVar.ShadowlightColour) {
Refresh(); Refresh();
} else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesLevel) { } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesOffset) {
int oldClip = builder.edgeLevel; int oldClip = builder.edgeLevel;
builder.sidesLevel = Math.Max(0, game.World.Env.SidesHeight); builder.sidesLevel = Math.Max(0, game.World.Env.SidesHeight);
builder.edgeLevel = Math.Max(0, game.World.Env.EdgeHeight); builder.edgeLevel = Math.Max(0, game.World.Env.EdgeHeight);

View File

@ -114,7 +114,7 @@ namespace ClassicalSharp.Renderers {
MakeTexture(ref sideTexId, ref lastSideTexLoc, map.Env.SidesBlock); MakeTexture(ref sideTexId, ref lastSideTexLoc, map.Env.SidesBlock);
if (game.BlockInfo.BlocksLight[map.Env.SidesBlock] != fullColSides) if (game.BlockInfo.BlocksLight[map.Env.SidesBlock] != fullColSides)
ResetSidesAndEdges(null, null); ResetSidesAndEdges(null, null);
} else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesLevel) { } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesOffset) {
ResetSidesAndEdges(null, null); ResetSidesAndEdges(null, null);
} else if (e.Var == EnvVar.SunlightColour) { } else if (e.Var == EnvVar.SunlightColour) {
ResetEdges(); ResetEdges();