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 SharedWaypoints v1.0.4
SharedWaypoints.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [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("SharedWaypoints")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4")] [assembly: AssemblyProduct("SharedWaypoints")] [assembly: AssemblyTitle("SharedWaypoints")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 SharedWaypoints { internal static class InputUtil { private static readonly Dictionary<KeyCode, Key> KeyMap = new Dictionary<KeyCode, Key> { { (KeyCode)97, (Key)15 }, { (KeyCode)98, (Key)16 }, { (KeyCode)99, (Key)17 }, { (KeyCode)100, (Key)18 }, { (KeyCode)101, (Key)19 }, { (KeyCode)102, (Key)20 }, { (KeyCode)103, (Key)21 }, { (KeyCode)104, (Key)22 }, { (KeyCode)105, (Key)23 }, { (KeyCode)106, (Key)24 }, { (KeyCode)107, (Key)25 }, { (KeyCode)108, (Key)26 }, { (KeyCode)109, (Key)27 }, { (KeyCode)110, (Key)28 }, { (KeyCode)111, (Key)29 }, { (KeyCode)112, (Key)30 }, { (KeyCode)113, (Key)31 }, { (KeyCode)114, (Key)32 }, { (KeyCode)115, (Key)33 }, { (KeyCode)116, (Key)34 }, { (KeyCode)117, (Key)35 }, { (KeyCode)118, (Key)36 }, { (KeyCode)119, (Key)37 }, { (KeyCode)120, (Key)38 }, { (KeyCode)121, (Key)39 }, { (KeyCode)122, (Key)40 }, { (KeyCode)48, (Key)50 }, { (KeyCode)49, (Key)41 }, { (KeyCode)50, (Key)42 }, { (KeyCode)51, (Key)43 }, { (KeyCode)52, (Key)44 }, { (KeyCode)53, (Key)45 }, { (KeyCode)54, (Key)46 }, { (KeyCode)55, (Key)47 }, { (KeyCode)56, (Key)48 }, { (KeyCode)57, (Key)49 }, { (KeyCode)32, (Key)1 }, { (KeyCode)304, (Key)51 }, { (KeyCode)303, (Key)52 }, { (KeyCode)306, (Key)55 }, { (KeyCode)305, (Key)56 }, { (KeyCode)308, (Key)53 }, { (KeyCode)307, (Key)54 }, { (KeyCode)9, (Key)3 }, { (KeyCode)301, (Key)72 }, { (KeyCode)8, (Key)65 }, { (KeyCode)13, (Key)2 }, { (KeyCode)27, (Key)60 }, { (KeyCode)273, (Key)63 }, { (KeyCode)274, (Key)64 }, { (KeyCode)276, (Key)61 }, { (KeyCode)275, (Key)62 }, { (KeyCode)277, (Key)70 }, { (KeyCode)127, (Key)71 }, { (KeyCode)278, (Key)68 }, { (KeyCode)279, (Key)69 }, { (KeyCode)280, (Key)67 }, { (KeyCode)281, (Key)66 }, { (KeyCode)282, (Key)94 }, { (KeyCode)283, (Key)95 }, { (KeyCode)284, (Key)96 }, { (KeyCode)285, (Key)97 }, { (KeyCode)286, (Key)98 }, { (KeyCode)287, (Key)99 }, { (KeyCode)288, (Key)100 }, { (KeyCode)289, (Key)101 }, { (KeyCode)290, (Key)102 }, { (KeyCode)291, (Key)103 }, { (KeyCode)292, (Key)104 }, { (KeyCode)293, (Key)105 } }; private static readonly Dictionary<KeyCode, bool> WasDown = new Dictionary<KeyCode, bool>(); private static readonly Dictionary<KeyCode, int> EdgeFrame = new Dictionary<KeyCode, int>(); private static readonly Dictionary<KeyCode, bool> EdgeResult = new Dictionary<KeyCode, bool>(); public static bool WasPressedThisFrame(KeyCode keyCode) { //IL_000b: 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) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_008b: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) //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) int frameCount = Time.frameCount; bool value2; if (EdgeFrame.TryGetValue(keyCode, out var value) && value == frameCount) { return EdgeResult.TryGetValue(keyCode, out value2) && value2; } EdgeFrame[keyCode] = frameCount; try { Keyboard current = Keyboard.current; if (current != null && KeyMap.TryGetValue(keyCode, out var value3)) { KeyControl val = current[value3]; if (val != null && ((ButtonControl)val).wasPressedThisFrame) { EdgeResult[keyCode] = true; WasDown[keyCode] = true; return true; } } } catch { } try { if (Input.GetKeyDown(keyCode)) { EdgeResult[keyCode] = true; WasDown[keyCode] = true; return true; } } catch { } bool flag = IsDown(keyCode); bool value4; bool flag2 = WasDown.TryGetValue(keyCode, out value4) && value4; bool flag3 = flag && !flag2; EdgeResult[keyCode] = flag3; WasDown[keyCode] = flag; return flag3; } public static bool IsDown(KeyCode keyCode) { //IL_000e: 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_0035: Unknown result type (might be due to invalid IL or missing references) try { Keyboard current = Keyboard.current; if (current != null && KeyMap.TryGetValue(keyCode, out var value)) { KeyControl val = current[value]; if (val != null && ((ButtonControl)val).isPressed) { return true; } } } catch { } try { if (Input.GetKey(keyCode)) { return true; } } catch { } return false; } public unsafe static string TipLabel(KeyCode keyCode) { //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) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_000c: 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) //IL_0030: Expected I4, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) KeyCode val = keyCode; if ((int)val != 13) { if ((int)val != 27) { switch (val - 303) { case 0: case 1: return "Shift"; case 2: case 3: return "Ctrl"; case 4: case 5: return "Alt"; default: if ((int)keyCode >= 48 && (int)keyCode <= 57) { return ((char)(48 + (keyCode - 48))).ToString(); } return ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString(); } } return "Esc"; } return "Enter"; } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class StartOfRoundStartPatch { private static void Postfix(StartOfRound __instance) { WaypointHud.EnsureExists(); if ((Object)(object)__instance != (Object)null && __instance.inShipPhase) { WaypointRegistry.ClearAll(); WaypointMapMarkers.DestroyAll(); } Plugin.Log.LogInfo((object)"SharedWaypoints HUD ensured after StartOfRound.Start."); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class HudManagerStartPatch { private static void Postfix() { WaypointHud.EnsureExists(); } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] internal static class ShipLeavePatch { private static void Prefix() { WaypointRegistry.ClearAll(); WaypointMapMarkers.DestroyAll(); Plugin.Log.LogInfo((object)"Cleared waypoints on ShipLeave."); } } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] internal static class DisconnectPatch { private static void Prefix() { WaypointRegistry.ClearAll(); WaypointMapMarkers.DestroyAll(); Plugin.Log.LogInfo((object)"Cleared waypoints on disconnect."); } } [BepInPlugin("com.benhough.lethal.SharedWaypoints", "SharedWaypoints", "1.0.4")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.benhough.lethal.SharedWaypoints"; public const string ModName = "SharedWaypoints"; public const string ModVersion = "1.0.4"; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static ConfigEntry<bool> Enabled { get; private set; } internal static ConfigEntry<KeyCode> DropKey { get; private set; } internal static ConfigEntry<KeyCode> ClearKey { get; private set; } internal static ConfigEntry<float> MaxDistance { get; private set; } internal static ConfigEntry<bool> ShowOwnWaypoint { get; private set; } internal static ConfigEntry<float> HudScale { get; private set; } private void Awake() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable shared waypoints."); DropKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DropKey", (KeyCode)289, "Place or replace your waypoint for the current zone (1 indoor + 1 outdoor per player)."); ClearKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ClearKey", (KeyCode)288, "Remove your waypoint for the current zone (indoor/outdoor) for everyone."); MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxDistance", 500f, "Hide waypoint markers beyond this distance (meters)."); ShowOwnWaypoint = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowOwnWaypoint", true, "Show your own waypoint on the HUD and ship radar / map feeds."); HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HudScale", 1f, "Scale of the fixed waypoint HUD panel."); try { new Harmony("com.benhough.lethal.SharedWaypoints").PatchAll(typeof(Plugin).Assembly); WaypointHud.EnsureExists(); Log.LogInfo((object)string.Format("{0} v{1} loaded. Drop={2} Clear={3}.", "SharedWaypoints", "1.0.4", DropKey.Value, ClearKey.Value)); } catch (Exception arg) { Log.LogError((object)$"Failed to start: {arg}"); } } } internal static class PluginInfo { public const string PLUGIN_GUID = "com.benhough.lethal.SharedWaypoints"; public const string PLUGIN_NAME = "SharedWaypoints"; public const string PLUGIN_VERSION = "1.0.4"; } internal sealed class WaypointHud : MonoBehaviour { private static WaypointHud? _instance; private Canvas? _canvas; private RectTransform? _panelRt; private Image? _backdrop; private TextMeshProUGUI? _label; private Text? _fallback; private bool _fontAssigned; private TMP_FontAsset? _tmpFont; private bool _wasInShipPhase; private float _nextRefresh; private string _cachedText = ""; private static readonly Color PanelBg = new Color(0.05f, 0.05f, 0.08f, 0.72f); internal static void EnsureExists() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("SharedWaypointsHUD"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent<WaypointHud>(); } } private void Awake() { _instance = this; BuildUi(); } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } private void BuildUi() { //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_008c: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_018b: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_canvas != (Object)null) { return; } _canvas = ((Component)this).gameObject.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 5000; CanvasScaler obj = ((Component)this).gameObject.AddComponent<CanvasScaler>(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); ((Component)this).gameObject.AddComponent<GraphicRaycaster>(); GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform, false); _panelRt = val.GetComponent<RectTransform>(); _panelRt.anchorMin = new Vector2(1f, 1f); _panelRt.anchorMax = new Vector2(1f, 1f); _panelRt.pivot = new Vector2(1f, 1f); _panelRt.sizeDelta = new Vector2(340f, 160f); _panelRt.anchoredPosition = new Vector2(-24f, -96f); _backdrop = val.AddComponent<Image>(); ((Graphic)_backdrop).color = PanelBg; ((Graphic)_backdrop).raycastTarget = false; GameObject val2 = new GameObject("Label", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = new Vector2(12f, 8f); component.offsetMax = new Vector2(-12f, -8f); try { _label = val2.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_label).alignment = (TextAlignmentOptions)257; ((TMP_Text)_label).fontStyle = (FontStyles)0; ((TMP_Text)_label).enableWordWrapping = true; ((Graphic)_label).raycastTarget = false; ((TMP_Text)_label).overflowMode = (TextOverflowModes)0; ((TMP_Text)_label).fontSize = 20f; ((TMP_Text)_label).lineSpacing = 2f; ((Graphic)_label).color = Color.white; ((TMP_Text)_label).text = ""; } catch { _fallback = val2.AddComponent<Text>(); _fallback.alignment = (TextAnchor)0; ((Graphic)_fallback).raycastTarget = false; _fallback.fontSize = 16; _fallback.horizontalOverflow = (HorizontalWrapMode)0; _fallback.verticalOverflow = (VerticalWrapMode)1; ((Graphic)_fallback).color = Color.white; Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf"); if (builtinResource != null) { _fallback.font = builtinResource; } _fallback.text = ""; } SetPanelVisible(visible: false); Plugin.Log.LogInfo((object)"SharedWaypoints fixed HUD panel built (top-right)."); } private void Update() { WaypointNet.EnsureRegistered(); HandleInput(); MaybeClearOnShipPhase(); } private void LateUpdate() { if ((Object)(object)_canvas == (Object)null) { BuildUi(); } TryAssignFont(); WaypointMapMarkers.Sync(); if (!(Time.unscaledTime < _nextRefresh)) { _nextRefresh = Time.unscaledTime + 0.1f; RefreshPanel(); } } private void MaybeClearOnShipPhase() { StartOfRound instance = StartOfRound.Instance; bool flag = (Object)(object)instance != (Object)null && instance.inShipPhase; if (flag && !_wasInShipPhase) { WaypointRegistry.ClearAll(); WaypointMapMarkers.DestroyAll(); Plugin.Log.LogInfo((object)"Cleared waypoints entering ship phase."); } _wasInShipPhase = flag; } private void HandleInput() { //IL_004e: 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) if (Plugin.Enabled == null || !Plugin.Enabled.Value) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !val.isTypingChat && !val.inTerminalMenu) { if (InputUtil.WasPressedThisFrame(Plugin.DropKey.Value)) { DropWaypoint(val); } if (InputUtil.WasPressedThisFrame(Plugin.ClearKey.Value)) { ClearWaypoint(val); } } } private static void DropWaypoint(PlayerControllerB player) { //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_00c1: Unknown result type (might be due to invalid IL or missing references) WaypointState waypointState = new WaypointState { OwnerPlayerClientId = player.playerClientId, OwnerName = (string.IsNullOrEmpty(player.playerUsername) ? "Player" : player.playerUsername), Position = ((Component)player).transform.position, IsInside = player.isInsideFactory, ColorIndex = WaypointState.ColorIndexFor(player.playerClientId) }; WaypointRegistry.Set(waypointState); WaypointNet.BroadcastSet(waypointState); string text = (waypointState.IsInside ? "inside" : "outside"); Feedback("Waypoint dropped (" + text + ")", "Shared Waypoint", "Dropped " + text + " pin (keeps your other zone pin)."); Plugin.Log.LogInfo((object)$"Dropped waypoint inside={waypointState.IsInside} pos={waypointState.Position} owner={waypointState.OwnerPlayerClientId}."); } private static void ClearWaypoint(PlayerControllerB player) { ulong playerClientId = player.playerClientId; bool isInsideFactory = player.isInsideFactory; if (!WaypointRegistry.TryGet(playerClientId, isInsideFactory, out WaypointState _)) { string text = (isInsideFactory ? "indoor" : "outdoor"); Feedback("No " + text + " waypoint", "Shared Waypoint", "You have no " + text + " pin to clear."); return; } WaypointRegistry.Clear(playerClientId, isInsideFactory); WaypointNet.BroadcastClear(playerClientId, isInsideFactory); string text2 = (isInsideFactory ? "indoor" : "outdoor"); Feedback("Waypoint cleared (" + text2 + ")", "Shared Waypoint", "Your " + text2 + " pin was removed."); Plugin.Log.LogInfo((object)$"Cleared own waypoint owner={playerClientId} inside={isInsideFactory}."); } private static void Feedback(string tip, string title, string body) { try { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null)) { instance.ChangeControlTip(3, tip, false); instance.DisplayTip(title, body, false, false, "LC_Tip1"); } } catch { } } private void TryAssignFont() { if (_fontAssigned) { return; } try { TMP_FontAsset val = null; HUDManager instance = HUDManager.Instance; if ((Object)(object)instance != (Object)null) { if ((Object)(object)instance.clockNumber != (Object)null && (Object)(object)((TMP_Text)instance.clockNumber).font != (Object)null) { val = ((TMP_Text)instance.clockNumber).font; } if ((Object)(object)val == (Object)null && instance.controlTipLines != null) { TextMeshProUGUI[] controlTipLines = instance.controlTipLines; foreach (TextMeshProUGUI val2 in controlTipLines) { if ((Object)(object)val2 != (Object)null && (Object)(object)((TMP_Text)val2).font != (Object)null) { val = ((TMP_Text)val2).font; break; } } } if ((Object)(object)val == (Object)null && (Object)(object)instance.weightCounter != (Object)null) { val = ((TMP_Text)instance.weightCounter).font; } } if ((Object)(object)val == (Object)null && (Object)(object)TMP_Settings.defaultFontAsset != (Object)null) { val = TMP_Settings.defaultFontAsset; } if ((Object)(object)val != (Object)null) { _tmpFont = val; _fontAssigned = true; if ((Object)(object)_label != (Object)null) { ((TMP_Text)_label).font = val; } Plugin.Log.LogInfo((object)("SharedWaypoints TMP font assigned: " + ((Object)val).name)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Font assign failed: " + ex.Message)); } } private void RefreshPanel() { //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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_canvas == (Object)null || (Object)(object)_panelRt == (Object)null) { return; } if (Plugin.Enabled == null || !Plugin.Enabled.Value) { SetPanelVisible(visible: false); return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || val.isPlayerDead) { SetPanelVisible(visible: false); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.inShipPhase) { SetPanelVisible(visible: false); return; } bool isInsideFactory = val.isInsideFactory; Vector3 position = ((Component)val).transform.position; ulong playerClientId = val.playerClientId; float num = Plugin.MaxDistance?.Value ?? 500f; bool flag = Plugin.ShowOwnWaypoint == null || Plugin.ShowOwnWaypoint.Value; float num2 = Mathf.Clamp(Plugin.HudScale?.Value ?? 1f, 0.6f, 2f); ((Transform)_panelRt).localScale = Vector3.one * num2; List<(string, Color)> list = new List<(string, Color)>(); foreach (WaypointState item3 in WaypointRegistry.Snapshot()) { if (item3.IsInside == isInsideFactory && (flag || item3.OwnerPlayerClientId != playerClientId)) { float num3 = Vector3.Distance(position, item3.Position); if (!(num3 > num)) { string text = BearingArrow(val, item3.Position); string text2 = Shorten(item3.OwnerName, 14); string text3 = (item3.IsInside ? "IN" : "OUT"); string text4 = ((item3.OwnerPlayerClientId == playerClientId) ? "*" : " "); list.Add(($"{text4}{text} {text2} {num3:0}m [{text3}]", item3.Color)); } } } if (list.Count == 0) { SetPanelVisible(visible: false); return; } StringBuilder stringBuilder = new StringBuilder(128); stringBuilder.Append("<color=#FFAA55>WAYPOINTS</color>\n"); foreach (var item4 in list) { string item = item4.Item1; string value = ColorUtility.ToHtmlStringRGB(item4.Item2); stringBuilder.Append("<color=#").Append(value).Append('>') .Append(item) .Append("</color>\n"); } string text5 = stringBuilder.ToString().TrimEnd(); if (text5 != _cachedText) { _cachedText = text5; if ((Object)(object)_label != (Object)null) { ((TMP_Text)_label).text = text5; ((Graphic)_label).color = Color.white; } else if ((Object)(object)_fallback != (Object)null) { StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.AppendLine("WAYPOINTS"); foreach (var item5 in list) { string item2 = item5.Item1; stringBuilder2.AppendLine(item2); } _fallback.text = stringBuilder2.ToString().TrimEnd(); } } float num4 = Mathf.Clamp(36f + (float)list.Count * 26f, 60f, 280f); _panelRt.sizeDelta = new Vector2(340f, num4); SetPanelVisible(visible: true); } private void SetPanelVisible(bool visible) { if ((Object)(object)_panelRt != (Object)null && ((Component)_panelRt).gameObject.activeSelf != visible) { ((Component)_panelRt).gameObject.SetActive(visible); } if (!visible) { _cachedText = ""; } } private static string Shorten(string name, int max) { if (string.IsNullOrEmpty(name)) { return "?"; } if (name.Length > max) { return name.Substring(0, max - 1) + "…"; } return name; } private static string BearingArrow(PlayerControllerB player, Vector3 target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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_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_0065: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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) Vector3 val = target - ((Component)player).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return "●"; } Vector3 forward = ((Component)player).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); float num = Vector3.SignedAngle(forward, ((Vector3)(ref val)).normalized, Vector3.up); float num2 = Mathf.Abs(num); if (num2 < 22.5f) { return "↑"; } if (num2 > 157.5f) { return "↓"; } if (num > 0f) { if (num < 67.5f) { return "↗"; } if (num < 112.5f) { return "→"; } return "↘"; } if (num > -67.5f) { return "↖"; } if (num > -112.5f) { return "←"; } return "↙"; } } internal static class WaypointMapMarkers { private sealed class MarkerVisual { public GameObject Go; public RectTransform Rt; public TextMeshProUGUI? Label; public Image? Box; public Text? FallbackText; public float BaseScale = 1f; } private const string RootName = "SharedWaypointMapMarkers"; private const float HeightOffset = 1.35f; private const float NearScaleDistance = 8f; private const float NearScale = 1.8f; private const float FarScale = 1f; private static Transform? _root; private static readonly Dictionary<(ulong Owner, bool Inside), MarkerVisual> Markers = new Dictionary<(ulong, bool), MarkerVisual>(); private static Sprite? _fallbackSprite; public static void Sync() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Enabled == null || !Plugin.Enabled.Value) { DestroyAll(); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.inShipPhase) { DestroyAll(); } else { if (!EnsureRoot(instance)) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; ulong num = (((Object)(object)val != (Object)null) ? val.playerClientId : ulong.MaxValue); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); bool flag = (Object)(object)val != (Object)null && !val.isPlayerDead; float num2 = Plugin.MaxDistance?.Value ?? 500f; bool flag2 = Plugin.ShowOwnWaypoint == null || Plugin.ShowOwnWaypoint.Value; Camera val3 = (((Object)(object)instance.mapScreen != (Object)null) ? instance.mapScreen.mapCamera : null); Vector3 mapCamPos = (((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : Vector3.zero); HashSet<(ulong, bool)> hashSet = new HashSet<(ulong, bool)>(); foreach (WaypointState item in WaypointRegistry.Snapshot()) { (ulong, bool) tuple = (item.OwnerPlayerClientId, item.IsInside); hashSet.Add(tuple); if (!flag2 && item.OwnerPlayerClientId == num) { HideOrRemove(tuple); continue; } bool flag3 = true; if (flag && Vector3.Distance(val2, item.Position) > num2) { flag3 = false; } if (!Markers.TryGetValue(tuple, out MarkerVisual value) || (Object)(object)value.Go == (Object)null) { value = CreateMarker(item); if (value == null) { continue; } Markers[tuple] = value; } else { ApplyLabelAndColor(value, item); } PositionMarker(value, item.Position); if (value.Go.activeSelf != flag3) { value.Go.SetActive(flag3); } if (flag3) { UpdateScale(value, (Object)(object)val3 != (Object)null, mapCamPos); } } List<(ulong, bool)> list = null; foreach (KeyValuePair<(ulong, bool), MarkerVisual> marker in Markers) { if (!hashSet.Contains(marker.Key)) { if (list == null) { list = new List<(ulong, bool)>(); } list.Add(marker.Key); } } if (list == null) { return; } foreach (var item2 in list) { if (Markers.TryGetValue(item2, out MarkerVisual value2) && (Object)(object)value2.Go != (Object)null) { Object.Destroy((Object)(object)value2.Go); } Markers.Remove(item2); } } } public static void DestroyAll() { foreach (KeyValuePair<(ulong, bool), MarkerVisual> marker in Markers) { if ((Object)(object)marker.Value.Go != (Object)null) { Object.Destroy((Object)(object)marker.Value.Go); } } Markers.Clear(); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); _root = null; } } private static void HideOrRemove((ulong, bool) key) { if (Markers.TryGetValue(key, out MarkerVisual value)) { if ((Object)(object)value.Go != (Object)null) { Object.Destroy((Object)(object)value.Go); } Markers.Remove(key); } } private static bool EnsureRoot(StartOfRound start) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) ManualCameraRenderer mapScreen = start.mapScreen; if ((Object)(object)mapScreen == (Object)null || (Object)(object)mapScreen.mapCameraStationaryUI == (Object)null) { DestroyAll(); return false; } Transform mapCameraStationaryUI = mapScreen.mapCameraStationaryUI; if ((Object)(object)_root != (Object)null && (Object)(object)_root.parent != (Object)(object)mapCameraStationaryUI) { DestroyAll(); } if ((Object)(object)_root == (Object)null) { GameObject val = new GameObject("SharedWaypointMapMarkers"); val.transform.SetParent(mapCameraStationaryUI, false); _root = val.transform; } return true; } private static MarkerVisual? CreateMarker(WaypointState wp) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return null; } StartOfRound instance = StartOfRound.Instance; bool flag = false; GameObject val; if ((Object)(object)instance != (Object)null && (Object)(object)instance.objectCodePrefab != (Object)null) { val = Object.Instantiate<GameObject>(instance.objectCodePrefab, _root, false); ((Object)val).name = string.Format("WP_{0}_{1}", wp.OwnerPlayerClientId, wp.IsInside ? "In" : "Out"); flag = true; } else { val = BuildFallbackMarker(); ((Object)val).name = string.Format("WP_{0}_{1}", wp.OwnerPlayerClientId, wp.IsInside ? "In" : "Out"); val.transform.SetParent(_root, false); } RectTransform val2 = val.GetComponent<RectTransform>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<RectTransform>(); } MarkerVisual markerVisual = new MarkerVisual { Go = val, Rt = val2, Label = val.GetComponentInChildren<TextMeshProUGUI>(true), Box = val.GetComponentInChildren<Image>(true), FallbackText = (flag ? null : val.GetComponentInChildren<Text>(true)), BaseScale = (flag ? 1f : 0.02f) }; val.transform.localScale = Vector3.one * markerVisual.BaseScale; if ((Object)(object)markerVisual.Box == (Object)null) { Image[] componentsInChildren = val.GetComponentsInChildren<Image>(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { markerVisual.Box = componentsInChildren[0]; } } ApplyLabelAndColor(markerVisual, wp); PositionMarker(markerVisual, wp.Position); return markerVisual; } private static GameObject BuildFallbackMarker() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a2: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SharedWaypointFallback", new Type[1] { typeof(RectTransform) }); val.GetComponent<RectTransform>().sizeDelta = new Vector2(48f, 28f); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.sortingOrder = 100; GameObject val2 = new GameObject("Box", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image obj2 = val2.AddComponent<Image>(); ((Graphic)obj2).raycastTarget = false; obj2.sprite = GetFallbackSprite(); ((Graphic)obj2).color = Color.white; GameObject val3 = new GameObject("Label", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val.transform, false); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = new Vector2(2f, 1f); component2.offsetMax = new Vector2(-2f, -1f); try { TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val4).alignment = (TextAlignmentOptions)514; ((TMP_Text)val4).fontSize = 14f; ((Graphic)val4).raycastTarget = false; ((Graphic)val4).color = Color.white; if ((Object)(object)TMP_Settings.defaultFontAsset != (Object)null) { ((TMP_Text)val4).font = TMP_Settings.defaultFontAsset; } } catch { Text val5 = val3.AddComponent<Text>(); val5.alignment = (TextAnchor)4; val5.fontSize = 12; ((Graphic)val5).raycastTarget = false; ((Graphic)val5).color = Color.white; Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf"); if (builtinResource != null) { val5.font = builtinResource; } } return val; } private static Sprite GetFallbackSprite() { //IL_0032: 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) if ((Object)(object)_fallbackSprite != (Object)null) { return _fallbackSprite; } Texture2D whiteTexture = Texture2D.whiteTexture; _fallbackSprite = Sprite.Create(whiteTexture, new Rect(0f, 0f, (float)((Texture)whiteTexture).width, (float)((Texture)whiteTexture).height), new Vector2(0.5f, 0.5f), 100f); return _fallbackSprite; } private static void ApplyLabelAndColor(MarkerVisual marker, WaypointState wp) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0056: 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) string text = FormatLabel(wp); Color color = wp.Color; if ((Object)(object)marker.Label != (Object)null) { ((TMP_Text)marker.Label).text = text; ((Graphic)marker.Label).color = color; } else if ((Object)(object)marker.FallbackText != (Object)null) { marker.FallbackText.text = text; ((Graphic)marker.FallbackText).color = color; } if ((Object)(object)marker.Box != (Object)null) { ((Graphic)marker.Box).color = color; } } private static string FormatLabel(WaypointState wp) { string text = wp.OwnerName; if (string.IsNullOrEmpty(text)) { text = "?"; } string obj = ((text.Length <= 8) ? text : (text.Substring(0, 7) + "…")); string text2 = (wp.IsInside ? "In" : "Out"); return obj + " " + text2; } private static void PositionMarker(MarkerVisual marker, Vector3 worldPos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0034: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) Transform rt = (Transform)(object)marker.Rt; rt.position = worldPos + Vector3.up * 1.35f; rt.position += rt.up * 1.2f - rt.right * 1.2f; } private static void UpdateScale(MarkerVisual marker, bool hasMapCam, Vector3 mapCamPos) { //IL_0012: 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_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_0076: Unknown result type (might be due to invalid IL or missing references) if (hasMapCam && !((Object)(object)marker.Go == (Object)null)) { float num = ((Vector3.Distance(mapCamPos, marker.Go.transform.position) < 8f) ? 1.8f : 1f); float num2 = marker.BaseScale * num; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num2, num2, num2); marker.Go.transform.localScale = Vector3.Lerp(marker.Go.transform.localScale, val, Time.deltaTime * 10f); } } } internal static class WaypointNet { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnMessage; public static Action<ulong> <1>__OnClientConnected; } public const string MessageName = "MrGlim.SharedWaypoints"; private static bool _registered; private static bool _clientConnectedHooked; private static bool _requestedSync; public static void EnsureRegistered() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { _registered = false; _clientConnectedHooked = false; _requestedSync = false; return; } if (!_registered) { CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; object obj = <>O.<0>__OnMessage; if (obj == null) { HandleNamedMessageDelegate val = OnMessage; <>O.<0>__OnMessage = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MrGlim.SharedWaypoints", (HandleNamedMessageDelegate)obj); _registered = true; Plugin.Log.LogInfo((object)"SharedWaypoints net handler registered."); } if (singleton.IsServer && !_clientConnectedHooked) { singleton.OnClientConnectedCallback += OnClientConnected; _clientConnectedHooked = true; } if (!singleton.IsServer && singleton.IsConnectedClient && !_requestedSync) { _requestedSync = true; RequestSync(); } } public unsafe static void BroadcastSet(WaypointState state) { //IL_0016: 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_0045: 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) EnsureRegistered(); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } FastBufferWriter val = WriteSet(state); try { if (singleton.IsServer) { singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2); } else { singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public static void BroadcastClear(ulong ownerPlayerClientId, bool isInside) { //IL_0028: 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_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) EnsureRegistered(); NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null)) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(24, (Allocator)2, -1); byte b = 0; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref ownerPlayerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isInside, default(ForPrimitives)); if (singleton.IsServer) { singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2); } else { singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2); } ((FastBufferWriter)(ref val)).Dispose(); } } private static void RequestSync() { //IL_002b: 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) //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_005a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && !singleton.IsServer) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); byte b = 2; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ulong num = 0uL; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2); ((FastBufferWriter)(ref val)).Dispose(); Plugin.Log.LogInfo((object)"Requested waypoint sync from server."); } } private static void OnClientConnected(ulong clientId) { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsServer && clientId != singleton.LocalClientId) { SendAllToClient(clientId); } } private unsafe static void SendAllToClient(ulong clientId) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } foreach (WaypointState item in WaypointRegistry.Snapshot()) { FastBufferWriter val = WriteSet(item); try { singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", clientId, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } Plugin.Log.LogInfo((object)$"Resynced {WaypointRegistry.Count} waypoint(s) to client {clientId}."); } private static FastBufferWriter WriteSet(WaypointState state) { //IL_002f: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00ad: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) int byteCount = Encoding.UTF8.GetByteCount(state.OwnerName ?? ""); FastBufferWriter result = default(FastBufferWriter); ((FastBufferWriter)(ref result))..ctor(48 + byteCount, (Allocator)2, -1); byte b = 1; ((FastBufferWriter)(ref result)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe<ulong>(ref state.OwnerPlayerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(state.OwnerName ?? "", false); ((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.x, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.y, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.z, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref state.IsInside, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe<int>(ref state.ColorIndex, default(ForPrimitives)); return result; } private unsafe static void OnMessage(ulong sender, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0041: 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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c8: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); NetworkManager singleton = NetworkManager.Singleton; if (b == 2) { if ((Object)(object)singleton != (Object)null && singleton.IsServer) { SendAllToClient(sender); } return; } ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); switch (b) { case 0: { bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); WaypointRegistry.Clear(num, flag2); Plugin.Log.LogInfo((object)$"Waypoint cleared for owner={num} inside={flag2}."); if ((Object)(object)singleton != (Object)null && singleton.IsServer) { FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(24, (Allocator)2, -1); byte b2 = 0; ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b2, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val2, (NetworkDelivery)2); ((FastBufferWriter)(ref val2)).Dispose(); } break; } case 1: { string text = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); float num2 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); float num4 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num4, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int colorIndex = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref colorIndex, default(ForPrimitives)); WaypointState state = new WaypointState { OwnerPlayerClientId = num, OwnerName = (text ?? ""), Position = new Vector3(num2, num3, num4), IsInside = flag, ColorIndex = colorIndex }; WaypointRegistry.Set(state); Plugin.Log.LogInfo((object)$"Waypoint set owner={num} name='{text}' inside={flag} pos=({num2:0.0},{num3:0.0},{num4:0.0})."); if ((Object)(object)singleton != (Object)null && singleton.IsServer && sender != 0L) { FastBufferWriter val = WriteSet(state); try { singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2); break; } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } break; } } } } internal static class WaypointRegistry { private static readonly Dictionary<(ulong Owner, bool Inside), WaypointState> BySlot = new Dictionary<(ulong, bool), WaypointState>(); public static int Count => BySlot.Count; public static void Set(WaypointState state) { BySlot[(state.OwnerPlayerClientId, state.IsInside)] = state; } public static void Clear(ulong ownerPlayerClientId, bool isInside) { BySlot.Remove((ownerPlayerClientId, isInside)); } public static void ClearOwner(ulong ownerPlayerClientId) { BySlot.Remove((ownerPlayerClientId, false)); BySlot.Remove((ownerPlayerClientId, true)); } public static bool TryGet(ulong ownerPlayerClientId, bool isInside, out WaypointState state) { return BySlot.TryGetValue((ownerPlayerClientId, isInside), out state); } public static bool HasAny(ulong ownerPlayerClientId) { if (!BySlot.ContainsKey((ownerPlayerClientId, false))) { return BySlot.ContainsKey((ownerPlayerClientId, true)); } return true; } public static void ClearAll() { BySlot.Clear(); } public static IEnumerable<WaypointState> Snapshot() { return BySlot.Values.ToList(); } } internal sealed class WaypointState { public ulong OwnerPlayerClientId; public string OwnerName = ""; public Vector3 Position; public bool IsInside; public int ColorIndex; public Color Color => WaypointPalette.Get(ColorIndex); public static int ColorIndexFor(ulong clientId) { return (int)(clientId % (ulong)WaypointPalette.Count); } } internal static class WaypointPalette { private static readonly Color[] Colors = (Color[])(object)new Color[8] { new Color(0.95f, 0.45f, 0.2f, 1f), new Color(0.3f, 0.85f, 0.95f, 1f), new Color(0.55f, 0.95f, 0.35f, 1f), new Color(0.95f, 0.35f, 0.75f, 1f), new Color(0.95f, 0.9f, 0.25f, 1f), new Color(0.55f, 0.55f, 1f, 1f), new Color(1f, 0.55f, 0.35f, 1f), new Color(0.4f, 0.95f, 0.7f, 1f) }; public static int Count => Colors.Length; public static Color Get(int index) { //IL_0008: 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) if (Colors.Length == 0) { return Color.white; } int num = index % Colors.Length; if (num < 0) { num += Colors.Length; } return Colors[num]; } } }