mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
1.1.0 release! many new features.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using FistVR;
|
||||
|
||||
namespace TNHQoLImprovements
|
||||
{
|
||||
public static class ShopTokenPatch
|
||||
{
|
||||
public static void Patch(Harmony harmony)
|
||||
{
|
||||
var original = typeof(TNH_ObjectConstructor).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var postfix = typeof(ShopTokenPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
harmony.Patch(original, postfix: new HarmonyMethod(postfix));
|
||||
}
|
||||
private static void Postfix(TNH_ObjectConstructor __instance)
|
||||
{
|
||||
// add component to 1st token icon
|
||||
__instance.transform.GetChild(0).GetChild(0).GetChild(2).GetChild(0).gameObject.AddComponent<ShopTokenNumber>();
|
||||
}
|
||||
}
|
||||
|
||||
// child of TopCell (the 0th child)
|
||||
class ShopTokenNumber : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var gObjText = new GameObject("TokenCounter");
|
||||
gObjText.transform.SetParent(transform, false);
|
||||
gObjText.transform.localPosition = new Vector3(0, -4, 0);
|
||||
|
||||
text = gObjText.AddComponent<Text>();
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
text.font = MeatKitPlugin.fontBombardier;
|
||||
text.fontSize = 55;
|
||||
text.color = new Color(0.1307786f, 0.2461715f, 0.359f);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
int tokens = InPlay.tnhManager.GetNumTokens();
|
||||
text.text = tokens.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user