Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PortalMarker v1.2.0
PortalMarker.dll
Decompiled 2 years agousing 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PortalMarker")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PortalMarker")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6bfa28af-5e85-4805-9e03-eac4435a6705")] [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 PortalMarker; [BepInPlugin("sebdei.portalmarker", "Marks all portals on the minimap when renaming and using them. Removes them on destroy.", "1.1.0")] [BepInProcess("valheim.exe")] public class PortalMarker : BaseUnityPlugin { [HarmonyPatch(typeof(TeleportWorld), "SetText")] private static class PinOnEditName { private static void Postfix(string text, TeleportWorld __instance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Vector3? obj; if (__instance == null) { obj = null; } else { GameObject gameObject = ((Component)__instance).gameObject; if (gameObject == null) { obj = null; } else { Transform transform = gameObject.transform; obj = ((transform != null) ? new Vector3?(transform.position) : null); } } Vector3? val = obj; if (val.HasValue) { ReplacePin(val.Value, text); } } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] private static class PinOnUse { private static void Postfix(TeleportWorld __instance, ZNetView ___m_nview) { string text = __instance.GetText(); if (text != null) { ReplaceOrigin(__instance, text); ReplaceTarget(___m_nview, text); } } private static void ReplaceTarget(ZNetView ___m_nview, string text) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) ZDOID zDOID = ___m_nview.GetZDO().GetZDOID("target"); ZDO zDO = ZDOMan.instance.GetZDO(zDOID); Vector3? val = ((zDO != null) ? new Vector3?(zDO.GetPosition()) : null); if (val.HasValue) { ReplacePin(val.Value, text); } } private static void ReplaceOrigin(TeleportWorld __instance, string text) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Vector3? obj; if (__instance == null) { obj = null; } else { GameObject gameObject = ((Component)__instance).gameObject; if (gameObject == null) { obj = null; } else { Transform transform = gameObject.transform; obj = ((transform != null) ? new Vector3?(transform.position) : null); } } Vector3? val = obj; if (val.HasValue) { ReplacePin(val.Value, text); } } } [HarmonyPatch(typeof(Piece), "OnDestroy")] private static class UnpinOnDestroy { private static void Prefix(Piece __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject != (Object)null && ((Object)gameObject).name == "portal_wood") { TeleportWorld component = gameObject.GetComponent<TeleportWorld>(); Vector3? obj; if (component == null) { obj = null; } else { Transform transform = ((Component)component).transform; obj = ((transform != null) ? new Vector3?(transform.position) : null); } Vector3? val = obj; if (val.HasValue) { RemovePin(val.Value); } } } } private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("sebdei.portalmarker"); val.PatchAll(); } private static void RemovePin(Vector3 position) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; PinData val = (PinData)typeof(Minimap).GetMethod("GetClosestPin", bindingAttr).Invoke(Minimap.instance, new object[2] { position, 1L }); if (val != null) { Minimap.instance.RemovePin(val); } } private static void ReplacePin(Vector3 position, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) RemovePin(position); AddPin(position, text); } private static void AddPin(Vector3 position, string text) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Minimap.instance.AddPin(position, (PinType)6, text, true, false, 0L, ""); } }