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 BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LimitlessPerks.Core; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("LimitlessPerks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3+c22aaa07e26728c9364e458e57a9516dc32526ee")] [assembly: AssemblyProduct("LimitlessPerks")] [assembly: AssemblyTitle("LimitlessPerks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.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 LimitlessPerks { public static class ConfigManager { public static bool EnabledLimitlessPerk; } [BepInPlugin("com.prideunique.limitlessperks", "LimitlessPerks", "1.1.3")] public sealed class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.prideunique.limitlessperks"; public const string PLUGIN_NAME = "LimitlessPerks"; public const string PLUGIN_VERSION = "1.1.3"; private Harmony harmony; internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; harmony = new Harmony("com.prideunique.limitlessperks"); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttribute() != null) { harmony.PatchAll(type); } } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } } namespace LimitlessPerks.Patches { [PatchOnEntry] [HarmonyPatch] public class ENT_PlayerPatch { [HarmonyPatch(typeof(ENT_Player), "Start")] [HarmonyPostfix] private static void ENT_PlayerStart(ENT_Player __instance) { if (!ConfigManager.EnabledLimitlessPerk || !CommandConsole.cheatsEnabled || CommandConsole.hasCheated) { return; } CommandConsole.hasCheated = true; CL_UIManager instance = CL_UIManager.instance; if (instance != null) { GameObject cheatTracker = instance.cheatTracker; if (cheatTracker != null) { cheatTracker.SetActive(true); } } CommandConsole.Log("WARNING: Cheat activated. Saving of stats has been disabled for this session."); } [HarmonyPatch(typeof(ENT_Player), "CreateCommands")] [HarmonyPostfix] private static void ENT_PlayerCreateCommands(ENT_Player __instance) { CommandConsole.AddCommand("addallperks", (Action)delegate(string[] args) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null)) { if (args == null || args.Length < 1) { foreach (WKDatabaseHolder database in CL_AssetManager.databases) { foreach (Perk perkAsset in database.database.perkAssets) { if (!((Object)(object)perkAsset == (Object)null)) { bool flag = false; for (int num = perkAsset.modules.Count - 1; num >= 0; num--) { PerkModule val = perkAsset.modules[num]; if (val != null && ((object)val).GetType() == typeof(PerkModule_InfectionDisplay)) { flag = true; break; } } if (flag) { try { __instance.AddPerk(perkAsset, 1, true); } catch { } } else { __instance.AddPerk(perkAsset, 1, true); } } } } return; } if (int.TryParse(args[0], out var result) && result > 0) { foreach (WKDatabaseHolder database2 in CL_AssetManager.databases) { foreach (Perk perkAsset2 in database2.database.perkAssets) { if (!((Object)(object)perkAsset2 == (Object)null)) { bool flag2 = false; bool flag3 = false; PerkModule_ItemAdder val2 = null; for (int num2 = perkAsset2.modules.Count - 1; num2 >= 0; num2--) { PerkModule val3 = perkAsset2.modules[num2]; if (val3 != null) { Type type = ((object)val3).GetType(); if (type == typeof(PerkModule_ItemAdder)) { flag2 = true; val2 = (PerkModule_ItemAdder)(object)((val3 is PerkModule_ItemAdder) ? val3 : null); } else if (type == typeof(PerkModule_InfectionDisplay)) { flag3 = true; } } } if (flag2) { for (int i = 1; i < result; i++) { List list = new List(); foreach (Item_Object item in val2.itemsToAdd) { if (!((Object)(object)item == (Object)null)) { Item clone = item.itemData.GetClone((Item)null); clone.bagPosition = new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f; clone.bagRotation = Quaternion.LookRotation(clone.upDirection); list.Add(clone); } } Inventory.instance.LoadItemsIntoBag(list); } } if (flag3) { try { __instance.AddPerk(perkAsset2, result, true); } catch { } } else { __instance.AddPerk(perkAsset2, result, true); } } } } } } }, true); CommandConsole.AddCommand("enablelimitlessperks", (Action)delegate { ConfigManager.EnabledLimitlessPerk = true; }, true); CommandConsole.AddCommand("disablelimitlessperks", (Action)delegate { ConfigManager.EnabledLimitlessPerk = false; }, true); } public static float MaxGravityReplacement(float a, float b) { if (!ConfigManager.EnabledLimitlessPerk || !CommandConsole.cheatsEnabled) { return Mathf.Max(a, b); } return a; } [HarmonyPatch(typeof(ENT_Player), "Movement")] [HarmonyTranspiler] public static IEnumerable ENT_PlayerMovement(IEnumerable instructions) { //IL_008e: 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_00bc: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(Mathf), "Max", new Type[2] { typeof(float), typeof(float) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ENT_PlayerPatch), "MaxGravityReplacement", new Type[2] { typeof(float), typeof(float) }, (Type[])null); if (methodInfo == null || methodInfo2 == null) { return list.AsEnumerable(); } return new CodeMatcher((IEnumerable)list, (ILGenerator)null).Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0.2f, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null) }).ThrowIfInvalid("Failed to match first `Mathf.Max` in ENT_Player.Movement") .SetOperandAndAdvance((object)methodInfo2) .InstructionEnumeration(); } public static float DamageResistClampReplacement(float value, float min, float max) { if (!ConfigManager.EnabledLimitlessPerk || !CommandConsole.cheatsEnabled) { return Mathf.Clamp(value, min, max); } if (value < min) { return min; } return value; } [HarmonyPatch(typeof(ENT_Player), "Damage")] [HarmonyTranspiler] public static IEnumerable ENT_PlayerDamage(IEnumerable instructions) { //IL_00a8: 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_00d1: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3] { typeof(float), typeof(float), typeof(float) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ENT_PlayerPatch), "DamageResistClampReplacement", new Type[3] { typeof(float), typeof(float), typeof(float) }, (Type[])null); if (methodInfo == null || methodInfo2 == null) { return list.AsEnumerable(); } return new CodeMatcher((IEnumerable)list, (ILGenerator)null).Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"damageResist", (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null) }).ThrowIfInvalid("Failed to match call opcode in ENT_Player.Damage") .Insert(Array.Empty()) .InstructionEnumeration(); } } [PatchOnEntry] [HarmonyPatch] public static class PerkPatch { public class PerkOriginalData { public int stackMax; public bool canStack; public List buffIds; public List baseBuffIds; } private static Dictionary _originalPerkData = new Dictionary(); [HarmonyPatch(typeof(Perk), "Update")] [HarmonyPrefix] private static void PerkUpdate(ref Perk __instance) { PerkOriginalData value; bool flag = _originalPerkData.TryGetValue(__instance, out value); if (!flag) { PerkOriginalData perkOriginalData = new PerkOriginalData(); perkOriginalData.stackMax = __instance.stackMax; perkOriginalData.canStack = __instance.canStack; List list = new List(); for (int i = 0; i < __instance.buff.buffs.Count; i++) { Buff val = __instance.buff.buffs[i]; if (val != null) { list.Add(val.id); } } perkOriginalData.buffIds = list; List list2 = new List(); for (int j = 0; j < __instance.baseBuff.buffs.Count; j++) { Buff val2 = __instance.buff.buffs[j]; if (val2 != null) { list2.Add(val2.id); } } perkOriginalData.baseBuffIds = list2; _originalPerkData.Add(__instance, perkOriginalData); } if (!ConfigManager.EnabledLimitlessPerk || !CommandConsole.cheatsEnabled) { if (!flag) { return; } __instance.stackMax = value.stackMax; __instance.canStack = value.canStack; if (value.baseBuffIds == null || value.baseBuffIds.Count <= 0) { return; } for (int num = __instance.buff.buffs.Count - 1; num >= 0; num--) { Buff val3 = __instance.buff.buffs[num]; if (val3 != null) { bool num2 = value.baseBuffIds.Contains(val3.id); bool flag2 = value.buffIds != null && value.buffIds.Contains(val3.id); if (num2 && !flag2) { __instance.baseBuff.buffs.Add(val3); __instance.buff.buffs.RemoveAt(num); } } } return; } for (int num3 = __instance.baseBuff.buffs.Count - 1; num3 >= 0; num3--) { Buff val4 = __instance.baseBuff.buffs[num3]; if (val4 != null) { __instance.buff.buffs.Add(val4); __instance.baseBuff.buffs.Remove(val4); } } __instance.stackMax = int.MaxValue; __instance.canStack = true; } } } namespace LimitlessPerks.Core { [PublicAPI] [AttributeUsage(AttributeTargets.Class, Inherited = false)] internal sealed class PatchOnEntryAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }