diff options
Diffstat (limited to 'Client/Assembly-CSharp/FollowerCamera.cs')
-rw-r--r-- | Client/Assembly-CSharp/FollowerCamera.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/FollowerCamera.cs b/Client/Assembly-CSharp/FollowerCamera.cs new file mode 100644 index 0000000..3184542 --- /dev/null +++ b/Client/Assembly-CSharp/FollowerCamera.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections; +using UnityEngine; + +internal class FollowerCamera : MonoBehaviour +{ + public MonoBehaviour Target; + + public Vector2 Offset; + + public bool Locked; + + public float shakeAmount; + + public float shakePeriod = 1f; + + public void FixedUpdate() + { + if (this.Target && !this.Locked) + { + base.transform.position = Vector3.Lerp(base.transform.position, this.Target.transform.position + this.Offset, 5f * Time.deltaTime); + if (this.shakeAmount > 0f) + { + float num = Mathf.PerlinNoise(0.5f, Time.time * this.shakePeriod) * 2f - 1f; + float num2 = Mathf.PerlinNoise(Time.time * this.shakePeriod, 0.5f) * 2f - 1f; + base.transform.Translate(num * this.shakeAmount, num2 * this.shakeAmount, 0f); + } + } + } + + public void ShakeScreen(float duration, float severity) + { + base.StartCoroutine(this.CoShakeScreen(duration, severity)); + } + + private IEnumerator CoShakeScreen(float duration, float severity) + { + WaitForFixedUpdate wait = new WaitForFixedUpdate(); + for (float t = duration; t > 0f; t -= Time.fixedDeltaTime) + { + float d = t / duration; + this.Offset = UnityEngine.Random.insideUnitCircle * d * severity; + yield return wait; + } + this.Offset = Vector2.zero; + yield break; + } + + internal void SetTarget(MonoBehaviour target) + { + this.Target = target; + base.transform.position = this.Target.transform.position + this.Offset; + } +} |