Decompiled source of RepairKey v0.1.0

RepairKey.dll

Decompiled 3 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RepairKey")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EZB")]
[assembly: AssemblyProduct("RepairKey")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace RepairKey;

[BepInPlugin("ezb.repairkey", "RepairKey", "0.1.0")]
public class RepairKeyPlugin : BaseUnityPlugin
{
	private ConfigEntry<KeyCode> repairKey;

	private void Awake()
	{
		repairKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keyboard", "RepairToggle", (KeyCode)98, "Key used to toggle the hammer's repair mode.");
	}

	private void Update()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || !Input.GetKeyDown(repairKey.Value) || ((Humanoid)localPlayer).GetInventory() == null)
		{
			return;
		}
		ItemData item = ((Humanoid)localPlayer).GetInventory().GetItem("$item_hammer", -1, false);
		if (item == null || !((Humanoid)localPlayer).IsItemEquiped(item) || item.m_shared == null)
		{
			return;
		}
		PieceTable buildPieces = item.m_shared.m_buildPieces;
		if ((Object)(object)buildPieces == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Hammer has no PieceTable.");
			return;
		}
		foreach (Piece availablePiece in buildPieces.m_availablePieces)
		{
			if ((Object)(object)availablePiece != (Object)null && availablePiece.m_repairPiece)
			{
				bool flag = localPlayer.SetSelectedPiece(availablePiece);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Repair selected: " + flag));
				return;
			}
		}
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Repair piece not found.");
	}
}