bigger hide-HP aim target, hide-HP opacity setting, no HP background by default,

This commit is contained in:
msk
2022-03-26 19:20:25 -07:00
parent 23eac84782
commit 2b73125f8e
4 changed files with 28 additions and 20 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.2.1 Version: 1.2.2
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
+14 -9
View File
@@ -44,6 +44,7 @@ public class MeatKitPlugin : BaseUnityPlugin
// BepInEx configuration // BepInEx configuration
//--- Health Counter ---// //--- Health Counter ---//
public static ConfigEntry<bool> cfgHPHiddenWhenAiming; public static ConfigEntry<bool> cfgHPHiddenWhenAiming;
public static ConfigEntry<float> cfgHPAimOpacity;
public static ConfigEntry<bool> cfgShowHPBackground; public static ConfigEntry<bool> cfgShowHPBackground;
public static ConfigEntry<float> cfgHPBackgroundOpacity; public static ConfigEntry<float> cfgHPBackgroundOpacity;
public static ConfigEntry<HPTextType> cfgHPTextType; public static ConfigEntry<HPTextType> cfgHPTextType;
@@ -62,7 +63,7 @@ public class MeatKitPlugin : BaseUnityPlugin
private static InPlay instance; private static InPlay instance;
// Searching for old leaderboards player count mod to disable // Searching for old leaderboards player count mod to disable
private bool lpcModGone = false; private bool lpcStopSearching = false;
private float lpcModSearchTimeEnd; private float lpcModSearchTimeEnd;
private Harmony harmony; private Harmony harmony;
@@ -147,10 +148,14 @@ public class MeatKitPlugin : BaseUnityPlugin
"Hide HP Counter When Aiming", "Hide HP Counter When Aiming",
true, true,
"While aiming around the health counter in view, hide it."); "While aiming around the health counter in view, hide it.");
cfgHPAimOpacity = cfgHPBackgroundOpacity = Config.Bind("Health Counter",
"Aiming opacity",
0f,
"Opacity of Health Counter when aiming around it (if Hide HP is enabled).");
cfgShowHPBackground = Config.Bind("Health Counter", cfgShowHPBackground = Config.Bind("Health Counter",
"Background enabled", "Background enabled",
true, false,
"Apply a background to the health text."); "Apply a background to the Health Counter.");
cfgHPBackgroundOpacity = Config.Bind("Health Counter", cfgHPBackgroundOpacity = Config.Bind("Health Counter",
"Background opacity", "Background opacity",
0.74f, 0.74f,
@@ -196,8 +201,8 @@ public class MeatKitPlugin : BaseUnityPlugin
HealthExpireIndicationType.Flashing, HealthExpireIndicationType.Flashing,
"Add a visual indication on the Health Crystal's despawn timer."); "Add a visual indication on the Health Crystal's despawn timer.");
// give 120 seconds to search for old mod, which we want to kill // give 60 seconds to search for old mod, which we want to kill
lpcModSearchTimeEnd = Time.time + 120; lpcModSearchTimeEnd = Time.time + 60;
RunPatches(); RunPatches();
} }
@@ -240,7 +245,7 @@ public class MeatKitPlugin : BaseUnityPlugin
/// </summary> /// </summary>
private void Update() private void Update()
{ {
if (lpcModGone) if (lpcStopSearching)
return; return;
foreach (var plugin in Chainloader.PluginInfos) foreach (var plugin in Chainloader.PluginInfos)
@@ -249,14 +254,14 @@ 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);
lpcModGone = true; lpcStopSearching = true;
} }
} }
if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd) if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd)
{ {
Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 120 seconds."); Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 60 seconds.");
lpcModGone = true; lpcStopSearching = true;
} }
} }
} }
+2 -2
View File
@@ -38,7 +38,7 @@ public class HPHideWhenAiming : MonoBehaviour {
hudCollider = gObjHUD.AddComponent<BoxCollider>(); hudCollider = gObjHUD.AddComponent<BoxCollider>();
hudCollider.isTrigger = true; hudCollider.isTrigger = true;
hudCollider.gameObject.layer = LayerMask.NameToLayer("UI"); hudCollider.gameObject.layer = LayerMask.NameToLayer("UI");
hudCollider.size = new Vector3(40, 25, .01f); hudCollider.size = new Vector3(50, 30, .01f);
//// TESTING: collider visuals //// TESTING: collider visuals
//gObjColliderRenderer = new GameObject(); //gObjColliderRenderer = new GameObject();
@@ -97,7 +97,7 @@ public class HPHideWhenAiming : MonoBehaviour {
if (rayHit) if (rayHit)
{ {
canvasGroup.alpha = 0.1f; canvasGroup.alpha = MeatKitPlugin.cfgHPAimOpacity.Value;
if (background != null) if (background != null)
background.enabled = false; background.enabled = false;
} }
+11 -8
View File
@@ -14,7 +14,9 @@ namespace TNHQoLImprovements
private float beginTime; private float beginTime;
private float onLength; private float onLength;
private float offLength; private float offLength;
private float stateChangeTime = 0; private float stateChangeTime = 0;
private float flashQuicklyAfter;
private bool visible = true; private bool visible = true;
private MeshRenderer mesh; private MeshRenderer mesh;
@@ -24,11 +26,19 @@ namespace TNHQoLImprovements
mesh = GetComponent<MeshRenderer>(); mesh = GetComponent<MeshRenderer>();
} }
public void Init(float interval, float onToOffRatio = 0.5f, float beginAfter = 0) /// <summary>
///
/// </summary>
/// <param name="interval">How long an off-on cycle lasts.</param>
/// <param name="onToOffRatio">On-time to off-time ratio for the flashing sequence.</param>
/// <param name="beginAfter">Postpone the flashing time.</param>
/// <param name="flashQuicklyAfter">Once flashing starts, how long until it flashes very quickly.</param>
public void Init(float interval, float onToOffRatio = 0.5f, float beginAfter = 0, float flashQuicklyAfter = -1)
{ {
beginTime = Time.time + beginAfter; beginTime = Time.time + beginAfter;
onLength = interval * onToOffRatio; onLength = interval * onToOffRatio;
offLength = interval * (1 - onToOffRatio); offLength = interval * (1 - onToOffRatio);
this.flashQuicklyAfter = flashQuicklyAfter;
initialized = true; initialized = true;
} }
@@ -52,13 +62,6 @@ namespace TNHQoLImprovements
stateChangeTime = Time.time + offLength; stateChangeTime = Time.time + offLength;
} }
} }
//if (Time.time >= stateChangeTime)
// {
// stateChangeTime = Time.time + interval;
// visible = !visible;
// mesh.enabled = visible;
// }
} }
} }
} }