Decompiled source of DSPAfterburner v0.0.1

DSPAfterburner.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace DSPAfterburner;

[BepInPlugin("Appun.DSP.plugin.Afterburner", "DSPAfterburner", "0.0.1")]
[HarmonyPatch]
public class DSPAfterburner : BaseUnityPlugin
{
	public class LogManager
	{
		public static ManualLogSource Logger;
	}

	public static ConfigEntry<float> speedMultiplier;

	public static ConfigEntry<float> maximumSpeed;

	public static ConfigEntry<KeyCode> KeyConfig;

	public void Awake()
	{
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		speedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("general", "speedMultiplier", 2.5f, "Speed Multiplier");
		maximumSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("general", "maximumSpeed", 100f, "Maximum Speed");
		KeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("general", "key", (KeyCode)304, "key to boost");
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PlayerMove_Fly), "GameTick")]
	public static bool PlayerMove_Fly_GameTick_Prefix(PlayerMove_Fly __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Invalid comparison between Unknown and I4
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Invalid comparison between Unknown and I4
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Invalid comparison between Unknown and I4
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Invalid comparison between Unknown and I4
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Invalid comparison between Unknown and I4
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_051f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0525: Invalid comparison between Unknown and I4
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Invalid comparison between Unknown and I4
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0631: Unknown result type (might be due to invalid IL or missing references)
		//IL_0637: Invalid comparison between Unknown and I4
		//IL_0703: Unknown result type (might be due to invalid IL or missing references)
		//IL_070e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0749: Unknown result type (might be due to invalid IL or missing references)
		//IL_0755: Unknown result type (might be due to invalid IL or missing references)
		//IL_0760: Unknown result type (might be due to invalid IL or missing references)
		//IL_0765: Unknown result type (might be due to invalid IL or missing references)
		//IL_0769: Unknown result type (might be due to invalid IL or missing references)
		//IL_0775: Unknown result type (might be due to invalid IL or missing references)
		//IL_077a: Unknown result type (might be due to invalid IL or missing references)
		//IL_077f: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_078c: Unknown result type (might be due to invalid IL or missing references)
		//IL_078e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0793: Unknown result type (might be due to invalid IL or missing references)
		//IL_0797: Unknown result type (might be due to invalid IL or missing references)
		//IL_079c: Unknown result type (might be due to invalid IL or missing references)
		//IL_079e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_081e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0823: Unknown result type (might be due to invalid IL or missing references)
		//IL_0827: Unknown result type (might be due to invalid IL or missing references)
		//IL_082e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0833: Unknown result type (might be due to invalid IL or missing references)
		//IL_083a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0840: Unknown result type (might be due to invalid IL or missing references)
		//IL_0845: Unknown result type (might be due to invalid IL or missing references)
		//IL_084a: Unknown result type (might be due to invalid IL or missing references)
		//IL_089a: Unknown result type (might be due to invalid IL or missing references)
		//IL_089c: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_086a: Unknown result type (might be due to invalid IL or missing references)
		//IL_086e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0873: Unknown result type (might be due to invalid IL or missing references)
		//IL_098c: Unknown result type (might be due to invalid IL or missing references)
		//IL_098e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0993: Unknown result type (might be due to invalid IL or missing references)
		//IL_0995: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a4d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a63: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a79: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a88: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		float num = 1f / 60f;
		if ((int)((PlayerAction)__instance).player.movementState == 2)
		{
			Vector3 forward = ((Component)((PlayerAction)__instance).controller.mainCamera).transform.forward;
			Vector3 val = ((PlayerAction)__instance).player.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = Vector3.Cross(normalized, forward);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			forward = Vector3.Cross(normalized2, normalized);
			Vector3 val2 = forward * ((PlayerAction)__instance).controller.input0.y + normalized2 * ((PlayerAction)__instance).controller.input0.x;
			if (((int)((PlayerAction)__instance).controller.cmd.type == 5 && !VFInput._godModeMechaMove && !PlayerController.operationWhenBuild) || __instance.navigation.navigating)
			{
				val2 = Vector3.zero;
			}
			bool flag2 = (int)((PlayerAction)__instance).controller.actionBuild.blueprintMode > 0;
			if (flag2 && !VFInput._godModeMechaMove)
			{
				val2 = Vector3.zero;
			}
			PlanetData localPlanet = GameMain.localPlanet;
			bool flag3 = localPlanet != null && (int)localPlanet.type != 5;
			float softLandingRecover = ((PlayerAction)__instance).controller.softLandingRecover;
			softLandingRecover *= softLandingRecover;
			float num2 = 0.022f * softLandingRecover;
			float num3 = ((PlayerAction)__instance).player.mecha.walkSpeed * 2.5f;
			if (Input.GetKey(KeyConfig.Value))
			{
				num3 *= speedMultiplier.Value;
				if (num3 > maximumSpeed.Value)
				{
					num3 = maximumSpeed.Value;
				}
				flag = true;
			}
			float num4 = ((PlayerAction)__instance).controller.input1.y;
			if (((int)((PlayerAction)__instance).controller.cmd.type == 5 && !VFInput._godModeMechaMove && !PlayerController.operationWhenBuild) || __instance.navigation.navigating)
			{
				num4 = 0f;
			}
			if (flag2 && !VFInput._godModeMechaMove)
			{
				num4 = 0f;
			}
			if (__instance.navigation.navigating)
			{
				bool flag4 = false;
				bool flag5 = false;
				__instance.navigation.DetermineHighOperation(num3, ref flag4, ref flag5);
				num4 = 0f;
				if (flag4)
				{
					num4 += 1f;
				}
				if (flag5 && __instance.targetAltitude > 15.01f + num * 20f)
				{
					num4 += -1f;
				}
			}
			__instance.targetAltitude += num4 * num * 20f;
			if ((int)((PlayerAction)__instance).controller.cmd.type == 5 && !PlayerController.operationWhenBuild && __instance.targetAltitude > 40f)
			{
				__instance.targetAltitude = 40f;
			}
			if (flag2 && !VFInput._godModeMechaMove && __instance.targetAltitude > 40f)
			{
				__instance.targetAltitude = 40f;
			}
			if (num4 == 0f && __instance.targetAltitude > 15f)
			{
				__instance.targetAltitude -= num * 20f * 0.3f;
				if (__instance.targetAltitude < 15f)
				{
					__instance.targetAltitude = 15f;
				}
			}
			else if (__instance.targetAltitude >= 50f)
			{
				if (__instance.currentAltitude > 49f && ((PlayerAction)__instance).controller.horzSpeed > 12.5f && __instance.mecha.thrusterLevel >= 2)
				{
					if ((int)((PlayerAction)__instance).controller.cmd.type == 5)
					{
						((CommandState)(ref ((PlayerAction)__instance).controller.cmd)).SetNoneCommand();
						((PlayerAction)__instance).controller.actionBuild.blueprintMode = (EBlueprintMode)0;
					}
					((PlayerAction)__instance).controller.movementStateInFrame = (EMovementState)3;
					((PlayerAction)__instance).controller.actionSail.ResetSailState();
					GameCamera.instance.SyncForSailMode();
					GameMain.gameScenario.NotifyOnSailModeEnter();
				}
				__instance.targetAltitude = 50f;
			}
			if (flag3)
			{
				if (__instance.targetAltitude < 14.5f)
				{
					if (num4 > 0f)
					{
						__instance.targetAltitude = 15f;
					}
					else
					{
						__instance.targetAltitude = 1f;
					}
					if (__instance.currentAltitude < 3f)
					{
						((PlayerAction)__instance).controller.movementStateInFrame = (EMovementState)0;
						((PlayerAction)__instance).controller.softLandingTime = 1.2f;
					}
				}
			}
			else if (__instance.targetAltitude < 20f)
			{
				__instance.targetAltitude = 20f;
			}
			float realRadius = ((PlayerAction)__instance).player.planetData.realRadius;
			val = ((PlayerAction)__instance).player.position;
			float num5 = Mathf.Max(((Vector3)(ref val)).magnitude, realRadius * 0.9f);
			__instance.currentAltitude = num5 - realRadius;
			if ((int)localPlanet.type == 5 && __instance.mecha.coreEnergy < 10000000.0 && __instance.currentAltitude < 10f)
			{
				__instance.targetAltitude = __instance.currentAltitude + 0.5f;
			}
			float num6 = __instance.targetAltitude - __instance.currentAltitude;
			float num7 = Mathf.Clamp(num / (Time.fixedDeltaTime + 1E-05f), 0.16f, 6f);
			if (__instance.targetAltitude > 17f || __instance.targetAltitude < 13f)
			{
				num7 = 1f / num7;
				num7 = Mathf.Sqrt(num7);
			}
			__instance.verticalThrusterForce = 0f;
			float num8 = Mathf.Clamp(num6 * 0.5f, -10f, 10f) * 100f * num7 + (float)((VectorLF3)(ref ((PlayerAction)__instance).controller.universalGravity)).magnitude;
			num8 = Mathf.Max(0f, num8);
			__instance.verticalThrusterForce += num8;
			float num9 = 1f;
			if ((int)localPlanet.type == 5 && __instance.mecha.coreEnergy < 120000000.0)
			{
				num9 = Mathf.Clamp01((float)(__instance.mecha.coreEnergy / 120000000.0 + 0.05));
			}
			__instance.verticalThrusterForce *= num9;
			__instance.UseThrustEnergy(ref __instance.verticalThrusterForce, ((PlayerAction)__instance).controller.vertSpeed, (double)num);
			__instance.verticalThrusterForce /= num9;
			float num10 = (float)(Math.Sin(GlobalObject.timeSinceStart * 2.0) * 0.1 + 1.0);
			if (Mathf.Abs(__instance.verticalThrusterForce) > 0.001f)
			{
				((PlayerAction)__instance).controller.AddLocalForce(normalized * (__instance.verticalThrusterForce * num10));
			}
			OrderNode currentOrder = ((PlayerAction)__instance).player.currentOrder;
			if (currentOrder != null && !currentOrder.targetReached)
			{
				Vector3 val3 = ((Vector3)(ref currentOrder.target)).normalized * localPlanet.realRadius;
				val = ((PlayerAction)__instance).player.position;
				Vector3 val4 = val3 - ((Vector3)(ref val)).normalized * localPlanet.realRadius;
				float magnitude = ((Vector3)(ref val4)).magnitude;
				val = Vector3.Cross(normalized, val4);
				val = Vector3.Cross(((Vector3)(ref val)).normalized, normalized);
				val4 = ((Vector3)(ref val)).normalized;
				__instance.rtsVelocity = Vector3.Slerp(__instance.rtsVelocity, val4 * num3, num2);
			}
			else
			{
				__instance.rtsVelocity = Vector3.MoveTowards(__instance.rtsVelocity, Vector3.zero, num * 6f * num3);
			}
			if (__instance.navigation.navigating)
			{
				__instance.navigation.DetermineHighVelocity(num3, num2, ref __instance.moveVelocity, num);
			}
			else
			{
				__instance.moveVelocity = Vector3.Slerp(__instance.moveVelocity, val2 * num3, num2);
			}
			Vector3 val5 = __instance.moveVelocity + __instance.rtsVelocity;
			if ((double)softLandingRecover > 0.9)
			{
				if (flag)
				{
				}
				val5 = Vector3.ClampMagnitude(val5, num3);
			}
			__instance.UseFlyEnergy(ref val5, __instance.mecha.walkPower * (double)num * (double)((PlayerAction)__instance).controller.softLandingRecover);
			Vector3 val6 = Vector3.Dot(val5, normalized) * normalized;
			val5 -= val6;
			float num11 = ((PlayerAction)__instance).controller.vertSpeed;
			if (num11 > 50f)
			{
				num11 = 50f;
			}
			float num12 = Mathf.Lerp(0.95f, 0.8f, Mathf.Abs(num6) * 0.3f);
			float num13 = num12;
			num12 = Mathf.Lerp(1f, num12, Mathf.Clamp01(__instance.verticalThrusterForce));
			num13 = Mathf.Lerp(1f, num13, Mathf.Clamp01(__instance.verticalThrusterForce) * Mathf.Clamp01((float)(__instance.mecha.coreEnergy - 5000.0) * 0.0001f));
			if (num11 > 0f)
			{
				num11 *= num12;
			}
			else if (num11 < 0f)
			{
				num11 *= num13;
			}
			((PlayerAction)__instance).controller.velocity = num11 * normalized + val5;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.25f)
			{
				((PlayerAction)__instance).controller.turning_raw = Vector3.SignedAngle(val5, val2, normalized);
			}
			else
			{
				((PlayerAction)__instance).controller.turning_raw = 0f;
			}
			if (flag3 && __instance.mecha.coreEnergy < 10000.0)
			{
				((PlayerAction)__instance).controller.movementStateInFrame = (EMovementState)0;
				((PlayerAction)__instance).controller.softLandingTime = 1.2f;
			}
			((PlayerAction)__instance).controller.actionWalk.rtsVelocity = __instance.rtsVelocity;
			((PlayerAction)__instance).controller.actionWalk.moveVelocity = __instance.moveVelocity * 0.5f;
			((PlayerAction)__instance).controller.actionDrift.rtsVelocity = __instance.rtsVelocity;
			((PlayerAction)__instance).controller.actionDrift.moveVelocity = __instance.moveVelocity * 0.5f;
		}
		return false;
	}
}