diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index b95b9af..da9857a 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -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() != null) @@ -101,11 +96,8 @@ 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)); - yield return new WaitForEndOfFrame(); - } + // 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); } - /// - /// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod. - /// - 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() diff --git a/Assets/_Scripts/LeaderboardPlayerCount.cs b/Assets/_Scripts/LeaderboardPlayerCount.cs index 9e94475..7b3b3ae 100644 --- a/Assets/_Scripts/LeaderboardPlayerCount.cs +++ b/Assets/_Scripts/LeaderboardPlayerCount.cs @@ -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(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker")) { tnhTweakerInstalled = true; - this.gObjLoading.transform.GetChild(0).GetComponent().text = "Online leaderboards player count unavailable for TNHTweaker."; - 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; - - initialized = true; } @@ -71,20 +62,16 @@ namespace TNHQoLImprovements lblGlobalScores.text = "Global Scores: (" + playerCountText + " players)"; curID = id; - gObjLoading.SetActive(false); } catch (KeyNotFoundException e) { lblGlobalScores.text = "Global Scores:"; - gObjLoading.GetComponentInChildren().text = loadingStr; - gObjLoading.SetActive(true); curID = null; } catch (Exception e) { - gObjLoading.GetComponentInChildren().text = string.Format("Unknown error occured trying to retrieve online player count.\n" + - "{0}", e); - gObjLoading.SetActive(true); + MeatKitPlugin.Logger.LogWarning("Unknown error occurred trying to retrieve online player count."); + MeatKitPlugin.Logger.LogWarning(e); } } } diff --git a/Assets/_Scripts/LeaderboardPlayerCountPatch.cs b/Assets/_Scripts/LeaderboardPlayerCountPatch.cs index e04f187..3e964e2 100644 --- a/Assets/_Scripts/LeaderboardPlayerCountPatch.cs +++ b/Assets/_Scripts/LeaderboardPlayerCountPatch.cs @@ -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("PlayerCount_LoadingText")); if (__instance.gameObject.name == "_MainMenu") // lobby { gObjLeaderboard = __instance.transform.GetChild(3).gameObject; // MainMenuCanvas_RightFar - gObjLoading.transform.SetParent(gObjLeaderboard.transform, false); - gObjLoading.GetComponent().pivot = new Vector2(0, 1); - gObjLoading.transform.localPosition = new Vector3(520, 380, 0); - gObjLoading.transform.GetChild(0).GetComponent().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().pivot = new Vector2(1, 1); - gObjLoading.transform.localPosition = new Vector3(-520, 380, 0); - gObjLoading.transform.GetChild(0).GetComponent().alignment = TextAnchor.UpperRight; } uiGlobalText = gObjLeaderboard.transform.GetChild(0).GetChild(2).GetComponent(); - gObjLoading.transform.rotation = gObjLeaderboard.transform.rotation; - gObjLoading.transform.GetChild(0).GetComponent().font = uiGlobalText.font; var playerCountComponent = gObjLeaderboard.AddComponent(); - playerCountComponent.Init(__instance, uiGlobalText, gObjLoading); + playerCountComponent.Init(__instance, uiGlobalText); } } } \ No newline at end of file