using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OneMine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OneMine")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dcd2b82a-c646-46ee-b4f6-94d126428fdd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TopMining;
[BepInPlugin("Uwazouri.TopMining", "TopMining", "1.0.1")]
[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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_002f: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_005f: 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, Array.Empty<object>()));
configTopMiningHold = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "TopMineHold"), false, new ConfigDescription("Hold Top Mine Key to activate top mining mode", (AcceptableValueBase)null, Array.Empty<object>()));
Harmony.PatchAll();
}
private static bool isTopMiningActive()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!configTopMiningHold.Value)
{
return !Input.GetKey(configTopMiningKey.Value);
}
return Input.GetKey(configTopMiningKey.Value);
}
}
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.1";
}
[HarmonyPatch(typeof(MineRock5), "Damage")]
internal class MineRock5Patch
{
private static void Prefix(ref MineRock5 __instance, ref HitData hit)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: 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_00ad: 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_00bc: 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)
if (!TopMining.TopMiningActive)
{
return;
}
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;
}
}
}