Decompiled source of NoFollowerLevelLimit v1.0.10

plugins/me.xhayper.NoFollowerLevelLimit/NoFollowerLevelLimit.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Lamb.UI.Rituals;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NoFollowerLevelLimit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Remove follower level limit")]
[assembly: AssemblyFileVersion("1.0.10.0")]
[assembly: AssemblyInformationalVersion("1.0.10+26b1ca4c44484f840af726ddbbfd85a7594bce47")]
[assembly: AssemblyProduct("NoFollowerLevelLimit")]
[assembly: AssemblyTitle("NoFollowerLevelLimit")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xhayper/NoFollowerLevelLimit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.10.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 NoFollowerLevelLimit
{
	[BepInPlugin("me.xhayper.NoFollowerLevelLimit", "NoFollowerLevelLimit", "1.0.10")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("me.xhayper.NoFollowerLevelLimit");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"NoFollowerLevelLimit loaded!");
		}

		private void OnEnable()
		{
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			SaveAndLoad.OnLoadComplete = (Action)Delegate.Combine(SaveAndLoad.OnLoadComplete, new Action(SaveAndLoad_OnLoadComplete));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{_harmony.GetPatchedMethods().Count()} harmony patches applied!");
		}

		private void OnDisable()
		{
			_harmony.UnpatchSelf();
			SaveAndLoad.OnLoadComplete = (Action)Delegate.Remove(SaveAndLoad.OnLoadComplete, new Action(SaveAndLoad_OnLoadComplete));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"NoFollowerLevelLimit unloaded!");
		}

		private void SaveAndLoad_OnLoadComplete()
		{
			foreach (FollowerInfo follower in DataManager.instance.Followers)
			{
				follower.MaxLevelReached = false;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "me.xhayper.NoFollowerLevelLimit";

		public const string PLUGIN_NAME = "NoFollowerLevelLimit";

		public const string PLUGIN_VERSION = "1.0.10";
	}
}
namespace NoFollowerLevelLimit.Patches
{
	[HarmonyPatch]
	public class FollowerBrainInfoPatches
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool FollowerBrainInfo_MaxLevelReached_getter(ref bool __result)
		{
			__result = false;
			return false;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool FollowerBrainInfo_MaxLevelReached_setter(FollowerBrainInfo __instance)
		{
			__instance._info.MaxLevelReached = false;
			return false;
		}
	}
	[HarmonyPatch]
	public class FollowerBrainPatches
	{
		[HarmonyPatch(typeof(FollowerBrain), "IsMaxLevel")]
		[HarmonyPrefix]
		private static bool FollowerBrain_IsMaxLevel(ref bool __result)
		{
			__result = false;
			return false;
		}

		[HarmonyPatch(typeof(FollowerBrain), "OnMaxLevelReached")]
		[HarmonyPrefix]
		private static bool FollowerBrain_OnMaxLevelReached()
		{
			return false;
		}

		[HarmonyPatch(typeof(FollowerBrain), "AddAdoration")]
		[HarmonyPatch(new Type[]
		{
			typeof(Follower),
			typeof(AdorationActions),
			typeof(Action)
		})]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> FollowerBrain_AddAdoration(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(FollowerBrain), "Info"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(FollowerBrainInfo), "XPLevel"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)10, (string)null),
				new CodeMatch((OpCode?)OpCodes.Bge, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Nop, (object)null).SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(FollowerBrain), "GetWillLevelUp")]
		[HarmonyPrefix]
		private static bool FollowerBrain_GetWillLevelUp(FollowerBrain __instance, ref bool __result, ref AdorationActions Action)
		{
			__result = (double)__instance.Stats.Adoration + (double)__instance.GetAddorationToAdd(Action) >= (double)__instance.Stats.MAX_ADORATION;
			return false;
		}

		[HarmonyPatch(typeof(FollowerBrain), "CanLevelUp")]
		[HarmonyPrefix]
		private static bool FollowerBrain_GetWillLevelUp(FollowerBrain __instance, ref bool __result)
		{
			__result = (double)__instance.Stats.Adoration >= (double)__instance.Stats.MAX_ADORATION;
			return false;
		}
	}
	[HarmonyPatch]
	public class FollowerInformationBoxPatches
	{
		[HarmonyPatch(typeof(FollowerInformationBox), "ConfigureImpl")]
		[HarmonyPostfix]
		private static void FollowerInformationBox_ConfigureImpl(FollowerInformationBox __instance)
		{
			__instance._adorationContainer.SetActive(true);
		}
	}
	[HarmonyPatch]
	public class RitualInfoCardPatches
	{
		[HarmonyPatch(typeof(RitualInfoCard), "Configure")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> RitualItem_Configure(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_0036: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(FollowerBrain), "Info"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(FollowerBrainInfo), "XPLevel"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)10, (string)null),
				new CodeMatch((OpCode?)OpCodes.Blt, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Nop, (object)null).SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	public class RitualItemPatches
	{
		[HarmonyPatch(typeof(RitualItem), "Configure")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> RitualItem_Configure(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(FollowerBrain), "Info"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(FollowerBrainInfo), "XPLevel"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)10, (string)null),
				new CodeMatch((OpCode?)OpCodes.Blt, (object)null, (string)null)
			}).SetAndAdvance(OpCodes.Nop, (object)null).SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.SetAndAdvance(OpCodes.Nop, (object)null)
				.InstructionEnumeration();
		}
	}
}