2022-01-28 19:57:50 -08:00
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
2022-01-22 20:13:49 -08:00
|
|
|
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;
|
|
|
|
|
|
2022-01-28 19:57:50 -08:00
|
|
|
private static Transform[] hands;
|
|
|
|
|
private static GameObject tnhInfo;
|
2022-01-22 20:13:49 -08:00
|
|
|
|
2022-01-30 03:16:24 -08:00
|
|
|
public static bool InHold()
|
|
|
|
|
{
|
|
|
|
|
if (tnhManager == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return tnhManager.Phase == TNH_Phase.Hold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bring extra info into game over
|
2022-01-28 19:57:50 -08:00
|
|
|
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)
|
2022-01-24 01:48:22 -08:00
|
|
|
{
|
2022-01-28 19:57:50 -08:00
|
|
|
int handSide = tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
tnhInfo.transform.SetParent(hands[handSide], false);
|
|
|
|
|
tnhInfo.GetComponent<TNHInfo>().GameOverPos();
|
2022-01-24 01:48:22 -08:00
|
|
|
}
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2022-06-06 19:09:31 -07:00
|
|
|
tnhManager = FindObjectOfType<TNH_Manager>();
|
2022-01-22 20:13:49 -08:00
|
|
|
|
2022-01-28 19:57:50 -08:00
|
|
|
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);
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|