remove joke func. that kills the long-deprecated "Leaderboard Player Count" mod; clean up logging

This commit is contained in:
Alex
2026-07-14 23:33:05 -07:00
parent 4d855203f6
commit a39667f6c0
3 changed files with 7 additions and 68 deletions
+2 -38
View File
@@ -70,11 +70,6 @@ public static AssetBundle bundle;
// Take and Hold modifications
private static InPlay playInstance;
// Searching for old leaderboards player count mod to disable
private float lpcSearchTime;
private bool lpcStopSearching = false;
private float lpcModSearchTimeEnd;
public static FVRHealthBar hpDisplay;
// toggle HP visibility from wrist menu
@@ -91,7 +86,7 @@ public static AssetBundle bundle;
private IEnumerator SceneChangedCoroutine()
{
Destroy(playInstance);
for (int i = 0; i < 11; ++i)
for (int i = 1; i <= 10; ++i)
{
// TNH patches
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
@@ -101,12 +96,9 @@ public static AssetBundle bundle;
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
break;
}
else
{
Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i+1));
// Logger.LogInfo(String.Format("Couldn't find a TNH game. Checking again...({0}/10)", i));
yield return new WaitForEndOfFrame();
}
}
if (playInstance == null)
{
@@ -162,7 +154,6 @@ public static AssetBundle bundle;
public MeatKitPlugin(): base()
{
harmony = new Harmony("muskit.TNHQualityOfLifeImprovements");
lpcSearchTime = 30f + 30f * Mathf.Sin(System.DateTime.Today.DayOfYear / 365f); // lolz
}
// You are free to edit this method, however please ensure LoadAssets is still called somewhere inside it.
@@ -245,9 +236,6 @@ public static AssetBundle bundle;
HealthExpireIndicationType.Flashing,
"Add a visual indication on the Health Crystal's despawn timer.");
// calculate end time to search for my deprecated Leaderboard
lpcModSearchTimeEnd = Time.time + lpcSearchTime;
wmbHPToggle = new WristMenuButton("Toggle HP Display", ToggleHPVisibility);
RunPatches();
@@ -296,30 +284,6 @@ public static AssetBundle bundle;
hpDisplay.gameObject.SetActive(hpDisplayEnabled);
}
/// <summary>
/// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod.
/// </summary>
private void Update()
{
if (lpcStopSearching)
return;
foreach (var plugin in Chainloader.PluginInfos)
{
if (plugin.Key == "me.muskit.tnhLeaderboardPlayerCount")
{
Logger.LogWarning("TNH Leaderboard Player Count mod detected. Destroying it to avoid interference.");
Destroy(plugin.Value.Instance);
lpcStopSearching = true;
}
}
if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd)
{
Logger.LogInfo(string.Format("Stopping search for TNH Leaderboard Player Count mod after {0} seconds.", lpcSearchTime));
lpcStopSearching = true;
}
}
// DO NOT CHANGE OR REMOVE THIS METHOD. It's contents will be overwritten when building your package.
private void LoadAssets()
+3 -16
View File
@@ -1,6 +1,5 @@
using System;
using System.Reflection;
using BepInEx.Bootstrap;
using UnityEngine;
using UnityEngine.UI;
using FistVR;
@@ -15,26 +14,21 @@ namespace TNHQoLImprovements
private bool tnhTweakerInstalled = false;
private string curID;
private string loadingStr;
private TNH_ScoreDisplay scoreDisplay;
private Text lblGlobalScores;
private GameObject gObjLoading;
#region INITIALIZATION
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel, GameObject gObjLoading)
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel)
{
if (initialized)
return;
// don't run with TNHTweaker installed
this.gObjLoading = gObjLoading;
var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker"))
{
tnhTweakerInstalled = true;
this.gObjLoading.transform.GetChild(0).GetComponent<Text>().text = "<color=lightblue><size=30>Online leaderboards player count unavailable for TNHTweaker.</size></color>";
this.gObjLoading.SetActive(true);
return;
}
@@ -42,9 +36,6 @@ namespace TNHQoLImprovements
this.lblGlobalScores = scoreLabel;
this.lblGlobalScores.resizeTextForBestFit = true;
this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow;
loadingStr = gObjLoading.GetComponentInChildren<Text>().text;
initialized = true;
}
@@ -71,20 +62,16 @@ namespace TNHQoLImprovements
lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
curID = id;
gObjLoading.SetActive(false);
}
catch (KeyNotFoundException e)
{
lblGlobalScores.text = "Global Scores:";
gObjLoading.GetComponentInChildren<Text>().text = loadingStr;
gObjLoading.SetActive(true);
curID = null;
}
catch (Exception e)
{
gObjLoading.GetComponentInChildren<Text>().text = string.Format("<color=lightblue><size=30>Unknown error occured trying to retrieve online player count.</size></color>\n" +
"<color=red>{0}</color>", e);
gObjLoading.SetActive(true);
MeatKitPlugin.Logger.LogWarning("Unknown error occurred trying to retrieve online player count.");
MeatKitPlugin.Logger.LogWarning(e);
}
}
}
+1 -13
View File
@@ -8,7 +8,6 @@ namespace TNHQoLImprovements
{
public static class LeaderboardPlayerCountPatch
{
private static GameObject gObjLoading;
private static Text uiGlobalText;
public static void Patch(Harmony harmony)
@@ -22,29 +21,18 @@ namespace TNHQoLImprovements
public static void Setup(TNH_ScoreDisplay __instance)
{
GameObject gObjLeaderboard = null;
gObjLoading = GameObject.Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("PlayerCount_LoadingText"));
if (__instance.gameObject.name == "_MainMenu") // lobby
{
gObjLeaderboard = __instance.transform.GetChild(3).gameObject; // MainMenuCanvas_RightFar
gObjLoading.transform.SetParent(gObjLeaderboard.transform, false);
gObjLoading.GetComponent<RectTransform>().pivot = new Vector2(0, 1);
gObjLoading.transform.localPosition = new Vector3(520, 380, 0);
gObjLoading.transform.GetChild(0).GetComponent<Text>().alignment = TextAnchor.UpperLeft;
}
if (__instance.gameObject.name == "_FinalScoreDisplay(Clone)") // game over room
{
gObjLeaderboard = __instance.transform.GetChild(0).gameObject; // ScoreCanvas_PastScores
gObjLoading.transform.SetParent(gObjLeaderboard.transform, false);
gObjLoading.GetComponent<RectTransform>().pivot = new Vector2(1, 1);
gObjLoading.transform.localPosition = new Vector3(-520, 380, 0);
gObjLoading.transform.GetChild(0).GetComponent<Text>().alignment = TextAnchor.UpperRight;
}
uiGlobalText = gObjLeaderboard.transform.GetChild(0).GetChild(2).GetComponent<Text>();
gObjLoading.transform.rotation = gObjLeaderboard.transform.rotation;
gObjLoading.transform.GetChild(0).GetComponent<Text>().font = uiGlobalText.font;
var playerCountComponent = gObjLeaderboard.AddComponent<LeaderboardPlayerCount>();
playerCountComponent.Init(__instance, uiGlobalText, gObjLoading);
playerCountComponent.Init(__instance, uiGlobalText);
}
}
}