mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Make sounds nicer - there is less of an audible gap between step sounds, also play step sounds when landing from a jump or fly.
This commit is contained in:
parent
0f95d6d92f
commit
5fc02e4536
@ -102,6 +102,7 @@ namespace ClassicalSharp {
|
|||||||
lastPos = Position = nextPos;
|
lastPos = Position = nextPos;
|
||||||
lastYaw = nextYaw;
|
lastYaw = nextYaw;
|
||||||
lastPitch = nextPitch;
|
lastPitch = nextPitch;
|
||||||
|
bool wasOnGround = onGround;
|
||||||
|
|
||||||
HandleInput( ref xMoving, ref zMoving );
|
HandleInput( ref xMoving, ref zMoving );
|
||||||
UpdateVelocityState( xMoving, zMoving );
|
UpdateVelocityState( xMoving, zMoving );
|
||||||
@ -112,18 +113,36 @@ namespace ClassicalSharp {
|
|||||||
UpdateAnimState( lastPos, nextPos, delta );
|
UpdateAnimState( lastPos, nextPos, delta );
|
||||||
CheckSkin();
|
CheckSkin();
|
||||||
|
|
||||||
Vector3 soundPos = Position;
|
Vector3 soundPos = nextPos;
|
||||||
byte blockUnder = (byte)BlockUnderFeet;
|
bool anyNonAir = false;
|
||||||
if( blockUnder == 0 ) soundPos = new Vector3( -100000 );
|
SoundType type = GetSoundUnder( ref anyNonAir );
|
||||||
|
if( !anyNonAir ) soundPos = new Vector3( -100000 );
|
||||||
|
|
||||||
float distSq = (lastSoundPos - soundPos).LengthSquared;
|
float distSq = (lastSoundPos - soundPos).LengthSquared;
|
||||||
if( onGround && distSq > 2 * 2 ) {
|
if( onGround && (distSq > 1.75f * 1.75f || !wasOnGround) ) {
|
||||||
SoundType type = game.BlockInfo.StepSounds[blockUnder];
|
|
||||||
game.AudioPlayer.PlayStepSound( type );
|
game.AudioPlayer.PlayStepSound( type );
|
||||||
lastSoundPos = soundPos;
|
lastSoundPos = soundPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundType GetSoundUnder( ref bool anyNonAir ) {
|
||||||
|
Vector3 pos = new Vector3( nextPos.X, nextPos.Y - 0.01f, nextPos.Z );
|
||||||
|
Vector3 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;
|
||||||
|
TouchesAny( bounds, b => {
|
||||||
|
SoundType newType = game.BlockInfo.StepSounds[b];
|
||||||
|
if( newType != SoundType.None ) type = newType;
|
||||||
|
if( b != 0 ) nonAir = true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
anyNonAir = nonAir;
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public override void RenderModel( double deltaTime, float t ) {
|
public override void RenderModel( double deltaTime, float t ) {
|
||||||
GetCurrentAnimState( t );
|
GetCurrentAnimState( t );
|
||||||
curSwing = Utils.Lerp( swingO, swingN, t );
|
curSwing = Utils.Lerp( swingO, swingN, t );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user