public static void UpdateEntry(PlayerNet playerNet, PlayerEntry entry, bool bypassActive = false) { entry.timeSinceLastUpdate.Restart(); // Update values but not text even if playerlist not active and before decode entry.distance = (entry.player.transform.position - Player.prop_Player_0.transform.position).magnitude; entry.fps = MelonUtils.Clamp((int)(1000f / playerNet.field_Private_Byte_0), -99, 999); entry.ping = playerNet.prop_VRCPlayer_0.prop_Int16_0; if (!(MenuManager.playerList.active || bypassActive)) { return; } StringBuilder tempString = new StringBuilder(); try { updateDelegate?.Invoke(playerNet, entry, ref tempString); } catch (Exception ex) { MelonLogger.Error($"Errored while updating {entry.apiUser.displayName}'s entry:\n{ex}"); } entry.textComponent.text = entry.TrimExtra(tempString.ToString()); }
private static void AddDistance(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { if (VRCUtils.AreRiskyFunctionsAllowed) { if (entry.distance < 100) { tempString.Append(entry.distance.ToString("N1").PadRight(4) + "m"); } else if (entry.distance < 10000) { tempString.Append((entry.distance / 1000).ToString("N1").PadRight(3) + "km"); } else if (entry.distance < 999900) { tempString.Append((entry.distance / 1000).ToString("N0").PadRight(3) + "km"); } else { tempString.Append((entry.distance / 9.461e+15).ToString("N2").PadRight(3) + "ly"); // If its too large for kilometers ***just convert to light years*** } } else { entry.distance = 0; tempString.Append("0.0 m"); } tempString.Append(separator); }
private static void AddOwnedObjectsSafe(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { if (entry.ownedObjects > (int)(totalObjects * 0.75)) { tempString.Append(entry.ownedObjects.ToString().PadRight(highestOwnedObjectsLength) + separator); } else { tempString.Append("0".PadRight(highestOwnedObjectsLength) + separator); } }
protected static void AddFps(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append("<color=" + PlayerUtils.GetFpsColor(entry.fps) + ">"); if (entry.fps == 0) { tempString.Append("?¿?</color>"); } else { tempString.Append(entry.fps.ToString().PadRight(3) + "</color>"); } tempString.Append(separator); }
protected static void AddPing(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append("<color=" + PlayerUtils.GetPingColor(entry.ping) + ">"); if (entry.ping < 9999 && entry.ping > -999) { tempString.Append(entry.ping.ToString().PadRight(4) + "ms</color>"); } else { tempString.Append(((double)(entry.ping / 1000)).ToString("N1").PadRight(5) + "s</color>"); } tempString.Append(separator); }
private static void AddDisplayName(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append("<color=" + entry.playerColor + ">" + entry.apiUser.displayName + "</color>" + separator); }
private static void AddOwnedObjects(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append(entry.ownedObjects.ToString().PadRight(highestOwnedObjectsLength) + separator); }
private static void AddPhotonId(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append(playerNet.prop_PhotonView_0.field_Private_Int32_0.ToString().PadRight(highestPhotonIdLength) + separator); }
private static void AddPerf(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString) { tempString.Append(entry.perfString + separator); }
protected override void ProcessText(object[] parameters) { // TODO: Figure out how to figure out how to know when someone blcosk u /* * List<PlayerEntry> playerEntries = PlayerListMod.playerEntries.Values.ToList(); * // Get blocked things * foreach (ApiPlayerModeration moderation in ModerationManager.prop_ModerationManager_0.field_Private_List_1_ApiPlayerModeration_0) * { * if (moderation.moderationType != ApiPlayerModeration.ModerationType.Block) continue; * * foreach (PlayerEntry playerEntry in playerEntries) * { * if (playerEntry.youBlocked) continue; * * if (playerEntry.player == null) * { * playerEntry.Remove(); * continue; * } * * if (playerEntry.userID == moderation.targetUserId) * { * playerEntry.youBlocked = true; * MelonLoader.MelonLogger.Msg($"You have blocked {moderation.targetDisplayName}"); * break; * } * } * } */ // Get highest photonId once per update int highestId = 0; foreach (int photonId in PlayerManager.prop_PlayerManager_0.field_Private_Dictionary_2_Int32_Player_0.Keys) { if (photonId > highestId) { highestId = photonId; } } PlayerEntry.highestPhotonIdLength = highestId.ToString().Length; // Convert to byte as that's what's sent over network so if you spoof your ping you'll see what's actually sent over the network if (Config.pingToggle.Value) { short ping = (short)Photon.Pun.PhotonNetwork.field_Public_Static_LoadBalancingClient_0.prop_LoadBalancingPeer_0.RoundTripTime; AddColor(PlayerEntry.GetPingColor(ping)); if (ping < 9999 && ping > -999) { AddEndColor(ping.ToString().PadRight(4) + "ms"); } else { AddEndColor(((double)(ping / 1000)).ToString("N1").PadRight(5) + "s"); } AddSpacer(); } // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone if (Config.fpsToggle.Value) { int fps = Mathf.Clamp((int)(1f / Time.deltaTime), -99, 999); // Clamp between -99 and 999 AddColoredText(PlayerEntry.GetFpsColor(fps), fps.ToString().PadRight(3)); AddSpacer(); } if (Config.platformToggle.Value) { AddText(PlayerEntry.ParsePlatform(Player.prop_Player_0).PadRight(2)); AddSpacer(); } if (Config.perfToggle.Value) { PerformanceRating rating = Player.prop_Player_0.field_Internal_VRCPlayer_0.prop_VRCAvatarManager_0.prop_AvatarPerformanceStats_0.field_Private_ArrayOf_PerformanceRating_0[(int)AvatarPerformanceCategory.Overall]; // Get from cache so it doesnt calculate perf all at once AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, rating)), PlayerEntry.ParsePerformanceText(rating).PadRight(5)); AddSpacer(); } if (Config.distanceToggle.Value) { AddText("0.0 m"); AddSpacer(); } if (Config.photonIdToggle.Value) { AddText(Player.prop_Player_0.field_Internal_VRCPlayer_0.field_Private_PhotonView_0.field_Private_Int32_0.ToString().PadRight(PlayerEntry.highestPhotonIdLength)); AddSpacer(); } if (Config.displayNameToggle.Value) { switch (Config.DisplayNameColorMode) { case PlayerListMod.DisplayNameColorMode.None: case PlayerListMod.DisplayNameColorMode.FriendsOnly: AddText(APIUser.CurrentUser.displayName); break; case PlayerListMod.DisplayNameColorMode.TrustAndFriends: case PlayerListMod.DisplayNameColorMode.TrustOnly: AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(APIUser.CurrentUser)), APIUser.CurrentUser.displayName); break; } AddSpacer(); } if (textComponent.text.Length > 0) { if (Config.condensedText.Value) { textComponent.text = textComponent.text.Remove(textComponent.text.Length - 1, 1); } else { textComponent.text = textComponent.text.Remove(textComponent.text.Length - 3, 3); } } if (!Config.numberedList.Value) { if (Config.condensedText.Value) { AddTextToBeginning("-"); } else { AddTextToBeginning(" - "); } } else if (Config.condensedText.Value) { AddTextToBeginning("1.".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 1)); } else { AddTextToBeginning("1. ".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 2)); } }
public override void Init(object[] parameters) { gameObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(new Action(() => PlayerEntry.OpenPlayerInQuickMenu(Player.prop_Player_0))); }