add small setup delays to address errors in Atlas maps

fixes #2
This commit is contained in:
msk
2023-07-26 23:56:22 -07:00
parent d2316bac96
commit 64d8df148b
12 changed files with 55 additions and 31 deletions
+1 -1
View File
@@ -26,5 +26,5 @@ MonoBehaviour:
ApplyHarmonyPatches: 1 ApplyHarmonyPatches: 1
BuildItems: BuildItems:
- {fileID: 11400000, guid: ccaff18373cd99848b344316974e6d46, type: 2} - {fileID: 11400000, guid: ccaff18373cd99848b344316974e6d46, type: 2}
BuildAction: 1 BuildAction: 2
OutputProfile: C:/Users/Alex/AppData/Roaming/r2modmanPlus-local/H3VR/profiles/dev OutputProfile: C:/Users/Alex/AppData/Roaming/r2modmanPlus-local/H3VR/profiles/dev
+16 -17
View File
@@ -84,9 +84,25 @@ public static AssetBundle bundle;
private Harmony harmony; private Harmony harmony;
private void SceneChanged(Scene from, Scene to) private void SceneChanged(Scene from, Scene to)
{
StartCoroutine("SceneChangedCoRoutine");
}
private IEnumerator SceneChangedCoRoutine()
{
// grab H3VR objects
playerCamera = null;
hpDisplay = null;
while (playerCamera == null)
{ {
playerCamera = GameObject.FindGameObjectWithTag("MainCamera"); playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
hpDisplay = FindObjectOfType<FVRHealthBar>(); hpDisplay = FindObjectOfType<FVRHealthBar>();
yield return null;
}
// ---- MAINCAMERA FOUND SIGNIFIES THAT ESSENTIAL GAME OBJECTS HAVE LOADED IN ---- //
// find Agency font
GetFonts(); GetFonts();
// apply health counter tweaks globally // apply health counter tweaks globally
@@ -104,29 +120,12 @@ public static AssetBundle bundle;
WristMenuAPI.Buttons.Remove(wmbHPToggle); WristMenuAPI.Buttons.Remove(wmbHPToggle);
} }
StartCoroutine("TryTNH");
}
private IEnumerator TryTNH()
{
for (int i = 0; i < 11; ++i)
{
// TNH patches
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null) if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
{ {
Logger.LogInfo("We are in a TNH game!"); Logger.LogInfo("We are in a TNH game!");
instance = new GameObject().AddComponent<InPlay>(); instance = new GameObject().AddComponent<InPlay>();
break;
} }
else else
{
Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i));
yield return new WaitForEndOfFrame();
}
}
// destroy self only if we are FOR SURE not in a TNH game
if (GameObject.Find("_GameManager") == null || FindObjectOfType<TNH_Manager>() == null)
{ {
Logger.LogInfo("We are NOT in a TNH game!"); Logger.LogInfo("We are NOT in a TNH game!");
Destroy(instance); Destroy(instance);
+4
View File
@@ -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). For any issues/ideas, please create an issue at the GitHub repository (linked on Thunderstore page).
## Changelog ## Changelog
1.2.4
* [TNH] Fix errors occurring in Atlas-based maps
* Update MeatKit (now on Unity 5.6.7f1!)
1.2.3 1.2.3
* Added button in wrist menu to toggle HP counter (thanks PutterMyBancakes for the suggestion!) * 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() * [TNH] Made the search time for deprecated Leaderboard mod based on day of year as an input of the sin()
+5
View File
@@ -58,5 +58,10 @@ namespace TNHQoLImprovements
tnhInfo = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TNHInfo"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3)); tnhInfo = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TNHInfo"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
tnhInfo.transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); tnhInfo.transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
} }
void OnDestroy()
{
tnhManager = null;
}
} }
} }
+19 -3
View File
@@ -1,4 +1,5 @@
using HarmonyLib; using System.Collections;
using HarmonyLib;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -26,7 +27,7 @@ namespace TNHQoLImprovements
{ {
private Text text; private Text text;
private void Start() private IEnumerator Start()
{ {
var gObjText = new GameObject("TokenCounter"); var gObjText = new GameObject("TokenCounter");
gObjText.transform.SetParent(transform, false); gObjText.transform.SetParent(transform, false);
@@ -37,11 +38,26 @@ namespace TNHQoLImprovements
text.font = MeatKitPlugin.fontBombardier; text.font = MeatKitPlugin.fontBombardier;
text.fontSize = 55; text.fontSize = 55;
text.color = new Color(0.1307786f, 0.2461715f, 0.359f); text.color = new Color(0.1307786f, 0.2461715f, 0.359f);
while (InPlay.tnhManager == null)
{
Debug.Log("[ShopTokenNumber] tnhManager is null!");
yield return null;
} }
private void Update()
InPlay.tnhManager.TokenCountChangeEvent += UpdateText;
UpdateText();
}
private void UpdateText(int _ = 0)
{ {
int tokens = InPlay.tnhManager.GetNumTokens(); int tokens = InPlay.tnhManager.GetNumTokens();
text.text = tokens.ToString(); text.text = tokens.ToString();
} }
private void OnDestroy()
{
InPlay.tnhManager.TokenCountChangeEvent -= UpdateText;
}
} }
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB