Decompiled source of DirtMiningXP v1.0.0

DirtMiningXP.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
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: AssemblyVersion("0.0.0.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 DirtMiningXP
{
	[BepInPlugin("com.custom.dirtminingxp", "DirtMiningXP", "1.0.0")]
	public class DirtMiningXPPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.custom.dirtminingxp";

		public const string ModName = "DirtMiningXP";

		public const string ModVersion = "1.0.0";

		public static ConfigEntry<float> XpGain;

		private void Awake()
		{
			XpGain = ((BaseUnityPlugin)this).Config.Bind<float>("General", "XpGain", 0.5f, "Pickaxes skill XP gained per terrain hit.");
			Harmony.CreateAndPatchAll(typeof(DirtMiningXPPlugin), (string)null);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Attack), "SpawnOnHitTerrain")]
		private static void OnSpawnOnHitTerrain(GameObject __result, Character character, ItemData weapon)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			if ((Object)(object)__result != (Object)null)
			{
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && weapon != null && (int)(weapon.m_shared?.m_skillType).GetValueOrDefault() == 12)
				{
					((Character)val).RaiseSkill((SkillType)12, XpGain.Value);
				}
			}
		}
	}
}