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 HighStrengthFix v1.0.0
REPO_HighStrengthFix.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("REPO_HighStrengthFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0eaaf6338908f4b832cc189455b65e627f3f4477")] [assembly: AssemblyProduct("HighStrengthFix")] [assembly: AssemblyTitle("REPO_HighStrengthFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HighStrengthFix { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> EnableMod { get; private set; } public static ConfigEntry<float> CapMultiplier { get; private set; } public static ConfigEntry<float> CapOffset { get; private set; } public static ConfigEntry<bool> LowerCapForHeavyMelee { get; private set; } public static ConfigEntry<float> HeavyMeleeCap { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown EnableMod = ConfigFile.Bind<bool>("General", "EnableMod", true, ""); CapMultiplier = ConfigFile.Bind<float>("General", "CapMultiplier", 1.95f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2.5f), Array.Empty<object>())); CapOffset = ConfigFile.Bind<float>("General", "CapOffset", 0.1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.99f), Array.Empty<object>())); LowerCapForHeavyMelee = ConfigFile.Bind<bool>("General", "LowerCapForHeavyMelee", true, "Lower cap for heavy melee weapons (sledgehammer)"); HeavyMeleeCap = ConfigFile.Bind<float>("General", "HeavyMeleeCap", 2.1f, new ConfigDescription("The cap to use for heavy melee", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>())); } } [HarmonyPatch] public static class Patches { internal static bool grabCapActive = false; internal static float initialGrabStrength = 0f; public static FieldInfo overrideGSFieldInfo = typeof(PhysGrabObject).GetField("overrideGrabStrength", BindingFlags.Instance | BindingFlags.NonPublic); public static FieldInfo isMeleeFieldInfo = typeof(PhysGrabObject).GetField("isMelee", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")] [HarmonyPostfix] public static void GrabStartedHook(PhysGrabber player, PhysGrabObject __instance) { if (!grabCapActive && ConfigManager.EnableMod.Value) { float num = Mathf.Ceil(__instance.rb.mass) * ConfigManager.CapMultiplier.Value + ConfigManager.CapOffset.Value; bool flag = (bool)isMeleeFieldInfo.GetValue(__instance); if (__instance.rb.mass > 2f && flag && ConfigManager.LowerCapForHeavyMelee.Value) { num = ConfigManager.HeavyMeleeCap.Value; } Plugin.Logger.LogDebug((object)$"Grab started, {__instance.rb.mass} {flag}, {player.grabStrength}, {num}, {(float)overrideGSFieldInfo.GetValue(__instance)}"); if (num > player.grabStrength) { Plugin.Logger.LogDebug((object)$"Grab strength less than calculatedCap: {num}, returning"); return; } grabCapActive = true; initialGrabStrength = (float)overrideGSFieldInfo.GetValue(__instance); float num2 = 1f / (player.grabStrength / num); overrideGSFieldInfo.SetValue(__instance, num2); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabEnded")] [HarmonyPostfix] public static void GrabEndedHook(PhysGrabber player, PhysGrabObject __instance) { if (ConfigManager.EnableMod.Value) { Plugin.Logger.LogDebug((object)$"Grab ended, {__instance.rb.mass}, {player.grabStrength}, {(float)overrideGSFieldInfo.GetValue(__instance)}"); if (grabCapActive) { grabCapActive = false; overrideGSFieldInfo.SetValue(__instance, initialGrabStrength); } } } } [BepInPlugin("REPO_HighStrengthFix", "HighStrengthFix", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private Harmony _harmony; private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin HighStrengthFix by Rozza is loaded!"); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); _harmony = new Harmony("HighStrengthFix"); PatchAll(); } private void PatchAll() { IEnumerable<Type> enumerable; try { enumerable = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { enumerable = ex.Types.Where((Type t) => t != null); } foreach (Type item in enumerable) { _harmony.PatchAll(item); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "REPO_HighStrengthFix"; public const string PLUGIN_NAME = "HighStrengthFix"; public const string PLUGIN_VERSION = "1.0.0"; } }