Decompiled source of WetCarryPenalty v1.0.0

Bepinex/plugins/WetCarryPenalty/WetCarryPenalty.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MyFirstMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyFirstMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c7768d10-6f26-48f0-ba77-cfba9953fa28")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WetCarryPenalty;

[BepInPlugin("curt.valheim.wetcarrypenalty", "Wet Carry Penalty", "1.0.0")]
public class Main : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
	public static class Patch_Player_GetMaxCarryWeight
	{
		private static void Postfix(Player __instance, ref float __result)
		{
			if (((Character)__instance).GetSEMan().HaveStatusEffect(SEMan.s_statusEffectWet))
			{
				float num = WetCarryWeightReduction.Value / 100f;
				__result *= 1f - num;
			}
		}
	}

	[HarmonyPatch(typeof(SE_Stats), "GetTooltipString")]
	public static class Patch_SE_Stats_GetTooltipString
	{
		private static void Postfix(SE_Stats __instance, ref string __result)
		{
			if (__instance is SE_Wet && WetCarryWeightReduction.Value > 0f)
			{
				float value = WetCarryWeightReduction.Value;
				__result += $"$se_max_carryweight: <color=orange>-{value:0.#}%</color>\n";
			}
		}
	}

	private const string pluginGUID = "curt.valheim.wetcarrypenalty";

	private const string pluginName = "Wet Carry Penalty";

	private const string pluginVersion = "1.0.0";

	private readonly Harmony HarmonyInstance = new Harmony("curt.valheim.wetcarrypenalty");

	public static ManualLogSource logger = Logger.CreateLogSource("Wet Carry Penalty");

	public static ConfigEntry<float> WetCarryWeightReduction;

	public void Awake()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		WetCarryWeightReduction = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Wet carry weight reduction (%)", 20f, new ConfigDescription("Percentage by which the Wet status effect reduces maximum carry weight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		logger.LogInfo((object)"Wet Carry Penalty loaded. Have fun.");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		HarmonyInstance.PatchAll(executingAssembly);
	}
}