Advertisement
InsetJesux

Untitled

Mar 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using MEC;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6. using UnityStandardAssets.Characters.FirstPerson;
  7.  
  8. // Token: 0x02000211 RID: 529
  9. public class Recoil : MonoBehaviour
  10. {
  11. // Token: 0x06000EEC RID: 3820 RVA: 0x00055DAC File Offset: 0x00053FAC
  12. public void DoRecoil(RecoilProperties r, float multip)
  13. {
  14. if (this.mlook != null)
  15. {
  16. this.backSpeed = r.backSpeed;
  17. this.lerpSpeed = r.lerpSpeed;
  18. this.recoil += r.shockSize * multip;
  19. this.target = new Vector3
  20. {
  21. x = (float)UnityEngine.Random.Range(-70, -50),
  22. y = (float)UnityEngine.Random.Range(-20, 20),
  23. z = (float)UnityEngine.Random.Range(-20, 20)
  24. };
  25. Vector3 vector = multip * this.target.normalized * 13f * r.upSize;
  26. this.mlook.Recoil(0f - vector.x, vector.y);
  27. }
  28. }
  29.  
  30. // Token: 0x06000EED RID: 3821 RVA: 0x00055E77 File Offset: 0x00054077
  31. private void Start()
  32. {
  33. Timing.RunCoroutine(this._Start(), Segment.FixedUpdate);
  34. }
  35.  
  36. // Token: 0x06000EEE RID: 3822 RVA: 0x00055E86 File Offset: 0x00054086
  37. private IEnumerator<float> _Start()
  38. {
  39. if (!base.GetComponentInParent<NetworkIdentity>().isLocalPlayer)
  40. {
  41. yield break;
  42. }
  43. Recoil.singleton = this;
  44. yield return 0f;
  45. this.mlook = base.GetComponentInParent<FirstPersonController>().m_MouseLook;
  46. while (this != null)
  47. {
  48. this.recoil -= this.backSpeed / 50f;
  49. this.recoil = Mathf.Clamp01(this.recoil);
  50. Vector3 euler = Vector3.Lerp(Vector3.zero, this.target, this.recoil);
  51. base.transform.localRotation = Quaternion.Lerp(base.transform.localRotation, Quaternion.Euler(euler), (this.lerpSpeed * this.recoil + 1f) / 10f);
  52. base.transform.localPosition = Vector3.up * (this.positionOffset + 0.8380203f);
  53. yield return 0f;
  54. }
  55. yield break;
  56. }
  57.  
  58. // Token: 0x06000EEF RID: 3823 RVA: 0x00055E95 File Offset: 0x00054095
  59. public static void StaticDoRecoil(RecoilProperties r, float multip)
  60. {
  61. Recoil.singleton.DoRecoil(r, multip);
  62. }
  63.  
  64. // Token: 0x04000F4C RID: 3916
  65. public static Recoil singleton;
  66.  
  67. // Token: 0x04000F4D RID: 3917
  68. public GameObject plyCam;
  69.  
  70. // Token: 0x04000F4E RID: 3918
  71. private float recoil;
  72.  
  73. // Token: 0x04000F4F RID: 3919
  74. private float backSpeed = 1f;
  75.  
  76. // Token: 0x04000F50 RID: 3920
  77. private float lerpSpeed = 1f;
  78.  
  79. // Token: 0x04000F51 RID: 3921
  80. private Vector3 target;
  81.  
  82. // Token: 0x04000F52 RID: 3922
  83. private MouseLook mlook;
  84.  
  85. // Token: 0x04000F53 RID: 3923
  86. public float positionOffset;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement