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.2")]
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);
}
}
}
[HarmonyPatch(typeof(TeleportWorld), "Teleport")]
public static class TeleportWorld_Teleport_Patch
{
public static void Postfix(TeleportWorld __instance, Player player)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance != (Object)null && __m_createPinOnTeleport)
{
RenamePortalPin(((Component)__instance).transform.position, __instance.GetText());
}
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEventFailable <>9__7_0;
internal object <AddConsoleCommands>b__7_0(ConsoleEventArgs args)
{
if (!Object.op_Implicit((Object)(object)Game.instance))
{
return true;
}
__m_createPinOnTeleport = !__m_createPinOnTeleport;
if (Object.op_Implicit((Object)(object)Chat.instance))
{
if (__m_createPinOnTeleport)
{
((Terminal)Chat.instance).AddString("CreatePinOnTeleport ENABLED!");
}
else
{
((Terminal)Chat.instance).AddString("CreatePinOnTeleport DISABLED!");
}
}
return true;
}
}
public const string PluginGUID = "com.oathorse.DWMP";
public const string PluginName = "Dude, Where's My Portal";
public const string PluginVersion = "0.1.2";
private readonly Harmony harmony = new Harmony("com.oathorse.DWMP");
private List<PinData> __m_pins = new List<PinData>();
public static bool __m_createPinOnTeleport;
public void Awake()
{
harmony.PatchAll();
AddConsoleCommands();
}
public static void AddConsoleCommands()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
object obj = <>c.<>9__7_0;
if (obj == null)
{
ConsoleEventFailable val = delegate
{
if (!Object.op_Implicit((Object)(object)Game.instance))
{
return true;
}
__m_createPinOnTeleport = !__m_createPinOnTeleport;
if (Object.op_Implicit((Object)(object)Chat.instance))
{
if (__m_createPinOnTeleport)
{
((Terminal)Chat.instance).AddString("CreatePinOnTeleport ENABLED!");
}
else
{
((Terminal)Chat.instance).AddString("CreatePinOnTeleport DISABLED!");
}
}
return true;
};
<>c.<>9__7_0 = val;
obj = (object)val;
}
new ConsoleCommand("createpinonteleport", "Add a portal pin to the minimap for each portal you pass through", (ConsoleEventFailable)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
}
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);
}
}