Decompiled source of DoubleJump v1.0.0

DoubleJump.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MyFirstBoplPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyFirstBoplPlugin")]
[assembly: AssemblyTitle("MyFirstBoplPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DoubleJump
{
	internal class Patches
	{
		[HarmonyPatch(typeof(SlimeController), "OldUpdate")]
		private class Patch1
		{
			private static Dictionary<SlimeController, int> nJumps = new Dictionary<SlimeController, int>();

			private static bool wasGrounded;

			private static void Prefix(SlimeController __instance)
			{
				wasGrounded = ((Component)__instance).GetComponent<PlayerPhysics>().IsGrounded();
			}

			private static void Postfix(SlimeController __instance)
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				Player player = PlayerHandler.Get().GetPlayer(__instance.playerNumber);
				PlayerPhysics component = ((Component)__instance).GetComponent<PlayerPhysics>();
				if (!nJumps.ContainsKey(__instance))
				{
					nJumps.Add(__instance, Plugin.maxNJumps.Value);
				}
				if (component.IsGrounded())
				{
					nJumps[__instance] = Plugin.maxNJumps.Value;
				}
				if (player.jumpButton_PressedThisFrame() && nJumps[__instance] > 0 && !wasGrounded)
				{
					nJumps[__instance]--;
					bool flag = !((Object)(object)component.getAttachedGround() == (Object)null) && component.getAttachedGround().currentNormal(__instance.body).y < 0L;
					Traverse.Create((object)__instance).Field("wasUpsideDown").SetValue((object)flag);
					component.Jump();
				}
			}
		}

		[HarmonyPatch(typeof(PlayerPhysics), "Jump")]
		private class Patch2
		{
			private static bool Prefix(PlayerPhysics __instance)
			{
				//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_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_005a: 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)
				//IL_0066: 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_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: 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_0094: 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_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: 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_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: 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_011f: 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_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				__instance.jumpedThisFrame = true;
				object value = Traverse.Create((object)__instance).Field("isGrounded").GetValue();
				bool flag = value is bool && (bool)value;
				PlayerBody component = ((Component)__instance).GetComponent<PlayerBody>();
				if (!flag)
				{
					Vec2 velocity = component.Velocity;
					velocity.y = Fix.One;
					velocity.x = Fix.Min(Fix.One, Fix.Max((Fix)(-1L), velocity.x));
					Vec2 val = default(Vec2);
					((Vec2)(ref val))..ctor(velocity.x, Fix.Zero);
					Vec2 up = Vec2.up;
					Fix val2 = (velocity.y + Fix.One) / __instance.jumpNormalScaleFactor;
					val2 = Fix.Min(Fix.One, val2);
					val2 = Fix.Max(Fix.Zero, val2);
					up *= val2;
					up += val * __instance.jumpExtraXStrength;
					Vec2 val3 = new Vec2(velocity.y, -velocity.x) * __instance.groundedSpeed;
					component.selfImposedVelocity = val3 * __instance.jumpKeptMomentum + up * __instance.jumpStrength;
					component.position += component.selfImposedVelocity * __instance.extraJumpTeleportMultiplier;
					((Component)__instance).transform.position = (Vector3)component.position;
					GameObject.Find("AudioManager").GetComponent<AudioManager>().Play("slimeJump" + ((Component)__instance).GetComponent<IPlayerIdHolder>().GetPlayerId());
					return false;
				}
				return true;
			}
		}
	}
	[BepInPlugin("com.thepro.doublejump", "Double Jump", "1.0.0")]
	[BepInProcess("BoplBattle.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Harmony harmony;

		internal static ManualLogSource logger;

		internal static ConfigFile config;

		internal static ConfigEntry<int> maxNJumps;

		internal static Sprite atomSprite;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			maxNJumps = config.Bind<int>("Settings", "Added air jumps", 1, (ConfigDescription)null);
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MyFirstBoplPlugin";

		public const string PLUGIN_NAME = "MyFirstBoplPlugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}