Decompiled source of DudeWheresMyPortal v0.1.0

plugins/DWMP.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DWMP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DWMP")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee0ccb4c-4389-47c4-967d-f37b5dbe65b1")]
[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 DWMP;

[BepInPlugin("com.oathorse.DWMP", "Dude, Where's My Portal", "0.1.0")]
public class DWMP : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "PlacePiece", new Type[]
	{
		typeof(Piece),
		typeof(Vector3),
		typeof(Quaternion),
		typeof(bool)
	})]
	public static class Player_PlacePiece_Patch
	{
		public static void Postfix(Player __instance, Piece piece, Vector3 pos, Quaternion rot, bool doAttack)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)piece != (Object)null && (((Object)piece).name == "portal_wood" || ((Object)piece).name == "portal_stone"))
			{
				AddPortalPin(pos);
			}
		}
	}

	[HarmonyPatch(typeof(Piece), "DropResources")]
	public static class Piece_DropResources_Patch
	{
		public static void Postfix(Piece __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)__instance).transform.position;
			if ((Object)(object)((Component)__instance).GetComponent<TeleportWorld>() != (Object)null)
			{
				RemovePortalPin(position);
			}
		}
	}

	[HarmonyPatch(typeof(TeleportWorld), "SetText")]
	public static class TeleportWorld_SetText_Patch
	{
		public static void Postfix(TeleportWorld __instance, string text)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance != (Object)null)
			{
				RenamePortalPin(((Component)__instance).transform.position, text);
			}
		}
	}

	public const string PluginGUID = "com.oathorse.DWMP";

	public const string PluginName = "Dude, Where's My Portal";

	public const string PluginVersion = "0.1.0";

	private readonly Harmony harmony = new Harmony("com.oathorse.DWMP");

	private List<PinData> __m_pins = new List<PinData>();

	private void Awake()
	{
		harmony.PatchAll();
	}

	private static void AddPortalPin(Vector3 pos, string text = "")
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		Minimap.instance.AddPin(pos, (PinType)6, text, true, false, 0L, "");
	}

	private static void RemovePortalPin(Vector3 pos)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		Minimap.instance.RemovePin(pos, 0.1f);
	}

	private static void RenamePortalPin(Vector3 pos, string text)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		RemovePortalPin(pos);
		AddPortalPin(pos, text);
	}
}