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
Binary file not shown.
Binary file not shown.
+45
View File
@@ -0,0 +1,45 @@
using UnityEngine;
using UnityEngine.UI;
namespace TNHQoLImprovements
{
public static class HPReadability
{
public static void ImproveHPTextReadability(GameObject gObjHUD)
{
Debug.Log("gObjHUD: " + gObjHUD);
var canvas = gObjHUD.GetComponent<Canvas>();
var gObjBG = new GameObject();
Transform[] tranHPText = {
gObjHUD.transform.Find("Label_Title (1)"),
gObjHUD.transform.Find("Label_Title")
};
// apply background
if (MeatKitPlugin.cfgShowHPBackground.Value)
{
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);
}
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 13876b4618c99394bbb2838f5c26cd19
timeCreated: 1643268023
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+12 -21
View File
@@ -6,7 +6,17 @@ using FistVR;
namespace TNHQoLImprovements
{
public class HoldCounter : MonoBehaviour
public static class HoldCounterPatch
{
public static void Patch(Harmony harmony)
{
var original = typeof(TNH_Manager).GetMethod("HoldPointCompleted", BindingFlags.Public | BindingFlags.Instance);
var patch = typeof(HoldCounter).GetMethod("OnHoldEnd");
harmony.Patch(original, postfix: new HarmonyMethod(patch));
}
}
public class HoldCounter : MonoBehaviour
{
private Text lblHoldCount;
private Text lblWinLose;
@@ -14,21 +24,6 @@ namespace TNHQoLImprovements
public static int[] winLose = { -1, 1 };
public const string WIN_LOSE_TEXT = "<color=#10ff10>{0}</color> <color=red>{1}</color>";
private void OnDeath(bool _)
{
Debug.Log("I died!");
// TODO: bind stats to controller hand
}
// TODO: win/lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted
public static void Patch(Harmony harmony)
{
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)
@@ -39,17 +34,13 @@ namespace TNHQoLImprovements
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);
transform.localPosition = new Vector3(-333, 0, -450);
lblHoldCount = transform.GetChild(1).GetComponent<Text>();
lblWinLose = transform.GetChild(2).GetComponent<Text>();
winLose[0] = 0;
winLose[1] = 0;
FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
}
void Update()
+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);
}
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using FistVR;
namespace TNHQoLImprovements
{
public class ShopCostPatch : MonoBehaviour
{
public static void Patch(Harmony harmony)
{
var original = typeof(TNH_ObjectConstructorIcon).GetMethod("Init", BindingFlags.Public | BindingFlags.Instance);
var postfix = typeof(ShopCostPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static);
harmony.Patch(original, new HarmonyMethod(postfix));
}
private static void AddNumericalRepresentation(TNH_ObjectConstructorIcon __instance)
{
foreach (Transform curTran in __instance.gameObject.transform)
{
if (curTran.name.Contains("Cost"))
curTran.gameObject.AddComponent<ShopCostNumber>();
}
}
}
public class ShopCostNumber : MonoBehaviour
{
private TNH_ObjectConstructorIcon objConstructor;
private Text text;
public void Awake()
{
objConstructor = transform.parent.GetComponent<TNH_ObjectConstructorIcon>();
}
public void Start()
{
var textTran = new GameObject().transform;
textTran.SetParent(transform, false);
textTran.localPosition = new Vector2(0, -245);
text = textTran.gameObject.AddComponent<Text>();
text.font = MeatKitPlugin.fontAgencyFB;
text.alignment = TextAnchor.MiddleCenter;
text.fontSize = 50;
}
public void Update()
{
text.text = objConstructor.Cost.ToString();
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 51b19459f850a654488e4057bf5dbb1f
timeCreated: 1643424482
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+38
View File
@@ -0,0 +1,38 @@
using UnityEngine;
using FistVR;
namespace TNHQoLImprovements
{
class TNHInfo : MonoBehaviour
{
private GameObject holdCounter;
private GameObject tokenCounter;
public void Start()
{
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);
}
public void PlayPos()
{
if (holdCounter != null)
holdCounter.transform.localPosition = new Vector3(-333, 0, -450);
if (tokenCounter != null)
tokenCounter.transform.localPosition = new Vector3(333, 0, -450);
}
public void GameOverPos()
{
if (holdCounter != null)
holdCounter.transform.localPosition = new Vector3(-250, 0, 0);
if (tokenCounter != null)
tokenCounter.transform.localPosition = new Vector3(250, 0, 0);
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0d549cfce77855f4e9d9778d4c602f21
timeCreated: 1643333500
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+10 -12
View File
@@ -5,6 +5,11 @@ using FistVR;
namespace TNHQoLImprovements
{
public enum HealthExpireIndicationType
{
None, Flashing, CircularGraphic
}
/// <summary>
/// If KillAfter is attached to a HealthCrystal, show visual representation of expiration.
/// </summary>
@@ -29,27 +34,20 @@ namespace TNHQoLImprovements
if (__instance.transform.GetComponentInChildren<HealthPickUp>() == null)
return;
Debug.Log("KillAfter will expire in " + __instance.DieTime + " seconds.");
GameObject timer;
Transform healthCrystal = __instance.transform.Find("HealthCrystal");
switch (VISUAL_APPROACH)
switch (MeatKitPlugin.cfgHealthCrystalIndicator.Value)
{
case 0: // ring above
case HealthExpireIndicationType.CircularGraphic: // ring above
timer = GameObject.Instantiate<GameObject>(timerAsset, healthCrystal);
timer.GetComponent<UIRingTimer>().Init(__instance.DieTime);
timer.transform.localScale = new Vector2(0.001f, 0.001f);
timer.transform.localPosition = new Vector3(0, .9f, 0);
// TODO: disable scoring?
break;
case 1: // ring around
timer = GameObject.Instantiate<GameObject>(timerAsset, healthCrystal);
timer.GetComponent<UIRingTimer>().Init(__instance.DieTime);
timer.transform.localScale = new Vector2(0.0035f, 0.0035f);
timer.transform.localPosition = Vector3.zero;
break;
case 2: // flashing crystal
case HealthExpireIndicationType.Flashing: // flashing crystal
var flicker = healthCrystal.gameObject.AddComponent<MeshRendererFlicker>();
flicker.Init(.4f, 0.6f, __instance.DieTime - 3f);
flicker.Init(.6f, .7f, __instance.DieTime - 3);
break;
}
}
+2 -4
View File
@@ -9,11 +9,9 @@ namespace TNHQoLImprovements
{
void Start()
{
transform.localPosition = new Vector3(1, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
transform.localPosition = new Vector3(333, 0, -450);
StartCoroutine(SetTokenImage());
StartCoroutine(SetTokenImage());
}
private IEnumerator SetTokenImage()
+54
View File
@@ -0,0 +1,54 @@
using System.Reflection;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using FistVR;
namespace TNHQoLImprovements
{
public static class WavePatch
{
public static void Patch(Harmony harmony)
{
var original = typeof(TNH_Manager).GetMethod("HoldPointStarted", BindingFlags.Public | BindingFlags.Instance);
var patch = typeof(WavePatch).GetMethod("OnHoldStart", BindingFlags.NonPublic | BindingFlags.Static);
harmony.Patch(original, postfix: new HarmonyMethod(patch));
}
private static void OnHoldStart(TNH_HoldPoint p)
{
WaveCounter.WaveStarted.Invoke(p);
}
}
public class WaveCounter : MonoBehaviour
{
[System.Serializable]
public class WaveStartedEvent : UnityEvent<TNH_HoldPoint> { }
public static WaveStartedEvent WaveStarted = new WaveStartedEvent();
private bool initialized = false;
private TNH_HoldPoint holdPoint;
// Use this for initialization
void Start()
{
}
void Init(TNH_Manager manager)
{
holdPoint = manager.m_curHoldPoint;
initialized = true;
}
// Update is called once per frame
void Update()
{
if (!initialized)
return;
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c0c3423ff90fccc45bc00c97177b33fb
timeCreated: 1643271842
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: