Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SizeMattersCompat v1.0.0
SizeMattersCompat.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PlayerScaling; 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: AssemblyCompany("SizeMattersCompat")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SizeMattersCompat")] [assembly: AssemblyTitle("SizeMattersCompat")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 SizeMattersCompat { internal static class MyPluginInfo { public const string PLUGIN_GUID = "dev.fix.sizematterscompat"; public const string PLUGIN_NAME = "SizeMattersCompat"; public const string PLUGIN_VERSION = "1.0.0"; } [BepInPlugin("dev.fix.sizematterscompat", "SizeMattersCompat", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log = null; private static Harmony _harmony = null; private static ValuableDirector? _activeDirector; private static readonly string[] CurveArrayPropNames = new string[9] { "TotalMaxAmountCurves", "TotalMaxValueCurves", "TinyCurves", "SmallCurves", "MediumCurves", "BigCurves", "WideCurves", "TallCurves", "VeryTallCurves" }; private static PropertyInfo?[] _curveProps = Array.Empty<PropertyInfo>(); private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("dev.fix.sizematterscompat"); Type typeFromHandle = typeof(ValuablePatch); _curveProps = new PropertyInfo[CurveArrayPropNames.Length]; for (int i = 0; i < CurveArrayPropNames.Length; i++) { _curveProps[i] = typeFromHandle.GetProperty(CurveArrayPropNames[i], BindingFlags.Static | BindingFlags.NonPublic); if (_curveProps[i] == null) { Log.LogWarning((object)("[SMCompat] Could not find ValuablePatch." + CurveArrayPropNames[i] + " — game version mismatch?")); } } MethodInfo methodInfo = AccessTools.Method(typeof(RunManager), "ChangeLevel", (Type[])null, (Type[])null); if (methodInfo != null) { _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnChangeLevel", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"[SMCompat] RunManager.ChangeLevel postfix installed"); } else { Log.LogError((object)"[SMCompat] Could not find RunManager.ChangeLevel — reset patch skipped"); } TryInstallPrefixGuard(typeFromHandle); Log.LogInfo((object)"[SMCompat] SizeMattersCompat loaded"); } private static void TryInstallPrefixGuard(Type valuablePatchType) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(valuablePatchType, "Prefix", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"[SMCompat] Could not find ValuablePatch.Prefix — run-once guard skipped"); return; } _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ValuablePrefixRunOnceGuard", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"[SMCompat] ValuablePatch.Prefix run-once guard installed"); } catch (Exception arg) { Log.LogError((object)$"[SMCompat] Failed to install run-once guard: {arg}"); } } public static bool ValuablePrefixRunOnceGuard(ValuableDirector __0) { if ((Object)(object)__0 == (Object)null) { return true; } if ((Object)(object)_activeDirector != (Object)null && _activeDirector == __0) { return false; } _activeDirector = __0; return true; } public static void OnChangeLevel() { _activeDirector = null; PropertyInfo[] curveProps = _curveProps; foreach (PropertyInfo propertyInfo in curveProps) { try { propertyInfo?.SetValue(null, null); } catch (Exception ex) { Log.LogDebug((object)("[SMCompat] Reset " + propertyInfo?.Name + " failed: " + ex.Message)); } } Log.LogDebug((object)"[SMCompat] ValuablePatch state reset for new level"); } } }