Decompiled source of Wingsuiting v2.0.0

Wingsuiting.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using Wingsuiting.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mikies mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mikies mod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b2fbf539-0689-4820-89ea-3543dcd20441")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class WingsuitGameManager : MonoBehaviour
{
	public float forwardSpeed;

	public float breakNeckSpeedTimer;

	public bool flyingForward;

	public Vector3 flightVector;

	private float floatLength;

	private float lerpSideManager;

	private float movementX;

	private float lerpMovementX;

	public float CameraUp;

	private bool modeOfTransportation;

	private float sprintMeter;

	private void FixedUpdate()
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		breakNeckSpeedTimer -= Time.deltaTime;
		if (UnityInput.Current.GetKey((KeyCode)114) && !localPlayerController.thisController.isGrounded && !localPlayerController.inTerminalMenu && !localPlayerController.isClimbingLadder && breakNeckSpeedTimer <= 0f)
		{
			localPlayerController.sprintMeter = sprintMeter;
			lerpMovementX = Mathf.Lerp(lerpMovementX, movementX, 12f * Time.fixedDeltaTime);
			lerpSideManager = Mathf.Lerp(lerpSideManager, 1f, 60f * Time.fixedDeltaTime);
			floatLength += Time.deltaTime;
			flyingForward = true;
			flightVector = Vector3.Lerp(flightVector, ((Component)localPlayerController.gameplayCamera).transform.TransformDirection(Vector3.forward * forwardSpeed * lerpSideManager * Time.deltaTime * 0.8f), 12f * Time.fixedDeltaTime);
			forwardSpeed += ((Component)localPlayerController.gameplayCamera).transform.localRotation.x / 8f;
			forwardSpeed = Mathf.Clamp(forwardSpeed, -10f, 10f);
			localPlayerController.thisController.Move(flightVector * 20f * lerpSideManager + Vector3.down * Time.fixedDeltaTime * 3.5f * Mathf.Clamp(Mathf.Sqrt(floatLength), -2f, 2f));
			localPlayerController.fallValue = Mathf.Lerp(localPlayerController.fallValue, flightVector.y * 50f * lerpSideManager, 0.5f);
			localPlayerController.fallValueUncapped = Mathf.Lerp(localPlayerController.fallValueUncapped, flightVector.y * 50f * lerpSideManager, 0.5f);
		}
		else
		{
			if (localPlayerController.isClimbingLadder)
			{
				flyingForward = false;
				flightVector = Vector3.zero;
			}
			floatLength = 0f;
			forwardSpeed = 0f;
			lerpSideManager = 0f;
			lerpMovementX = 0f;
			movementX = 0f;
		}
		if (flyingForward && !UnityInput.Current.GetKey((KeyCode)114))
		{
			if (!localPlayerController.thisController.isGrounded)
			{
				localPlayerController.thisController.Move(flightVector * 20f);
			}
			else
			{
				flyingForward = false;
			}
			if (localPlayerController.thisController.isGrounded)
			{
				flightVector = Vector3.zero;
				flyingForward = false;
			}
		}
	}

	private void Update()
	{
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03de: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_044e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if (UnityInput.Current.GetKeyDown((KeyCode)114) && !localPlayerController.thisController.isGrounded && !localPlayerController.inTerminalMenu && !localPlayerController.isClimbingLadder && breakNeckSpeedTimer <= 0f)
		{
			sprintMeter = localPlayerController.sprintMeter;
		}
		if (modeOfTransportation)
		{
			movementX = Mathf.Lerp(movementX, 0f, 0.15f * Time.deltaTime);
		}
		else
		{
			movementX = Mathf.Lerp(movementX, 0f, 3f * Time.deltaTime);
		}
		if (UnityInput.Current.GetKeyDown((KeyCode)282))
		{
			HUDManager.Instance.DisplayTip("Swapped Transportation Mode", "Press F1 to swapp", false, false, "LC_Tip1");
			modeOfTransportation = !modeOfTransportation;
		}
		MovementActions movement = localPlayerController.playerActions.Movement;
		Vector2 val = ((MovementActions)(ref movement)).Look.ReadValue<Vector2>() * 0.008f * (float)IngamePlayerSettings.Instance.settings.lookSensitivity;
		if (UnityInput.Current.GetKey((KeyCode)114) && !localPlayerController.thisController.isGrounded && !localPlayerController.inTerminalMenu && !localPlayerController.isClimbingLadder && breakNeckSpeedTimer <= 0f)
		{
			movementX += val.x * -0.8f;
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(((Component)localPlayerController.gameplayCamera).transform.position + ((Vector3)(ref flightVector)).normalized * 2f, ((Vector3)(ref flightVector)).normalized);
			if (modeOfTransportation)
			{
				((Component)localPlayerController).transform.localEulerAngles = new Vector3(0f, ((Component)localPlayerController).transform.localEulerAngles.y - lerpMovementX * Time.deltaTime * 0.8f - val.x / 1.3f, lerpMovementX / 2f);
			}
			else
			{
				((Component)localPlayerController).transform.localEulerAngles = new Vector3(0f, ((Component)localPlayerController).transform.localEulerAngles.y, movementX / 3f);
			}
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, 1f, RoundManager.Instance.collisionsMask) && (forwardSpeed > 1f || forwardSpeed < -1f))
			{
				((Component)localPlayerController).transform.position = ((RaycastHit)(ref val3)).point + ((RaycastHit)(ref val3)).normal;
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				if ((int)Mathf.Sqrt(Mathf.Pow(forwardSpeed, 2f)) * 20 > localPlayerController.health)
				{
					localPlayerController.KillPlayer(flightVector * 400f, true, (CauseOfDeath)3, 0);
				}
				else
				{
					localPlayerController.DamagePlayer((int)Mathf.Sqrt(Mathf.Pow(forwardSpeed, 2f)) * 20, true, true, (CauseOfDeath)2, 0, true, flightVector);
				}
				flightVector = Vector3.zero;
				flyingForward = false;
				breakNeckSpeedTimer = 3f;
				localPlayerController.fallValue = flightVector.y * 0f;
				localPlayerController.fallValueUncapped = flightVector.y * 0f;
			}
		}
		else
		{
			sprintMeter = localPlayerController.sprintMeter;
		}
		if (!flyingForward || UnityInput.Current.GetKey((KeyCode)114) || localPlayerController.thisController.isGrounded)
		{
			return;
		}
		Ray val4 = default(Ray);
		((Ray)(ref val4))..ctor(((Component)localPlayerController.gameplayCamera).transform.position + ((Vector3)(ref flightVector)).normalized * 1.1f, ((Vector3)(ref flightVector)).normalized);
		RaycastHit val5 = default(RaycastHit);
		if (Physics.Raycast(val4, ref val5, 1f, RoundManager.Instance.collisionsMask) && (forwardSpeed > 1f || forwardSpeed < -1f))
		{
			((Component)localPlayerController).transform.position = ((RaycastHit)(ref val5)).point + ((RaycastHit)(ref val5)).normal;
			HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
			if ((int)((Vector3)(ref flightVector)).magnitude * 80 > localPlayerController.health)
			{
				localPlayerController.KillPlayer(flightVector * 160f, true, (CauseOfDeath)2, 0);
			}
			else
			{
				localPlayerController.DamagePlayer((int)((Vector3)(ref flightVector)).magnitude * 80, true, true, (CauseOfDeath)2, 0, true, flightVector);
			}
			flightVector = Vector3.zero;
			flyingForward = false;
			breakNeckSpeedTimer = 3f;
			localPlayerController.fallValue = flightVector.y * 4f;
			localPlayerController.fallValueUncapped = flightVector.y * 4f;
		}
	}

	public static GameObject createImageOnLocalInstance(Color color, Texture sprite, Vector3 size)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		GameObject val = new GameObject();
		RawImage val2 = val.AddComponent<RawImage>();
		val.transform.parent = ((Component)localPlayerController.playerScreen).transform.parent;
		((Graphic)val2).rectTransform.sizeDelta = Vector2.op_Implicit(size);
		((Transform)((Graphic)val2).rectTransform).localPosition = Vector3.zero;
		val2.texture = sprite;
		((Graphic)val2).color = color;
		return val;
	}
}
namespace Wingsuiting
{
	[BepInPlugin("Poseidon.Wingsuiting", "Wingsuiting", "1.0.0.0")]
	public class WingsuitingBase : BaseUnityPlugin
	{
		private const string modGUID = "Poseidon.Wingsuiting";

		private const string modName = "Wingsuiting";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Poseidon.Wingsuiting");

		private static WingsuitingBase instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Poseidon.Wingsuiting");
			mls.LogInfo((object)"All mods in .dll are mine");
			harmony.PatchAll(typeof(WingsuitingBase));
			harmony.PatchAll(typeof(playerControllerBPatch));
		}
	}
}
namespace Wingsuiting.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class playerControllerBPatch : MonoBehaviour
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infiniteSprintPatch(ref float ___cameraUp)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)((Component)localPlayerController).GetComponent<WingsuitGameManager>() == (Object)null)
			{
				((Component)localPlayerController).gameObject.AddComponent<WingsuitGameManager>();
			}
			else if (UnityInput.Current.GetKey((KeyCode)114) && !localPlayerController.thisController.isGrounded && !localPlayerController.inTerminalMenu && !localPlayerController.isClimbingLadder && ((Component)localPlayerController).GetComponent<WingsuitGameManager>().breakNeckSpeedTimer <= 0f)
			{
				___cameraUp = Mathf.Lerp(___cameraUp, 0f, 1f * Time.deltaTime);
			}
			else
			{
				((Component)localPlayerController).GetComponent<WingsuitGameManager>().CameraUp = ___cameraUp;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch : MonoBehaviour
	{
	}
}