From 2b73125f8e9b86a38c828626fdc58c2599979b41 Mon Sep 17 00:00:00 2001 From: msk <15199219+muskit@users.noreply.github.com> Date: Sat, 26 Mar 2022 19:20:25 -0700 Subject: [PATCH] bigger hide-HP aim target, hide-HP opacity setting, no HP background by default, --- Assets/MeatKit/BuildProfile.asset | 2 +- Assets/MeatKit/MeatKitPlugin.cs | 23 ++++++++++++++--------- Assets/_Scripts/HPHideWhenAiming.cs | 4 ++-- Assets/_Scripts/MeshRendererFlicker.cs | 19 +++++++++++-------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Assets/MeatKit/BuildProfile.asset b/Assets/MeatKit/BuildProfile.asset index c157441..3cf2ca9 100644 --- a/Assets/MeatKit/BuildProfile.asset +++ b/Assets/MeatKit/BuildProfile.asset @@ -13,7 +13,7 @@ MonoBehaviour: m_EditorClassIdentifier: PackageName: TNH_Quality_of_Life_Improvements Author: muskit - Version: 1.2.1 + Version: 1.2.2 Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3} ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3} WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index c34dd63..55534a1 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -44,6 +44,7 @@ public class MeatKitPlugin : BaseUnityPlugin // BepInEx configuration //--- Health Counter ---// public static ConfigEntry cfgHPHiddenWhenAiming; + public static ConfigEntry cfgHPAimOpacity; public static ConfigEntry cfgShowHPBackground; public static ConfigEntry cfgHPBackgroundOpacity; public static ConfigEntry cfgHPTextType; @@ -62,7 +63,7 @@ public class MeatKitPlugin : BaseUnityPlugin private static InPlay instance; // Searching for old leaderboards player count mod to disable - private bool lpcModGone = false; + private bool lpcStopSearching = false; private float lpcModSearchTimeEnd; private Harmony harmony; @@ -147,10 +148,14 @@ public class MeatKitPlugin : BaseUnityPlugin "Hide HP Counter When Aiming", true, "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", "Background enabled", - true, - "Apply a background to the health text."); + false, + "Apply a background to the Health Counter."); cfgHPBackgroundOpacity = Config.Bind("Health Counter", "Background opacity", 0.74f, @@ -196,8 +201,8 @@ public class MeatKitPlugin : BaseUnityPlugin HealthExpireIndicationType.Flashing, "Add a visual indication on the Health Crystal's despawn timer."); - // give 120 seconds to search for old mod, which we want to kill - lpcModSearchTimeEnd = Time.time + 120; + // give 60 seconds to search for old mod, which we want to kill + lpcModSearchTimeEnd = Time.time + 60; RunPatches(); } @@ -240,7 +245,7 @@ public class MeatKitPlugin : BaseUnityPlugin /// private void Update() { - if (lpcModGone) + if (lpcStopSearching) return; 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."); Destroy(plugin.Value.Instance); - lpcModGone = true; + lpcStopSearching = true; } } if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd) { - Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 120 seconds."); - lpcModGone = true; + Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 60 seconds."); + lpcStopSearching = true; } } } diff --git a/Assets/_Scripts/HPHideWhenAiming.cs b/Assets/_Scripts/HPHideWhenAiming.cs index e29e5f5..0ceb499 100644 --- a/Assets/_Scripts/HPHideWhenAiming.cs +++ b/Assets/_Scripts/HPHideWhenAiming.cs @@ -38,7 +38,7 @@ public class HPHideWhenAiming : MonoBehaviour { hudCollider = gObjHUD.AddComponent(); hudCollider.isTrigger = true; hudCollider.gameObject.layer = LayerMask.NameToLayer("UI"); - hudCollider.size = new Vector3(40, 25, .01f); + hudCollider.size = new Vector3(50, 30, .01f); //// TESTING: collider visuals //gObjColliderRenderer = new GameObject(); @@ -97,7 +97,7 @@ public class HPHideWhenAiming : MonoBehaviour { if (rayHit) { - canvasGroup.alpha = 0.1f; + canvasGroup.alpha = MeatKitPlugin.cfgHPAimOpacity.Value; if (background != null) background.enabled = false; } diff --git a/Assets/_Scripts/MeshRendererFlicker.cs b/Assets/_Scripts/MeshRendererFlicker.cs index 78af9c1..cf4d8d5 100644 --- a/Assets/_Scripts/MeshRendererFlicker.cs +++ b/Assets/_Scripts/MeshRendererFlicker.cs @@ -14,7 +14,9 @@ namespace TNHQoLImprovements private float beginTime; private float onLength; private float offLength; + private float stateChangeTime = 0; + private float flashQuicklyAfter; private bool visible = true; private MeshRenderer mesh; @@ -24,11 +26,19 @@ namespace TNHQoLImprovements mesh = GetComponent(); } - public void Init(float interval, float onToOffRatio = 0.5f, float beginAfter = 0) + /// + /// + /// + /// How long an off-on cycle lasts. + /// On-time to off-time ratio for the flashing sequence. + /// Postpone the flashing time. + /// Once flashing starts, how long until it flashes very quickly. + public void Init(float interval, float onToOffRatio = 0.5f, float beginAfter = 0, float flashQuicklyAfter = -1) { beginTime = Time.time + beginAfter; onLength = interval * onToOffRatio; offLength = interval * (1 - onToOffRatio); + this.flashQuicklyAfter = flashQuicklyAfter; initialized = true; } @@ -52,13 +62,6 @@ namespace TNHQoLImprovements stateChangeTime = Time.time + offLength; } } - - //if (Time.time >= stateChangeTime) - // { - // stateChangeTime = Time.time + interval; - // visible = !visible; - // mesh.enabled = visible; - // } } } } \ No newline at end of file