Decompiled source of ArchitectDrill v1.0.0

ArchitectDrill.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArchitectDrill")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArchitectDrill")]
[assembly: AssemblyTitle("ArchitectDrill")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ArchitectDrill
{
	[BepInPlugin("Mhz.architectdrill", "ArchitectDrill", "1.0.0")]
	public class ArchitectDrillMod : BaseUnityPlugin
	{
		private static ManualLogSource? _logger;

		private Harmony? _harmony;

		public static ConfigEntry<bool>? EnableArchitectDrill { get; private set; }

		private void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			_logger = ((BaseUnityPlugin)this).Logger;
			EnableArchitectDrill = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableArchitectDrill", true, "Enable replacing Architect's downward attack with drill effect. 启用将建筑师向下攻击替换为掘洞钻效果。");
			_logger.LogInfo((object)"Loading ArchitectDrill v1.0.0 | 加载 ArchitectDrill v1.0.0");
			_harmony = new Harmony("Mhz.architectdrill");
			_harmony.PatchAll();
			_logger.LogInfo((object)"Architect Drill MOD loaded successfully! | 建筑师掘洞钻MOD加载完成!");
		}

		private void OnDestroy()
		{
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		internal static void LogError(string message)
		{
			ManualLogSource? logger = _logger;
			if (logger != null)
			{
				logger.LogError((object)message);
			}
		}
	}
	[HarmonyPatch]
	public class ArchitectDrillPatches
	{
		[HarmonyPatch(typeof(HeroController), "DownAttack")]
		[HarmonyPrefix]
		public static bool DownAttackPrefix(HeroController __instance, ref bool isSlashing)
		{
			try
			{
				ConfigEntry<bool>? enableArchitectDrill = ArchitectDrillMod.EnableArchitectDrill;
				if (enableArchitectDrill == null || !enableArchitectDrill.Value)
				{
					return true;
				}
				if (!__instance.IsArchitectCrestEquipped())
				{
					return true;
				}
				isSlashing = false;
				object? obj = typeof(HeroController).GetField("toolEventTarget", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance);
				PlayMakerFSM val = (PlayMakerFSM)((obj is PlayMakerFSM) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					__instance.CancelAttack(true);
					__instance.ResetLook();
					__instance.cState.recoiling = false;
					__instance.cState.floating = false;
					val.SendEvent("TAKE CONTROL");
					val.SendEvent("SCREW");
					typeof(HeroController).GetMethod("DidAttack", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(__instance, null);
					return false;
				}
				return true;
			}
			catch (Exception arg)
			{
				ArchitectDrillMod.LogError($"Error in DownAttack patch | DownAttack补丁发生错误: {arg}");
				return true;
			}
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "Mhz.architectdrill";

		public const string PLUGIN_NAME = "ArchitectDrill";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}