Decompiled source of TrapMeNot v1.1.2

TrapMeNot.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
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("TrapMeNot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TrapMeNot")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("709cf7ea-9fb3-4df5-8398-9cb2f849dcd3")]
[assembly: AssemblyFileVersion("1.1.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
namespace TrapMeNot;

[BepInPlugin("Eardwulf.TrapMeNot", "TrapMeNot", "1.1.2")]
public class TrapMeNot : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Trap))]
	private static class TrapPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerEnter")]
		private static bool OnTriggerEnterPrefix(ref Trap __instance, ref Collider collider)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			if (__instance.m_triggeredByPlayers)
			{
				Player componentInParent = ((Component)collider).GetComponentInParent<Player>();
				if (Object.op_Implicit((Object)(object)componentInParent) && !((Character)componentInParent).IsPVPEnabled())
				{
					bool flag = IsComfyWorld() && (int)Heightmap.FindBiome(((Component)componentInParent).transform.position) == 64;
					bool flag2 = IsComfyWorld() && (int)Heightmap.FindBiome(((Component)componentInParent).transform.position) == 32;
					bool flag3 = IsComfyWorld() && IsInSpace();
					if (flag || flag2 || flag3)
					{
						return true;
					}
					return false;
				}
			}
			return true;
		}
	}

	public const string PluginGuid = "Eardwulf.TrapMeNot";

	public const string PluginName = "TrapMeNot";

	public const string PluginVersion = "1.1.2";

	private Harmony _harmony;

	public void Awake()
	{
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Eardwulf.TrapMeNot");
	}

	public void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	public static bool IsComfyWorld()
	{
		return Object.op_Implicit((Object)(object)ZNet.m_instance) && ZNet.m_world != null && ZNet.m_world.m_name.StartsWith("ComfyEra");
	}

	public static bool IsInSpace()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		return Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, Vector3.zero) > 10500f;
	}
}