Decompiled source of TopMining v1.0.3

TopMining.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("TopMining")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4809f763cbeb9b7904bfa39c71fd4cd9d928a40c")]
[assembly: AssemblyProduct("Top Mining")]
[assembly: AssemblyTitle("TopMining")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 TopMining
{
	[BepInPlugin("Uwazouri.TopMining", "TopMining", "1.0.2")]
	[BepInProcess("valheim.exe")]
	[BepInProcess("valheim_server.exe")]
	public class TopMining : BaseUnityPlugin
	{
		private static ConfigEntry<KeyCode> configTopMiningKey;

		private static ConfigEntry<bool> configTopMiningHold;

		public static readonly Harmony Harmony = new Harmony("Uwazouri.TopMining");

		public static bool TopMiningActive => isTopMiningActive();

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0031: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Expected O, but got Unknown
			configTopMiningKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(new ConfigDefinition("General", "TopMineKey"), (KeyCode)304, new ConfigDescription("Hold to disable top mining mode", (AcceptableValueBase)null, new object[0]));
			configTopMiningHold = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "TopMineHold"), false, new ConfigDescription("Hold Top Mine Key to activate top mining mode", (AcceptableValueBase)null, new object[0]));
			Harmony.PatchAll();
		}

		private static bool isTopMiningActive()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return configTopMiningHold.Value ? Input.GetKey(configTopMiningKey.Value) : (!Input.GetKey(configTopMiningKey.Value));
		}
	}
	[HarmonyPatch(typeof(MineRock5), "Damage")]
	internal class MineRock5InstantMineCheat
	{
		private static void Prefix(ref MineRock5 __instance, ref HitData hit)
		{
			HitData val = hit;
			val.m_damage.m_pickaxe = val.m_damage.m_pickaxe + 0f;
		}
	}
	public static class TopMiningInfo
	{
		public const string AUTHOR_NAME = "Uwazouri";

		public const string MOD_NAME = "TopMining";

		public const string MOD_ID = "Uwazouri.TopMining";

		public const string MOD_VERSION = "1.0.2";
	}
	[HarmonyPatch(typeof(MineRock5), "Damage")]
	internal class MineRock5Patch
	{
		private static void Prefix(ref MineRock5 __instance, ref HitData hit)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (!TopMining.TopMiningActive)
			{
				__instance.m_hitEffectAreaCenter = true;
				return;
			}
			__instance.m_hitEffectAreaCenter = false;
			Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>();
			if (componentsInChildren.Length < 1)
			{
				return;
			}
			bool flag = false;
			Collider val = componentsInChildren[0];
			Collider[] array = componentsInChildren;
			Bounds bounds;
			foreach (Collider val2 in array)
			{
				if (!flag)
				{
					flag = (Object)(object)val2 == (Object)(object)hit.m_hitCollider;
					if (flag)
					{
						continue;
					}
				}
				bounds = val.bounds;
				float y = ((Bounds)(ref bounds)).center.y;
				bounds = val2.bounds;
				if (y > ((Bounds)(ref bounds)).center.y)
				{
					val = val2;
				}
			}
			if (flag)
			{
				HitData obj = hit;
				Vector3 point = hit.m_point;
				Vector3 point2 = hit.m_point;
				bounds = hit.m_hitCollider.bounds;
				Vector3 val3 = point2 - ((Bounds)(ref bounds)).center;
				obj.m_point = point + ((Vector3)(ref val3)).normalized * 0.3f;
				hit.m_hitCollider = val;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TopMining";

		public const string PLUGIN_NAME = "Top Mining";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}