mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Move CloudsLevel to map class, simplify various map set methods, reset texture pack to default if we can't download the .png or .zip., fixes #90.
This commit is contained in:
parent
28583dd90d
commit
dc5a29e9f1
@ -33,11 +33,8 @@ namespace ClassicalSharp {
|
|||||||
env.CloudsSpeed = Single.Parse( v ); } ),
|
env.CloudsSpeed = Single.Parse( v ); } ),
|
||||||
|
|
||||||
Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick,
|
Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick,
|
||||||
g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
g => (g.Map.CloudHeight - g.Map.Height).ToString(),
|
||||||
return env == null ? "(not active)" : env.CloudsOffset.ToString(); },
|
(g, v) => g.Map.SetCloudsLevel( g.Map.Height + Int32.Parse( v ) ) ),
|
||||||
(g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
|
||||||
if( env != null )
|
|
||||||
env.SetCloudsOffset( Int32.Parse( v ) ); } ),
|
|
||||||
|
|
||||||
Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick,
|
Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.Sunlight.ToRGBHexString(),
|
g => g.Map.Sunlight.ToRGBHexString(),
|
||||||
|
@ -43,8 +43,8 @@ namespace ClassicalSharp {
|
|||||||
internal void RaiseTerrainAtlasChanged() { Raise( TerrainAtlasChanged ); }
|
internal void RaiseTerrainAtlasChanged() { Raise( TerrainAtlasChanged ); }
|
||||||
|
|
||||||
/// <summary> Raised when an environment variable is changed by the user, CPE, or WoM config. </summary>
|
/// <summary> Raised when an environment variable is changed by the user, CPE, or WoM config. </summary>
|
||||||
public event EventHandler<EnvVariableEventArgs> EnvVariableChanged;
|
public event EventHandler<EnvVarEventArgs> EnvVariableChanged;
|
||||||
internal void RaiseEnvVariableChanged( EnvVariable envVar ) { envArgs.Var = envVar; Raise( EnvVariableChanged, envArgs ); }
|
internal void RaiseEnvVariableChanged( EnvVar envVar ) { envArgs.Var = envVar; Raise( EnvVariableChanged, envArgs ); }
|
||||||
|
|
||||||
/// <summary> Raised when the user changed their view/fog distance. </summary>
|
/// <summary> Raised when the user changed their view/fog distance. </summary>
|
||||||
public event EventHandler ViewDistanceChanged;
|
public event EventHandler ViewDistanceChanged;
|
||||||
@ -71,7 +71,7 @@ namespace ClassicalSharp {
|
|||||||
// Cache event instances so we don't create needless new objects.
|
// Cache event instances so we don't create needless new objects.
|
||||||
IdEventArgs idArgs = new IdEventArgs();
|
IdEventArgs idArgs = new IdEventArgs();
|
||||||
MapLoadingEventArgs loadingArgs = new MapLoadingEventArgs();
|
MapLoadingEventArgs loadingArgs = new MapLoadingEventArgs();
|
||||||
EnvVariableEventArgs envArgs = new EnvVariableEventArgs();
|
EnvVarEventArgs envArgs = new EnvVarEventArgs();
|
||||||
ChatEventArgs chatArgs = new ChatEventArgs();
|
ChatEventArgs chatArgs = new ChatEventArgs();
|
||||||
|
|
||||||
void Raise( EventHandler handler ) {
|
void Raise( EventHandler handler ) {
|
||||||
@ -104,15 +104,16 @@ namespace ClassicalSharp {
|
|||||||
public int Progress;
|
public int Progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class EnvVariableEventArgs : EventArgs {
|
public sealed class EnvVarEventArgs : EventArgs {
|
||||||
|
|
||||||
public EnvVariable Var;
|
public EnvVar Var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EnvVariable {
|
public enum EnvVar {
|
||||||
SidesBlock,
|
SidesBlock,
|
||||||
EdgeBlock,
|
EdgeBlock,
|
||||||
WaterLevel,
|
WaterLevel,
|
||||||
|
CloudsLevel,
|
||||||
Weather,
|
Weather,
|
||||||
|
|
||||||
SkyColour,
|
SkyColour,
|
||||||
|
@ -25,6 +25,7 @@ namespace ClassicalSharp {
|
|||||||
public FastColour Shadowlight, ShadowlightXSide, ShadowlightZSide, ShadowlightYBottom;
|
public FastColour Shadowlight, ShadowlightXSide, ShadowlightZSide, ShadowlightYBottom;
|
||||||
public Weather Weather = Weather.Sunny;
|
public Weather Weather = Weather.Sunny;
|
||||||
public Guid Uuid;
|
public Guid Uuid;
|
||||||
|
public int CloudHeight;
|
||||||
|
|
||||||
public int GroundHeight {
|
public int GroundHeight {
|
||||||
get { return WaterHeight - 2; }
|
get { return WaterHeight - 2; }
|
||||||
@ -43,17 +44,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public void Reset() {
|
public void Reset() {
|
||||||
WaterHeight = -1;
|
WaterHeight = -1;
|
||||||
SetShadowlight( DefaultShadowlight );
|
CloudHeight = -1;
|
||||||
SetSunlight( DefaultSunlight );
|
|
||||||
Width = Height = Length = 0;
|
Width = Height = Length = 0;
|
||||||
|
Uuid = Guid.NewGuid();
|
||||||
EdgeBlock = Block.StillWater;
|
EdgeBlock = Block.StillWater;
|
||||||
SidesBlock = Block.Bedrock;
|
SidesBlock = Block.Bedrock;
|
||||||
|
|
||||||
|
SetShadowlight( DefaultShadowlight );
|
||||||
|
SetSunlight( DefaultSunlight );
|
||||||
SkyCol = DefaultSkyColour;
|
SkyCol = DefaultSkyColour;
|
||||||
FogCol = DefaultFogColour;
|
FogCol = DefaultFogColour;
|
||||||
CloudsCol = DefaultCloudsColour;
|
CloudsCol = DefaultCloudsColour;
|
||||||
Weather = Weather.Sunny;
|
Weather = Weather.Sunny;
|
||||||
Uuid = Guid.NewGuid();
|
|
||||||
|
|
||||||
game.Events.RaiseOnNewMap();
|
game.Events.RaiseOnNewMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ namespace ClassicalSharp {
|
|||||||
block = Block.Bedrock;
|
block = Block.Bedrock;
|
||||||
}
|
}
|
||||||
SidesBlock = block;
|
SidesBlock = block;
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.SidesBlock );
|
game.Events.RaiseEnvVariableChanged( EnvVar.SidesBlock );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEdgeBlock( Block block ) {
|
public void SetEdgeBlock( Block block ) {
|
||||||
@ -74,51 +76,39 @@ namespace ClassicalSharp {
|
|||||||
block = Block.StillWater;
|
block = Block.StillWater;
|
||||||
}
|
}
|
||||||
EdgeBlock = block;
|
EdgeBlock = block;
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.EdgeBlock );
|
game.Events.RaiseEnvVariableChanged( EnvVar.EdgeBlock );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWaterLevel( int level ) {
|
public void SetCloudsLevel( int level ) { Set( level, ref CloudHeight, EnvVar.CloudsLevel ); }
|
||||||
if( level == WaterHeight ) return;
|
|
||||||
WaterHeight = level;
|
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.WaterLevel );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetWeather( Weather weather ) {
|
public void SetWaterLevel( int level ) { Set( level, ref WaterHeight, EnvVar.WaterLevel ); }
|
||||||
if( weather == Weather ) return;
|
|
||||||
Weather = weather;
|
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.Weather );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSkyColour( FastColour col ) {
|
public void SetSkyColour( FastColour col ) { Set( col, ref SkyCol, EnvVar.SkyColour ); }
|
||||||
if( col == SkyCol ) return;
|
|
||||||
SkyCol = col;
|
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.SkyColour );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetFogColour( FastColour col ) {
|
public void SetFogColour( FastColour col ) { Set( col, ref FogCol, EnvVar.FogColour ); }
|
||||||
if( col == FogCol ) return;
|
|
||||||
FogCol = col;
|
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.FogColour );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetCloudsColour( FastColour col ) {
|
public void SetCloudsColour( FastColour col ) { Set( col, ref CloudsCol, EnvVar.CloudsColour ); }
|
||||||
if( col == CloudsCol ) return;
|
|
||||||
CloudsCol = col;
|
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.CloudsColour );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSunlight( FastColour col ) {
|
public void SetSunlight( FastColour col ) {
|
||||||
if( col == Sunlight ) return;
|
Set( col, ref Sunlight, EnvVar.SunlightColour );
|
||||||
Sunlight = col;
|
|
||||||
AdjustLight( Sunlight, ref SunlightXSide, ref SunlightZSide, ref SunlightYBottom );
|
AdjustLight( Sunlight, ref SunlightXSide, ref SunlightZSide, ref SunlightYBottom );
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.SunlightColour );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetShadowlight( FastColour col ) {
|
public void SetShadowlight( FastColour col ) {
|
||||||
if( col == Shadowlight ) return;
|
Set( col, ref Shadowlight, EnvVar.ShadowlightColour );
|
||||||
Shadowlight = col;
|
|
||||||
AdjustLight( Shadowlight, ref ShadowlightXSide, ref ShadowlightZSide, ref ShadowlightYBottom );
|
AdjustLight( Shadowlight, ref ShadowlightXSide, ref ShadowlightZSide, ref ShadowlightYBottom );
|
||||||
game.Events.RaiseEnvVariableChanged( EnvVariable.ShadowlightColour );
|
}
|
||||||
|
|
||||||
|
public void SetWeather( Weather weather ) {
|
||||||
|
if( weather == Weather ) return;
|
||||||
|
Weather = weather;
|
||||||
|
game.Events.RaiseEnvVariableChanged( EnvVar.Weather );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set<T>( T value, ref T target, EnvVar var ) where T : IEquatable<T> {
|
||||||
|
if( value.Equals( target ) ) return;
|
||||||
|
target = value;
|
||||||
|
game.Events.RaiseEnvVariableChanged( var );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetLightHeight( int x, int z ) {
|
public int GetLightHeight( int x, int z ) {
|
||||||
@ -178,6 +168,7 @@ namespace ClassicalSharp {
|
|||||||
if( WaterHeight == -1 ) WaterHeight = height / 2;
|
if( WaterHeight == -1 ) WaterHeight = height / 2;
|
||||||
maxY = height - 1;
|
maxY = height - 1;
|
||||||
oneY = length * width;
|
oneY = length * width;
|
||||||
|
if( CloudHeight == -1 ) CloudHeight = height + 2;
|
||||||
|
|
||||||
heightmap = new short[width * length];
|
heightmap = new short[width * length];
|
||||||
for( int i = 0; i < heightmap.Length; i++ ) {
|
for( int i = 0; i < heightmap.Length; i++ ) {
|
||||||
|
@ -80,6 +80,7 @@ namespace ClassicalSharp {
|
|||||||
UsingPlayerClick = true;
|
UsingPlayerClick = true;
|
||||||
} else if( extName == "EnvMapAppearance" && extVersion == 2 ) {
|
} else if( extName == "EnvMapAppearance" && extVersion == 2 ) {
|
||||||
usingTexturePack = true;
|
usingTexturePack = true;
|
||||||
|
packetSizes[(int)PacketId.CpeEnvSetMapApperance] += 4;
|
||||||
}
|
}
|
||||||
cpeServerExtensionsCount--;
|
cpeServerExtensionsCount--;
|
||||||
|
|
||||||
@ -235,12 +236,13 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void HandleCpeEnvSetMapApperance() {
|
void HandleCpeEnvSetMapApperance() {
|
||||||
string url = reader.ReadAsciiString();
|
string url = reader.ReadAsciiString();
|
||||||
byte sideBlock = reader.ReadUInt8();
|
game.Map.SetSidesBlock( (Block)reader.ReadUInt8() );
|
||||||
byte edgeBlock = reader.ReadUInt8();
|
game.Map.SetEdgeBlock( (Block)reader.ReadUInt8() );
|
||||||
short waterLevel = reader.ReadInt16();
|
game.Map.SetWaterLevel( reader.ReadInt16() );
|
||||||
game.Map.SetWaterLevel( waterLevel );
|
if( usingTexturePack ) {
|
||||||
game.Map.SetEdgeBlock( (Block)edgeBlock );
|
game.Map.SetCloudsLevel( reader.ReadInt16() );
|
||||||
game.Map.SetSidesBlock( (Block)sideBlock );
|
short maxViewDist = reader.ReadInt16(); // TODO: what to do with this?
|
||||||
|
}
|
||||||
|
|
||||||
if( url == String.Empty ) {
|
if( url == String.Empty ) {
|
||||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
|
@ -73,14 +73,22 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void CheckForNewTerrainAtlas() {
|
void CheckForNewTerrainAtlas() {
|
||||||
DownloadedItem item;
|
DownloadedItem item;
|
||||||
game.AsyncDownloader.TryGetItem( "terrain", out item );
|
if( game.AsyncDownloader.TryGetItem( "terrain", out item ) ) {
|
||||||
if( item != null && item.Data != null ) {
|
if( item.Data != null ) {
|
||||||
game.ChangeTerrainAtlas( (Bitmap)item.Data );
|
game.ChangeTerrainAtlas( (Bitmap)item.Data );
|
||||||
|
} else {
|
||||||
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
|
extractor.Extract( game.defaultTexPack, game );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
game.AsyncDownloader.TryGetItem( "texturePack", out item );
|
|
||||||
if( item != null && item.Data != null ) {
|
if( game.AsyncDownloader.TryGetItem( "texturePack", out item ) ) {
|
||||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
extractor.Extract( (byte[])item.Data, game );
|
if( item.Data != null ) {
|
||||||
|
extractor.Extract( (byte[])item.Data, game );
|
||||||
|
} else {
|
||||||
|
extractor.Extract( game.defaultTexPack, game );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,14 +452,14 @@ namespace ClassicalSharp {
|
|||||||
HandleLevelDataChunk, HandleLevelFinalise, null, HandleSetBlock,
|
HandleLevelDataChunk, HandleLevelFinalise, null, HandleSetBlock,
|
||||||
HandleAddEntity, HandleEntityTeleport, HandleRelPosAndOrientationUpdate,
|
HandleAddEntity, HandleEntityTeleport, HandleRelPosAndOrientationUpdate,
|
||||||
HandleRelPositionUpdate, HandleOrientationUpdate, HandleRemoveEntity,
|
HandleRelPositionUpdate, HandleOrientationUpdate, HandleRemoveEntity,
|
||||||
HandleMessage, HandleKick, HandleSetPermission,
|
HandleMessage, HandleKick, HandleSetPermission,
|
||||||
|
|
||||||
HandleCpeExtInfo, HandleCpeExtEntry, HandleCpeSetClickDistance,
|
HandleCpeExtInfo, HandleCpeExtEntry, HandleCpeSetClickDistance,
|
||||||
HandleCpeCustomBlockSupportLevel, HandleCpeHoldThis, null,
|
HandleCpeCustomBlockSupportLevel, HandleCpeHoldThis, null,
|
||||||
HandleCpeExtAddPlayerName, HandleCpeExtAddEntity, HandleCpeExtRemovePlayerName,
|
HandleCpeExtAddPlayerName, HandleCpeExtAddEntity, HandleCpeExtRemovePlayerName,
|
||||||
HandleCpeEnvColours, HandleCpeMakeSelection, HandleCpeRemoveSelection,
|
HandleCpeEnvColours, HandleCpeMakeSelection, HandleCpeRemoveSelection,
|
||||||
HandleCpeSetBlockPermission, HandleCpeChangeModel, HandleCpeEnvSetMapApperance,
|
HandleCpeSetBlockPermission, HandleCpeChangeModel, HandleCpeEnvSetMapApperance,
|
||||||
HandleCpeEnvWeatherType, HandleCpeHackControl, HandleCpeExtAddEntity2,
|
HandleCpeEnvWeatherType, HandleCpeHackControl, HandleCpeExtAddEntity2,
|
||||||
null, HandleCpeDefineBlock, HandleCpeRemoveBlockDefinition,
|
null, HandleCpeDefineBlock, HandleCpeRemoveBlockDefinition,
|
||||||
};
|
};
|
||||||
maxHandledPacket = handlers.Length;
|
maxHandledPacket = handlers.Length;
|
||||||
|
@ -30,20 +30,6 @@ namespace ClassicalSharp.Renderers {
|
|||||||
|
|
||||||
public abstract void Render( double deltaTime );
|
public abstract void Render( double deltaTime );
|
||||||
|
|
||||||
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
protected abstract void EnvVariableChanged( object sender, EnvVarEventArgs e );
|
||||||
if( e.Var == EnvVariable.SkyColour ) {
|
|
||||||
SkyColourChanged();
|
|
||||||
} else if( e.Var == EnvVariable.FogColour ) {
|
|
||||||
FogColourChanged();
|
|
||||||
} else if( e.Var == EnvVariable.CloudsColour ) {
|
|
||||||
CloudsColourChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void SkyColourChanged();
|
|
||||||
|
|
||||||
protected abstract void FogColourChanged();
|
|
||||||
|
|
||||||
protected abstract void CloudsColourChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,14 +87,14 @@ namespace ClassicalSharp {
|
|||||||
RebuildEdges( map.WaterHeight, legacy ? 128 : 65536 );
|
RebuildEdges( map.WaterHeight, legacy ? 128 : 65536 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
void EnvVariableChanged( object sender, EnvVarEventArgs e ) {
|
||||||
if( e.Var == EnvVariable.EdgeBlock ) {
|
if( e.Var == EnvVar.EdgeBlock ) {
|
||||||
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, map.EdgeBlock );
|
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, map.EdgeBlock );
|
||||||
} else if( e.Var == EnvVariable.SidesBlock ) {
|
} else if( e.Var == EnvVar.SidesBlock ) {
|
||||||
MakeTexture( ref sideTexId, ref lastSideTexLoc, map.SidesBlock );
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, map.SidesBlock );
|
||||||
} else if( e.Var == EnvVariable.WaterLevel ) {
|
} else if( e.Var == EnvVar.WaterLevel ) {
|
||||||
ResetSidesAndEdges( null, null );
|
ResetSidesAndEdges( null, null );
|
||||||
} else if( e.Var == EnvVariable.SunlightColour ) {
|
} else if( e.Var == EnvVar.SunlightColour ) {
|
||||||
ResetSidesAndEdges( null, null );
|
ResetSidesAndEdges( null, null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,10 +74,10 @@ namespace ClassicalSharp {
|
|||||||
chunkPos = new Vector3I( int.MaxValue, int.MaxValue, int.MaxValue );
|
chunkPos = new Vector3I( int.MaxValue, int.MaxValue, int.MaxValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
void EnvVariableChanged( object sender, EnvVarEventArgs e ) {
|
||||||
if( e.Var == EnvVariable.SunlightColour || e.Var == EnvVariable.ShadowlightColour ) {
|
if( e.Var == EnvVar.SunlightColour || e.Var == EnvVar.ShadowlightColour ) {
|
||||||
Refresh();
|
Refresh();
|
||||||
} else if( e.Var == EnvVariable.WaterLevel ) {
|
} else if( e.Var == EnvVar.WaterLevel ) {
|
||||||
builder.clipLevel = Math.Max( 0, game.Map.GroundHeight );
|
builder.clipLevel = Math.Max( 0, game.Map.GroundHeight );
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,10 @@ namespace ClassicalSharp.Renderers {
|
|||||||
graphics.ClearColour( map.SkyCol );
|
graphics.ClearColour( map.SkyCol );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CloudsColourChanged() {
|
protected override void EnvVariableChanged( object sender, EnvVarEventArgs e ) {
|
||||||
}
|
if( e.Var == EnvVar.SkyColour ) {
|
||||||
|
graphics.ClearColour( map.SkyCol );
|
||||||
protected override void FogColourChanged() {
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SkyColourChanged() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,8 @@ namespace ClassicalSharp.Renderers {
|
|||||||
|
|
||||||
int cloudsVb = -1, cloudsIndices, skyVb = -1, skyIndices;
|
int cloudsVb = -1, cloudsIndices, skyVb = -1, skyIndices;
|
||||||
public float CloudsSpeed = 1;
|
public float CloudsSpeed = 1;
|
||||||
public int CloudsOffset = 2;
|
|
||||||
bool legacy;
|
bool legacy;
|
||||||
|
|
||||||
public void SetCloudsOffset( int offset ) {
|
|
||||||
CloudsOffset = offset;
|
|
||||||
ResetClouds();
|
|
||||||
ResetSky();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetUseLegacyMode( bool legacy ) {
|
public void SetUseLegacyMode( bool legacy ) {
|
||||||
this.legacy = legacy;
|
this.legacy = legacy;
|
||||||
ResetSky();
|
ResetSky();
|
||||||
@ -33,7 +26,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
if( skyVb == -1 || cloudsVb == -1 ) return;
|
if( skyVb == -1 || cloudsVb == -1 ) return;
|
||||||
|
|
||||||
Vector3 pos = game.LocalPlayer.EyePosition;
|
Vector3 pos = game.LocalPlayer.EyePosition;
|
||||||
if( pos.Y < map.Height + CloudsOffset + 8 ) {
|
if( pos.Y < map.CloudHeight + 8 ) {
|
||||||
graphics.BeginVbBatch( VertexFormat.Pos3fCol4b );
|
graphics.BeginVbBatch( VertexFormat.Pos3fCol4b );
|
||||||
graphics.BindVb( skyVb );
|
graphics.BindVb( skyVb );
|
||||||
graphics.DrawIndexedVb( DrawMode.Triangles, skyIndices, 0 );
|
graphics.DrawIndexedVb( DrawMode.Triangles, skyIndices, 0 );
|
||||||
@ -42,16 +35,17 @@ namespace ClassicalSharp.Renderers {
|
|||||||
ResetFog();
|
ResetFog();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CloudsColourChanged() {
|
protected override void EnvVariableChanged( object sender, EnvVarEventArgs e ) {
|
||||||
ResetClouds();
|
if( e.Var == EnvVar.SkyColour ) {
|
||||||
}
|
ResetSky();
|
||||||
|
} else if( e.Var == EnvVar.FogColour ) {
|
||||||
protected override void FogColourChanged() {
|
ResetFog();
|
||||||
ResetFog();
|
} else if( e.Var == EnvVar.CloudsColour ) {
|
||||||
}
|
ResetClouds();
|
||||||
|
} else if( e.Var == EnvVar.CloudsLevel ) {
|
||||||
protected override void SkyColourChanged() {
|
ResetSky();
|
||||||
ResetSky();
|
ResetClouds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnNewMap( object sender, EventArgs e ) {
|
public override void OnNewMap( object sender, EventArgs e ) {
|
||||||
@ -160,7 +154,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
cloudsIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
cloudsIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
||||||
|
|
||||||
VertexPos3fTex2fCol4b* vertices = stackalloc VertexPos3fTex2fCol4b[cloudsIndices / 6 * 4];
|
VertexPos3fTex2fCol4b* vertices = stackalloc VertexPos3fTex2fCol4b[cloudsIndices / 6 * 4];
|
||||||
DrawCloudsY( x1, z1, x2, z2, map.Height + CloudsOffset, axisSize, map.CloudsCol, vertices );
|
DrawCloudsY( x1, z1, x2, z2, map.CloudHeight, axisSize, map.CloudsCol, vertices );
|
||||||
cloudsVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fTex2fCol4b, cloudsIndices / 6 * 4 );
|
cloudsVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fTex2fCol4b, cloudsIndices / 6 * 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +164,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
skyIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
skyIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
||||||
|
|
||||||
VertexPos3fCol4b* vertices = stackalloc VertexPos3fCol4b[skyIndices / 6 * 4];
|
VertexPos3fCol4b* vertices = stackalloc VertexPos3fCol4b[skyIndices / 6 * 4];
|
||||||
DrawSkyY( x1, z1, x2, z2, map.Height + CloudsOffset + 8, axisSize, map.SkyCol, vertices );
|
DrawSkyY( x1, z1, x2, z2, map.CloudHeight + 8, axisSize, map.SkyCol, vertices );
|
||||||
skyVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fCol4b, skyIndices / 6 * 4 );
|
skyVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fCol4b, skyIndices / 6 * 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
/// <summary> Structure that can be used for quick manipulations of A/R/G/B colours. </summary>
|
/// <summary> Structure that can be used for quick manipulations of A/R/G/B colours. </summary>
|
||||||
/// <remarks> This structure is **not** suitable for interop with OpenGL or Direct3D. </remarks>
|
/// <remarks> This structure is **not** suitable for interop with OpenGL or Direct3D. </remarks>
|
||||||
public struct FastColour {
|
public struct FastColour : IEquatable<FastColour> {
|
||||||
|
|
||||||
public byte A, R, G, B;
|
public byte A, R, G, B;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user