2022-01-26 01:23:39 -08:00
|
|
|
using System.Reflection;
|
|
|
|
|
using HarmonyLib;
|
2022-01-22 20:13:49 -08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using FistVR;
|
|
|
|
|
|
|
|
|
|
namespace TNHQoLImprovements
|
|
|
|
|
{
|
|
|
|
|
public class HoldCounter : MonoBehaviour
|
|
|
|
|
{
|
2022-01-26 01:23:39 -08:00
|
|
|
private Text lblHoldCount;
|
|
|
|
|
private Text lblWinLose;
|
|
|
|
|
|
|
|
|
|
public static int[] winLose = { -1, 1 };
|
|
|
|
|
public const string WIN_LOSE_TEXT = "<color=#10ff10>{0}</color> <color=red>{1}</color>";
|
|
|
|
|
|
|
|
|
|
|
2022-01-22 23:41:31 -08:00
|
|
|
private void OnDeath(bool _)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("I died!");
|
2022-01-26 01:23:39 -08:00
|
|
|
// TODO: bind stats to controller hand
|
2022-01-24 03:40:08 -08:00
|
|
|
}
|
|
|
|
|
|
2022-01-26 01:23:39 -08:00
|
|
|
// TODO: win/lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted
|
|
|
|
|
public static void Patch(Harmony harmony)
|
2022-01-24 03:40:08 -08:00
|
|
|
{
|
2022-01-26 01:23:39 -08:00
|
|
|
var original = typeof(TNH_Manager).GetMethod("HoldPointCompleted", BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
var patch = typeof(HoldCounter).GetMethod("OnHoldEnd");
|
|
|
|
|
Debug.Log(string.Format("Original: {0} // Patch: {1}", original, patch));
|
|
|
|
|
harmony.Patch(original, postfix: new HarmonyMethod(patch));
|
|
|
|
|
}
|
|
|
|
|
public static void OnHoldEnd(TNH_HoldPoint p, bool success)
|
|
|
|
|
{
|
|
|
|
|
if (success)
|
|
|
|
|
winLose[0]++;
|
|
|
|
|
else
|
|
|
|
|
winLose[1]++;
|
2022-01-22 23:41:31 -08:00
|
|
|
}
|
|
|
|
|
|
2022-01-22 20:13:49 -08:00
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
transform.localPosition = new Vector3(-1f, 0, -.5f);
|
|
|
|
|
transform.localRotation = Quaternion.Euler(90, 0, 0);
|
|
|
|
|
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
|
2022-01-22 23:41:31 -08:00
|
|
|
|
2022-01-26 01:23:39 -08:00
|
|
|
lblHoldCount = transform.GetChild(1).GetComponent<Text>();
|
|
|
|
|
lblWinLose = transform.GetChild(2).GetComponent<Text>();
|
|
|
|
|
|
|
|
|
|
winLose[0] = 0;
|
|
|
|
|
winLose[1] = 0;
|
|
|
|
|
|
2022-01-24 03:40:08 -08:00
|
|
|
FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2022-01-26 01:23:39 -08:00
|
|
|
// Total hold count
|
2022-01-22 20:13:49 -08:00
|
|
|
string display = "";
|
|
|
|
|
if (InPlay.tnhManager.ProgressionMode == TNHSetting_ProgressionType.Marathon)
|
2022-01-22 23:41:31 -08:00
|
|
|
display = InPlay.tnhManager.m_level.ToString() + " / ∞";
|
2022-01-22 20:13:49 -08:00
|
|
|
else
|
|
|
|
|
display = string.Format("{0} / {1}", InPlay.tnhManager.m_level, InPlay.tnhManager.m_maxLevels);
|
2022-01-26 01:23:39 -08:00
|
|
|
lblHoldCount.text = display;
|
2022-01-22 20:13:49 -08:00
|
|
|
|
2022-01-26 01:23:39 -08:00
|
|
|
// Win/Lost holds
|
|
|
|
|
lblWinLose.text = string.Format(WIN_LOSE_TEXT, winLose[0], winLose[1]);
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|