mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
change initialization approach, refactoring
should resolve errors occurring on both Atlas and WurstMod maps
This commit is contained in:
@@ -68,7 +68,7 @@ public static AssetBundle bundle;
|
|||||||
public static ConfigEntry<HealthExpireIndicationType> cfgHealthCrystalIndicator;
|
public static ConfigEntry<HealthExpireIndicationType> cfgHealthCrystalIndicator;
|
||||||
|
|
||||||
// Take and Hold modifications
|
// Take and Hold modifications
|
||||||
private static InPlay instance;
|
private static InPlay playInstance;
|
||||||
|
|
||||||
// Searching for old leaderboards player count mod to disable
|
// Searching for old leaderboards player count mod to disable
|
||||||
private float lpcSearchTime;
|
private float lpcSearchTime;
|
||||||
@@ -83,21 +83,40 @@ public static AssetBundle bundle;
|
|||||||
|
|
||||||
private Harmony harmony;
|
private Harmony harmony;
|
||||||
|
|
||||||
// Could soft-lock if we're not in TNH!
|
|
||||||
public static IEnumerator WaitForTNHInit()
|
|
||||||
{
|
|
||||||
while (InPlay.tnhManager == null || FindObjectOfType<TNH_Manager>() == null)
|
|
||||||
{
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SceneChanged(Scene from, Scene to)
|
private void SceneChanged(Scene from, Scene to)
|
||||||
{
|
{
|
||||||
|
StartCoroutine("SceneChangedCoroutine");
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator SceneChangedCoroutine()
|
||||||
|
{
|
||||||
|
Destroy(playInstance);
|
||||||
|
for (int i = 0; i < 11; ++i)
|
||||||
|
{
|
||||||
|
// TNH patches
|
||||||
|
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
||||||
|
{
|
||||||
|
Logger.LogInfo("We are in a TNH game!");
|
||||||
|
playInstance = new GameObject().AddComponent<InPlay>();
|
||||||
|
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i));
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playInstance == null)
|
||||||
|
{
|
||||||
|
Logger.LogInfo("We are NOT in a TNH game!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup non-TNH specific static objects
|
||||||
|
// running AFTER searching for TNH_Manager ensures we have everything initialized
|
||||||
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
||||||
hpDisplay = FindObjectOfType<FVRHealthBar>();
|
hpDisplay = FindObjectOfType<FVRHealthBar>();
|
||||||
GetFonts();
|
|
||||||
|
|
||||||
// apply health counter tweaks globally
|
// apply health counter tweaks globally
|
||||||
if (hpDisplay != null)
|
if (hpDisplay != null)
|
||||||
{
|
{
|
||||||
@@ -112,34 +131,7 @@ public static AssetBundle bundle;
|
|||||||
{
|
{
|
||||||
WristMenuAPI.Buttons.Remove(wmbHPToggle);
|
WristMenuAPI.Buttons.Remove(wmbHPToggle);
|
||||||
}
|
}
|
||||||
|
GetFonts();
|
||||||
StartCoroutine("TryTNH");
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator TryTNH()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 11; ++i)
|
|
||||||
{
|
|
||||||
// TNH patches
|
|
||||||
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
|
||||||
{
|
|
||||||
Logger.LogInfo("We are in a TNH game!");
|
|
||||||
instance = new GameObject().AddComponent<InPlay>();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
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!");
|
|
||||||
Destroy(instance);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// called on scene change, find fonts from game if they're not set
|
// called on scene change, find fonts from game if they're not set
|
||||||
|
|||||||
Generated
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a7e0925cb0a2d20488bcb5d230cf74f7
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1690792321
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
using System.Collections;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using FistVR;
|
using FistVR;
|
||||||
|
|
||||||
// To be attached to FVRHealthBar object
|
// To be attached to FVRHealthBar object
|
||||||
public class HPHideWhenAiming : MonoBehaviour {
|
public class HPHideWhenAiming : MonoBehaviour
|
||||||
|
{
|
||||||
CanvasGroup canvasGroup;
|
CanvasGroup canvasGroup;
|
||||||
|
|
||||||
GameObject gObjHUD;
|
GameObject gObjHUD;
|
||||||
@@ -25,7 +24,8 @@ public class HPHideWhenAiming : MonoBehaviour {
|
|||||||
//LineRenderer colliderRenderer;
|
//LineRenderer colliderRenderer;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start() {
|
void Start()
|
||||||
|
{
|
||||||
gObjHUD = transform.GetChild(0).gameObject;
|
gObjHUD = transform.GetChild(0).gameObject;
|
||||||
leftHand = MeatKitPlugin.playerCamera.transform.parent.GetChild(1).GetComponent<FVRViveHand>();
|
leftHand = MeatKitPlugin.playerCamera.transform.parent.GetChild(1).GetComponent<FVRViveHand>();
|
||||||
rightHand = MeatKitPlugin.playerCamera.transform.parent.GetChild(0).GetComponent<FVRViveHand>();
|
rightHand = MeatKitPlugin.playerCamera.transform.parent.GetChild(0).GetComponent<FVRViveHand>();
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using HarmonyLib;
|
using UnityEngine;
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
using FistVR;
|
using FistVR;
|
||||||
|
|
||||||
namespace TNHQoLImprovements
|
namespace TNHQoLImprovements
|
||||||
@@ -32,7 +30,6 @@ namespace TNHQoLImprovements
|
|||||||
|
|
||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
{
|
{
|
||||||
// Destroy statics
|
|
||||||
tnhManager = null;
|
tnhManager = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user