Decompiled source of Unburdened v0.1.0

Unburdened.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Unburdened")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2a3bdc8afb40d9f40e8473b5b451e31a6fec656b")]
[assembly: AssemblyProduct("Unburdened")]
[assembly: AssemblyTitle("Unburdened")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Unburdened
{
	[BepInPlugin("games.loxley.unburdened", "Unburdened", "0.1.0")]
	public class UnburdenedPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class OnDbAwake
		{
			private static void Postfix(ObjectDB __instance)
			{
				Apply(__instance);
			}
		}

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

		public const string PluginGUID = "games.loxley.unburdened";

		public const string PluginName = "Unburdened";

		public const string PluginVersion = "0.1.0";

		public static ConfigEntry<bool> Armour;

		public static ConfigEntry<bool> Shields;

		public static ConfigEntry<bool> Weapons;

		public static ConfigEntry<float> Keep;

		private void Awake()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Armour = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Armour", true, "Remove the movement penalty from helmets, chests, legs and capes.");
			Shields = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Shields", false, "Also from shields (tower shields carry a big one).");
			Weapons = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Weapons", false, "Also from weapons and tools.");
			Keep = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Keep", 0f, "Fraction of the penalty to keep. 0 = none, 0.5 = half, 1 = vanilla.");
			new Harmony("games.loxley.unburdened").PatchAll();
		}

		private static bool Covered(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected I4, but got Unknown
			switch (t - 3)
			{
			case 3:
			case 4:
			case 8:
			case 14:
				return Armour.Value;
			case 2:
				return Shields.Value;
			case 0:
			case 1:
			case 11:
			case 12:
			case 16:
			case 19:
				return Weapons.Value;
			default:
				return false;
			}
		}

		public static void Apply(ObjectDB db)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)db == (Object)null || db.m_items == null)
			{
				return;
			}
			foreach (GameObject item in db.m_items)
			{
				SharedData val = (Object.op_Implicit((Object)(object)item) ? item.GetComponent<ItemDrop>() : null)?.m_itemData?.m_shared;
				if (val != null && !(val.m_movementModifier >= 0f) && Covered(val.m_itemType))
				{
					val.m_movementModifier *= Keep.Value;
				}
			}
		}
	}
}