many shit (survived an SSD failure, plz push more)

This commit is contained in:
msk
2022-01-28 19:57:50 -08:00
parent fcea383739
commit 1eb6628a37
22 changed files with 732 additions and 113 deletions
+29 -40
View File
@@ -1,4 +1,5 @@
using System.Collections;
using HarmonyLib;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
using FistVR;
@@ -10,42 +11,30 @@ namespace TNHQoLImprovements
/// </summary>
public class InPlay : MonoBehaviour
{
private GameObject gObjHUD;
public static TNH_Manager tnhManager;
void ImproveHPTextReadability()
{
var canvas = gObjHUD.GetComponent<Canvas>();
var gObjBG = new GameObject();
Transform[] tranHPText = {
gObjHUD.transform.Find("Label_Title (1)"),
gObjHUD.transform.Find("Label_Title")
};
private static Transform[] hands;
private static GameObject tnhInfo;
// apply background
if (MeatKitPlugin.cfgShowHPBackground.Value)
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)
{
gObjBG.transform.parent = gObjHUD.transform;
gObjBG.transform.SetSiblingIndex(0);
gObjBG.transform.localPosition = new Vector3(0, 1, 0);
gObjBG.transform.localRotation = Quaternion.identity;
gObjBG.transform.localScale = tranHPText[0].localScale;
var rawImage = gObjBG.AddComponent<RawImage>();
rawImage.color = new Color(0, 0, 0, MeatKitPlugin.cfgHPBackgroundOpacity.Value);
rawImage.rectTransform.SetWidth(100);
rawImage.rectTransform.SetHeight(52);
}
if (MeatKitPlugin.cfgSolidifyHPText.Value)
{
foreach (var text in tranHPText)
{
// full alpha
text.GetComponent<Text>().color = Color.white;
// drop shadow
var shadow = text.gameObject.AddComponent<Shadow>();
shadow.effectColor = new Color(0, 0, 0, .95f);
shadow.effectDistance = new Vector2(0.5f, -0.5f);
}
int handSide = tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1;
tnhInfo.transform.SetParent(hands[handSide], false);
tnhInfo.transform.localScale = new Vector3(.0002f, .0002f, .0002f);
tnhInfo.GetComponent<TNHInfo>().GameOverPos();
}
}
@@ -53,14 +42,14 @@ namespace TNHQoLImprovements
void Start()
{
tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>();
gObjHUD = GameObject.Find("HealthBar(Clone)/f");
if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value)
ImproveHPTextReadability();
if (MeatKitPlugin.cfgShowTokens.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
if (MeatKitPlugin.cfgShowHolds.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
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);
}
}
}