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 SharedPOIPins v0.2.1
SharedPOIPins.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Common; using EpicLoot; using EpicLoot.Adventure; using HarmonyLib; using Microsoft.CodeAnalysis; using ServerSideMap; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SharedPOIPins")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1+3a0fdbb7644f15a7fb4b67801cbb476e1e636bbd")] [assembly: AssemblyProduct("SharedPOIPins")] [assembly: AssemblyTitle("SharedPOIPins")] [assembly: AssemblyVersion("0.2.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SharedPOIPins { internal static class BountyPins { private const float CheckInterval = 2f; private static float _nextCheck; internal static void Update() { //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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextCheck) { return; } _nextCheck = Time.time + 2f; Player localPlayer = Player.m_localPlayer; Minimap instance = Minimap.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || !Plugin.HaveServerPins || !Store.IsSharingPin()) { return; } AdventureSaveData adventureSaveData = PlayerExtensions_Adventure.GetAdventureSaveData(localPlayer); if (adventureSaveData == null) { return; } PinType type = EpicLoot.BountyPinType; string text = " (" + localPlayer.GetPlayerName() + ")"; List<KeyValuePair<string, Vector3>> list = new List<KeyValuePair<string, Vector3>>(); foreach (BountyInfo inProgressBounty in adventureSaveData.GetInProgressBounties()) { string text2 = Localization.instance.Localize("$mod_epicloot_bounties_minimappin", new string[1] { AdventureDataManager.GetBountyName(inProgressBounty) }); list.Add(new KeyValuePair<string, Vector3>(text2 + text, SerializableVector3.op_Implicit(inProgressBounty.Position + inProgressBounty.MinimapCircleOffset))); } foreach (PinData pin in ExplorationDatabase.ClientPins.ToList()) { if (pin.Type == type && pin.Name.EndsWith(text) && !list.Any((KeyValuePair<string, Vector3> b) => IsPin(b, pin.Name, pin.Pos))) { PinSync.RemovePinFromServer(pin); } } foreach (KeyValuePair<string, Vector3> bounty in list) { if (!ExplorationDatabase.ClientPins.Any((PinData val) => val.Type == type && IsPin(bounty, val.Name, val.Pos))) { PinSync.SendPinToServer(instance.AddPin(bounty.Value, type, bounty.Key, false, false, 0L, default(PlatformUserID)), true); } } foreach (PinData pin2 in Plugin.MinimapPins.Invoke(instance).ToList()) { if (!pin2.m_save && pin2.m_type == type && list.Any((KeyValuePair<string, Vector3> b) => IsPin(b, pin2.m_name, pin2.m_pos))) { instance.RemovePin(pin2); } } } private static bool IsPin(KeyValuePair<string, Vector3> bounty, string name, Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (name == bounty.Key) { return Utils.DistanceXZ(position, bounty.Value) < 1f; } return false; } } [BepInPlugin("Manke.SharedPOIPins", "SharedPOIPins", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "Manke.SharedPOIPins"; public const string Name = "SharedPOIPins"; public const string Version = "0.2.1"; private const string AutoPoiMarkerGuid = "rollstuhltreter.valheim.autopoimarker"; private const string ServerSideMapGuid = "eu.mydayyy.plugins.serversidemap"; private const string EpicLootGuid = "randyknapp.mods.epicloot"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> DuplicateRadius; internal static ConfigEntry<bool> SkipKnownAnnouncements; internal static ConfigEntry<bool> ShareBounties; internal static bool HaveServerPins; private static bool _epicLoot; internal static readonly FieldRef<Minimap, List<PinData>> MinimapPins = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins"); private static string _skipMessage; private static int _skipMessageFrame = -1; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Share the pins of Auto POI Marker through ServerSideMap. Needs marker sharing on in ServerSideMap, on the server and on the client."); DuplicateRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DuplicateRadius", 15f, new ConfigDescription("A shared pin with the same name within this many meters counts as the same place, so no new pin is added.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); SkipKnownAnnouncements = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SkipKnownAnnouncements", true, "Leave out Auto POI Marker's \"found!\" message for places already on the shared map."); ShareBounties = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShareBounties", true, "Share the bounties you take from Epic Loot's merchant as pins, so other players see which bounties are taken and by whom. The reward stays yours."); _epicLoot = Chainloader.PluginInfos.ContainsKey("randyknapp.mods.epicloot"); MethodInfo methodInfo = AccessTools.Method("AutoPOIMarkerPlugin:AddMapMarker", new Type[3] { typeof(Vector3), typeof(string), typeof(PinType) }, (Type[])null); if (methodInfo == null) { Log.LogError((object)"Auto POI Marker's AddMapMarker method was not found, so its pins stay personal. This version of SharedPOIPins does not support the installed Auto POI Marker."); return; } Harmony val = new Harmony("Manke.SharedPOIPins"); val.Patch((MethodBase)AccessTools.Method(typeof(InitialPinSync), "OnReceiveInitialDataPin", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ReceivedServerPins", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZNet), "Shutdown", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Disconnected", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "AddMapMarkerPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(MessageHud), "ShowMessage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ShowMessagePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private void Update() { if (_epicLoot && Enabled.Value && ShareBounties.Value) { BountyPins.Update(); } } private static void ReceivedServerPins() { HaveServerPins = true; } private static void Disconnected() { HaveServerPins = false; } private static bool AddMapMarkerPrefix(Vector3 position, string shortName, PinType icon) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; if (!Enabled.Value || (Object)(object)instance == (Object)null || !HaveServerPins || !Store.IsSharingPin()) { return true; } if (HaveSharedPin(position, shortName)) { if (SkipKnownAnnouncements.Value) { _skipMessage = shortName + " found!"; _skipMessageFrame = Time.frameCount; } return false; } PinData val = FindPersonalPin(instance, position, shortName, icon) ?? instance.AddPin(position, icon, shortName, true, false, 0L, default(PlatformUserID)); try { PinSync.SendPinToServer(val, true); } catch (Exception ex) { Log.LogWarning((object)("Could not share the pin \"" + shortName + "\": " + ex.Message)); } return false; } private static bool ShowMessagePrefix(string text) { if (_skipMessage == null) { return true; } bool num = _skipMessageFrame == Time.frameCount && text == _skipMessage; _skipMessage = null; return !num; } private static bool HaveSharedPin(Vector3 position, string name) { //IL_0030: 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) float value = DuplicateRadius.Value; foreach (PinData clientPin in ExplorationDatabase.ClientPins) { if (string.Equals(clientPin.Name, name, StringComparison.OrdinalIgnoreCase) && Utils.DistanceXZ(clientPin.Pos, position) < value) { return true; } } return false; } private static PinData FindPersonalPin(Minimap minimap, Vector3 position, string name, PinType type) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) foreach (PinData item in MinimapPins.Invoke(minimap)) { if (item.m_save && item.m_name == name && item.m_type == type && Utils.DistanceXZ(position, item.m_pos) < 1f) { return item; } } return null; } } }