Please disclose if any significant portion of your mod was created 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 Wormhole Potion v0.1.2
RegisideWormholePotion.dll
Decompiled a month agousing System.CodeDom.Compiler; using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("RegisideWormholePotion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RegisideWormholePotion")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace RegisideWormholePotion { [BepInPlugin("com.jotunn.ValheimTeleportPlugin", "Teleport to Player (Jotunn)", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class RegisideWormholePotion : BaseUnityPlugin { [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] private static class Minimap_OnMapLeftClick_Patch { private static bool Prefix(Minimap __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !((Character)localPlayer).m_seman.HaveStatusEffect("WormholeEffect".GetHashCode())) { return true; } Vector3 clickPosition = __instance.ScreenToWorldPoint(Input.mousePosition); if (!TryFindClosestPublicPlayer(__instance, clickPosition, out var closestPlayer)) { Logger.LogInfo((object)"No public player marker found near the clicked position."); MessageHud.instance.ShowMessage((MessageType)2, "No player found nearby.", 0, (Sprite)null, false); return false; } Inventory inventory = ((Humanoid)localPlayer).m_inventory; if (s_pendingPotion == null || !inventory.GetAllItems().Contains(s_pendingPotion)) { Logger.LogWarning((object)"The pending wormhole potion is no longer in the player's inventory."); MessageHud.instance.ShowMessage((MessageType)2, "The wormhole potion is no longer in your inventory.", 0, (Sprite)null, false); s_pendingPotion = null; ((Character)localPlayer).m_seman.RemoveStatusEffect("WormholeEffect".GetHashCode(), false); __instance.SetMapMode((MapMode)1); return false; } if (!((Character)localPlayer).TeleportTo(closestPlayer.m_position, ((Component)localPlayer).transform.rotation, true)) { Logger.LogWarning((object)("Teleport to " + closestPlayer.m_name + " was rejected; the potion was not consumed.")); MessageHud.instance.ShowMessage((MessageType)2, "The wormhole cannot open yet. Try again in a moment.", 0, (Sprite)null, false); return false; } inventory.RemoveItem(s_pendingPotion, 1); s_pendingPotion = null; string text = (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) ? "host" : "client"); Logger.LogInfo((object)$"Teleport started to {closestPlayer.m_name} ({closestPlayer.m_characterID}) at {closestPlayer.m_position} as {text}."); Logger.LogInfo((object)"Removed one $item_wormholePotion from inventory."); __instance.SetMapMode((MapMode)1); return false; } private static bool TryFindClosestPublicPlayer(Minimap minimap, Vector3 clickPosition, out PlayerInfo closestPlayer) { //IL_0001: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) closestPlayer = default(PlayerInfo); if ((Object)(object)ZNet.instance == (Object)null) { return false; } List<PlayerInfo> list = new List<PlayerInfo>(); ZNet.instance.GetOtherPublicPlayers(list); float num = minimap.m_removeRadius * minimap.m_largeZoom * 2f; bool result = false; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(clickPosition.x, clickPosition.z); Vector2 val2 = default(Vector2); foreach (PlayerInfo item in list) { if (!(item.m_characterID == ZDOID.None)) { ((Vector2)(ref val2))..ctor(item.m_position.x, item.m_position.z); float num2 = Vector2.Distance(val, val2); if (num2 <= num) { num = num2; closestPlayer = item; result = true; } } } return result; } } [HarmonyPatch(typeof(Player), "ConsumeItem")] public static class Player_ConsumeItem_Patch { public static bool Prefix(Player __instance, Inventory inventory, ItemData item, bool checkWorldLevel = false) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) if (item == null || item.m_shared.m_name != "$item_wormholePotion") { return true; } if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (s_pendingPotion != null || ((Character)__instance).m_seman.HaveStatusEffect("WormholeEffect".GetHashCode())) { MessageHud.instance.ShowMessage((MessageType)2, "Choose a player on the map or close the map to cancel.", 0, (Sprite)null, false); return false; } if (!inventoryCanPortal(inventory)) { MessageHud.instance.ShowMessage((MessageType)2, "The weight of the world binds you. Try dropping your ores.", 0, (Sprite)null, false); return false; } if ((Object)(object)ZNet.instance == (Object)null || (Object)(object)Minimap.instance == (Object)null) { Logger.LogWarning((object)"The network or minimap is not ready for wormhole targeting."); return false; } List<PlayerInfo> list = new List<PlayerInfo>(); ZNet.instance.GetOtherPublicPlayers(list); if (list.Count == 0) { MessageHud.instance.ShowMessage((MessageType)2, "No players are currently sharing their map position.", 0, (Sprite)null, false); return false; } StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect("WormholeEffect".GetHashCode()); if ((Object)(object)(((Object)(object)statusEffect == (Object)null) ? null : ((Character)__instance).m_seman.AddStatusEffect(statusEffect, false, 0, 0f)) == (Object)null) { Logger.LogWarning((object)"Failed to apply wormhole effect; the potion was not consumed."); return false; } s_pendingPotion = item; Logger.LogInfo((object)"Wormhole targeting began."); if ((Object)(object)((Character)__instance).m_zanim != (Object)null) { Logger.LogInfo((object)"Playing 'eat' animation."); ((Character)__instance).m_zanim.SetTrigger("eat"); } else { Logger.LogWarning((object)"Player animation controller (m_zanim) is null!"); } if (((Humanoid)__instance).m_consumeItemEffects != null) { ((Humanoid)__instance).m_consumeItemEffects.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } else { Logger.LogWarning((object)"Consume item effects not found!"); } if ((Object)(object)InventoryGui.instance != (Object)null && InventoryGui.IsVisible()) { InventoryGui.instance.Hide(); } Minimap.instance.SetMapMode((MapMode)2); return false; } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] public static class Minimap_SetMapMode_Patch { public static void Postfix(MapMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)mode != 2) { s_pendingPotion = null; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Logger.LogWarning((object)"Local player not found."); } else if (((Character)localPlayer).m_seman.HaveStatusEffect("WormholeEffect".GetHashCode())) { ((Character)localPlayer).m_seman.RemoveStatusEffect("WormholeEffect".GetHashCode(), false); Logger.LogInfo((object)"Wormhole effect removed by map close."); } } } } public const string PluginGUID = "com.jotunn.RegisideWormholePotion"; public const string PluginName = "RegisideWormholePotion"; public const string PluginVersion = "0.0.1"; private CustomStatusEffect WormholeEffect; private const string WormholeEffectName = "WormholeEffect"; private const string WormholePotionName = "$item_wormholePotion"; private static ItemData s_pendingPotion; private CustomLocalization Localization; private readonly Harmony harmony = new Harmony("com.jotunn.ValheimTeleportPlugin"); private void Awake() { AddStatusEffects(); PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems; AddLocalizations(); harmony.PatchAll(); Logger.LogInfo((object)"RegisideWormholePotion is loaded"); } private void OnDestroy() { harmony.UnpatchSelf(); PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems; } private void AddLocalizations() { Localization = LocalizationManager.Instance.GetLocalization(); CustomLocalization localization = Localization; string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_wormholePotion", "Potion of Frith’s Bond v1" }, { "item_wormholePotion_desc", "This elixir binds the threads of fate between companions. With a single sip, the distance melts away, and you are carried to the side of your shield-brothers and sisters, no matter how far the battle has taken them." }, { "wormhole_effect", "Frith’s Bond" }, { "wormhole_effect_desc", "Teleport to the location of a chosen ally. Cannot be used within realms barred by the gods." }, { "wormhole_effectstart", "Choose a friend to be reunited with." }, { "wormhole_effectstop", "Wormhole effect removed." } }); } private static bool inventoryCanPortal(Inventory inventory) { foreach (ItemData allItem in inventory.GetAllItems()) { if (!allItem.m_shared.m_teleportable) { return false; } } return true; } private void AddStatusEffects() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004d: Expected O, but got Unknown StatusEffect val = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)val).name = "WormholeEffect"; val.m_name = "$wormhole_effect"; val.m_tooltip = "$wormhole_effect_desc"; val.m_startMessageType = (MessageType)2; val.m_startMessage = "$wormhole_effectstart"; val.m_stopMessageType = (MessageType)2; WormholeEffect = new CustomStatusEffect(val, false); ItemManager.Instance.AddStatusEffect(WormholeEffect); } private void AddClonedItems() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "$item_wormholePotion", Description = "$item_wormholePotion_desc", CraftingStation = CraftingStations.Cauldron, MinStationLevel = 2 }; val.AddRequirement(new RequirementConfig("MushroomYellow", 10, 0, false)); val.AddRequirement(new RequirementConfig("Raspberry", 3, 0, false)); val.AddRequirement(new RequirementConfig("Fish2", 1, 0, false)); CustomItem val2 = new CustomItem("WormholePotion", "MeadPoisonResist", val); GameObject itemPrefab = val2.ItemPrefab; if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_shared.m_food = 0f; component.m_itemData.m_shared.m_foodStamina = 0f; component.m_itemData.m_shared.m_foodBurnTime = 0f; component.m_itemData.m_shared.m_consumeStatusEffect = WormholeEffect.StatusEffect; } } ItemManager.Instance.AddItem(val2); PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems; } } } namespace RegisideWormholePotion.Properties { [CompilerGenerated] [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] internal sealed class Settings : ApplicationSettingsBase { private static Settings defaultInstance = (Settings)(object)SettingsBase.Synchronized((SettingsBase)(object)new Settings()); public static Settings Default => defaultInstance; } }