Decompiled source of noProtection v1.0.3

plugins/noProtection/noProtection.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("noProtection")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("noProtection")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bee069ac-acf9-4d48-acce-5b44ea8e92c7")]
[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 noProtection
{
	[BepInPlugin("com.casper.noProtection", "noProtection", "1.0.0")]
	public class noProtection : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> EnablePatch;

		private const string MyGUID = "com.casper.noProtection";

		private const string PluginName = "noProtection";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.casper.noProtection");

		public static ManualLogSource Log = new ManualLogSource("noProtection");

		private void Awake()
		{
			EnablePatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePatch", false, "Enable or disable the PreBuiltMachine patch.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: noProtection, VersionString: 1.0.0 is loading...");
			Harmony.PatchAll();
		}
	}
}
namespace noProtection.Patches
{
	[HarmonyPatch(typeof(PreBuiltMachine))]
	[HarmonyPatch("BuildMe")]
	public static class PreBuiltMachinePatch
	{
		private static bool Prefix(PreBuiltMachine __instance, bool justUpdateProtectionStatus)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			if (!noProtection.EnablePatch.Value)
			{
				return true;
			}
			MachineTypeEnum instanceType = __instance.machineType.GetInstanceType();
			if ((int)instanceType != 13 && (int)instanceType != 21 && (int)instanceType != 3 && (int)instanceType != 29 && (int)instanceType != 2 && (int)instanceType != 12)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GridManager), "RegisterProtectedZone")]
	public static class SkipRegisterProtectedZonePatch
	{
		[HarmonyPatch(typeof(VoxelManager), "RegisterProtectedVoxels")]
		public static class SkipRegisterProtectedVoxelsPatch
		{
			[HarmonyPrefix]
			public static bool Prefix()
			{
				return false;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class AlwaysCanErasePatch
		{
			[HarmonyPostfix]
			public static void Postfix(ref bool __result)
			{
				__result = true;
			}
		}

		[HarmonyPrefix]
		public static bool Prefix()
		{
			return false;
		}
	}
}