Decompiled source of KeepMyHammer v1.0.0

KeepMyHammer.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("KeepMyHammer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KeepMyHammer")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("58aea8a1-0db9-4957-b35a-8a9c357b24bd")]
[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 KeepMyHammer;

[BepInPlugin("actuallytime.keepmyhammer", "KeepMyHammer", "1.0.0")]
public class KeepMyHammer : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ItemStand), "UseItem")]
	public static class HammerBlockPatch
	{
		private static bool Prefix(ItemData item)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			if (item.m_shared.m_name == "$item_hammer" && GetHammerMode())
			{
				return false;
			}
			return true;
		}
	}

	private const string pluginGUID = "actuallytime.keepmyhammer";

	private const string pluginName = "KeepMyHammer";

	private const string pluginVersion = "1.0.0";

	private static bool keepHammer = true;

	public static void Print(string message)
	{
		Logger.CreateLogSource("KeepMyHammer").LogInfo((object)message);
	}

	public static void ShowMessage(string message)
	{
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null))
		{
			((Character)localPlayer).Message((MessageType)2, message, 0, (Sprite)null);
		}
	}

	public void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		Print("Starting Plugin: KeepMyHammer");
		InitToggleCommand();
		Harmony val = new Harmony("actuallytime.keepmyhammer");
		val.PatchAll();
	}

	private void InitToggleCommand()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		new ConsoleCommand("togglemyhammer", "Toggle whether or not you can place a hammer on an item stand", (ConsoleEvent)delegate
		{
			ToggleMyHammer();
		}, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
	}

	public static bool GetHammerMode()
	{
		return keepHammer;
	}

	private void ToggleMyHammer()
	{
		if (GetHammerMode())
		{
			keepHammer = false;
			ShowMessage("Item Stands will steal your hammer");
		}
		else
		{
			keepHammer = true;
			ShowMessage("Your hammer is safe from Item Stands");
		}
	}
}