From 6f938e95c8a8d29fa2bb48e67d487c6515a9486b Mon Sep 17 00:00:00 2001 From: msk <15199219+muskit@users.noreply.github.com> Date: Mon, 24 Jan 2022 03:40:08 -0800 Subject: [PATCH] fix in-play stuff not working in other maps --- Assets/MeatKit/MeatKitPlugin.cs | 16 +++++++++++++--- Assets/README.md | 16 ++++++++++++++-- Assets/_Scripts/HoldCounter.cs | 11 +++++++++-- Assets/_Scripts/TokenCounter.cs | 7 ++++--- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 48e22e8..88c6a61 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -33,6 +33,7 @@ public class MeatKitPlugin : BaseUnityPlugin private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); #pragma warning restore 414 public static AssetBundle bundle; + public static ConfigEntry cfgShowLPC; public static ConfigEntry cfgSolidifyHPText; public static ConfigEntry cfgShowHPBackground; public static ConfigEntry cfgHPBackgroundOpacity; @@ -48,12 +49,16 @@ public class MeatKitPlugin : BaseUnityPlugin private void SceneChanged(Scene from, Scene to) { //Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name)); - if(GameObject.Find("_NewTAHReticle") != null) + Logger.LogInfo("_GameManager present: " + (GameObject.Find("_GameManager") != null)); + Logger.LogInfo("TNH_Manager object present: " + (FindObjectOfType() != null)); + if(GameObject.Find("_GameManager") != null || FindObjectOfType() != null) { + Logger.LogInfo("We are in a TNH game!"); instance = new GameObject().AddComponent(); } else { + Logger.LogInfo("We are NOT in a TNH game!"); Destroy(instance); } } @@ -78,6 +83,10 @@ public class MeatKitPlugin : BaseUnityPlugin "Solidify HP text", true, "Set opacity of HP text to full and give it a shadow."); + cfgShowLPC = Config.Bind("Game Info", + "Show player count in online leaderboards", + true, + "Shows the number of players in the currently selected TNH leaderboard."); cfgShowTokens = Config.Bind("Game Info", "Show Tokens", true, @@ -88,7 +97,8 @@ public class MeatKitPlugin : BaseUnityPlugin "Shows how many holds the player has completed by their radar hand."); // patch leaderboard code - lpc = new LeaderboardPlayerCountPatch(); + if (cfgShowLPC.Value) + lpc = new LeaderboardPlayerCountPatch(); // give 120 seconds to search for old mod lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120; @@ -116,7 +126,7 @@ public class MeatKitPlugin : BaseUnityPlugin if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd) { - Logger.LogWarning("Stopping search for TNH Leaderboard Player Count mod after 120 seconds."); + Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 120 seconds."); lpcModGone = true; } } diff --git a/Assets/README.md b/Assets/README.md index 725c274..f1f38c3 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -2,13 +2,25 @@ This mod adds quality of life improvements to the *Take and Hold* experience. ## Features -* More visible HP counter +* Better Health counter visibility * Token and hold counter on wrist * Player count for online leaderboards; see how you stack up! - * Incompatible with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/); feature will be disabled! + * Won't work with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/) installed Enable/disable these features in your mod manager's *Config editor*. For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page). +## Changelog +1.0.1 +* Fixed the in-play improvements only applying in Classic Hallways map (whoops!!) +* Added option to enable/disable showing player count of online leaderboards +* Added option to enable/disable HP text opacity/shadow change + * (Surprisingly, the HP text normally doesn't have full opacity) +* Searching for TNH Leaderboards Player Count now stops after 120s + + +1.0.0 +* Initial release! + **NOTE: [*TNH Leaderboard Player Count*](https://h3vr.thunderstore.io/package/muskit/TNH_Leaderboard_Player_Count/) has been merged with this mod. If installed, please remove that mod as it lacks features and is no longer supported.** \ No newline at end of file diff --git a/Assets/_Scripts/HoldCounter.cs b/Assets/_Scripts/HoldCounter.cs index 2059b0c..2661bca 100644 --- a/Assets/_Scripts/HoldCounter.cs +++ b/Assets/_Scripts/HoldCounter.cs @@ -11,16 +11,23 @@ namespace TNHQoLImprovements private void OnDeath(bool _) { Debug.Log("I died!"); + } + + // TODO: lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted + private void OnHoldLose() + { + } void Start() { - transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; + //transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; + transform.parent = FindObjectOfType().transform.GetChild(3); transform.localPosition = new Vector3(-1f, 0, -.5f); transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); - GameObject.Find("[SceneSettings]").GetComponent().PlayerDeathEvent += OnDeath; + FindObjectOfType().PlayerDeathEvent += OnDeath; } void Update() diff --git a/Assets/_Scripts/TokenCounter.cs b/Assets/_Scripts/TokenCounter.cs index d024ed5..6db66b6 100644 --- a/Assets/_Scripts/TokenCounter.cs +++ b/Assets/_Scripts/TokenCounter.cs @@ -1,7 +1,7 @@ using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using FistVR; namespace TNHQoLImprovements { @@ -9,7 +9,8 @@ namespace TNHQoLImprovements { void Start() { - transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; + //transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; + transform.parent = FindObjectOfType().transform.GetChild(3); transform.localPosition = new Vector3(1, 0, -.5f); transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); @@ -31,7 +32,7 @@ namespace TNHQoLImprovements else { debug_iterations++; - yield return new WaitForSeconds(0.25f); + yield return new WaitForEndOfFrame(); } } Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations.");