diff --git a/Assets/MeatKit/BuildProfile.asset b/Assets/MeatKit/BuildProfile.asset index 3cf2ca9..49677b0 100644 --- a/Assets/MeatKit/BuildProfile.asset +++ b/Assets/MeatKit/BuildProfile.asset @@ -13,18 +13,19 @@ MonoBehaviour: m_EditorClassIdentifier: PackageName: TNH_Quality_of_Life_Improvements Author: muskit - Version: 1.2.2 + Version: 1.2.3 Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3} ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3} WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements Description: Quality of life improvements to the Take and Hold experience. AdditionalDependencies: - BepInEx-BepInExPack_H3VR-5.4.1700 + - nrgill28-Sodalite-1.3.5 StripNamespaces: 0 AdditionalNamespaces: - TNHQoLImprovements BuildItems: - {fileID: 11400000, guid: ccaff18373cd99848b344316974e6d46, type: 2} BundleCompressionType: 2 - BuildAction: 2 - OutputProfile: + BuildAction: 1 + OutputProfile: C:/Users/Alex/AppData/Roaming/r2modmanPlus-local/H3VR/profiles/dev diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 55534a1..e6e5cc2 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -9,7 +9,10 @@ using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; +using FistVR; using TNHQoLImprovements; +using Sodalite.Api; +using Sodalite; /* * SUPER LARGE WARNING ABOUT THIS CLASS @@ -61,11 +64,17 @@ public class MeatKitPlugin : BaseUnityPlugin // Take and Hold modifications private static InPlay instance; - + // Searching for old leaderboards player count mod to disable + private float lpcSearchTime; private bool lpcStopSearching = false; private float lpcModSearchTimeEnd; + // toggle HP visibility from wrist menu + private bool hpDisplayEnabled = true; + public static FVRHealthBar hpDisplay; + private WristMenuButton wmbHPToggle; + private Harmony harmony; private void SceneChanged(Scene from, Scene to) @@ -74,17 +83,23 @@ public class MeatKitPlugin : BaseUnityPlugin playerCamera = GameObject.FindGameObjectWithTag("MainCamera"); // apply health counter tweaks globally - var healthCounter = FindObjectOfType(); - if (healthCounter != null) + hpDisplay = FindObjectOfType(); + if (hpDisplay != null) { - HPReadability.ImproveHPTextReadability(healthCounter.transform.GetChild(0).gameObject); + HPReadability.ImproveHPTextReadability(hpDisplay.transform.GetChild(0).gameObject); if (cfgHPHiddenWhenAiming.Value) - healthCounter.gameObject.AddComponent(); + hpDisplay.gameObject.AddComponent(); + + WristMenuAPI.Buttons.Add(wmbHPToggle); + } + else + { + WristMenuAPI.Buttons.Remove(wmbHPToggle); } // TNH patches - if (GameObject.Find("_GameManager") != null || FindObjectOfType() != null) + if (GameObject.Find("_GameManager") != null || FindObjectOfType() != null) { Logger.LogInfo("We are in a TNH game!"); instance = new GameObject().AddComponent(); @@ -102,7 +117,7 @@ public class MeatKitPlugin : BaseUnityPlugin // Agency FB if (fontAgencyFB == null) { - var healthCounter = FindObjectOfType(); + var healthCounter = FindObjectOfType(); if (healthCounter != null) { fontAgencyFB = healthCounter.transform.GetChild(0).GetChild(0).GetComponent().font; @@ -126,6 +141,7 @@ public class MeatKitPlugin : BaseUnityPlugin public MeatKitPlugin(): base() { harmony = new Harmony("muskit.TNHQualityOfLifeImprovements"); + lpcSearchTime = 30 + 30 * Mathf.Sin(System.DateTime.Today.DayOfYear / 365); } private void Awake() @@ -201,11 +217,14 @@ public class MeatKitPlugin : BaseUnityPlugin HealthExpireIndicationType.Flashing, "Add a visual indication on the Health Crystal's despawn timer."); - // give 60 seconds to search for old mod, which we want to kill - lpcModSearchTimeEnd = Time.time + 60; + // calculate end time to search for my deprecated Leaderboard + lpcModSearchTimeEnd = Time.time + lpcSearchTime; + + wmbHPToggle = new WristMenuButton("Toggle HP Display", ToggleHPVisibility); RunPatches(); } + // DO NOT EDIT. private void LoadAssets() {} @@ -240,6 +259,13 @@ public class MeatKitPlugin : BaseUnityPlugin } } + private void ToggleHPVisibility(object sender, ButtonClickEventArgs args) + { + hpDisplayEnabled = !hpDisplayEnabled; + if (hpDisplay != null) + hpDisplay.gameObject.SetActive(hpDisplayEnabled); + } + /// /// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod. /// @@ -260,7 +286,7 @@ public class MeatKitPlugin : BaseUnityPlugin if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd) { - Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 60 seconds."); + Logger.LogInfo(string.Format("Stopping search for TNH Leaderboard Player Count mod after {0} seconds.", lpcSearchTime)); lpcStopSearching = true; } } diff --git a/Assets/README.md b/Assets/README.md index d93194f..3207a36 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -21,6 +21,15 @@ Toggle and customize these features in your mod manager's *Config editor*. For any issues/ideas, please create an issue at the GitHub repository (linked on Thunderstore page). ## Changelog +1.2.3 +* Added button in wrist menu to toggle HP counter (thanks PutterMyBancakes for the suggestion!) +* [TNH] Made the search time for deprecated Leaderboard mod based on day of year as an input of the sin() + +1.2.2 +* When aiming around the HP counter, its opacity can now change to a player setting +* Increased size of hide-HP aiming region +* [TNH] Decreased search time for deprecated Leaderboard mod + 1.2.1 * [TNH] Changed leaderboard player count message for unavailability with TNHTweaker diff --git a/Assets/_Scripts/InPlay.cs b/Assets/_Scripts/InPlay.cs index 32cd89e..3acec19 100644 --- a/Assets/_Scripts/InPlay.cs +++ b/Assets/_Scripts/InPlay.cs @@ -48,7 +48,7 @@ namespace TNHQoLImprovements void Start() { - tnhManager = GameObject.Find("_GameManager").GetComponent(); + tnhManager = FindObjectOfType(); var rig = Object.FindObjectOfType().transform; hands = new Transform[] {