Decompiled source of Root Harnesk Nerf v1.0.0

RootHarneskNerf.dll

Decompiled 6 hours ago
using System.Reflection;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: AssemblyVersion("1.0.0.0")]
namespace RootHarneskNerf;

[BepInPlugin("doom_hamster.rootharnesknerf", "Root Harnesk Nerf", "1.0.0")]
public class RootHarneskNerfPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Patch
	{
		public static void Postfix(ObjectDB __instance)
		{
			RebalanceRootArmor(__instance);
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class ObjectDB_CopyOtherDB_Patch
	{
		public static void Postfix(ObjectDB __instance)
		{
			RebalanceRootArmor(__instance);
		}
	}

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("doom_hamster.rootharnesknerf").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"RootHarneskNerf loaded successfully.");
	}

	private static void RebalanceRootArmor(ObjectDB db)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Invalid comparison between Unknown and I4
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)db == (Object)null || db.m_items.Count == 0)
		{
			return;
		}
		string[] array = new string[3] { "HelmetRoot", "ArmorRootChest", "ArmorRootLegs" };
		foreach (string text in array)
		{
			GameObject itemPrefab = db.GetItemPrefab(text);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				continue;
			}
			ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				continue;
			}
			SharedData shared = component.m_itemData.m_shared;
			for (int j = 0; j < shared.m_damageModifiers.Count; j++)
			{
				DamageModPair val = shared.m_damageModifiers[j];
				if ((int)val.m_type == 32)
				{
					val.m_modifier = (DamageModifier)8;
					shared.m_damageModifiers[j] = val;
				}
			}
			if (text == "ArmorRootChest")
			{
				shared.m_damageModifiers.RemoveAll((DamageModPair mod) => (int)mod.m_type == 4);
			}
			if (!((Object)(object)shared.m_setStatusEffect != (Object)null))
			{
				continue;
			}
			if (Localization.instance != null && Localization.instance.GetSelectedLanguage() == "English")
			{
				shared.m_setStatusEffect.m_name = "Root Might";
				shared.m_setStatusEffect.m_tooltip = "Ancient roots are sealed around you, granting high resistance to piercing attacks while steadying your bow arm.";
			}
			StatusEffect setStatusEffect = shared.m_setStatusEffect;
			SE_Stats val2 = (SE_Stats)(object)((setStatusEffect is SE_Stats) ? setStatusEffect : null);
			if (!((Object)(object)val2 != (Object)null))
			{
				continue;
			}
			bool flag = false;
			foreach (DamageModPair mod in val2.m_mods)
			{
				if ((int)mod.m_type == 4)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				DamageModPair item = new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)1
				};
				val2.m_mods.Add(item);
			}
		}
	}
}