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 PowerUpgrade v1.0.0
PowerUpgrade.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PowerUpgrade")] [assembly: AssemblyDescription("Power Upgrade Mod")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("hyy")] [assembly: AssemblyProduct("PowerUpgrade")] [assembly: AssemblyCopyright("Copyright © hyy 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5a7e8b9c-2d4f-4a1b-9c3d-8f2e7a6b5c4d")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace PowerUpgrade; [BepInPlugin("com.hyy.powerupgrade", "PowerUpgrade", "1.0.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static ConfigEntry<float> GrabStrengthMultiplier; public static ConfigEntry<float> ThrowStrengthMultiplier; public static ConfigEntry<float> GrabRangeMultiplier; public static ConfigEntry<bool> EnableDebugLogs; public static ConfigEntry<bool> OnlyEnhanceLocalPlayer; private Harmony harmony; public static void LogInfo(string message) { if (EnableDebugLogs.Value && (Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } public static void LogError(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogError((object)message); } } public static void LogWarning(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)message); } } private void Awake() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown Instance = this; EnableDebugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLogs", false, "Enable debug log output"); OnlyEnhanceLocalPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "OnlyEnhanceLocalPlayer", true, "Only enhance the local player's grabbing power"); GrabStrengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("GrabSettings", "GrabStrengthMultiplier", 3f, new ConfigDescription("Multiplier for grab strength", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>())); ThrowStrengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("GrabSettings", "ThrowStrengthMultiplier", 3f, new ConfigDescription("Multiplier for throw strength", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>())); GrabRangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("GrabSettings", "GrabRangeMultiplier", 2f, new ConfigDescription("Multiplier for grab range", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); harmony = new Harmony("com.hyy.powerupgrade"); try { Type typeFromHandle = typeof(PowerEnhancer); harmony.PatchAll(typeFromHandle); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied successfully"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error applying Harmony patches: " + ex.Message)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"PowerUpgrade mod loaded!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Author: hyy | Version: 1.0.0"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Grab Strength: {GrabStrengthMultiplier.Value}x"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Throw Strength: {ThrowStrengthMultiplier.Value}x"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Grab Range: {GrabRangeMultiplier.Value}x"); ((BaseUnityPlugin)this).Config.SettingChanged += OnConfigChanged; } private void OnConfigChanged(object sender, SettingChangedEventArgs e) { LogInfo($"Config changed: {e.ChangedSetting.Definition.Key} = {e.ChangedSetting.BoxedValue}"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigChanged; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } public static bool IsLocalPlayer(Component component) { try { if ((Object)(object)component == (Object)null) { return false; } if (!OnlyEnhanceLocalPlayer.Value) { return true; } PhotonView component2 = component.GetComponent<PhotonView>(); if ((Object)(object)component2 != (Object)null) { return component2.IsMine; } component2 = component.GetComponentInParent<PhotonView>(); if ((Object)(object)component2 != (Object)null) { return component2.IsMine; } return false; } catch (Exception) { return false; } } } [HarmonyPatch] public static class PowerEnhancer { private class OriginalPhysics { public float mass; public float drag; public float angularDrag; } private static Dictionary<int, OriginalPhysics> originalPhysics = new Dictionary<int, OriginalPhysics>(); [HarmonyPatch(typeof(PhysGrabber), "Start")] [HarmonyPostfix] private static void PhysGrabberStartPostfix(PhysGrabber __instance) { try { if (Plugin.IsLocalPlayer((Component)(object)__instance)) { ApplyGrabberEnhancements(__instance); Plugin.LogInfo("Enhanced local player's grabber"); } } catch (Exception ex) { Plugin.LogError("Error enhancing grabber: " + ex.Message); } } [HarmonyPatch(typeof(PhysGrabber), "Update")] [HarmonyPostfix] private static void PhysGrabberUpdatePostfix(PhysGrabber __instance) { try { if (Plugin.IsLocalPlayer((Component)(object)__instance)) { ApplyGrabberEnhancements(__instance); } } catch { } } private static void ApplyGrabberEnhancements(PhysGrabber grabber) { try { Type type = ((object)grabber).GetType(); if (Plugin.GrabStrengthMultiplier.Value > 1f) { FieldInfo field = type.GetField("grabStrength", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { float num = 10f; float num2 = num * Plugin.GrabStrengthMultiplier.Value; field.SetValue(grabber, num2); } } if (Plugin.ThrowStrengthMultiplier.Value > 1f) { FieldInfo field2 = type.GetField("throwStrength", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { float num3 = 1f; float num4 = num3 * Plugin.ThrowStrengthMultiplier.Value; field2.SetValue(grabber, num4); } } if (Plugin.GrabRangeMultiplier.Value > 1f) { FieldInfo field3 = type.GetField("grabRange", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field3 != null) { float num5 = 4f; float num6 = Mathf.Min(num5 * Plugin.GrabRangeMultiplier.Value, 50f); field3.SetValue(grabber, num6); } } } catch (Exception ex) { Plugin.LogError("Error applying grabber enhancements: " + ex.Message); } } [HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")] [HarmonyPostfix] private static void PhysGrabObjectFixedUpdatePostfix(PhysGrabObject __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.rb == (Object)null) { return; } try { bool flag = false; if (__instance.playerGrabbing != null) { foreach (PhysGrabber item in __instance.playerGrabbing) { if ((Object)(object)item != (Object)null && Plugin.IsLocalPlayer((Component)(object)item)) { flag = true; break; } } } if (flag) { ReduceObjectPhysics(__instance); } else if (!__instance.grabbed) { RestoreObjectPhysics(__instance); } } catch (Exception ex) { Plugin.LogWarning("Error in PhysGrabObject FixedUpdate: " + ex.Message); } } private static void ReduceObjectPhysics(PhysGrabObject grabObject) { try { int instanceID = ((Object)grabObject).GetInstanceID(); if (!originalPhysics.ContainsKey(instanceID)) { originalPhysics[instanceID] = new OriginalPhysics { mass = grabObject.rb.mass, drag = grabObject.rb.drag, angularDrag = grabObject.rb.angularDrag }; } float value = Plugin.GrabStrengthMultiplier.Value; if (value > 1f) { grabObject.rb.mass = Mathf.Max(originalPhysics[instanceID].mass / value, 0.1f); grabObject.rb.drag = Mathf.Max(originalPhysics[instanceID].drag / value, 0.01f); grabObject.rb.angularDrag = Mathf.Max(originalPhysics[instanceID].angularDrag / value, 0.01f); } } catch (Exception ex) { Plugin.LogError("Error reducing object physics: " + ex.Message); } } private static void RestoreObjectPhysics(PhysGrabObject grabObject) { try { int instanceID = ((Object)grabObject).GetInstanceID(); if (originalPhysics.ContainsKey(instanceID)) { grabObject.rb.mass = originalPhysics[instanceID].mass; grabObject.rb.drag = originalPhysics[instanceID].drag; grabObject.rb.angularDrag = originalPhysics[instanceID].angularDrag; originalPhysics.Remove(instanceID); } } catch (Exception ex) { Plugin.LogError("Error restoring object physics: " + ex.Message); } } [HarmonyPatch(typeof(PhysGrabObject), "Throw")] [HarmonyPostfix] private static void PhysGrabObjectThrowPostfix(PhysGrabObject __instance, PhysGrabber player) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.rb == (Object)null || (Object)(object)player == (Object)null || !Plugin.IsLocalPlayer((Component)(object)player)) { return; } float value = Plugin.ThrowStrengthMultiplier.Value; if (value > 1f) { Vector3 velocity = __instance.rb.velocity; Vector3 velocity2 = velocity * value; float num = 50f * value; if (((Vector3)(ref velocity2)).magnitude > num) { velocity2 = ((Vector3)(ref velocity2)).normalized * num; } __instance.rb.velocity = velocity2; if (Plugin.EnableDebugLogs.Value) { Plugin.LogInfo($"Throw boosted: {((Vector3)(ref velocity)).magnitude:F2} -> {((Vector3)(ref velocity2)).magnitude:F2}"); } } } catch (Exception ex) { Plugin.LogWarning("Error boosting throw: " + ex.Message); } } [HarmonyPatch(typeof(PhysGrabber), "RayCheck")] [HarmonyPrefix] private static bool PhysGrabberRayCheckPrefix(PhysGrabber __instance, ref float maxDistance) { try { if (Plugin.IsLocalPlayer((Component)(object)__instance)) { float value = Plugin.GrabRangeMultiplier.Value; if (value > 1f) { float num = 4f; maxDistance = Mathf.Min(num * value, 50f); if (Plugin.EnableDebugLogs.Value) { Plugin.LogInfo($"Grab range enhanced to: {maxDistance}"); } } } return true; } catch (Exception ex) { Plugin.LogError("Error enhancing grab range: " + ex.Message); return true; } } }