Decompiled source of BagOfHoldingWeightFix v3.3.0

BagOfHoldingWeightFix.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BagOfHoldingWeightFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BagOfHoldingWeightFix")]
[assembly: AssemblyTitle("BagOfHoldingWeightFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BagOfHoldingWeightFix;

[BepInPlugin("Scott.BagOfHoldingWeightFix", "BagOfHolding Weight Fix", "3.3.0")]
public class Plugin : BaseUnityPlugin
{
	private static readonly Dictionary<PlayerControllerB, float> OriginalWeights = new Dictionary<PlayerControllerB, float>();

	private static MethodInfo UpdateWeightMethod;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		Harmony val = new Harmony("Scott.BagOfHoldingWeightFix");
		MethodInfo methodInfo = AccessTools.Method("BagOfHolding.BagRetrieval:Grab", (Type[])null, (Type[])null);
		if (methodInfo != null)
		{
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("GrabPostfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"BagOfHolding Weight Fix v3.3 loaded");
		}
		Type type = AccessTools.TypeByName("MoreShipUpgrades.UpgradeComponents.TierUpgrades.AttributeUpgrades.BackMuscles");
		if (type != null)
		{
			UpdateWeightMethod = AccessTools.Method(type, "UpdatePlayerWeight", (Type[])null, (Type[])null);
		}
	}

	public static void GrabPostfix(PlayerControllerB player)
	{
		if (!((Object)(object)player == (Object)null))
		{
			OriginalWeights.Remove(player);
			if (UpdateWeightMethod != null)
			{
				UpdateWeightMethod.Invoke(null, null);
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				StartOfRound.Instance.SendChangedWeightEvent();
			}
		}
	}
}