diff --git a/Assets/BuildProfile.asset b/Assets/BuildProfile.asset index 922ddad..bd553e7 100644 --- a/Assets/BuildProfile.asset +++ b/Assets/BuildProfile.asset @@ -26,5 +26,5 @@ MonoBehaviour: ApplyHarmonyPatches: 1 BuildItems: - {fileID: 11400000, guid: ccaff18373cd99848b344316974e6d46, type: 2} - BuildAction: 1 + BuildAction: 2 OutputProfile: C:/Users/Alex/AppData/Roaming/r2modmanPlus-local/H3VR/profiles/dev diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 7d48654..947f81b 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -85,8 +85,24 @@ public static AssetBundle bundle; private void SceneChanged(Scene from, Scene to) { - playerCamera = GameObject.FindGameObjectWithTag("MainCamera"); - hpDisplay = FindObjectOfType(); + StartCoroutine("SceneChangedCoRoutine"); + } + + private IEnumerator SceneChangedCoRoutine() + { + // grab H3VR objects + playerCamera = null; + hpDisplay = null; + while (playerCamera == null) + { + playerCamera = GameObject.FindGameObjectWithTag("MainCamera"); + hpDisplay = FindObjectOfType(); + yield return null; + } + + // ---- MAINCAMERA FOUND SIGNIFIES THAT ESSENTIAL GAME OBJECTS HAVE LOADED IN ---- // + + // find Agency font GetFonts(); // apply health counter tweaks globally @@ -104,34 +120,17 @@ public static AssetBundle bundle; WristMenuAPI.Buttons.Remove(wmbHPToggle); } - StartCoroutine("TryTNH"); - } - - private IEnumerator TryTNH() - { - for (int i = 0; i < 11; ++i) + if (GameObject.Find("_GameManager") != null || FindObjectOfType() != null) { - // TNH patches - if (GameObject.Find("_GameManager") != null || FindObjectOfType() != null) - { - Logger.LogInfo("We are in a TNH game!"); - instance = new GameObject().AddComponent(); - break; - } - else - { - Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i)); - yield return new WaitForEndOfFrame(); - } + Logger.LogInfo("We are in a TNH game!"); + instance = new GameObject().AddComponent(); } - - // destroy self only if we are FOR SURE not in a TNH game - if (GameObject.Find("_GameManager") == null || FindObjectOfType() == null) + else { Logger.LogInfo("We are NOT in a TNH game!"); Destroy(instance); } - } + } // called on scene change, find fonts from game if they're not set private void GetFonts() diff --git a/Assets/README.md b/Assets/README.md index 82a8067..ba7b0ac 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -21,6 +21,10 @@ 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.4 +* [TNH] Fix errors occurring in Atlas-based maps +* Update MeatKit (now on Unity 5.6.7f1!) + 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() diff --git a/Assets/_Scripts/InPlay.cs b/Assets/_Scripts/InPlay.cs index 3acec19..5fb50c6 100644 --- a/Assets/_Scripts/InPlay.cs +++ b/Assets/_Scripts/InPlay.cs @@ -58,5 +58,10 @@ namespace TNHQoLImprovements tnhInfo = Instantiate(MeatKitPlugin.bundle.LoadAsset("TNHInfo"), FindObjectOfType().transform.GetChild(3)); tnhInfo.transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); } + + void OnDestroy() + { + tnhManager = null; + } } } \ No newline at end of file diff --git a/Assets/_Scripts/ShopTokenPatch.cs b/Assets/_Scripts/ShopTokenPatch.cs index 200b8f9..3c185dd 100644 --- a/Assets/_Scripts/ShopTokenPatch.cs +++ b/Assets/_Scripts/ShopTokenPatch.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using System.Collections; +using HarmonyLib; using System.Reflection; using UnityEngine; using UnityEngine.UI; @@ -26,7 +27,7 @@ namespace TNHQoLImprovements { private Text text; - private void Start() + private IEnumerator Start() { var gObjText = new GameObject("TokenCounter"); gObjText.transform.SetParent(transform, false); @@ -37,11 +38,26 @@ namespace TNHQoLImprovements text.font = MeatKitPlugin.fontBombardier; text.fontSize = 55; text.color = new Color(0.1307786f, 0.2461715f, 0.359f); - } - private void Update() + + while (InPlay.tnhManager == null) + { + Debug.Log("[ShopTokenNumber] tnhManager is null!"); + yield return null; + } + + InPlay.tnhManager.TokenCountChangeEvent += UpdateText; + UpdateText(); + } + + private void UpdateText(int _ = 0) { int tokens = InPlay.tnhManager.GetNumTokens(); text.text = tokens.ToString(); } + + private void OnDestroy() + { + InPlay.tnhManager.TokenCountChangeEvent -= UpdateText; + } } } \ No newline at end of file diff --git a/Assets/_Scripts/TNHInfo.cs b/Assets/_Scripts/TNHInfo.cs index 45f07a0..e8141d3 100644 --- a/Assets/_Scripts/TNHInfo.cs +++ b/Assets/_Scripts/TNHInfo.cs @@ -62,8 +62,8 @@ namespace TNHQoLImprovements public void Update() { - // game over area; do not update anything else - if (InPlay.tnhManager.Phase == TNH_Phase.Dead || InPlay.tnhManager.Phase == TNH_Phase.Completed) + // game over area; do not update anything else + if (InPlay.tnhManager.Phase == TNH_Phase.Dead || InPlay.tnhManager.Phase == TNH_Phase.Completed) { if (tokenCounter != null) tokenCounter.SetActive(true); diff --git a/preview/aimhide.png b/preview/aimhide.png new file mode 100644 index 0000000..540b31a Binary files /dev/null and b/preview/aimhide.png differ diff --git a/preview/hp.png b/preview/hp.png new file mode 100644 index 0000000..5f37280 Binary files /dev/null and b/preview/hp.png differ diff --git a/preview/item station.png b/preview/item station.png new file mode 100644 index 0000000..3546e24 Binary files /dev/null and b/preview/item station.png differ diff --git a/preview/leaderboard.png b/preview/leaderboard.png new file mode 100644 index 0000000..8f5b1b8 Binary files /dev/null and b/preview/leaderboard.png differ diff --git a/preview/stats.png b/preview/stats.png new file mode 100644 index 0000000..496db0a Binary files /dev/null and b/preview/stats.png differ diff --git a/preview/stats_new.png b/preview/stats_new.png new file mode 100644 index 0000000..a3b4a99 Binary files /dev/null and b/preview/stats_new.png differ