From bb69f628da5cd1d4be19758deae794680004d0ef Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 27 Dec 2015 21:12:02 +1100 Subject: [PATCH] Play sounds of gas/liquid blocks intersecting with before solid blocks underneath (Thanks 123DontMessWitMe), don't italic classical in the launcher. --- ClassicalSharp/Entities/LocalPlayer.cs | 31 ++++++++++++++++++-------- Launcher2/Gui/Drawer2DExt.cs | 6 ++--- Launcher2/LauncherWindow.Background.cs | 13 ++++------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 32be6f0cf..d243ef19b 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -115,7 +115,7 @@ namespace ClassicalSharp { Vector3 soundPos = nextPos; bool anyNonAir = false; - SoundType type = GetSoundUnder( ref anyNonAir ); + SoundType type = GetSound( ref anyNonAir ); if( !anyNonAir ) soundPos = new Vector3( -100000 ); if( onGround && (DoPlaySound( soundPos ) || !wasOnGround) ) { @@ -126,24 +126,37 @@ namespace ClassicalSharp { bool DoPlaySound( Vector3 soundPos ) { float distSq = (lastSoundPos - soundPos).LengthSquared; + bool enoughDist = distSq > 1.75f * 1.75f; // just play every certain block interval when not animating - if( curSwing < 0.999f ) - return distSq > 1.75f * 1.75f; + if( curSwing < 0.999f ) return enoughDist; // have our legs just crossed over the '0' point? float oldLegRot = (float)Math.Sin( walkTimeO ); float newLegRot = (float)Math.Sin( walkTimeN ); - return Math.Sign( oldLegRot ) != Math.Sign( newLegRot ); + return (Math.Sign( oldLegRot ) != Math.Sign( newLegRot )); } - SoundType GetSoundUnder( ref bool anyNonAir ) { - Vector3 pos = new Vector3( nextPos.X, nextPos.Y - 0.01f, nextPos.Z ); - Vector3 size = CollisionSize; + SoundType GetSound( ref bool anyNonAir ) { + Vector3 pos = nextPos, size = CollisionSize; BoundingBox bounds = new BoundingBox( pos - size / 2, pos + size / 2); - bounds.Max.Y = bounds.Min.Y = pos.Y; - SoundType type = SoundType.None; bool nonAir = false; + + // first check surrounding liquids/gas for sounds + TouchesAny( bounds, b => { + SoundType newType = game.BlockInfo.StepSounds[b]; + BlockCollideType collide = game.BlockInfo.CollideType[b]; + if( newType != SoundType.None && collide != BlockCollideType.Solid) + type = newType; + if( b != 0 ) nonAir = true; + return false; + }); + if( type != SoundType.None ) + return type; + + // then check soliod blocks below + pos.Y -= 0.01f; + bounds.Max.Y = bounds.Min.Y = pos.Y; TouchesAny( bounds, b => { SoundType newType = game.BlockInfo.StepSounds[b]; if( newType != SoundType.None ) type = newType; diff --git a/Launcher2/Gui/Drawer2DExt.cs b/Launcher2/Gui/Drawer2DExt.cs index f26c0feaf..0ac9d69e1 100644 --- a/Launcher2/Gui/Drawer2DExt.cs +++ b/Launcher2/Gui/Drawer2DExt.cs @@ -53,9 +53,9 @@ namespace Launcher2 { int* row = dst.GetRowPtr( dstY + yy ); for( int xx = 0; xx < dstWidth; xx++ ) { float n = Noise( dstX + xx, dstY + yy ); - int r = col.R + (int)(5 * n); Utils.Clamp( ref r, 0, 255 ); - int g = col.G + (int)(5 * n); Utils.Clamp( ref g, 0, 255 ); - int b = col.B + (int)(5 * n); Utils.Clamp( ref b, 0, 255 ); + int r = col.R + (int)(n * 6); Utils.Clamp( ref r, 0, 255 ); + int g = col.G + (int)(n * 6); Utils.Clamp( ref g, 0, 255 ); + int b = col.B + (int)(n * 6); Utils.Clamp( ref b, 0, 255 ); row[dstX + xx] = alpha | (r << 16) | (g << 8) | b; } } diff --git a/Launcher2/LauncherWindow.Background.cs b/Launcher2/LauncherWindow.Background.cs index adccb7e11..07370c5a7 100644 --- a/Launcher2/LauncherWindow.Background.cs +++ b/Launcher2/LauncherWindow.Background.cs @@ -43,15 +43,10 @@ namespace Launcher2 { drawer.SetBitmap( Framebuffer ); ClearArea( 0, 0, Width, Height ); - DrawTextArgs args1 = new DrawTextArgs( "&eClassical", logoItalicFont, true ); - Size size1 = drawer.MeasureChatSize( ref args1 ); - DrawTextArgs args2 = new DrawTextArgs( "&fSharp", logoFont, true ); - Size size2 = drawer.MeasureChatSize( ref args2 ); - - int adjust = Drawer.UseBitmappedChat ? -8 : 2; - int xStart = Width / 2 - (size1.Width + size2.Width) / 2; - drawer.DrawChatText( ref args1, xStart, 20 + (size2.Height - size1.Height - 1) ); - drawer.DrawChatText( ref args2, xStart + size1.Width + adjust, 20 ); + DrawTextArgs args = new DrawTextArgs( "&eClassical&fSharp", logoFont, true ); + Size size = drawer.MeasureChatSize( ref args ); + int xStart = Width / 2 - size.Width / 2; + drawer.DrawChatText( ref args, xStart, 20 ); } Dirty = true; }