Decompiled source of Unbreakable Doors v1.0.0

IndestructibleDoors.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
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("IndestructibleDoors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("IndestructibleDoors")]
[assembly: AssemblyTitle("IndestructibleDoors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace IndestructibleDoors
{
	[BepInPlugin("com.exemplo.indestructibledoors", "Indestructible Doors", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.exemplo.indestructibledoors").PatchAll();
			Log.LogInfo((object)"Indestructible Doors v2 carregado.");
		}
	}
	[HarmonyPatch]
	internal static class BlockBreakPatch
	{
		private static readonly string[] Names = new string[5] { "HingeBreakImpulse", "HingeBreakRPC", "DestroyHinge", "DestroyHingeRPC", "OnJointBreak" };

		private static IEnumerable<MethodBase> TargetMethods()
		{
			string[] names = Names;
			foreach (string text in names)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabHinge), text, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					Plugin.Log.LogWarning((object)("Método não encontrado: PhysGrabHinge." + text));
					continue;
				}
				Plugin.Log.LogInfo((object)("Patch em PhysGrabHinge." + text));
				yield return methodInfo;
			}
		}

		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PhysGrabHinge), "FixedUpdate")]
	internal static class ReinforcePatch
	{
		private static readonly FieldRef<PhysGrabHinge, HingeJoint> JointRef = AccessTools.FieldRefAccess<PhysGrabHinge, HingeJoint>("joint");

		private static readonly FieldRef<PhysGrabHinge, bool> BrokenRef = AccessTools.FieldRefAccess<PhysGrabHinge, bool>("broken");

		private static readonly FieldRef<PhysGrabHinge, bool> DeadRef = AccessTools.FieldRefAccess<PhysGrabHinge, bool>("dead");

		private static void Postfix(PhysGrabHinge __instance)
		{
			HingeJoint val = JointRef.Invoke(__instance);
			if ((Object)(object)val != (Object)null)
			{
				if (!float.IsInfinity(((Joint)val).breakForce))
				{
					((Joint)val).breakForce = float.PositiveInfinity;
				}
				if (!float.IsInfinity(((Joint)val).breakTorque))
				{
					((Joint)val).breakTorque = float.PositiveInfinity;
				}
			}
			BrokenRef.Invoke(__instance) = false;
			DeadRef.Invoke(__instance) = false;
		}
	}
}