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 MapMarkers v0.4.0
plugins/MapMarkers/MapMarkers.dll
Decompiled 5 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("MapMarkers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.0")] [assembly: AssemblyInformationalVersion("0.4.0")] [assembly: AssemblyProduct("MapMarkers")] [assembly: AssemblyTitle("MapMarkers")] [assembly: AssemblyVersion("0.4.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 MapMarkers { public static class AdminCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static ConsoleEvent <>9__0_2; internal void <Register>b__0_0(ConsoleEventArgs args) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { args.Context.AddString($"Shared pins on server: {SharedPinStore.All.Count}"); int num = 0; { foreach (SharedPinStore.SharedPin item in SharedPinStore.All) { if (++num > 10) { args.Context.AddString("... (truncated)"); break; } args.Context.AddString($" [{item.OwnerName}] {item.Name} @ ({(int)item.Pos.x},{(int)item.Pos.z})"); } return; } } args.Context.AddString($"Shared pins on this client: {MapMarkerClient.LocalCount}"); } internal void <Register>b__0_1(ConsoleEventArgs args) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { args.Context.AddString("Must be run on the server."); return; } int count = SharedPinStore.All.Count; SharedPinStore.Clear(); if (ZRoutedRpc.instance != null) { ZPackage val = new ZPackage(); val.Write(0); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_SyncAll", new object[1] { val }); } args.Context.AddString($"Cleared {count} shared pins."); } internal void <Register>b__0_2(ConsoleEventArgs args) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown long uID = ZNet.GetUID(); if (ZRoutedRpc.instance == null) { args.Context.AddString("No network."); return; } ZPackage val = new ZPackage(); val.Write(uID); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_RemoveByOwner", new object[1] { val }); args.Context.AddString("Requested removal of your shared pins."); } } public static void Register() { //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 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { args.Context.AddString($"Shared pins on server: {SharedPinStore.All.Count}"); int num = 0; { foreach (SharedPinStore.SharedPin item in SharedPinStore.All) { if (++num > 10) { args.Context.AddString("... (truncated)"); break; } args.Context.AddString($" [{item.OwnerName}] {item.Name} @ ({(int)item.Pos.x},{(int)item.Pos.z})"); } return; } } args.Context.AddString($"Shared pins on this client: {MapMarkerClient.LocalCount}"); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("mapmarkers_info", "Show MapMarkers stats (pin count, last owners).", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { args.Context.AddString("Must be run on the server."); } else { int count = SharedPinStore.All.Count; SharedPinStore.Clear(); if (ZRoutedRpc.instance != null) { ZPackage val5 = new ZPackage(); val5.Write(0); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_SyncAll", new object[1] { val5 }); } args.Context.AddString($"Cleared {count} shared pins."); } }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("mapmarkers_clear_all", "[ADMIN, SERVER ONLY] Clear every shared pin.", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__0_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown long uID = ZNet.GetUID(); if (ZRoutedRpc.instance == null) { args.Context.AddString("No network."); } else { ZPackage val4 = new ZPackage(); val4.Write(uID); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_RemoveByOwner", new object[1] { val4 }); args.Context.AddString("Requested removal of your shared pins."); } }; <>c.<>9__0_2 = val3; obj3 = (object)val3; } new ConsoleCommand("mapmarkers_clear_mine", "Remove shared pins you own.", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } public static class MapMarkerClient { public struct SharedEntry { public PinData Pin; public long OwnerId; public string OwnerName; public Color Color; public string Name; public Vector3 Pos; } private class Vec3Comparer : IEqualityComparer<Vector3> { public bool Equals(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(a, b) < 1f; } public int GetHashCode(Vector3 v) { //IL_0000: 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) return ((int)Mathf.Round(v.x) * 73856093) ^ ((int)Mathf.Round(v.z) * 83492791); } } private static readonly Dictionary<Vector3, SharedEntry> _shared = new Dictionary<Vector3, SharedEntry>(new Vec3Comparer()); public static int LocalCount => _shared.Count; public static IEnumerable<SharedEntry> AllLocal => _shared.Values; public static void RegisterLocalAsShared(Vector3 pos, PinData pinData, long ownerId, string ownerName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_003e: 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_0053: 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 (pinData != null) { Color value = Plugin.SharedPinTint.Value; ApplyTint(pinData, value); _shared[pos] = new SharedEntry { Pin = pinData, OwnerId = ownerId, OwnerName = ownerName, Color = value, Name = pinData.m_name, Pos = pos }; } } public static void AddLocal(SharedPinStore.SharedPin pin, bool announce) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || _shared.ContainsKey(pin.Pos)) { return; } long num = 0L; try { num = ZNet.GetUID(); } catch { } if (pin.OwnerId == num) { return; } Color color = ((pin.Color == default(Color)) ? Plugin.SharedPinTint.Value : pin.Color); string text = (string.IsNullOrEmpty(pin.OwnerName) ? pin.Name : (pin.Name + " [" + pin.OwnerName + "]")); PinData val = Minimap.instance.AddPin(pin.Pos, (PinType)pin.Type, text, false, pin.IsChecked, 0L, default(PlatformUserID)); if (val != null) { ApplyTint(val, color); _shared[pin.Pos] = new SharedEntry { Pin = val, OwnerId = pin.OwnerId, OwnerName = pin.OwnerName, Color = color, Name = pin.Name, Pos = pin.Pos }; } if (!announce || !((Object)(object)MessageHud.instance != (Object)null)) { return; } string text2 = (string.IsNullOrEmpty(pin.OwnerName) ? "Someone" : pin.OwnerName); string text3 = (string.IsNullOrEmpty(pin.Name) ? "a pin" : ("'" + pin.Name + "'")); try { MessageHud.instance.ShowMessage((MessageType)1, text2 + " shared " + text3, 0, (Sprite)null, false); } catch { } } public static void UpdateLocal(Vector3 pos, string newName, Color newColor) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || !_shared.TryGetValue(pos, out var value) || value.Pin == null) { return; } try { string text = (string.IsNullOrEmpty(value.OwnerName) ? newName : (newName + " [" + value.OwnerName + "]")); value.Pin.m_name = text; if (value.Pin.m_NamePinData != null && (Object)(object)value.Pin.m_NamePinData.PinNameText != (Object)null) { value.Pin.m_NamePinData.PinNameText.text = text; } ApplyTint(value.Pin, newColor); value.Name = newName; value.Color = newColor; _shared[pos] = value; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("UpdateLocal failed: " + ex.Message)); } } } public static void RemoveLocal(Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!_shared.TryGetValue(pos, out var value)) { return; } if ((Object)(object)Minimap.instance != (Object)null && value.Pin != null) { try { Minimap.instance.RemovePin(value.Pin); } catch { } } _shared.Remove(pos); } public static void UntrackLocal(Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _shared.Remove(pos); } public static void ClearLocal() { if ((Object)(object)Minimap.instance != (Object)null) { foreach (KeyValuePair<Vector3, SharedEntry> item in _shared) { try { if (item.Value.Pin != null) { Minimap.instance.RemovePin(item.Value.Pin); } } catch { } } } _shared.Clear(); } public static bool IsShared(Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return _shared.ContainsKey(pos); } private static void ApplyTint(PinData pinData, Color color) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (pinData == null || !Plugin.TintSharedPins.Value) { return; } try { if ((Object)(object)pinData.m_iconElement != (Object)null) { ((Graphic)pinData.m_iconElement).color = color; } } catch { } } } [BepInPlugin("com.stronox.mapmarkers", "MapMarkers", "0.4.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.stronox.mapmarkers"; public const string PluginName = "MapMarkers"; public const string PluginVersion = "0.4.0"; public static ManualLogSource Log; public static ConfigEntry<KeyCode> ShareHotkey; public static ConfigEntry<bool> DefaultShared; public static ConfigEntry<bool> NotifyOnShare; public static ConfigEntry<bool> NotifyAllPlayersOnShare; public static ConfigEntry<bool> TintSharedPins; public static ConfigEntry<Color> SharedPinTint; public static ConfigEntry<bool> ShowSidebar; private Harmony _harmony; private bool _rpcRegistered; private SidebarUI _sidebar; public static Plugin Instance { get; private set; } private void Awake() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ShareHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1. Controls", "Share Hotkey", (KeyCode)304, "Hold this key while placing a pin to make it shared with the whole server."); DefaultShared = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Controls", "New Pins Shared By Default", false, "If true, new pins are shared by default. Hold the Share Hotkey to make them private instead."); NotifyOnShare = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Notifications", "Show toast when I place shared pin", true, "Display a toast on your screen confirming the pin was shared."); NotifyAllPlayersOnShare = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Notifications", "Announce shared pins to everyone", true, "When someone adds a shared pin, everyone gets a subtle notification."); TintSharedPins = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Appearance", "Tint shared pins", true, "Apply a color tint to shared pins so they look visually different from private ones."); SharedPinTint = ((BaseUnityPlugin)this).Config.Bind<Color>("3. Appearance", "Default shared pin color", new Color(1f, 0.85f, 0.3f, 1f), "Default color for new shared pins. Each pin can override this via the sidebar's Edit dialog."); ShowSidebar = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Sidebar", "Show sidebar on map", true, "Show the shared-pins sidebar when the big map is open."); _harmony = new Harmony("com.stronox.mapmarkers"); _harmony.PatchAll(); AdminCommands.Register(); _sidebar = ((Component)this).gameObject.AddComponent<SidebarUI>(); Log.LogInfo((object)"MapMarkers v0.4.0 loaded."); } private void Update() { if (!_rpcRegistered && ZRoutedRpc.instance != null) { RpcHandler.Register(); _rpcRegistered = true; Log.LogInfo((object)"Registered MapMarkers RPCs."); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public static class RpcHandler { public const string AddPin = "MapMarkers_AddPin"; public const string RemovePin = "MapMarkers_RemovePin"; public const string UpdatePin = "MapMarkers_UpdatePin"; public const string RemoveByOwner = "MapMarkers_RemoveByOwner"; public const string SyncAll = "MapMarkers_SyncAll"; public static void Register() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("MapMarkers_AddPin", (Action<long, ZPackage>)RPC_AddPin); ZRoutedRpc.instance.Register<ZPackage>("MapMarkers_RemovePin", (Action<long, ZPackage>)RPC_RemovePin); ZRoutedRpc.instance.Register<ZPackage>("MapMarkers_UpdatePin", (Action<long, ZPackage>)RPC_UpdatePin); ZRoutedRpc.instance.Register<ZPackage>("MapMarkers_RemoveByOwner", (Action<long, ZPackage>)RPC_RemoveByOwner); ZRoutedRpc.instance.Register<ZPackage>("MapMarkers_SyncAll", (Action<long, ZPackage>)RPC_SyncAll); } } private static bool IsServer() { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } private static void BroadcastToPeers(string rpc, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null) { return; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, rpc, new object[1] { pkg }); } } private static void RPC_AddPin(long sender, ZPackage pkg) { SharedPinStore.SharedPin pin = ReadPin(pkg); if (IsServer()) { SharedPinStore.Add(pin); BroadcastToPeers("MapMarkers_AddPin", WritePin(pin)); } else { MapMarkerClient.AddLocal(pin, Plugin.NotifyAllPlayersOnShare.Value); } } private static void RPC_RemovePin(long sender, ZPackage pkg) { //IL_0001: 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) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0021: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pkg.ReadVector3(); if (IsServer()) { if (SharedPinStore.Remove(val)) { ZPackage val2 = new ZPackage(); val2.Write(val); BroadcastToPeers("MapMarkers_RemovePin", val2); } } else { MapMarkerClient.RemoveLocal(val); } } private static void RPC_UpdatePin(long sender, ZPackage pkg) { //IL_0001: 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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0049: Expected O, but got Unknown //IL_004a: 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_006d: 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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pkg.ReadVector3(); string text = pkg.ReadString(); Color val2 = default(Color); ((Color)(ref val2))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); if (IsServer()) { if (SharedPinStore.UpdatePin(val, text, val2)) { ZPackage val3 = new ZPackage(); val3.Write(val); val3.Write(text ?? ""); val3.Write(val2.r); val3.Write(val2.g); val3.Write(val2.b); val3.Write(val2.a); BroadcastToPeers("MapMarkers_UpdatePin", val3); } } else { MapMarkerClient.UpdateLocal(val, text, val2); } } private static void RPC_RemoveByOwner(long sender, ZPackage pkg) { long ownerId = pkg.ReadLong(); if (IsServer()) { SharedPinStore.RemoveByOwner(ownerId); BroadcastToPeers("MapMarkers_SyncAll", BuildFullSyncPackage()); } } private static void RPC_SyncAll(long sender, ZPackage pkg) { if (!IsServer()) { int num = pkg.ReadInt(); MapMarkerClient.ClearLocal(); for (int i = 0; i < num; i++) { MapMarkerClient.AddLocal(ReadPin(pkg), announce: false); } } } public static ZPackage BuildFullSyncPackage() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(SharedPinStore.All.Count); foreach (SharedPinStore.SharedPin item in SharedPinStore.All) { WritePinInto(val, item); } return val; } public static ZPackage WritePin(SharedPinStore.SharedPin pin) { //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_000c: Expected O, but got Unknown //IL_000d: Expected O, but got Unknown ZPackage val = new ZPackage(); WritePinInto(val, pin); return val; } private static void WritePinInto(ZPackage pkg, SharedPinStore.SharedPin pin) { //IL_0023: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) pkg.Write(pin.OwnerId); pkg.Write(pin.OwnerName ?? ""); pkg.Write(pin.Pos); pkg.Write(pin.Type); pkg.Write(pin.Name ?? ""); pkg.Write(pin.IsChecked); pkg.Write(pin.Color.r); pkg.Write(pin.Color.g); pkg.Write(pin.Color.b); pkg.Write(pin.Color.a); } public static SharedPinStore.SharedPin ReadPin(ZPackage pkg) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) SharedPinStore.SharedPin result = default(SharedPinStore.SharedPin); result.OwnerId = pkg.ReadLong(); result.OwnerName = pkg.ReadString(); result.Pos = pkg.ReadVector3(); result.Type = pkg.ReadInt(); result.Name = pkg.ReadString(); result.IsChecked = pkg.ReadBool(); result.Color = new Color(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); return result; } } public static class SharedPinStore { public struct SharedPin { public long OwnerId; public string OwnerName; public Vector3 Pos; public int Type; public string Name; public bool IsChecked; public Color Color; public static SharedPin WithDefaultColor(SharedPin p) { //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) //IL_000e: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (p.Color == default(Color)) { p.Color = new Color(1f, 0.85f, 0.3f, 1f); } return p; } } private static readonly List<SharedPin> _pins = new List<SharedPin>(); private static string _saveFile; private const int SAVE_VERSION = 2; public static IReadOnlyList<SharedPin> All => _pins; public static void Init(string worldSaveDir, string worldName) { _saveFile = Path.Combine(worldSaveDir, worldName + ".mapmarkers.dat"); Load(); } public static void Add(SharedPin pin) { _pins.Add(pin); Save(); } public static bool Remove(Vector3 pos, float radius = 1.5f) { //IL_0007: 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) int num = _pins.RemoveAll((SharedPin p) => Vector3.Distance(p.Pos, pos) < radius); if (num > 0) { Save(); } return num > 0; } public static bool UpdatePin(Vector3 pos, string newName, Color newColor, float radius = 1.5f) { //IL_0007: 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) //IL_0047: 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) int num = _pins.FindIndex((SharedPin p) => Vector3.Distance(p.Pos, pos) < radius); if (num < 0) { return false; } SharedPin value = _pins[num]; value.Name = newName; value.Color = newColor; _pins[num] = value; Save(); return true; } public static int RemoveByOwner(long ownerId) { int num = _pins.RemoveAll((SharedPin p) => p.OwnerId == ownerId); if (num > 0) { Save(); } return num; } public static void Clear() { _pins.Clear(); Save(); } private static void Save() { //IL_0073: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(_saveFile)) { return; } try { using FileStream output = File.Open(_saveFile, FileMode.Create); using BinaryWriter binaryWriter = new BinaryWriter(output); binaryWriter.Write(2); binaryWriter.Write(_pins.Count); foreach (SharedPin pin in _pins) { binaryWriter.Write(pin.OwnerId); binaryWriter.Write(pin.OwnerName ?? ""); binaryWriter.Write(pin.Pos.x); binaryWriter.Write(pin.Pos.y); binaryWriter.Write(pin.Pos.z); binaryWriter.Write(pin.Type); binaryWriter.Write(pin.Name ?? ""); binaryWriter.Write(pin.IsChecked); binaryWriter.Write(pin.Color.r); binaryWriter.Write(pin.Color.g); binaryWriter.Write(pin.Color.b); binaryWriter.Write(pin.Color.a); } } catch { } } private static void Load() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) _pins.Clear(); if (string.IsNullOrEmpty(_saveFile) || !File.Exists(_saveFile)) { return; } try { using FileStream input = File.OpenRead(_saveFile); using BinaryReader binaryReader = new BinaryReader(input); int num = binaryReader.ReadInt32(); if (num < 1 || num > 2) { return; } int num2 = binaryReader.ReadInt32(); for (int i = 0; i < num2; i++) { SharedPin sharedPin = default(SharedPin); sharedPin.OwnerId = binaryReader.ReadInt64(); sharedPin.OwnerName = binaryReader.ReadString(); sharedPin.Pos = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); sharedPin.Type = binaryReader.ReadInt32(); sharedPin.Name = binaryReader.ReadString(); sharedPin.IsChecked = binaryReader.ReadBoolean(); SharedPin item = sharedPin; if (num >= 2) { item.Color = new Color(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } _pins.Add(item); } } catch { } } } public class SidebarUI : MonoBehaviour { private static readonly Color[] PresetColors = (Color[])(object)new Color[8] { new Color(1f, 0.85f, 0.3f, 1f), new Color(1f, 0.3f, 0.3f, 1f), new Color(0.3f, 0.8f, 1f, 1f), new Color(0.4f, 0.9f, 0.4f, 1f), new Color(0.9f, 0.5f, 1f, 1f), new Color(1f, 0.65f, 0.2f, 1f), new Color(1f, 1f, 1f, 1f), new Color(0.4f, 0.4f, 0.4f, 1f) }; private Vector2 _scroll; private string _search = ""; private bool _editing; private Vector3 _editingPos; private string _editName = ""; private Color _editColor = Color.white; private bool _collapsed; private GUIStyle _box; private GUIStyle _title; private GUIStyle _btn; private GUIStyle _row; private GUIStyle _label; private GUIStyle _field; private GUIStyle _smallBtn; private bool IsMapOpen { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if ((Object)(object)Minimap.instance != (Object)null) { return (int)Minimap.instance.m_mode == 2; } return false; } } private void InitStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0028: Expected O, but got Unknown //IL_002d: Expected O, but got Unknown //IL_0038: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0084: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00df: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown if (_box == null) { _box = new GUIStyle(GUI.skin.box) { padding = new RectOffset(8, 8, 8, 8) }; _title = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, fontSize = 16, alignment = (TextAnchor)3 }; _btn = new GUIStyle(GUI.skin.button) { fontSize = 12, padding = new RectOffset(6, 6, 4, 4) }; _smallBtn = new GUIStyle(GUI.skin.button) { fontSize = 11, padding = new RectOffset(4, 4, 2, 2), fixedHeight = 22f }; _row = new GUIStyle(GUI.skin.box) { padding = new RectOffset(6, 6, 4, 4) }; _label = new GUIStyle(GUI.skin.label) { fontSize = 12, wordWrap = false, clipping = (TextClipping)1 }; _field = new GUIStyle(GUI.skin.textField) { fontSize = 12 }; } } private void OnGUI() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ShowSidebar.Value || !IsMapOpen || (Object)(object)Player.m_localPlayer == (Object)null) { return; } InitStyles(); float num = (_collapsed ? 150 : 340); float num2 = Screen.height - 120; GUILayout.BeginArea(new Rect((float)Screen.width - num - 16f, 70f, num, num2), _box); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(_collapsed ? "Pins" : $"Shared Pins ({MapMarkerClient.LocalCount + CountMine()})", _title, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(_collapsed ? "▸" : "◂", _smallBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) })) { _collapsed = !_collapsed; } GUILayout.EndHorizontal(); if (_collapsed) { GUILayout.EndArea(); return; } GUILayout.Space(4f); _search = GUILayout.TextField(_search, _field, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); foreach (MapMarkerClient.SharedEntry item in CollectAll()) { if (string.IsNullOrEmpty(_search) || (item.Name ?? "").ToLower().Contains(_search.ToLower()) || (item.OwnerName ?? "").ToLower().Contains(_search.ToLower())) { DrawRow(item); } } GUILayout.EndScrollView(); GUILayout.EndArea(); if (_editing) { DrawEditDialog(); } } private void DrawRow(MapMarkerClient.SharedEntry entry) { //IL_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(_row, Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(16f, 16f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(16f), GUILayout.Height(16f) }); Color color = GUI.color; GUI.color = entry.Color; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label(string.IsNullOrEmpty(entry.Name) ? "(no name)" : entry.Name, _label, Array.Empty<GUILayoutOption>()); string text = "by " + (entry.OwnerName ?? "?"); GUIStyle val = new GUIStyle(_label) { fontSize = 10 }; val.normal.textColor = new Color(0.7f, 0.7f, 0.7f); GUILayout.Label(text, val, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Go", _smallBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) })) { CenterMapOn(entry.Pos); } long num = 0L; try { num = ZNet.GetUID(); } catch { } GUI.enabled = entry.OwnerId == num; if (GUILayout.Button("Edit", _smallBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) })) { _editing = true; _editingPos = entry.Pos; _editName = entry.Name ?? ""; _editColor = entry.Color; } if (GUILayout.Button("X", _smallBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { DeletePin(entry.Pos); } GUI.enabled = true; GUILayout.EndHorizontal(); } private void DrawEditDialog() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) float num = 360f; float num2 = 220f; GUILayout.BeginArea(new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2), _box); GUILayout.Label("Edit shared pin", _title, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.Label("Name:", _label, Array.Empty<GUILayoutOption>()); _editName = GUILayout.TextField(_editName, _field, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.Label("Color:", _label, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Color[] presetColors = PresetColors; foreach (Color val in presetColors) { Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = val; if (GUILayout.Button(" ", _smallBtn, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(34f), GUILayout.Height(24f) })) { _editColor = val; } GUI.backgroundColor = backgroundColor; } GUILayout.EndHorizontal(); GUILayout.Space(6f); Color color = GUI.color; GUI.color = _editColor; GUILayout.Label("██ preview", _label, Array.Empty<GUILayoutOption>()); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Cancel", _btn, Array.Empty<GUILayoutOption>())) { _editing = false; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Save", _btn, Array.Empty<GUILayoutOption>())) { SendUpdate(_editingPos, _editName, _editColor); _editing = false; } GUILayout.EndHorizontal(); GUILayout.EndArea(); } private IEnumerable<MapMarkerClient.SharedEntry> CollectAll() { return MapMarkerClient.AllLocal; } private int CountMine() { long num = 0L; try { num = ZNet.GetUID(); } catch { return 0; } int num2 = 0; foreach (MapMarkerClient.SharedEntry item in MapMarkerClient.AllLocal) { if (item.OwnerId == num) { num2++; } } return num2; } private void CenterMapOn(Vector3 pos) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) try { Traverse.Create((object)Minimap.instance).Method("CenterMap", new Type[1] { typeof(Vector3) }, (object[])null).GetValue(new object[1] { pos }); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("CenterMap failed: " + ex.Message)); } } } private void DeletePin(Vector3 pos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance == null) { return; } MapMarkerClient.UntrackLocal(pos); if (MapMarkerClient.AllLocal != null) { foreach (MapMarkerClient.SharedEntry item in MapMarkerClient.AllLocal) { if (Vector3.Distance(item.Pos, pos) < 1f && item.Pin != null) { try { Minimap.instance.RemovePin(item.Pin); } catch { } break; } } } ZPackage val = new ZPackage(); val.Write(pos); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_RemovePin", new object[1] { val }); } private void SendUpdate(Vector3 pos, string newName, Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0016: Expected O, but got Unknown //IL_0017: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance != null) { MapMarkerClient.UpdateLocal(pos, newName, color); ZPackage val = new ZPackage(); val.Write(pos); val.Write(newName ?? ""); val.Write(color.r); val.Write(color.g); val.Write(color.b); val.Write(color.a); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_UpdatePin", new object[1] { val }); } } } } namespace MapMarkers.Patches { [HarmonyPatch(typeof(Minimap))] public static class MinimapPatches { [HarmonyPostfix] [HarmonyPatch("AddPin")] public static void AddPin_Postfix(Vector3 pos, PinType type, string name, bool save, bool isChecked, PinData __result) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected I4, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 try { if (__result == null || !ShouldShare() || MapMarkerClient.IsShared(pos) || ZRoutedRpc.instance == null || (int)type == 4 || (int)type == 12 || (int)type == 13) { return; } Player localPlayer = Player.m_localPlayer; long ownerId = 0L; try { ownerId = ZNet.GetUID(); } catch { } string ownerName = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerName() : ""); MapMarkerClient.RegisterLocalAsShared(pos, __result, ownerId, ownerName); SharedPinStore.SharedPin pin = default(SharedPinStore.SharedPin); pin.OwnerId = ownerId; pin.OwnerName = ownerName; pin.Pos = pos; pin.Type = (int)type; pin.Name = name ?? ""; pin.IsChecked = isChecked; ZPackage val = RpcHandler.WritePin(pin); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_AddPin", new object[1] { val }); if (!Plugin.NotifyOnShare.Value || !((Object)(object)MessageHud.instance != (Object)null)) { return; } string text = (string.IsNullOrEmpty(name) ? "pin" : ("'" + name + "'")); try { MessageHud.instance.ShowMessage((MessageType)1, "Shared " + text + " with server", 0, (Sprite)null, false); } catch { } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("AddPin_Postfix failed: " + ex.Message)); } } } [HarmonyPrefix] [HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })] public static void RemovePin_Prefix(PinData pin) { //IL_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) try { if (pin != null && MapMarkerClient.IsShared(pin.m_pos) && ZRoutedRpc.instance != null) { Vector3 pos = pin.m_pos; MapMarkerClient.UntrackLocal(pos); ZPackage val = new ZPackage(); val.Write(pos); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MapMarkers_RemovePin", new object[1] { val }); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("RemovePin_Prefix failed: " + ex.Message)); } } } public static bool ShouldShare() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) bool key = Input.GetKey(Plugin.ShareHotkey.Value); if (!Plugin.DefaultShared.Value) { return key; } return !key; } } [HarmonyPatch(typeof(ZNet))] public static class ZNetPatches { private static bool _storeInited; [HarmonyPostfix] [HarmonyPatch("SetServer")] public static void SetServer_Postfix(ZNet __instance, bool server, bool openServer, bool publicServer, string serverName, string password, World world) { if (server && !_storeInited && world != null) { string? worldSaveDir = Path.GetDirectoryName(world.GetDBPath()) ?? ""; string worldName = world.m_name ?? "world"; SharedPinStore.Init(worldSaveDir, worldName); _storeInited = true; } } [HarmonyPostfix] [HarmonyPatch("RPC_PeerInfo")] public static void RPC_PeerInfo_Postfix(ZNet __instance, ZRpc rpc) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsServer() || ZRoutedRpc.instance == null) { return; } long num = 0L; foreach (ZNetPeer peer in __instance.GetPeers()) { if (peer.m_rpc == rpc) { num = peer.m_uid; break; } } if (num == 0L) { return; } ZPackage val = new ZPackage(); val.Write(SharedPinStore.All.Count); foreach (SharedPinStore.SharedPin item in SharedPinStore.All) { val.Write(item.OwnerId); val.Write(item.OwnerName ?? ""); val.Write(item.Pos); val.Write(item.Type); val.Write(item.Name ?? ""); val.Write(item.IsChecked); } ZRoutedRpc.instance.InvokeRoutedRPC(num, "MapMarkers_SyncAll", new object[1] { val }); } } }