Decompiled source of Portalvator v1.0.0

Portalvator.dll

Decompiled 3 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.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Portalvator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Portalvator")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1ecc2e28-9647-471b-8872-0cef956d9094")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Portalvator;

[BepInPlugin("org.ssmvc.portalvator", "Portalvator", "1.0.0")]
[BepInProcess("valheim.exe")]
public class Portalvator : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player))]
	public static class PlayerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("TeleportTo")]
		public static void TeleportToPostfix(Player __instance, Vector3 pos, Quaternion rot, ref bool distantTeleport, ref bool __result)
		{
			//IL_000e: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (__result && distantTeleport && ZNetScene.instance.IsAreaReady(pos))
			{
				Vector2i zone = ZoneSystem.instance.GetZone(((Component)__instance).transform.position);
				Vector2i zone2 = ZoneSystem.instance.GetZone(pos);
				if (Mathf.Abs(zone.x - zone2.x) <= 1 && Mathf.Abs(zone.y - zone2.y) <= 1)
				{
					__instance.m_distantTeleport = false;
				}
			}
		}
	}

	public const string PluginGUID = "org.ssmvc.portalvator";

	public const string PluginName = "Portalvator";

	public const string PluginVersion = "1.0.0";

	private static Harmony _harmony;

	public void Awake()
	{
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "org.ssmvc.portalvator");
	}

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