Decompiled source of NoRepair v1.0.0

plugins/NoRepairAllowed.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoRepairAllowed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoRepairAllowed")]
[assembly: AssemblyTitle("NoRepairAllowed")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 NoRepairAllowed
{
	[BepInPlugin("com.igentuman.norepairallowed", "NoRepair", "1.0.0")]
	public sealed class NoRepairAllowedPlugin : BaseUnityPlugin
	{
		private const string PluginGuid = "com.igentuman.norepairallowed";

		private Harmony? _harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("com.igentuman.norepairallowed");
			_harmony.PatchAll(typeof(NoRepairAllowedPlugin).Assembly);
		}

		private void OnDestroy()
		{
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui))]
	internal static class CraftingStationRepair
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateRepair")]
		private static bool HideRepairControls(InventoryGui __instance)
		{
			if (!IsUsingCraftingStation())
			{
				return true;
			}
			((Component)__instance.m_repairPanel).gameObject.SetActive(false);
			((Component)__instance.m_repairPanelSelection).gameObject.SetActive(false);
			((Component)__instance.m_repairButton).gameObject.SetActive(false);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("RepairOneItem")]
		private static bool BlockRepair()
		{
			return !IsUsingCraftingStation();
		}

		private static bool IsUsingCraftingStation()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				return (Object)(object)localPlayer.GetCurrentCraftingStation() != (Object)null;
			}
			return false;
		}
	}
}