Decompiled source of ConfigurableCarryWeight v1.0.0

ConfigurableCarryWeight.dll

Decompiled a day ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ConfigurableCarryWeight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigurableCarryWeight")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c4303cad-da28-4738-9146-ff9452702ee3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ConfigurableCarryWeight;

[BepInPlugin("robit.configurablecarryweight", "Configurable Carry Weight", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "Awake")]
	private static class PlayerAwakePatch
	{
		private static void Postfix(ref float ___m_maxCarryWeight)
		{
			___m_maxCarryWeight = BaseCarryWeight.Value;
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	private static class ObjectDBAwakePatch
	{
		private static void Postfix(ObjectDB __instance)
		{
			ApplyMegingjordBonus(__instance);
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	private static class ObjectDBCopyOtherDBPatch
	{
		private static void Postfix(ObjectDB __instance)
		{
			ApplyMegingjordBonus(__instance);
		}
	}

	private const string ModGUID = "robit.configurablecarryweight";

	private const string ModName = "Configurable Carry Weight";

	private const string ModVersion = "1.0.0";

	internal static ConfigEntry<float> BaseCarryWeight;

	internal static ConfigEntry<float> MegingjordBonus;

	private readonly Harmony _harmony = new Harmony("robit.configurablecarryweight");

	private void Awake()
	{
		BaseCarryWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Carry Weight", "Base Carry Weight", 300f, "The player's base maximum carry weight. Vanilla default: 300.");
		MegingjordBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Carry Weight", "Megingjord Bonus", 150f, "Additional carry weight granted by Megingjord. Vanilla default: 150.");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Configurable Carry Weight 1.0.0 loaded.");
		((BaseUnityPlugin)this).Logger.LogInfo((object)($"Base carry weight: {BaseCarryWeight.Value}, " + $"Megingjord bonus: {MegingjordBonus.Value}"));
	}

	private static void ApplyMegingjordBonus(ObjectDB objectDB)
	{
		if ((Object)(object)objectDB == (Object)null)
		{
			return;
		}
		foreach (StatusEffect statusEffect in objectDB.m_StatusEffects)
		{
			if (((Object)statusEffect).name == "BeltStrength")
			{
				SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null);
				if (val != null)
				{
					val.m_addMaxCarryWeight = MegingjordBonus.Value;
					break;
				}
			}
		}
	}
}