summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/EngineBehaviour.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-12-30 20:59:04 +0800
committerchai <chaifix@163.com>2020-12-30 20:59:04 +0800
commite9ea621b93fbb58d9edfca8375918791637bbd52 (patch)
tree19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/EngineBehaviour.cs
+init
Diffstat (limited to 'Client/Assembly-CSharp/EngineBehaviour.cs')
-rw-r--r--Client/Assembly-CSharp/EngineBehaviour.cs48
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;
+ }
+}