Decompiled source of ConfigurableFeatherCape v1.0.8

ConfigurableFeatherCape.dll

Decompiled a week 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ConfigurableFeatherCape")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.8")]
[assembly: AssemblyProduct("ConfigurableFeatherCape")]
[assembly: AssemblyTitle("ConfigurableFeatherCape")]
[assembly: AssemblyVersion("1.0.8.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 Betablockr.ConfigurableFeatherCape
{
	[BepInPlugin("com.Betablockr.ConfigurableFeatherCape", "Configurable Feather Cape", "1.0.8")]
	public class FeatherCapeBuffPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.Betablockr.ConfigurableFeatherCape";

		public const string ModName = "Configurable Feather Cape";

		public const string ModAuthor = "Betablockr";

		public const string ModVersion = "1.0.8";

		public static ConfigEntry<bool> RemoveFireWeakness;

		public static ConfigEntry<bool> AddFrostResistance;

		public static ConfigEntry<float> EitrRegenModifier;

		public static ConfigEntry<float> JumpHeightModifier;

		public static ConfigEntry<float> JumpStaminaUsageModifier;

		public static ConfigEntry<float> MaxFallSpeed;

		public static ConfigEntry<float> FallDamageReduction;

		private readonly Harmony harmony = new Harmony("com.Betablockr.ConfigurableFeatherCape");

		private void Awake()
		{
			RemoveFireWeakness = ((BaseUnityPlugin)this).Config.Bind<bool>("Resistances", "RemoveFireWeakness", true, "Removes the Feather Cape's Very Weak to Fire effect.");
			AddFrostResistance = ((BaseUnityPlugin)this).Config.Bind<bool>("Resistances", "AddFrostResistance", true, "Adds Frost resistance while wearing the Feather Cape.");
			EitrRegenModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "EitrRegenModifier", 0.1f, "Eitr regeneration bonus. 0.10 = +10%.");
			JumpHeightModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "JumpHeightModifier", 0.2f, "Jump height bonus. 0.20 = +20%.");
			JumpStaminaUsageModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "JumpStaminaUsageModifier", -0.2f, "Jump stamina usage modifier. -0.20 = 20% less stamina.");
			MaxFallSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fall Mechanics", "MaxFallSpeed", 3f, "Maximum downward fall speed in m/s. 3.0 = 3 m/s.");
			FallDamageReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Fall Mechanics", "FallDamageReduction", 1f, "Fall damage reduction. 1.0 = 100% fall damage reduction.");
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Configurable Feather Cape by Betablockr v1.0.8 loaded successfully.");
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class Patch_ObjectDB_CopyOtherDB
	{
		[HarmonyPostfix]
		public static void Postfix(ObjectDB __instance)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			GameObject itemPrefab = __instance.GetItemPrefab("CapeFeather");
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return;
			}
			ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null || component.m_itemData == null)
			{
				return;
			}
			SharedData shared = component.m_itemData.m_shared;
			if (shared == null)
			{
				return;
			}
			for (int num = shared.m_damageModifiers.Count - 1; num >= 0; num--)
			{
				DamageType type = shared.m_damageModifiers[num].m_type;
				if ((int)type == 32 || (int)type == 64)
				{
					shared.m_damageModifiers.RemoveAt(num);
				}
			}
			if (!FeatherCapeBuffPlugin.RemoveFireWeakness.Value)
			{
				DamageModPair item = new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)6
				};
				shared.m_damageModifiers.Add(item);
			}
			if (FeatherCapeBuffPlugin.AddFrostResistance.Value)
			{
				DamageModPair item2 = new DamageModPair
				{
					m_type = (DamageType)64,
					m_modifier = (DamageModifier)1
				};
				shared.m_damageModifiers.Add(item2);
			}
			StatusEffect equipStatusEffect = shared.m_equipStatusEffect;
			SE_Stats val = (SE_Stats)(object)((equipStatusEffect is SE_Stats) ? equipStatusEffect : null);
			if (val != null)
			{
				val.m_maxMaxFallSpeed = Mathf.Max(0f, FeatherCapeBuffPlugin.MaxFallSpeed.Value);
				val.m_fallDamageModifier = 0f - Mathf.Clamp01(FeatherCapeBuffPlugin.FallDamageReduction.Value);
				val.m_jumpModifier = new Vector3(0f, FeatherCapeBuffPlugin.JumpHeightModifier.Value, 0f);
				val.m_jumpStaminaUseModifier = FeatherCapeBuffPlugin.JumpStaminaUsageModifier.Value;
				val.m_eitrRegenMultiplier = 1f + FeatherCapeBuffPlugin.EitrRegenModifier.Value;
			}
		}
	}
}