using Sandbox;
using System;

namespace VeloX;


public partial class VeloXWheel : Component
{
	private RealTimeUntil expandSoundCD;
	private RealTimeUntil contractSoundCD;
	private void DoSuspensionSounds( VeloXBase vehicle, float change )
	{
		if ( change > 0.1f && expandSoundCD )
		{
			expandSoundCD = 0.3f;
			var sound = Sound.Play( vehicle.SuspensionUpSound, WorldPosition );
			sound.Volume = Math.Clamp( Math.Abs( change ) * 5f, 0, 0.5f );
		}

		if ( change < -0.1f && contractSoundCD )
		{
			contractSoundCD = 0.3f;
			change = MathF.Abs( change );
			var sound = Sound.Play( change > 0.3f ? vehicle.SuspensionHeavySound : vehicle.SuspensionDownSound, WorldPosition );
			sound.Volume = Math.Clamp( change * 5f, 0, 1 );
		}
	}
}
