using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("StrongHuman")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StrongHuman")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("585CF532-9527-464E-903E-7E17AED5F30D")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StrongHuman
{
public static class PluginInformation
{
public const string Name = "StrongHuman";
public const string Guid = "de.lighty.stronghuman";
public const string Version = "1.0.0";
}
[BepInPlugin("de.lighty.stronghuman", "StrongHuman", "1.0.0")]
public class StrongHumanPlugin : BaseUnityPlugin
{
internal static float StrengthMultiplier = 1f;
internal static readonly Dictionary<Rigidbody, float> StoredBodies = new Dictionary<Rigidbody, float>();
private const string Command = "playerstrength";
public static void SetStrength(float newStrength)
{
StrengthMultiplier = newStrength;
foreach (KeyValuePair<Rigidbody, float> storedBody in StoredBodies)
{
storedBody.Key.mass = storedBody.Value / StrengthMultiplier;
}
}
private static void ShowHelp()
{
Debug.Log((object)"[ StrongHuman ] playerstrength\t\t- Get Current Strength Multiplier");
Debug.Log((object)"[ StrongHuman ] playerstrength [value]\t- Set Strength Multiplier");
Debug.Log((object)"[ StrongHuman ] playerstrength reset\t- Reset Strength Multiplier");
}
public static void RememberObject(Rigidbody rb)
{
if (!StoredBodies.ContainsKey(rb))
{
StoredBodies.Add(rb, rb.mass);
rb.mass /= StrengthMultiplier;
}
}
public static void ForgetObject(Rigidbody rb)
{
if (StoredBodies.TryGetValue(rb, out var value))
{
rb.mass = value;
StoredBodies.Remove(rb);
}
}
public static void RememberJointObject(Rigidbody rb)
{
if (!((Object)(object)rb == (Object)null) && !StoredBodies.ContainsKey(rb) && !((Object)(object)((Component)rb).GetComponentInChildren<Human>() != (Object)null))
{
StoredBodies.Add(rb, rb.mass);
rb.mass /= StrengthMultiplier;
ConfigurableJoint component = ((Component)rb).GetComponent<ConfigurableJoint>();
if ((Object)(object)((component != null) ? ((Joint)component).connectedBody : null) != (Object)null && !StoredBodies.ContainsKey(((Joint)component).connectedBody))
{
RememberJointObject(((Joint)component).connectedBody);
}
}
}
public static void ForgetJointObject(Rigidbody rb)
{
if (!((Object)(object)rb == (Object)null) && StoredBodies.TryGetValue(rb, out var value))
{
rb.mass = value;
StoredBodies.Remove(rb);
ConfigurableJoint component = ((Component)rb).GetComponent<ConfigurableJoint>();
if ((Object)(object)((component != null) ? ((Joint)component).connectedBody : null) != (Object)null)
{
ForgetJointObject(((Joint)component).connectedBody);
}
}
}
public void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"Setting up Patches...");
new Harmony("de.lighty.stronghuman").PatchAll();
Shell.RegisterCommand("playerstrength", (Action<string>)delegate(string args)
{
string[] array = args.Split(new char[1] { ' ' });
switch (array.Length)
{
case 1:
{
float result;
if (array[0].Trim() == "reset")
{
Debug.Log((object)("[ StrongHuman ] - Resetting Strength to: " + 1));
SetStrength(1f);
}
else if (float.TryParse(array[0], out result))
{
if (result == 0f)
{
result = 1f;
}
Debug.Log((object)("[ StrongHuman ] - Setting Strength to: " + result));
SetStrength(result);
}
else
{
Debug.LogError((object)"[ StrongHuman ] - Strength must be a valid Number! Usage:");
ShowHelp();
}
break;
}
case 0:
Debug.Log((object)"[ StrongHuman ] - Current Strength: ");
break;
default:
Debug.LogError((object)"[ StrongHuman ] - Invalid Usage! Usage:");
ShowHelp();
break;
}
}, (string)null);
}
}
}
namespace StrongHuman.Patches.GrabManager
{
[HarmonyPatch(typeof(GrabManager), "ObjectGrabbed")]
public class ObjectGrabbedPatch
{
private static void Postfix(GrabManager __instance, GameObject grabObject)
{
Debug.Log((object)("[Postfix] Grabbed: " + ((Object)grabObject).name));
ConfigurableJoint component = grabObject.GetComponent<ConfigurableJoint>();
Rigidbody component2 = grabObject.GetComponent<Rigidbody>();
if (!Object.op_Implicit((Object)(object)component))
{
if (Object.op_Implicit((Object)(object)component2))
{
StrongHumanPlugin.RememberObject(component2);
}
}
else if (Object.op_Implicit((Object)(object)component2))
{
StrongHumanPlugin.RememberJointObject(component2);
}
else if (Object.op_Implicit((Object)(object)((Joint)component).connectedBody))
{
StrongHumanPlugin.RememberJointObject(((Joint)component).connectedBody);
}
}
}
[HarmonyPatch(typeof(GrabManager), "ObjectReleased")]
public class ObjectReleasedPatch
{
private static void Postfix(GrabManager __instance, GameObject grabObject)
{
Debug.Log((object)("[Postfix] Released: " + ((Object)grabObject).name));
ConfigurableJoint component = grabObject.GetComponent<ConfigurableJoint>();
Rigidbody component2 = grabObject.GetComponent<Rigidbody>();
if (!Object.op_Implicit((Object)(object)component))
{
if (Object.op_Implicit((Object)(object)component2))
{
StrongHumanPlugin.ForgetObject(component2);
}
}
else if (Object.op_Implicit((Object)(object)component2))
{
StrongHumanPlugin.ForgetJointObject(component2);
}
else if (Object.op_Implicit((Object)(object)((Joint)component).connectedBody))
{
StrongHumanPlugin.ForgetJointObject(((Joint)component).connectedBody);
}
}
}
}