mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-03 04:34:26 -07:00
6249f07788
encompasses releases 1.1.2 and 1.1.3
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using HarmonyLib;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using FistVR;
|
|
|
|
namespace TNHQoLImprovements
|
|
{
|
|
/// <summary>
|
|
/// Code here should only be run when in TNH play.
|
|
/// </summary>
|
|
public class InPlay : MonoBehaviour
|
|
{
|
|
public static TNH_Manager tnhManager;
|
|
|
|
private static Transform[] hands;
|
|
private static GameObject tnhInfo;
|
|
|
|
public static bool InHold()
|
|
{
|
|
if (tnhManager == null)
|
|
return false;
|
|
|
|
return tnhManager.Phase == TNH_Phase.Hold;
|
|
}
|
|
|
|
// Bring extra info into game over
|
|
public static void Patch(Harmony harmony)
|
|
{
|
|
var original = typeof(TNH_Manager).GetMethod("SetPhase", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
var patch = typeof(InPlay).GetMethod("MoveStatsToController", BindingFlags.NonPublic | BindingFlags.Static);
|
|
harmony.Patch(original, postfix: new HarmonyMethod(patch));
|
|
}
|
|
|
|
private static void MoveStatsToController(TNH_Phase p)
|
|
{
|
|
if (tnhManager == null)
|
|
return;
|
|
|
|
if (p == TNH_Phase.Dead || p == TNH_Phase.Completed)
|
|
{
|
|
int handSide = tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1;
|
|
|
|
tnhInfo.transform.SetParent(hands[handSide], false);
|
|
tnhInfo.GetComponent<TNHInfo>().GameOverPos();
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>();
|
|
|
|
var rig = Object.FindObjectOfType<FVRMovementManager>().transform;
|
|
hands = new Transform[] {
|
|
rig.transform.GetChild(1), rig.transform.GetChild(0)
|
|
};
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |