Reorganize, revert changes for "fixing" Atlas maps

This commit is contained in:
msk
2023-07-31 00:12:10 -07:00
parent cf4b2847be
commit 73d8a5b89d
5 changed files with 70 additions and 41 deletions
+9 -32
View File
@@ -1,7 +1,6 @@
using HarmonyLib;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
using FistVR;
namespace TNHQoLImprovements
@@ -13,9 +12,6 @@ namespace TNHQoLImprovements
{
public static TNH_Manager tnhManager;
private static Transform[] hands;
private static GameObject tnhInfo;
public static bool InHold()
{
if (tnhManager == null)
@@ -24,39 +20,20 @@ namespace TNHQoLImprovements
return tnhManager.Phase == TNH_Phase.Hold;
}
// 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(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)
{
int handSide = tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1;
tnhInfo.transform.SetParent(hands[handSide], false);
tnhInfo.GetComponent<TNHInfo>().GameOverPos();
}
}
void Start()
{
tnhManager = FindObjectOfType<TNH_Manager>();
var rig = Object.FindObjectOfType<FVRMovementManager>().transform;
hands = new Transform[] {
rig.transform.GetChild(1), rig.transform.GetChild(0)
};
TNHInfo.instance = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TNHInfo"),
FindObjectOfType<TAH_Reticle>().transform.GetChild(3))
.GetComponent<TNHInfo>();
TNHInfo.instance.transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
}
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);
void OnDestroy()
{
// Destroy statics
tnhManager = null;
}
}
}
+44 -6
View File
@@ -1,4 +1,5 @@
using HarmonyLib;
using System.Reflection;
using UnityEngine;
using FistVR;
@@ -6,23 +7,55 @@ namespace TNHQoLImprovements
{
class TNHInfo : MonoBehaviour
{
private GameObject holdCounter;
public static TNHInfo instance;
public Transform[] hands;
private GameObject holdCounter;
private GameObject tokenCounter;
private GameObject waveCounter;
public void Start()
// Bring extra info into game over
public static void Patch(Harmony harmony)
{
if (MeatKitPlugin.cfgShowHolds.Value)
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()
{
instance = this;
if (MeatKitPlugin.cfgShowHolds.Value)
holdCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), transform);
if (MeatKitPlugin.cfgShowTokens.Value)
tokenCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), transform);
if (MeatKitPlugin.cfgShowWaves.Value)
waveCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("WaveCounter"), transform);
var rig = Object.FindObjectOfType<FVRMovementManager>().transform;
hands = new Transform[] {
rig.transform.GetChild(1), rig.transform.GetChild(0)
};
PlayPos();
}
public void PlayPos()
private void PlayPos()
{
transform.localPosition = new Vector3(0, 0, -1.2f);
if (holdCounter != null)
@@ -35,7 +68,7 @@ namespace TNHQoLImprovements
waveCounter.transform.localPosition = new Vector3(333, 0, 0);
}
public void GameOverPos()
private void GameOverPos()
{
transform.localScale = new Vector3(.0002f, .0002f, .0002f);
transform.localPosition = Vector3.zero;
@@ -60,7 +93,7 @@ namespace TNHQoLImprovements
}
}
public void Update()
private void Update()
{
// game over area; do not update anything else
if (InPlay.tnhManager.Phase == TNH_Phase.Dead || InPlay.tnhManager.Phase == TNH_Phase.Completed)
@@ -100,5 +133,10 @@ namespace TNHQoLImprovements
waveCounter.SetActive(false);
}
}
void OnDestroy()
{
instance = null;
}
}
}