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 BepInEx.Logging;
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("RandomWeightMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RandomWeightMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ff66169-0f32-41da-8c12-7097ab36c0df")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RandomWeightMod;
[BepInPlugin("N0w4h.RandomWeightMod", "RandomWeightMod", "1.0.0")]
public class RandomWeightMod : BaseUnityPlugin
{
private const string modGUID = "N0w4h.RandomWeightMod";
private const string modName = "RandomWeightMod";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("N0w4h.RandomWeightMod");
private static RandomWeightMod Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("N0w4h.RandomWeightMod");
mls.LogInfo((object)"RandomWeightMod loaded");
harmony.PatchAll();
}
}
[HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")]
public class PatchPhysGrabObject
{
private static readonly HashSet<GameObject> modifiedObjects = new HashSet<GameObject>();
private static void Postfix(PhysGrabObject __instance)
{
ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
if ((Object)(object)component != (Object)null && !modifiedObjects.Contains(((Component)__instance).gameObject))
{
float num = Random.Range(0.5f, 8f);
float massOriginal = __instance.massOriginal;
__instance.massOriginal = num;
if ((Object)(object)__instance.rb != (Object)null)
{
__instance.rb.mass = num;
}
modifiedObjects.Add(((Component)__instance).gameObject);
Debug.Log((object)$"\ud83d\udd90\ufe0f Objet Valuable attrapé une seule fois : {((Object)((Component)__instance).gameObject).name} | Ancienne Mass : {massOriginal} | Nouvelle Masse: {num}");
}
}
}