using System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("InfRefreshes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("InfRefreshes")] [assembly: AssemblyTitle("InfRefreshes")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.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 InfRefreshes { [BepInPlugin("com.cellinside.infrefreshes", "InfRefreshes", "1.3.0")] public class Core : BasePlugin { public const string PluginGuid = "com.cellinside.infrefreshes"; public const string PluginName = "InfRefreshes"; public const string PluginVersion = "1.3.0"; private Harmony _harmony; public override void Load() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _harmony = new Harmony("com.cellinside.infrefreshes"); try { InfiniteRefreshesPatches.Apply(_harmony, ((BasePlugin)this).Log); ((BasePlugin)this).Log.LogInfo((object)"Infinite refreshes patch applied (reinforced)."); } catch (Exception ex) { ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to apply infinite refresh patches: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } internal static class InfiniteRefreshesPatches { private const int InfiniteRefreshValue = 10000; private static MethodInfo _setRefreshes; private static MethodInfo _setRefreshesUsed; public static void Apply(Harmony harmony, ManualLogSource log) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown Type type = AccessTools.TypeByName("PlayerInventory"); if (type == null) { throw new InvalidOperationException("Type 'PlayerInventory' not found. Cannot apply infinite refresh patches."); } _setRefreshes = AccessTools.Method(type, "set_refreshes", (Type[])null, (Type[])null); _setRefreshesUsed = AccessTools.Method(type, "set_refreshesUsed", (Type[])null, (Type[])null); if (_setRefreshes == null) { log.LogWarning((object)"Setter set_refreshes not found."); } if (_setRefreshesUsed == null) { log.LogWarning((object)"Setter set_refreshesUsed not found."); } MethodInfo methodInfo = AccessTools.Method(type, "get_refreshes", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(InfiniteRefreshesPatches), "GetRefreshesPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"Method get_refreshes not found on PlayerInventory."); } MethodInfo methodInfo2 = AccessTools.Method(type, "get_refreshesUsed", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(InfiniteRefreshesPatches), "GetRefreshesUsedPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"Method get_refreshesUsed not found on PlayerInventory."); } MethodInfo methodInfo3 = AccessTools.Method(type, "Update", (Type[])null, (Type[])null); if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(InfiniteRefreshesPatches), "UpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"PlayerInventory.Update not found; relying on getter patches only."); } } public static void GetRefreshesPostfix(object __instance, ref int __result) { if (__result < 10000) { ForceSet(__instance, 10000, 0); __result = 10000; } } public static void GetRefreshesUsedPostfix(object __instance, ref int __result) { if (__result != 0) { ForceSet(__instance, 10000, 0); __result = 0; } } public static void UpdatePostfix(object __instance) { ForceSet(__instance, 10000, 0); } private static void ForceSet(object instance, int refreshes, int used) { try { if (_setRefreshes != null) { _setRefreshes.Invoke(instance, new object[1] { refreshes }); } if (_setRefreshesUsed != null) { _setRefreshesUsed.Invoke(instance, new object[1] { used }); } } catch { } } } }