2022-01-30 03:16:24 -08:00
|
|
|
using HarmonyLib;
|
2023-07-31 00:12:10 -07:00
|
|
|
using System.Reflection;
|
2022-01-30 03:16:24 -08:00
|
|
|
using UnityEngine;
|
2022-01-28 19:57:50 -08:00
|
|
|
using FistVR;
|
|
|
|
|
|
|
|
|
|
namespace TNHQoLImprovements
|
|
|
|
|
{
|
|
|
|
|
class TNHInfo : MonoBehaviour
|
|
|
|
|
{
|
2023-07-31 00:12:10 -07:00
|
|
|
public static TNHInfo instance;
|
|
|
|
|
|
|
|
|
|
public Transform[] hands;
|
|
|
|
|
private GameObject holdCounter;
|
2022-01-28 19:57:50 -08:00
|
|
|
private GameObject tokenCounter;
|
2022-01-30 03:16:24 -08:00
|
|
|
private GameObject waveCounter;
|
2022-01-28 19:57:50 -08:00
|
|
|
|
2023-07-31 00:12:10 -07:00
|
|
|
// 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(TNHInfo).GetMethod("MoveStatsToController", BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
|
|
harmony.Patch(original, postfix: new HarmonyMethod(patch));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void MoveStatsToController(TNH_Phase p)
|
|
|
|
|
{
|
|
|
|
|
if (InPlay.tnhManager == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (p == TNH_Phase.Dead || p == TNH_Phase.Completed)
|
|
|
|
|
{
|
|
|
|
|
int handSide = InPlay.tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
instance.transform.SetParent(instance.hands[handSide], false);
|
|
|
|
|
instance.GetComponent<TNHInfo>().GameOverPos();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
2022-01-28 19:57:50 -08:00
|
|
|
{
|
2023-07-31 00:12:10 -07:00
|
|
|
instance = this;
|
|
|
|
|
|
|
|
|
|
if (MeatKitPlugin.cfgShowHolds.Value)
|
2022-01-28 19:57:50 -08:00
|
|
|
holdCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), transform);
|
|
|
|
|
if (MeatKitPlugin.cfgShowTokens.Value)
|
|
|
|
|
tokenCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), transform);
|
2022-01-30 03:16:24 -08:00
|
|
|
if (MeatKitPlugin.cfgShowWaves.Value)
|
|
|
|
|
waveCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("WaveCounter"), transform);
|
2022-01-28 19:57:50 -08:00
|
|
|
|
2023-07-31 00:12:10 -07:00
|
|
|
var rig = Object.FindObjectOfType<FVRMovementManager>().transform;
|
|
|
|
|
hands = new Transform[] {
|
|
|
|
|
rig.transform.GetChild(1), rig.transform.GetChild(0)
|
|
|
|
|
};
|
|
|
|
|
|
2022-01-30 03:16:24 -08:00
|
|
|
PlayPos();
|
2022-01-28 19:57:50 -08:00
|
|
|
}
|
|
|
|
|
|
2023-07-31 00:12:10 -07:00
|
|
|
private void PlayPos()
|
2022-01-28 19:57:50 -08:00
|
|
|
{
|
2022-02-13 03:17:47 -08:00
|
|
|
transform.localPosition = new Vector3(0, 0, -1.2f);
|
2022-01-28 19:57:50 -08:00
|
|
|
if (holdCounter != null)
|
2022-02-13 03:17:47 -08:00
|
|
|
holdCounter.transform.localPosition = new Vector3(-333, 0, 0);
|
2022-01-28 19:57:50 -08:00
|
|
|
|
|
|
|
|
if (tokenCounter != null)
|
2022-02-13 03:17:47 -08:00
|
|
|
tokenCounter.transform.localPosition = new Vector3(333, 0, 0);
|
2022-01-30 03:16:24 -08:00
|
|
|
|
|
|
|
|
if (waveCounter != null)
|
2022-02-13 03:17:47 -08:00
|
|
|
waveCounter.transform.localPosition = new Vector3(333, 0, 0);
|
2022-01-28 19:57:50 -08:00
|
|
|
}
|
|
|
|
|
|
2023-07-31 00:12:10 -07:00
|
|
|
private void GameOverPos()
|
2022-01-28 19:57:50 -08:00
|
|
|
{
|
2022-02-13 03:17:47 -08:00
|
|
|
transform.localScale = new Vector3(.0002f, .0002f, .0002f);
|
|
|
|
|
transform.localPosition = Vector3.zero;
|
|
|
|
|
transform.localRotation = Quaternion.identity;
|
|
|
|
|
|
2022-01-28 19:57:50 -08:00
|
|
|
if (holdCounter != null)
|
2022-02-13 03:17:47 -08:00
|
|
|
{
|
|
|
|
|
holdCounter.gameObject.GetComponent<RectTransform>().pivot = new Vector2(1, 1);
|
2022-01-28 19:57:50 -08:00
|
|
|
holdCounter.transform.localPosition = new Vector3(-250, 0, 0);
|
2022-02-13 03:17:47 -08:00
|
|
|
}
|
2022-01-28 19:57:50 -08:00
|
|
|
|
|
|
|
|
if (tokenCounter != null)
|
2022-02-13 03:17:47 -08:00
|
|
|
{
|
|
|
|
|
tokenCounter.gameObject.GetComponent<RectTransform>().pivot = new Vector2(0, 1);
|
2022-01-28 19:57:50 -08:00
|
|
|
tokenCounter.transform.localPosition = new Vector3(250, 0, 0);
|
2022-02-13 03:17:47 -08:00
|
|
|
}
|
2022-01-30 03:16:24 -08:00
|
|
|
|
|
|
|
|
if (waveCounter != null)
|
|
|
|
|
{
|
|
|
|
|
waveCounter.gameObject.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
|
|
|
|
waveCounter.transform.localPosition = new Vector3(0, 0, 140);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-31 00:12:10 -07:00
|
|
|
private void Update()
|
2022-01-30 03:16:24 -08:00
|
|
|
{
|
2023-07-30 22:46:37 -07:00
|
|
|
// game over area; do not update anything else
|
|
|
|
|
if (InPlay.tnhManager.Phase == TNH_Phase.Dead || InPlay.tnhManager.Phase == TNH_Phase.Completed)
|
2022-01-30 03:16:24 -08:00
|
|
|
{
|
|
|
|
|
if (tokenCounter != null)
|
|
|
|
|
tokenCounter.SetActive(true);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-13 03:17:47 -08:00
|
|
|
// TNHInfo rotate to player camera
|
|
|
|
|
if (MeatKitPlugin.cfgInfoFollowCamera.Value)
|
|
|
|
|
{
|
|
|
|
|
transform.LookAt(MeatKitPlugin.playerCamera.transform);
|
|
|
|
|
var rotLook = transform.localEulerAngles;
|
|
|
|
|
var rot = Vector3.zero;
|
|
|
|
|
|
|
|
|
|
rot.x = -rotLook.x - 90;
|
|
|
|
|
transform.localRotation = Quaternion.Euler(rot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we're in a hold; hide token count and show wave count
|
|
|
|
|
if (InPlay.tnhManager.Phase == TNH_Phase.Hold)
|
2022-01-30 03:16:24 -08:00
|
|
|
{
|
|
|
|
|
if (tokenCounter != null)
|
|
|
|
|
tokenCounter.SetActive(false);
|
|
|
|
|
|
|
|
|
|
if (waveCounter != null)
|
|
|
|
|
waveCounter.SetActive(true);
|
|
|
|
|
}
|
2022-02-13 03:17:47 -08:00
|
|
|
else // NOT in hold; do the inverse
|
2022-01-30 03:16:24 -08:00
|
|
|
{
|
|
|
|
|
if (tokenCounter != null)
|
|
|
|
|
tokenCounter.SetActive(true);
|
|
|
|
|
|
|
|
|
|
if (waveCounter != null)
|
|
|
|
|
waveCounter.SetActive(false);
|
|
|
|
|
}
|
2022-01-28 19:57:50 -08:00
|
|
|
}
|
2023-07-31 00:12:10 -07:00
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
instance = null;
|
|
|
|
|
}
|
2022-01-28 19:57:50 -08:00
|
|
|
}
|
|
|
|
|
}
|