diff options
Diffstat (limited to 'Client/Assembly-CSharp/EngineBehaviour.cs')
-rw-r--r-- | Client/Assembly-CSharp/EngineBehaviour.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/EngineBehaviour.cs b/Client/Assembly-CSharp/EngineBehaviour.cs new file mode 100644 index 0000000..87bdccf --- /dev/null +++ b/Client/Assembly-CSharp/EngineBehaviour.cs @@ -0,0 +1,48 @@ +using System; +using UnityEngine; + +public class EngineBehaviour : MonoBehaviour +{ + public AudioClip ElectricSound; + + public AudioClip SteamSound; + + public float SoundDistance = 5f; + + public void PlayElectricSound() + { + if (Constants.ShouldPlaySfx()) + { + SoundManager.Instance.PlayDynamicSound("EngineShock" + base.name, this.ElectricSound, false, new DynamicSound.GetDynamicsFunction(this.GetSoundDistance), false); + } + } + + public void PlaySteamSound() + { + if (Constants.ShouldPlaySfx()) + { + float pitch = FloatRange.Next(0.7f, 1.1f); + SoundManager.Instance.PlayDynamicSound("EngineSteam" + base.name, this.SteamSound, false, delegate(AudioSource p, float d) + { + this.GetSoundDistance(p, d, pitch); + }, false); + } + } + + private void GetSoundDistance(AudioSource player, float dt) + { + this.GetSoundDistance(player, dt, 1f); + } + + private void GetSoundDistance(AudioSource player, float dt, float pitch) + { + float num = 1f; + if (PlayerControl.LocalPlayer) + { + float num2 = Vector2.Distance(base.transform.position, PlayerControl.LocalPlayer.GetTruePosition()); + num = 1f - num2 / this.SoundDistance; + } + player.volume = num * 0.8f; + player.pitch = pitch; + } +} |