Decompiled source of No Gravity v1.0.2

NoGravity.dll

Decompiled 8 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DeathStar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeathStar")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[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")]
namespace NoGravity;

[BepInPlugin("com.codemob.nogravity", "NoGravity", "1.0.0")]
public class NoGravity : BaseUnityPlugin
{
	public Harmony harmony;

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"who needs gravity anyway?");
		harmony.PatchAll(typeof(NoGravity));
		MethodInfo method = typeof(SlimeController).GetMethod("Spawn", BindingFlags.Instance | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(NoGravity).GetMethod("SpawnPatch", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo method2 = typeof(DetPhysics).GetMethod("IntegrateBody", BindingFlags.Instance | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(NoGravity).GetMethod("DetPhysicsGravityPatch", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	[HarmonyPatch(typeof(PlayerPhysics), "UpdateSim")]
	[HarmonyPrefix]
	public static void PatchUpdateSim(ref PlayerPhysics __instance)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		__instance.airAccel = (Fix)0.005f;
		__instance.gravity_modifier = Fix.Zero;
		__instance.gravity_accel = Fix.Zero;
	}

	[HarmonyPatch(typeof(PlayerPhysics), "AddGravityFactor")]
	[HarmonyPrefix]
	public static bool PatchPlayerGravity()
	{
		return false;
	}

	[HarmonyPatch(typeof(Gravity), "UpdateSim")]
	[HarmonyPrefix]
	public static bool PatchGravityUpdate(ref Gravity __instance)
	{
		return false;
	}

	[HarmonyPatch(typeof(BoplBody), "UpdateSim")]
	[HarmonyPrefix]
	public static void PatchBoplBodyUpdate(ref BoplBody __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		__instance.gravityScale = Fix.Zero;
	}

	[HarmonyPatch(typeof(PlayerPhysics), "Jump")]
	[HarmonyPrefix]
	public static bool PatchJump(ref PlayerPhysics __instance)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		object? value = typeof(PlayerPhysics).GetField("attachedGround", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
		StickyRoundedRectangle val = (StickyRoundedRectangle)((value is StickyRoundedRectangle) ? value : null);
		PlayerBody playerBody = __instance.GetPlayerBody();
		__instance.jumpedThisFrame = true;
		Vec2 val2 = ((!__instance.IsGrounded()) ? Vec2.up : val.currentNormal(playerBody));
		playerBody.selfImposedVelocity = val2 * __instance.jumpStrength * (Fix)0.25f;
		playerBody.position += playerBody.selfImposedVelocity * __instance.extraJumpTeleportMultiplier;
		((Component)__instance).transform.position = (Vector3)playerBody.position;
		__instance.UnGround(false, true);
		return false;
	}

	[HarmonyPatch(typeof(PlayerPhysics), "Move")]
	[HarmonyPrefix]
	public static bool PatchMove(ref PlayerPhysics __instance, ref Vec2 inputVector, ref Fix simDeltaTime)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
		if (!__instance.IsGrounded())
		{
			object? value = typeof(PlayerPhysics).GetField("playerIdHolder", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
			IPlayerIdHolder val = (IPlayerIdHolder)((value is IPlayerIdHolder) ? value : null);
			PlayerBody playerBody = __instance.GetPlayerBody();
			playerBody.selfImposedVelocity += inputVector * __instance.airAccel;
			Fix val2 = __instance.airAccel / (__instance.Speed + __instance.airAccel);
			playerBody.selfImposedVelocity += Vec2.left * val2 * playerBody.selfImposedVelocity.x;
			playerBody.selfImposedVelocity += Vec2.down * val2 * playerBody.selfImposedVelocity.y;
			__instance.VelocityBasedRaycasts(true, GameTime.FixedDeltaTime(val, simDeltaTime));
			return false;
		}
		return true;
	}

	public static void SpawnPatch(ref SlimeController __instance)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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)
		object? value = typeof(SlimeController).GetField("playerPhysics", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
		PlayerPhysics val = (PlayerPhysics)((value is PlayerPhysics) ? value : null);
		__instance.body.selfImposedVelocity = Vec2.down * val.jumpStrength * (Fix)0.125f;
	}

	public static void DetPhysicsGravityPatch(ref PhysicsBody body)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		body.gravityScale = Fix.Zero;
	}

	[HarmonyPatch(typeof(Drill), "UpdateSim")]
	[HarmonyPrefix]
	public static void DrillUpdatePatch(ref Drill __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		__instance.strongGravity = Fix.Zero;
		__instance.gravityStr = Fix.Zero;
	}

	[HarmonyPatch(typeof(Boulder), "UpdateSim")]
	[HarmonyPrefix]
	public static void BoulderUpdatePatch(ref Boulder __instance)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		__instance.hitbox.SetGravityScale(Fix.Zero);
	}

	[HarmonyPatch(typeof(DetPhysics), "UpdateRopeMesh_parallell")]
	[HarmonyPrefix]
	public static void RopePatch(ref DetPhysics __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		__instance.playerGravity = Fix.Zero;
		__instance.ropeGravity = Fix.Zero;
	}
}