2 Commits

Author SHA1 Message Date
msk 6f938e95c8 fix in-play stuff not working in other maps 2022-01-24 03:40:08 -08:00
msk b259424300 stop searching for TNHLBPC after 120s, add option for hp text visibility 2022-01-24 01:48:22 -08:00
6 changed files with 104 additions and 57 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
PackageName: TNH_Quality_of_Life_Improvements PackageName: TNH_Quality_of_Life_Improvements
Author: muskit Author: muskit
Version: 1.0.0 Version: 1.0.1
Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3} Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3}
ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3} ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3}
WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements
+52 -29
View File
@@ -32,28 +32,33 @@ public class MeatKitPlugin : BaseUnityPlugin
#pragma warning disable 414 #pragma warning disable 414
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
#pragma warning restore 414 #pragma warning restore 414
private bool lpcKilled = false;
public static AssetBundle bundle; public static AssetBundle bundle;
public static ConfigEntry<bool> cfgShowLPC;
public static ConfigEntry<bool> showHPBackground; public static ConfigEntry<bool> cfgSolidifyHPText;
public static ConfigEntry<float> hpBackgroundOpacity; public static ConfigEntry<bool> cfgShowHPBackground;
public static ConfigEntry<bool> showTokens; public static ConfigEntry<float> cfgHPBackgroundOpacity;
public static ConfigEntry<bool> showHolds; public static ConfigEntry<bool> cfgShowTokens;
public static ConfigEntry<bool> cfgShowHolds;
private static InPlay instance; private static InPlay instance;
private LeaderboardPlayerCountPatch lpc; private LeaderboardPlayerCountPatch lpc;
private bool lpcModGone = false;
private float lpcModSearchTimeEnd;
private void SceneChanged(Scene from, Scene to) private void SceneChanged(Scene from, Scene to)
{ {
//Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name)); //Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name));
if(GameObject.Find("_NewTAHReticle") != null) Logger.LogInfo("_GameManager present: " + (GameObject.Find("_GameManager") != null));
Logger.LogInfo("TNH_Manager object present: " + (FindObjectOfType<FistVR.TNH_Manager>() != null));
if(GameObject.Find("_GameManager") != null || FindObjectOfType<FistVR.TNH_Manager>() != null)
{ {
Logger.LogInfo("We are in a TNH game!");
instance = new GameObject().AddComponent<InPlay>(); instance = new GameObject().AddComponent<InPlay>();
} }
else else
{ {
Logger.LogInfo("We are NOT in a TNH game!");
Destroy(instance); Destroy(instance);
} }
} }
@@ -66,35 +71,47 @@ public class MeatKitPlugin : BaseUnityPlugin
LoadAssets(); LoadAssets();
// setup configuration // setup configuration
showHPBackground = Config.Bind("Health Counter", cfgShowHPBackground = Config.Bind("Health Counter",
"Background enabled", "Background enabled",
true, true,
"Apply a background to the health text."); "Apply a background to the health text.");
hpBackgroundOpacity = Config.Bind("Health Counter", cfgHPBackgroundOpacity = Config.Bind("Health Counter",
"Background opacity", "Background opacity",
0.74f, 0.74f,
"Set opacity of health text's background (if enabled)."); "Set opacity of health text's background (if enabled).");
showTokens = Config.Bind("Game Info", cfgSolidifyHPText = Config.Bind("Health Counter",
"Show Tokens", "Solidify HP text",
true,
"Set opacity of HP text to full and give it a shadow.");
cfgShowLPC = Config.Bind("Game Info",
"Show player count in online leaderboards",
true, true,
"Shows how many tokens the player has by their radar hand."); "Shows the number of players in the currently selected TNH leaderboard.");
showHolds = Config.Bind("Game Info", cfgShowTokens = Config.Bind("Game Info",
"Show Holds", "Show Tokens",
true, true,
"Shows how many holds the player has completed by their radar hand."); "Shows how many tokens the player has by their radar hand.");
cfgShowHolds = Config.Bind("Game Info",
"Show Holds",
true,
"Shows how many holds the player has completed by their radar hand.");
// patch the leaderboard // patch leaderboard code
lpc = new LeaderboardPlayerCountPatch(); if (cfgShowLPC.Value)
lpc = new LeaderboardPlayerCountPatch();
// give 120 seconds to search for old mod
lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120;
} }
// DO NOT EDIT. // DO NOT EDIT.
private void LoadAssets() {} private void LoadAssets() {}
/// <summary> /// <summary>
/// Its only purpose: to kill TNH Leaderboard Player Count /// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod.
/// </summary> /// </summary>
private void Update() private void Update()
{ {
if (lpcKilled) if (lpcModGone)
return; return;
foreach (var plugin in Chainloader.PluginInfos) foreach (var plugin in Chainloader.PluginInfos)
@@ -103,9 +120,15 @@ public class MeatKitPlugin : BaseUnityPlugin
{ {
Logger.LogWarning("TNH Leaderboard Player Count mod detected. Destroying it to avoid interference."); Logger.LogWarning("TNH Leaderboard Player Count mod detected. Destroying it to avoid interference.");
Destroy(plugin.Value.Instance); Destroy(plugin.Value.Instance);
lpcKilled = true; lpcModGone = true;
} }
} }
if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd)
{
Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 120 seconds.");
lpcModGone = true;
}
} }
} }
#endif #endif
+14 -2
View File
@@ -2,13 +2,25 @@
This mod adds quality of life improvements to the *Take and Hold* experience. This mod adds quality of life improvements to the *Take and Hold* experience.
## Features ## Features
* More visible HP counter * Better Health counter visibility
* Token and hold counter on wrist * Token and hold counter on wrist
* Player count for online leaderboards; see how you stack up! * Player count for online leaderboards; see how you stack up!
* Incompatible with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/); feature will be disabled! * Won't work with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/) installed
Enable/disable these features in your mod manager's *Config editor*. Enable/disable these features in your mod manager's *Config editor*.
For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page). For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page).
## Changelog
1.0.1
* Fixed the in-play improvements only applying in Classic Hallways map (whoops!!)
* Added option to enable/disable showing player count of online leaderboards
* Added option to enable/disable HP text opacity/shadow change
* (Surprisingly, the HP text normally doesn't have full opacity)
* Searching for TNH Leaderboards Player Count now stops after 120s
1.0.0
* Initial release!
**NOTE: [*TNH Leaderboard Player Count*](https://h3vr.thunderstore.io/package/muskit/TNH_Leaderboard_Player_Count/) has been merged with this mod. If installed, please remove that mod as it lacks features and is no longer supported.** **NOTE: [*TNH Leaderboard Player Count*](https://h3vr.thunderstore.io/package/muskit/TNH_Leaderboard_Player_Count/) has been merged with this mod. If installed, please remove that mod as it lacks features and is no longer supported.**
+9 -2
View File
@@ -11,16 +11,23 @@ namespace TNHQoLImprovements
private void OnDeath(bool _) private void OnDeath(bool _)
{ {
Debug.Log("I died!"); Debug.Log("I died!");
}
// TODO: lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted
private void OnHoldLose()
{
} }
void Start() void Start()
{ {
transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; //transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(-1f, 0, -.5f); transform.localPosition = new Vector3(-1f, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
GameObject.Find("[SceneSettings]").GetComponent<FVRSceneSettings>().PlayerDeathEvent += OnDeath; FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
} }
void Update() void Update()
+23 -19
View File
@@ -19,33 +19,36 @@ namespace TNHQoLImprovements
{ {
var canvas = gObjHUD.GetComponent<Canvas>(); var canvas = gObjHUD.GetComponent<Canvas>();
var gObjBG = new GameObject(); var gObjBG = new GameObject();
var tranHPTitle = gObjHUD.transform.Find("Label_Title (1)"); Transform[] tranHPText = {
var tranHP = gObjHUD.transform.Find("Label_Title"); gObjHUD.transform.Find("Label_Title (1)"),
gObjHUD.transform.Find("Label_Title")
};
// apply background // apply background
if (MeatKitPlugin.showHPBackground.Value) if (MeatKitPlugin.cfgShowHPBackground.Value)
{ {
gObjBG.transform.parent = gObjHUD.transform; gObjBG.transform.parent = gObjHUD.transform;
gObjBG.transform.SetSiblingIndex(0); gObjBG.transform.SetSiblingIndex(0);
gObjBG.transform.localPosition = new Vector3(0, 1, 0); gObjBG.transform.localPosition = new Vector3(0, 1, 0);
gObjBG.transform.localRotation = Quaternion.identity; gObjBG.transform.localRotation = Quaternion.identity;
gObjBG.transform.localScale = tranHP.localScale; gObjBG.transform.localScale = tranHPText[0].localScale;
var rawImage = gObjBG.AddComponent<RawImage>(); var rawImage = gObjBG.AddComponent<RawImage>();
rawImage.color = new Color(0, 0, 0, MeatKitPlugin.hpBackgroundOpacity.Value); rawImage.color = new Color(0, 0, 0, MeatKitPlugin.cfgHPBackgroundOpacity.Value);
rawImage.rectTransform.SetWidth(100); rawImage.rectTransform.SetWidth(100);
rawImage.rectTransform.SetHeight(52); rawImage.rectTransform.SetHeight(52);
} }
if (MeatKitPlugin.cfgSolidifyHPText.Value)
// full text alphas {
tranHPTitle.GetComponent<Text>().color = Color.white; foreach (var text in tranHPText)
tranHP.GetComponent<Text>().color = Color.white; {
// text shadows // full alpha
var shadow = tranHPTitle.gameObject.AddComponent<Shadow>(); text.GetComponent<Text>().color = Color.white;
shadow.effectColor = new Color(0, 0, 0, .95f); // drop shadow
shadow.effectDistance = new Vector2(0.5f, -0.5f); var shadow = text.gameObject.AddComponent<Shadow>();
shadow = tranHP.gameObject.AddComponent<Shadow>(); shadow.effectColor = new Color(0, 0, 0, .95f);
shadow.effectColor = new Color(0, 0, 0, .95f); shadow.effectDistance = new Vector2(0.5f, -0.5f);
shadow.effectDistance = new Vector2(0.5f, -0.5f); }
}
} }
// Use this for initialization // Use this for initialization
@@ -54,10 +57,11 @@ namespace TNHQoLImprovements
tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>(); tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>();
gObjHUD = GameObject.Find("HealthBar(Clone)/f"); gObjHUD = GameObject.Find("HealthBar(Clone)/f");
ImproveHPTextReadability(); if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value)
if (MeatKitPlugin.showTokens.Value) ImproveHPTextReadability();
if (MeatKitPlugin.cfgShowTokens.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter")); Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"));
if (MeatKitPlugin.showHolds.Value) if (MeatKitPlugin.cfgShowHolds.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter")); Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"));
} }
#endregion #endregion
+4 -3
View File
@@ -1,7 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using FistVR;
namespace TNHQoLImprovements namespace TNHQoLImprovements
{ {
@@ -9,7 +9,8 @@ namespace TNHQoLImprovements
{ {
void Start() void Start()
{ {
transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform; //transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(1, 0, -.5f); transform.localPosition = new Vector3(1, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
@@ -31,7 +32,7 @@ namespace TNHQoLImprovements
else else
{ {
debug_iterations++; debug_iterations++;
yield return new WaitForSeconds(0.25f); yield return new WaitForEndOfFrame();
} }
} }
Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations."); Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations.");