Decompiled source of RebalancedMuck v1.0.0

RebalancedMuck.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using RebalancedMuck.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RebalancedMuck")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RebalancedMuck")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("33388dff-57b9-4c07-968a-dc19929c494a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RebalancedMuck
{
	[BepInPlugin("MeedasGuy_RebalancedMuck", "RebalancedMuck", "1.0.0.0")]
	public class Main : BaseUnityPlugin
	{
		public static List<InventoryItem> itemlist = new List<InventoryItem>();

		public const string modName = "RebalancedMuck";

		public const string author = "MeedasGuy";

		public const string modGuid = "MeedasGuy_RebalancedMuck";

		public const string ver = "1.0.0.0";

		internal readonly ManualLogSource log;

		internal readonly Assembly assembly;

		public readonly string modFolder;

		private readonly Harmony harmony = new Harmony("MeedasGuy_RebalancedMuck");

		public Main()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			log = ((BaseUnityPlugin)this).Logger;
			assembly = Assembly.GetExecutingAssembly();
			modFolder = Path.GetDirectoryName(assembly.Location);
		}

		private void Awake()
		{
			log.LogInfo((object)"RebalancedMuck is working");
			harmony.PatchAll(typeof(PowerupInventoryMod));
		}

		public void Start()
		{
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			InventoryItem[] allScriptableItems = ItemManager.Instance.allScriptableItems;
			foreach (InventoryItem val in allScriptableItems)
			{
				switch (val.name)
				{
				case "Sugon Shroom":
					val.stamina = 30f;
					break;
				case "Gulpon Shroom":
					val.heal = 18f;
					break;
				case "Ligon Shroom":
					val.hunger = 18f;
					break;
				case "Slurbon Shroom":
					val.heal = 18f;
					val.hunger = 18f;
					val.stamina = 30f;
					break;
				case "Meat Pie":
					val.hunger = 75f;
					break;
				case "Red Apple":
					val.heal = 4f;
					val.hunger = 12f;
					val.stamina = 4f;
					break;
				case "Purple Soup":
					val.stamina = 50f;
					break;
				case "Red Soup":
					val.heal = 50f;
					break;
				case "Chunkium Ore":
					val.processTime = 17f;
					break;
				case "Chunky Hammer":
					val.type = (ItemType)2;
					val.tier = 4;
					val.resourceDamage = 50;
					break;
				case "Chiefs Spear":
					val.attackSpeed = 0.9f;
					val.attackDamage = 140;
					break;
				case "Adamantite Pickaxe":
					val.attackDamage = 48;
					break;
				case "Gronks Sword":
					val.description = "very heavy, +10% crit chance";
					break;
				case "Wyvern Dagger":
					val.description = "extremely sharp, +25% movement speed";
					break;
				}
				itemlist.Add(val);
			}
		}
	}
}
namespace RebalancedMuck.Patches
{
	[HarmonyPatch(typeof(PowerupInventory))]
	internal class PowerupInventoryMod
	{
		public static float gronkSwordCritChance = 0.1f;

		public static float wyvernDaggerSpeedBoost = 0.25f;

		public static Hotbar hotbarInstance = null;

		public static void CheckHotbar()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if ((Object)(object)hotbarInstance == (Object)null)
			{
				hotbarInstance = (Hotbar)Object.FindObjectOfType(typeof(Hotbar));
			}
		}

		[HarmonyPatch("GetCritChance")]
		[HarmonyPostfix]
		public static void CritChancePatch(ref float __result)
		{
			CheckHotbar();
			if ((Object)(object)hotbarInstance != (Object)null && (Object)(object)hotbarInstance.currentItem != (Object)null && hotbarInstance.currentItem.name == "Gronks Sword")
			{
				float num = __result + gronkSwordCritChance;
				num = Mathf.Clamp(num, 0f, 1f);
				__result = num;
			}
		}

		[HarmonyPatch("GetSpeedMultiplier")]
		[HarmonyPostfix]
		public static void SpeedMultiplierPatch(ref float __result)
		{
			CheckHotbar();
			if ((Object)(object)hotbarInstance != (Object)null && (Object)(object)hotbarInstance.currentItem != (Object)null && hotbarInstance.currentItem.name == "Wyvern Dagger")
			{
				__result *= 1f + wyvernDaggerSpeedBoost;
			}
		}
	}
}