using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BifrostBeacon; [BepInPlugin("com.drakosdj.bifrostbeacon", "BifrostBeacon", "1.0.3")] public class BifrostBeaconPlugin : BaseUnityPlugin { public class PeerBeaconInfo { public Vector3 Position; public string Name; public float AudioPitch; public string PlayerName; public WorldTextInstance WorldTextInstance; public BifrostBeam BeamInstance; public float AudioTimer; } public static ConfigEntry configModEnabled; public static ConfigEntry configModifierKey; public static ConfigEntry configShowHudMessage; public static ConfigEntry configShowVisualBeam; public static ConfigEntry configPlayAudioBeeps; public static ConfigEntry configAudioRange; public static ConfigEntry configAudioPitch; public static ConfigEntry configShowPeerHudMessage; public static ConfigEntry configShowPeerVisualBeam; public static Vector3? activeBeaconPosition = null; public static string activeBeaconName = ""; public static WorldTextInstance activeBeaconWorldText = null; public static BifrostBeam beamInstance = null; public static readonly long BeaconTalkerID = 20260708L; public static float audioTimer = 0f; public static float broadcastTimer = 0f; public static Dictionary peerBeacons = new Dictionary(); public static BifrostBeaconPlugin instance; private void Awake() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown instance = this; configModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "ModEnabled", true, "If true, the entire mod is active. If false, disables all beacons, visual beams, and audio sounds."); configModifierKey = ((BaseUnityPlugin)this).Config.Bind("Keybinds", "ModifierKey", (KeyCode)304, "Modifier key held during map middle-click to set or toggle the beacon waypoint."); configShowHudMessage = ((BaseUnityPlugin)this).Config.Bind("General", "ShowHudMessage", true, "If true, displays the distance and height difference to the beacon on the 3D HUD waypoint text."); configShowVisualBeam = ((BaseUnityPlugin)this).Config.Bind("General", "ShowVisualBeam", true, "If true, projects a vertical shifting rainbow light beam from the beacon waypoint."); configPlayAudioBeeps = ((BaseUnityPlugin)this).Config.Bind("Audio", "PlayAudioBeeps", true, "If true, plays proximity audio beeps (wishbone sound) that speed up and get sharper as you approach."); configAudioRange = ((BaseUnityPlugin)this).Config.Bind("Audio", "AudioRange", 100f, "Maximum distance in meters at which the proximity audio beeping starts."); configAudioPitch = ((BaseUnityPlugin)this).Config.Bind("Audio", "AudioPitch", 1.5f, "Pitch of the proximity audio beep (1.0 is default wishbone, higher is sharper/more distinct)."); configShowPeerHudMessage = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "ShowPeerHudMessage", true, "If true, displays other players' active waypoints on the 3D HUD."); configShowPeerVisualBeam = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "ShowPeerVisualBeam", false, "If true, projects vertical rainbow light beams from other players' waypoints."); Harmony val = new Harmony("com.drakosdj.bifrostbeacon"); val.PatchAll(); Debug.Log((object)"[BifrostBeacon] Plugin loaded successfully!"); } public static void SetBeacon(Vector3 position, string name) { //IL_006a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if (configModEnabled.Value) { float y = position.y; float num = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(position, ref num)) { y = num + 1.5f; } position.y = y; Debug.Log((object)string.Concat("[BifrostBeacon] Setting beacon at ", position, " named: ", name)); ClearBeacon(); activeBeaconPosition = position; activeBeaconName = (string.IsNullOrEmpty(name) ? "Beacon" : name); if (configShowVisualBeam.Value) { GameObject val = new GameObject("BifrostBeaconBeam"); beamInstance = val.AddComponent(); beamInstance.SetPositions(position, position + Vector3.up * 1000f); } BroadcastLocalBeacon(); } } public static void ClearBeacon() { Debug.Log((object)"[BifrostBeacon] Clearing active beacon"); activeBeaconPosition = null; activeBeaconName = ""; if ((Object)(object)Chat.instance != (Object)null && activeBeaconWorldText != null) { if ((Object)(object)activeBeaconWorldText.m_gui != (Object)null) { Object.Destroy((Object)(object)activeBeaconWorldText.m_gui); } GetWorldTexts(Chat.instance)?.Remove(activeBeaconWorldText); activeBeaconWorldText = null; } if ((Object)(object)beamInstance != (Object)null) { Object.Destroy((Object)(object)((Component)beamInstance).gameObject); beamInstance = null; } if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "BifrostBeacon_ClearBeacon", new object[0]); } } public static void ClearPeerBeacon(long sender) { if (!peerBeacons.TryGetValue(sender, out var value)) { return; } if ((Object)(object)Chat.instance != (Object)null && value.WorldTextInstance != null) { if ((Object)(object)value.WorldTextInstance.m_gui != (Object)null) { Object.Destroy((Object)(object)value.WorldTextInstance.m_gui); } GetWorldTexts(Chat.instance)?.Remove(value.WorldTextInstance); value.WorldTextInstance = null; } if ((Object)(object)value.BeamInstance != (Object)null) { Object.Destroy((Object)(object)((Component)value.BeamInstance).gameObject); value.BeamInstance = null; } } public static void ClearAllBeacons() { ClearBeacon(); foreach (long item in peerBeacons.Keys.ToList()) { ClearPeerBeacon(item); } peerBeacons.Clear(); } public static void BroadcastLocalBeacon() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance != null && activeBeaconPosition.HasValue) { string text = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerName() : "Player"); string text2 = activeBeaconName + "|" + text; ZRoutedRpc.instance.InvokeRoutedRPC(0L, "BifrostBeacon_SetBeacon", new object[3] { activeBeaconPosition.Value, text2, configAudioPitch.Value }); } } public static void RPC_SetBeacon(long sender, Vector3 position, string nameAndPlayer, float audioPitch) { //IL_00a7: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null && sender == ZNet.GetUID()) { return; } string text = "Beacon"; string text2 = "Player"; if (!string.IsNullOrEmpty(nameAndPlayer)) { int num = nameAndPlayer.IndexOf('|'); if (num >= 0) { text = nameAndPlayer.Substring(0, num); text2 = nameAndPlayer.Substring(num + 1); } else { text = nameAndPlayer; } } Debug.Log((object)string.Concat("[BifrostBeacon] Received SetBeacon RPC from peer: ", sender, " name: ", text, " pos: ", position, " pitch: ", audioPitch, " player: ", text2)); if (!peerBeacons.TryGetValue(sender, out var value)) { value = new PeerBeaconInfo(); peerBeacons[sender] = value; } else if (value.Position != position) { ClearPeerBeacon(sender); } value.Position = position; value.Name = (string.IsNullOrEmpty(text) ? "Beacon" : text); value.AudioPitch = audioPitch; value.PlayerName = text2; } public static void RPC_ClearBeacon(long sender) { if (!((Object)(object)ZNet.instance != (Object)null) || sender != ZNet.GetUID()) { Debug.Log((object)("[BifrostBeacon] Received ClearBeacon RPC from peer: " + sender)); ClearPeerBeacon(sender); peerBeacons.Remove(sender); } } public static void AddInworldTextForPeer(Chat chat, long talkerID, Vector3 position, string text) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chat == (Object)null) { return; } try { MethodInfo method = typeof(Chat).GetMethod("AddInworldText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object obj = null; try { obj = UserInfo.GetLocalUser(); } catch (Exception) { } method.Invoke(chat, new object[6] { null, talkerID, position, (object)(Type)3, obj, text }); } } catch (Exception ex2) { Debug.LogWarning((object)("[BifrostBeacon] Failed to invoke Chat.AddInworldText for peer: " + ex2.Message)); } } public static List GetAllPlayers() { try { MethodInfo method = typeof(Player).GetMethod("GetAllPlayers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && method.Invoke(null, null) is List result) { return result; } FieldInfo field = typeof(Player).GetField("m_players", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.GetValue(null) is List result2) { return result2; } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed to get player list: " + ex.Message)); } return new List(); } public static long GetZDOOwner(object zdo) { if (zdo == null) { return 0L; } try { MethodInfo method = zdo.GetType().GetMethod("GetOwner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (long)method.Invoke(zdo, null); } FieldInfo field = zdo.GetType().GetField("m_owner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (long)field.GetValue(zdo); } } catch (Exception) { } return 0L; } public static Player FindPlayerByPeerID(long peerID) { List allPlayers = GetAllPlayers(); foreach (Player item in allPlayers) { if ((Object)(object)item == (Object)null) { continue; } ZNetView component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { ZDO zDO = component.GetZDO(); if (zDO != null && GetZDOOwner(zDO) == peerID) { return item; } } } return null; } public static long GetZDOIDUserID(ZDOID zdoid) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) try { PropertyInfo property = typeof(ZDOID).GetProperty("UserID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { return (long)property.GetValue(zdoid, null); } MethodInfo method = typeof(ZDOID).GetMethod("GetUserID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (long)method.Invoke(zdoid, null); } FieldInfo field = typeof(ZDOID).GetField("m_userID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { field = typeof(ZDOID).GetField("userID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (field != null) { return (long)field.GetValue(zdoid); } } catch (Exception) { } return 0L; } public static string FindPlayerNameByPeerID(long peerID) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null) { try { MethodInfo method = typeof(ZNet).GetMethod("GetPlayerList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { IList list = (IList)method.Invoke(ZNet.instance, null); if (list != null) { foreach (object item in list) { if (item != null) { Type type = item.GetType(); FieldInfo field = type.GetField("m_characterID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("m_name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field2 != null && field.GetValue(item) is ZDOID zdoid && GetZDOIDUserID(zdoid) == peerID) { return (string)field2.GetValue(item); } } } } } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed in FindPlayerNameByPeerID: " + ex.Message)); } } return null; } public static bool MyGetKey(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0043: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Invalid comparison between Unknown and I4 //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Invalid comparison between Unknown and I4 //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Invalid comparison between Unknown and I4 //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Invalid comparison between Unknown and I4 //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Invalid comparison between Unknown and I4 //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Invalid comparison between Unknown and I4 if (Input.GetKey(key)) { return true; } if (ZInput.GetKey(key, true)) { return true; } try { Keyboard current = Keyboard.current; if (current != null) { if ((int)key == 280) { return ((ButtonControl)current.pageUpKey).isPressed; } if ((int)key == 281) { return ((ButtonControl)current.pageDownKey).isPressed; } if ((int)key == 273) { return ((ButtonControl)current.upArrowKey).isPressed; } if ((int)key == 274) { return ((ButtonControl)current.downArrowKey).isPressed; } if ((int)key == 278) { return ((ButtonControl)current.homeKey).isPressed; } if ((int)key == 27) { return ((ButtonControl)current.escapeKey).isPressed; } if ((int)key == 304) { return ((ButtonControl)current.leftShiftKey).isPressed; } if ((int)key == 303) { return ((ButtonControl)current.rightShiftKey).isPressed; } if ((int)key == 306) { return ((ButtonControl)current.leftCtrlKey).isPressed; } if ((int)key == 305) { return ((ButtonControl)current.rightCtrlKey).isPressed; } if ((int)key == 308) { return ((ButtonControl)current.leftAltKey).isPressed; } if ((int)key == 307) { return ((ButtonControl)current.rightAltKey).isPressed; } } } catch (Exception) { } return false; } public static Vector3 GetMouseOrPointerPosition() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0035: 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_007c: 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_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) try { PropertyInfo property = typeof(ZInput).GetProperty("pointerPosition", BindingFlags.Static | BindingFlags.Public); if (property != null) { return (Vector3)property.GetValue(null, null); } FieldInfo field = typeof(ZInput).GetField("mousePosition", BindingFlags.Static | BindingFlags.Public); if (field != null) { return (Vector3)field.GetValue(null); } } catch (Exception) { } try { return Input.mousePosition; } catch (Exception) { } return Vector3.zero; } public static void ShowCenterMessage(string text) { if ((Object)(object)MessageHud.instance == (Object)null) { return; } try { MethodInfo method = typeof(MessageHud).GetMethod("ShowMessage", BindingFlags.Instance | BindingFlags.Public); if (method != null) { ParameterInfo[] parameters = method.GetParameters(); object[] array = new object[parameters.Length]; array[0] = (object)(MessageType)2; array[1] = text; for (int i = 2; i < parameters.Length; i++) { array[i] = ((parameters[i].DefaultValue != DBNull.Value) ? parameters[i].DefaultValue : null); } method.Invoke(MessageHud.instance, array); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed to display HUD message: " + ex.Message)); } } public static Vector3 ScreenToWorldPoint(Minimap minimap, Vector3 mousePos) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0085: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null) { return Vector3.zero; } try { MethodInfo method = typeof(Minimap).GetMethod("ScreenToWorldPoint", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (Vector3)method.Invoke(minimap, new object[1] { mousePos }); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed ScreenToWorldPoint: " + ex.Message)); } return Vector3.zero; } public static PinData GetClosestPin(Minimap minimap, Vector3 pos, float radius) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null) { return null; } try { List minimapPins = GetMinimapPins(minimap); if (minimapPins == null) { return null; } PinData result = null; float num = radius; foreach (PinData item in minimapPins) { if (item != null) { float num2 = Utils.DistanceXZ(pos, item.m_pos); if (num2 < num) { num = num2; result = item; } } } return result; } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed GetClosestPin: " + ex.Message)); } return null; } public static void AddInworldText(Chat chat, Vector3 position, string text) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chat == (Object)null) { return; } try { MethodInfo method = typeof(Chat).GetMethod("AddInworldText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object obj = null; try { obj = UserInfo.GetLocalUser(); } catch (Exception) { } method.Invoke(chat, new object[6] { null, BeaconTalkerID, position, (object)(Type)3, obj, text }); } } catch (Exception ex2) { Debug.LogWarning((object)("[BifrostBeacon] Failed to invoke Chat.AddInworldText: " + ex2.Message)); } } public static WorldTextInstance FindExistingWorldText(Chat chat, long talkerID) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if ((Object)(object)chat == (Object)null) { return null; } try { MethodInfo method = typeof(Chat).GetMethod("FindExistingWorldText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (WorldTextInstance)method.Invoke(chat, new object[1] { talkerID }); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed FindExistingWorldText: " + ex.Message)); } return null; } public static List GetWorldTexts(Chat chat) { if ((Object)(object)chat == (Object)null) { return null; } try { PropertyInfo property = typeof(Chat).GetProperty("WorldTexts", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { return (List)property.GetValue(chat, null); } FieldInfo field = typeof(Chat).GetField("m_worldTexts", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (List)field.GetValue(chat); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed GetWorldTexts: " + ex.Message)); } return null; } public static List GetMinimapPins(Minimap minimap) { if ((Object)(object)minimap == (Object)null) { return null; } try { FieldInfo field = typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (List)field.GetValue(minimap); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Failed GetMinimapPins: " + ex.Message)); } return null; } public static float GetLargeZoom(Minimap minimap) { if ((Object)(object)minimap == (Object)null) { return 1f; } try { FieldInfo field = typeof(Minimap).GetField("m_largeZoom", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (float)field.GetValue(minimap); } } catch (Exception) { } return 1f; } public static float GetRemoveRadius(Minimap minimap) { if ((Object)(object)minimap == (Object)null) { return 10f; } try { FieldInfo field = typeof(Minimap).GetField("m_removeRadius", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (float)field.GetValue(minimap); } } catch (Exception) { } return 10f; } } [HarmonyPatch(typeof(Minimap), "OnMapMiddleClick", new Type[] { typeof(UIInputHandler) })] public static class Minimap_OnMapMiddleClick_Patch { public static bool Prefix(Minimap __instance, UIInputHandler handler) { //IL_003b: 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_0041: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b3: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (!BifrostBeaconPlugin.configModEnabled.Value) { return true; } KeyCode value = BifrostBeaconPlugin.configModifierKey.Value; bool flag = BifrostBeaconPlugin.MyGetKey(value); Debug.Log((object)string.Concat("[BifrostBeacon] OnMapMiddleClick Prefix. ModifierKey: ", value, ", Pressed: ", flag)); if (flag) { Vector3 mouseOrPointerPosition = BifrostBeaconPlugin.GetMouseOrPointerPosition(); Vector3 val = BifrostBeaconPlugin.ScreenToWorldPoint(__instance, mouseOrPointerPosition); Debug.Log((object)string.Concat("[BifrostBeacon] MousePos: ", mouseOrPointerPosition, ", Click WorldPoint: ", val)); float largeZoom = BifrostBeaconPlugin.GetLargeZoom(__instance); float removeRadius = BifrostBeaconPlugin.GetRemoveRadius(__instance); float num = removeRadius * largeZoom * 2f; num = Mathf.Clamp(num, 5f, 100f); PinData closestPin = BifrostBeaconPlugin.GetClosestPin(__instance, val, num); if (closestPin != null) { Debug.Log((object)("[BifrostBeacon] Found closest pin: " + closestPin.m_name + " at position: " + closestPin.m_pos)); if (BifrostBeaconPlugin.activeBeaconPosition.HasValue && Utils.DistanceXZ(BifrostBeaconPlugin.activeBeaconPosition.Value, closestPin.m_pos) < 1f) { BifrostBeaconPlugin.ClearBeacon(); BifrostBeaconPlugin.ShowCenterMessage("Waypoint cleared"); } else { BifrostBeaconPlugin.SetBeacon(closestPin.m_pos, closestPin.m_name); BifrostBeaconPlugin.ShowCenterMessage("Waypoint set: " + (string.IsNullOrEmpty(closestPin.m_name) ? "Pin" : closestPin.m_name)); } } else { Debug.Log((object)("[BifrostBeacon] No pin found within zoom-scaled radius of " + num + "m.")); if (BifrostBeaconPlugin.activeBeaconPosition.HasValue) { BifrostBeaconPlugin.ClearBeacon(); BifrostBeaconPlugin.ShowCenterMessage("Waypoint cleared"); } } return false; } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Exception in OnMapMiddleClick Prefix, falling back to default ping: " + ex)); return true; } return true; } } [HarmonyPatch(typeof(Chat), "UpdateWorldTexts", new Type[] { typeof(float) })] public static class Chat_UpdateWorldTexts_Patch { public static void Postfix(Chat __instance, float dt) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0092: 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_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Expected O, but got Unknown //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } if (!BifrostBeaconPlugin.configModEnabled.Value) { if (BifrostBeaconPlugin.activeBeaconPosition.HasValue || BifrostBeaconPlugin.peerBeacons.Count > 0) { BifrostBeaconPlugin.ClearAllBeacons(); } return; } Vector3 position = ((Component)Player.m_localPlayer).transform.position; if (BifrostBeaconPlugin.activeBeaconPosition.HasValue) { Vector3 value = BifrostBeaconPlugin.activeBeaconPosition.Value; float num = Utils.DistanceXZ(position, value); if (num < 5f && !((Character)Player.m_localPlayer).IsTeleporting() && !((Character)Player.m_localPlayer).IsDead()) { BifrostBeaconPlugin.ClearBeacon(); BifrostBeaconPlugin.ShowCenterMessage("Waypoint reached"); } else { if (BifrostBeaconPlugin.configShowVisualBeam.Value && (Object)(object)BifrostBeaconPlugin.beamInstance == (Object)null) { GameObject val = new GameObject("BifrostBeaconBeam"); BifrostBeaconPlugin.beamInstance = val.AddComponent(); BifrostBeaconPlugin.beamInstance.SetPositions(value, value + Vector3.up * 1000f); Debug.Log((object)"[BifrostBeacon] Recreated visual beam."); } if (BifrostBeaconPlugin.activeBeaconWorldText == null || (Object)(object)BifrostBeaconPlugin.activeBeaconWorldText.m_gui == (Object)null) { BifrostBeaconPlugin.AddInworldText(__instance, value, "PING"); BifrostBeaconPlugin.activeBeaconWorldText = BifrostBeaconPlugin.FindExistingWorldText(__instance, BifrostBeaconPlugin.BeaconTalkerID); Debug.Log((object)"[BifrostBeacon] Spawned new 3D world text tracker."); } if (BifrostBeaconPlugin.activeBeaconWorldText != null) { BifrostBeaconPlugin.activeBeaconWorldText.m_timer = 0f; BifrostBeaconPlugin.activeBeaconWorldText.m_position = value; string text = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerName() : ""); string text2 = BifrostBeaconPlugin.activeBeaconName; if (!string.IsNullOrEmpty(text)) { text2 = text2 + " (" + text + ")"; } if (BifrostBeaconPlugin.configShowHudMessage.Value) { float num2 = value.y - position.y; string text3 = ((num2 > 0f) ? ("+" + num2.ToString("F0") + "m") : (num2.ToString("F0") + "m")); string text4 = text2; text2 = text4 + "\n" + num.ToString("F0") + "m, " + text3; } BifrostBeaconPlugin.activeBeaconWorldText.m_text = text2; if ((Object)(object)BifrostBeaconPlugin.activeBeaconWorldText.m_textMeshField != (Object)null) { ((TMP_Text)BifrostBeaconPlugin.activeBeaconWorldText.m_textMeshField).text = text2; } } if (BifrostBeaconPlugin.configPlayAudioBeeps.Value && num <= BifrostBeaconPlugin.configAudioRange.Value) { BifrostBeaconPlugin.audioTimer += dt; float num3 = Mathf.Clamp01(num / BifrostBeaconPlugin.configAudioRange.Value); float num4 = Mathf.Lerp(0.5f, 4f, num3); if (BifrostBeaconPlugin.audioTimer >= num4) { BifrostBeaconPlugin.audioTimer = 0f; PlayProximityBeep(num3, ((Component)Player.m_localPlayer).transform, BifrostBeaconPlugin.configAudioPitch.Value); } } } } foreach (KeyValuePair peerBeacon in BifrostBeaconPlugin.peerBeacons) { long key = peerBeacon.Key; BifrostBeaconPlugin.PeerBeaconInfo value2 = peerBeacon.Value; Vector3 value = value2.Position; float num5 = Utils.DistanceXZ(position, value); Player val2 = BifrostBeaconPlugin.FindPlayerByPeerID(key); string text5 = (string.IsNullOrEmpty(value2.PlayerName) ? "Player" : value2.PlayerName); if (BifrostBeaconPlugin.configShowPeerHudMessage.Value) { if (value2.WorldTextInstance == null || (Object)(object)value2.WorldTextInstance.m_gui == (Object)null) { BifrostBeaconPlugin.AddInworldTextForPeer(__instance, key, value, "PING"); value2.WorldTextInstance = BifrostBeaconPlugin.FindExistingWorldText(__instance, key); Debug.Log((object)("[BifrostBeacon] Spawned new 3D world text tracker for peer " + key)); } if (value2.WorldTextInstance != null) { value2.WorldTextInstance.m_timer = 0f; value2.WorldTextInstance.m_position = value; string text2 = value2.Name + " (" + text5 + ")"; if (BifrostBeaconPlugin.configShowHudMessage.Value) { float num2 = value.y - position.y; string text3 = ((num2 > 0f) ? ("+" + num2.ToString("F0") + "m") : (num2.ToString("F0") + "m")); string text4 = text2; text2 = text4 + "\n" + num5.ToString("F0") + "m, " + text3; } value2.WorldTextInstance.m_text = text2; if ((Object)(object)value2.WorldTextInstance.m_textMeshField != (Object)null) { ((TMP_Text)value2.WorldTextInstance.m_textMeshField).text = text2; } } } else if (value2.WorldTextInstance != null) { if ((Object)(object)value2.WorldTextInstance.m_gui != (Object)null) { Object.Destroy((Object)(object)value2.WorldTextInstance.m_gui); } BifrostBeaconPlugin.GetWorldTexts(__instance)?.Remove(value2.WorldTextInstance); value2.WorldTextInstance = null; } if (BifrostBeaconPlugin.configShowPeerVisualBeam.Value) { if ((Object)(object)value2.BeamInstance == (Object)null) { GameObject val = new GameObject("BifrostBeaconBeam_Peer_" + key); value2.BeamInstance = val.AddComponent(); value2.BeamInstance.SetPositions(value, value + Vector3.up * 1000f); Debug.Log((object)("[BifrostBeacon] Recreated visual beam for peer " + key)); } } else if ((Object)(object)value2.BeamInstance != (Object)null) { Object.Destroy((Object)(object)((Component)value2.BeamInstance).gameObject); value2.BeamInstance = null; } if (!((Object)(object)val2 != (Object)null)) { continue; } float num6 = Utils.DistanceXZ(((Component)val2).transform.position, value); if (num6 <= BifrostBeaconPlugin.configAudioRange.Value) { value2.AudioTimer += dt; float num3 = Mathf.Clamp01(num6 / BifrostBeaconPlugin.configAudioRange.Value); float num4 = Mathf.Lerp(0.5f, 4f, num3); if (value2.AudioTimer >= num4) { value2.AudioTimer = 0f; PlayProximityBeep(num3, ((Component)val2).transform, value2.AudioPitch); } } } BifrostBeaconPlugin.broadcastTimer += dt; if (BifrostBeaconPlugin.broadcastTimer >= 10f) { BifrostBeaconPlugin.broadcastTimer = 0f; BifrostBeaconPlugin.BroadcastLocalBeacon(); } } catch (Exception ex) { Debug.LogWarning((object)("[BifrostBeacon] Exception in Chat_UpdateWorldTexts_Patch: " + ex)); } } public static void PlayProximityBeep(float pct, Transform targetTransform, float pitch) { //IL_0089: 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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown if ((Object)(object)ObjectDB.instance == (Object)null || (Object)(object)targetTransform == (Object)null) { return; } SE_Finder val = ObjectDB.instance.m_StatusEffects.OfType().FirstOrDefault(); if (!((Object)(object)val != (Object)null)) { return; } EffectList val2 = ((pct < 0.2f) ? val.m_pingEffectNear : ((pct < 0.6f) ? val.m_pingEffectMed : val.m_pingEffectFar)); if (val2 == null) { return; } GameObject[] array = val2.Create(targetTransform.position, targetTransform.rotation, targetTransform, 1f, -1, default(ZDOID)); if (array == null) { return; } GameObject[] array2 = array; foreach (GameObject val3 in array2) { if ((Object)(object)val3 == (Object)null) { continue; } MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren(); foreach (MonoBehaviour val4 in componentsInChildren) { if ((Object)(object)val4 == (Object)null || ((object)val4).GetType().Name != "ZSFX") { continue; } try { Type type = ((object)val4).GetType(); FieldInfo field = type.GetField("m_minPitch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("m_maxPitch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(val4, pitch); } if (field2 != null) { field2.SetValue(val4, pitch); } FieldInfo field3 = type.GetField("m_audioSource", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field3 != null) { AudioSource val5 = (AudioSource)field3.GetValue(val4); if ((Object)(object)val5 != (Object)null) { val5.pitch = pitch; } } } catch (Exception) { } } AudioSource[] componentsInChildren2 = val3.GetComponentsInChildren(); foreach (AudioSource val5 in componentsInChildren2) { if (!((Object)(object)val5 == (Object)null)) { val5.pitch = pitch; } } } } } [HarmonyPatch(typeof(Game), "Start")] public static class Game_Start_Patch { public static void Prefix() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register("BifrostBeacon_SetBeacon", (Action)BifrostBeaconPlugin.RPC_SetBeacon); ZRoutedRpc.instance.Register("BifrostBeacon_ClearBeacon", (Action)BifrostBeaconPlugin.RPC_ClearBeacon); Debug.Log((object)"[BifrostBeacon] Registered network RPCs successfully."); } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class ZNet_Disconnect_Patch { public static void Prefix(ZNetPeer peer) { if (peer != null) { long uid = peer.m_uid; BifrostBeaconPlugin.ClearPeerBeacon(uid); BifrostBeaconPlugin.peerBeacons.Remove(uid); } } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] public static class ZNet_OnDestroy_Patch { public static void Postfix() { BifrostBeaconPlugin.ClearAllBeacons(); } } public class BifrostBeam : MonoBehaviour { private LineRenderer lineRenderer; private float hueOffset = 0f; private void Awake() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown lineRenderer = ((Component)this).gameObject.AddComponent(); lineRenderer.useWorldSpace = true; lineRenderer.positionCount = 2; lineRenderer.startWidth = 1.5f; lineRenderer.endWidth = 1.5f; Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Particles/Standard Unlit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if ((Object)(object)val != (Object)null) { ((Renderer)lineRenderer).material = new Material(val); } else { Debug.LogWarning((object)"[BifrostBeacon] Failed to find a suitable shader for the beam LineRenderer!"); } } public void SetPositions(Vector3 start, Vector3 end) { //IL_001c: 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) if ((Object)(object)lineRenderer != (Object)null) { lineRenderer.SetPosition(0, start); lineRenderer.SetPosition(1, end); } } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) if (!((Object)(object)lineRenderer == (Object)null)) { hueOffset += Time.deltaTime * 0.15f; if (hueOffset > 1f) { hueOffset -= 1f; } Gradient val = new Gradient(); GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[5]; for (int i = 0; i < array.Length; i++) { float num = (float)i / (float)(array.Length - 1); float num2 = (num + hueOffset) % 1f; ref GradientColorKey reference = ref array[i]; reference = new GradientColorKey(Color.HSVToRGB(num2, 0.9f, 1f), num); } val.SetKeys(array, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.7f, 0f), new GradientAlphaKey(0f, 1f) }); lineRenderer.colorGradient = val; } } private void OnDestroy() { if ((Object)(object)lineRenderer != (Object)null && (Object)(object)((Renderer)lineRenderer).material != (Object)null) { Object.Destroy((Object)(object)((Renderer)lineRenderer).material); } } }