Decompiled source of Up To Faydown v1.2.2

UpToFaydown.dll

Decompiled a month ago
using System;
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 HarmonyLib;
using InControl;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UpToFaydown")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+fcf47944916066c3bdf4a4543e71ec3fe14f5de1")]
[assembly: AssemblyProduct("UpToFaydown")]
[assembly: AssemblyTitle("Silksong.UpToFaydown")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Silksong.UpToFaydown
{
	[HarmonyPatch]
	[BepInPlugin("runhello.silksong.uptofaydown", "Up to Faydown", "1.2.0")]
	public class UpToFaydown : BaseUnityPlugin
	{
		private static ManualLogSource logger;

		private static ConfigEntry<bool> enabled;

		private Harmony harmony;

		public const string Id = "runhello.silksong.uptofaydown";

		public static string Name => "Up to Faydown";

		public static string Version => "1.2.0";

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Faydown Require Up", true, "Enable up-to-doublejump requirement");
			harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		[HarmonyPatch(typeof(HeroController), "CanDoubleJump")]
		[HarmonyILManipulator]
		private static void IlCanDoubleJump(ILContext ctx)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => instruction.OpCode == OpCodes.Ldfld && instruction.Operand.ToString().EndsWith("hasDoubleJump")
			}))
			{
				logger.LogWarning((object)"Failed to find instruction in HeroController.CanDoubleJump()");
			}
			else
			{
				val.Emit(OpCodes.Ldarg_0).EmitDelegate<Func<bool, HeroController, bool>>((Func<bool, HeroController, bool>)AllowDoubleJump);
			}
		}

		private static bool AllowDoubleJump(bool hasDoubleJump, HeroController heroController)
		{
			if (!enabled.Value)
			{
				return hasDoubleJump;
			}
			if (!((OneAxisInputControl)heroController.inputHandler.inputActions.Up).IsPressed)
			{
				return false;
			}
			return hasDoubleJump;
		}
	}
}