From 3e8afda0e9386671afd8733c2ec807af75d0029c Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 10:47:16 -0400 Subject: [PATCH 01/10] nameplate improvements --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 179 ++++++++++++++++--------- Fika.Core/FikaPlugin.cs | 49 +++++-- 2 files changed, 156 insertions(+), 72 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 1b8cca51..f0eac703 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -43,29 +43,31 @@ protected void Update() playerPlate.gameObject.SetActive(true); } UpdateScreenSpacePosition(); - float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; - float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; - if (FikaPlugin.UseHealthNumber.Value) - { - if (!playerPlate.healthNumberBackgroundScreen.gameObject.activeSelf) + if (!FikaPlugin.HideHealthBar.Value) { + float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; + float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; + if (FikaPlugin.UseHealthNumber.Value) { - playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(true); - playerPlate.healthBarBackgroundScreen.gameObject.SetActive(false); + if (!playerPlate.healthNumberBackgroundScreen.gameObject.activeSelf) + { + playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(true); + playerPlate.healthBarBackgroundScreen.gameObject.SetActive(false); + } + int healthNumberPercentage = (int)Math.Round((currentHealth / maxHealth) * 100); + playerPlate.SetHealthNumberText($"{healthNumberPercentage}%"); } - int healthNumberPercentage = (int)Math.Round((currentHealth / maxHealth) * 100); - playerPlate.SetHealthNumberText($"{healthNumberPercentage}%"); - } - else - { - if (!playerPlate.healthBarBackgroundScreen.gameObject.active) + else { - playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(false); - playerPlate.healthBarBackgroundScreen.gameObject.SetActive(true); - } + if (!playerPlate.healthBarBackgroundScreen.gameObject.active) + { + playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(false); + playerPlate.healthBarBackgroundScreen.gameObject.SetActive(true); + } - float normalizedHealth = Mathf.Clamp01(currentHealth / maxHealth); - playerPlate.healthBarScreen.fillAmount = normalizedHealth; - UpdateHealthBarColor(normalizedHealth); + float normalizedHealth = Mathf.Clamp01(currentHealth / maxHealth); + playerPlate.healthBarScreen.fillAmount = normalizedHealth; + UpdateHealthBarColor(normalizedHealth); + } } if (!currentPlayer.HealthController.IsAlive) { @@ -80,20 +82,43 @@ protected void Update() private void UpdateScreenSpacePosition() { + Camera camera = CameraClass.Instance.Camera; + + float opacityMultiplier = 1f; if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) { + // Scope scaling and positioning if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) { - playerPlate.ScalarObjectScreen.active = false; - return; + if (FikaPlugin.HideNamePlateInOptic.Value) { + playerPlate.ScalarObjectScreen.active = false; + return; + } } + // Opacity in ADS + opacityMultiplier = FikaPlugin.OpacityInADS.Value; + } + + float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; + float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); + if (sqrDistance > maxDistanceToShow) + { + // Disable the nameplate if the player is too far away + playerPlate.ScalarObjectScreen.active = false; + return; } - else if (playerPlate.ScalarObjectScreen.active == false) + + if (playerPlate.ScalarObjectScreen.active == false) { playerPlate.ScalarObjectScreen.active = true; } - Camera camera = CameraClass.Instance.Camera; + float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); + Vector3 position; + + position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + + Vector3 screenPoint = camera.WorldToScreenPoint(position); if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) { @@ -102,55 +127,62 @@ private void UpdateScreenSpacePosition() screenScale = outputWidth / inputWidth; } - float distance = Vector3.Distance(CameraClass.Instance.Camera.transform.position, currentPlayer.Position) / 25; - distance = Mathf.Clamp(distance, 0.6f, 1f); - Vector3 position; - - position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * distance), currentPlayer.PlayerBones.Neck.position.z); - - Vector3 screenPoint = camera.WorldToScreenPoint(position); - if (screenPoint.z > 0) { playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / distance) * FikaPlugin.NamePlateScale.Value; - - float distanceToCenter = Vector3.Distance(screenPoint, new Vector3(Screen.width, Screen.height, 0) / 2); - #region Alpha Control for Health Bars. This code is ugly so its getting regioned so I can hide my shame. - if (distanceToCenter < 200) + // Less opaque when not looking at the player + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) { - playerPlate.playerNameScreen.color = new Color(playerPlate.playerNameScreen.color.r, playerPlate.playerNameScreen.color.g, playerPlate.playerNameScreen.color.b, Mathf.Max(0.1f, distanceToCenter / 200)); - playerPlate.healthBarScreen.color = new Color(playerPlate.healthBarScreen.color.r, playerPlate.healthBarScreen.color.g, playerPlate.healthBarScreen.color.b, Mathf.Max(0.1f, distanceToCenter / 200)); - playerPlate.healthBarBackgroundScreen.color = new Color(playerPlate.healthBarBackgroundScreen.color.r, playerPlate.healthBarBackgroundScreen.color.g, playerPlate.healthBarBackgroundScreen.color.b, Mathf.Clamp(Mathf.Max(0.1f, distanceToCenter / 200), 0f, 0.4392157f)); - playerPlate.healthNumberBackgroundScreen.color = new Color(playerPlate.healthNumberBackgroundScreen.color.r, playerPlate.healthNumberBackgroundScreen.color.g, playerPlate.healthNumberBackgroundScreen.color.b, Mathf.Clamp(Mathf.Max(0.1f, distanceToCenter / 200), 0f, 0.4392157f)); - playerPlate.healthNumberScreen.color = new Color(playerPlate.healthNumberScreen.color.r, playerPlate.healthNumberScreen.color.g, playerPlate.healthNumberScreen.color.b, Mathf.Max(0.1f, distanceToCenter / 200)); - playerPlate.usecPlateScreen.color = new Color(playerPlate.usecPlateScreen.color.r, playerPlate.usecPlateScreen.color.g, playerPlate.usecPlateScreen.color.b, Mathf.Max(0.1f, distanceToCenter / 200)); - playerPlate.bearPlateScreen.color = new Color(playerPlate.bearPlateScreen.color.r, playerPlate.bearPlateScreen.color.g, playerPlate.bearPlateScreen.color.b, Mathf.Max(0.1f, distanceToCenter / 200)); - + Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0); + float sqrDistFromCenter = (screenCenter - screenPoint).sqrMagnitude; + float maxSqrDistFromCenter = Mathf.Pow(Mathf.Min(Screen.width, Screen.height) / 2, 2); + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); } - else + + float alpha = 1f; + float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; + float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); + alpha = Mathf.Lerp(alpha, 0, lerpValue); + namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + + // Setting the nameplate scale + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + + // Setting the overall nameplate alpha + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + + float healthAlphaMultiplier = 1f; + if (FikaPlugin.HideHealthBar.Value) { - playerPlate.playerNameScreen.color = new Color(playerPlate.playerNameScreen.color.r, playerPlate.playerNameScreen.color.g, playerPlate.playerNameScreen.color.b, 1); - playerPlate.healthBarScreen.color = new Color(playerPlate.healthBarScreen.color.r, playerPlate.healthBarScreen.color.g, playerPlate.healthBarScreen.color.b, 1); - playerPlate.healthBarBackgroundScreen.color = new Color(playerPlate.healthBarBackgroundScreen.color.r, playerPlate.healthBarBackgroundScreen.color.g, playerPlate.healthBarBackgroundScreen.color.b, 1); - playerPlate.healthNumberBackgroundScreen.color = new Color(playerPlate.healthNumberBackgroundScreen.color.r, playerPlate.healthNumberBackgroundScreen.color.g, playerPlate.healthNumberBackgroundScreen.color.b, 1); - playerPlate.healthNumberScreen.color = new Color(playerPlate.healthNumberScreen.color.r, playerPlate.healthNumberScreen.color.g, playerPlate.healthNumberScreen.color.b, 1); - playerPlate.usecPlateScreen.color = new Color(playerPlate.usecPlateScreen.color.r, playerPlate.usecPlateScreen.color.g, playerPlate.usecPlateScreen.color.b, 1); - playerPlate.bearPlateScreen.color = new Color(playerPlate.bearPlateScreen.color.r, playerPlate.bearPlateScreen.color.g, playerPlate.bearPlateScreen.color.b, 1); + healthAlphaMultiplier = 0; } + + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); } else { - playerPlate.playerNameScreen.color = new Color(playerPlate.playerNameScreen.color.r, playerPlate.playerNameScreen.color.g, playerPlate.playerNameScreen.color.b, 0); - playerPlate.healthBarScreen.color = new Color(playerPlate.healthBarScreen.color.r, playerPlate.healthBarScreen.color.g, playerPlate.healthBarScreen.color.b, 0); - playerPlate.healthBarBackgroundScreen.color = new Color(playerPlate.healthBarBackgroundScreen.color.r, playerPlate.healthBarBackgroundScreen.color.g, playerPlate.healthBarBackgroundScreen.color.b, 0); - playerPlate.healthNumberBackgroundScreen.color = new Color(playerPlate.healthNumberBackgroundScreen.color.r, playerPlate.healthNumberBackgroundScreen.color.g, playerPlate.healthNumberBackgroundScreen.color.b, 0); - playerPlate.healthNumberScreen.color = new Color(playerPlate.healthNumberScreen.color.r, playerPlate.healthNumberScreen.color.g, playerPlate.healthNumberScreen.color.b, 0); - playerPlate.usecPlateScreen.color = new Color(playerPlate.usecPlateScreen.color.r, playerPlate.usecPlateScreen.color.g, playerPlate.usecPlateScreen.color.b, 0); - playerPlate.bearPlateScreen.color = new Color(playerPlate.bearPlateScreen.color.r, playerPlate.bearPlateScreen.color.g, playerPlate.bearPlateScreen.color.b, 0); + // Hide the nameplate if the player is behind the camera + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); + UpdateColorImage(playerPlate.healthBarScreen, 0); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); + UpdateColorImage(playerPlate.usecPlateScreen, 0); + UpdateColorImage(playerPlate.bearPlateScreen, 0); } - #endregion } private void CreateHealthBar() @@ -172,6 +204,13 @@ private void CreateHealthBar() playerPlate.bearPlateScreen.gameObject.SetActive(true); } } + if (FikaPlugin.HideHealthBar.Value) + { + playerPlate.healthBarScreen.gameObject.SetActive(false); + playerPlate.healthNumberScreen.gameObject.SetActive(false); + playerPlate.healthBarBackgroundScreen.gameObject.SetActive(false); + playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(false); + } if (FikaPlugin.DevelopersList.ContainsKey(currentPlayer.Profile.Nickname.ToLower())) { playerPlate.playerNameScreen.color = new Color(0, 0.6091f, 1, 1); @@ -200,6 +239,26 @@ private void UpdateHealthBarColor(float normalizedHealth) playerPlate.healthBarScreen.color = color; } + private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) + { + if (screenObject.gameObject.activeInHierarchy) + { + var color = screenObject.color; + color.a = alpha; + screenObject.color = color; + } + } + + private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, float alpha) + { + if (screenObject.gameObject.activeInHierarchy) + { + var color = screenObject.color; + color.a = alpha; + screenObject.color = color; + } + } + private void OnDestroy() { playerPlate.gameObject.SetActive(false); diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 26d8c3cf..c81132e6 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -106,11 +106,20 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry FasterInventoryScrollSpeed { get; set; } public static ConfigEntry ExtractKey { get; set; } - // Coop | Custom + // Coop | NamePlates public static ConfigEntry UseNamePlates { get; set; } + public static ConfigEntry HideHealthBar { get; set; } public static ConfigEntry UseHealthNumber { get; set; } public static ConfigEntry UsePlateFactionSide { get; set; } + public static ConfigEntry HideNamePlateInOptic { get; set; } + public static ConfigEntry DecreaseOpacityNotLookingAt { get; set; } public static ConfigEntry NamePlateScale { get; set; } + public static ConfigEntry OpacityInADS { get; set; } + public static ConfigEntry MaxDistanceToShow { get; set; } + public static ConfigEntry MinimumOpacity { get; set; } + public static ConfigEntry MinimumNamePlateScale { get; set; } + + // Coop | Custom public static ConfigEntry UsePingSystem { get; set; } public static ConfigEntry PingButton { get; set; } public static ConfigEntry PingColor { get; set; } @@ -121,7 +130,7 @@ public class FikaPlugin : BaseUnityPlugin // Coop | Debug public static ConfigEntry FreeCamButton { get; set; } - // Performance + // Performance public static ConfigEntry EnforcedSpawnLimits { get; set; } public static ConfigEntry DespawnFurthest { get; set; } public static ConfigEntry DynamicAI { get; set; } @@ -130,7 +139,7 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry CullPlayers { get; set; } public static ConfigEntry CullingRange { get; set; } - // Bot Limits + // Bot Limits public static ConfigEntry MaxBotsFactory { get; set; } public static ConfigEntry MaxBotsCustoms { get; set; } public static ConfigEntry MaxBotsInterchange { get; set; } @@ -253,17 +262,33 @@ private void SetupConfig() FasterInventoryScrollSpeed = Config.Bind("Coop", "Faster Inventory Scroll Speed", 63, new ConfigDescription("The speed at which the inventory scrolls at. Default is 63.", new AcceptableValueRange(63, 500), new ConfigurationManagerAttributes() { Order = 2 })); ExtractKey = Config.Bind("Coop", "Extract Key", new KeyboardShortcut(KeyCode.F8), new ConfigDescription("The key used to extract from the raid.", tags: new ConfigurationManagerAttributes() { Order = 1 })); - + + // Coop | NamePlates + + UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); + + HideHealthBar = Config.Bind("Coop | NamePlates", "Hide Health Bar", false, new ConfigDescription("Completely hides the health bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); + + UseHealthNumber = Config.Bind("Coop | NamePlates", "Show HP% instead of bar", false, new ConfigDescription("Shows health in % amount instead of using the bar.", tags: new ConfigurationManagerAttributes() { Order = 8 })); + + UsePlateFactionSide = Config.Bind("Coop | NamePlates", "Show Player Faction Icon", true, new ConfigDescription("Shows the player faction icon next to the HP bar.", tags: new ConfigurationManagerAttributes() { Order = 7 })); + + HideNamePlateInOptic = Config.Bind("Coop | NamePlates", "Hide Name Plate in Optic", true, new ConfigDescription("Hides the name plate when viewing through PiP scopes since it's kinda janky.", tags: new ConfigurationManagerAttributes() { Order = 6 })); + + DecreaseOpacityNotLookingAt = Config.Bind("Coop | NamePlates", "Decrease Opacity In Peripheral", true, new ConfigDescription("Decreases the opacity of the name plates when not looking at a player.", tags: new ConfigurationManagerAttributes() { Order = 5 })); + + NamePlateScale = Config.Bind("Coop | NamePlates", "Name Plate Scale", 0.22f, new ConfigDescription("Size of the name plates", new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 4 })); + + OpacityInADS = Config.Bind("Coop | NamePlates", "Opacity in ADS", 0.75f, new ConfigDescription("The opacity of the name plates when aiming down sights.", new AcceptableValueRange(0.1f, 1f), new ConfigurationManagerAttributes() { Order = 3 })); + + MaxDistanceToShow = Config.Bind("Coop | NamePlates", "Max Distance to Show", 500f, new ConfigDescription("The maximum distance at which name plates will become invisible, starts to fade at half the input value.", new AcceptableValueRange(10f, 1000f), new ConfigurationManagerAttributes() { Order = 2 })); + + MinimumOpacity = Config.Bind("Coop | NamePlates", "Minimum Opacity", 0.1f, new ConfigDescription("The minimum opacity of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); + + MinimumNamePlateScale = Config.Bind("Coop | NamePlates", "Minimum Name Plate Scale", 0.01f, new ConfigDescription("The minimum scale of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 0 })); + // Coop | Custom - UseNamePlates = Config.Bind("Coop | Custom", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); - - UseHealthNumber = Config.Bind("Coop | Custom", "Show HP% instead of bar", false, new ConfigDescription("Shows health in % amount instead of using the bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); - - UsePlateFactionSide = Config.Bind("Coop | Custom", "Show Player Faction Icon", true, new ConfigDescription("Shows the player faction icon next to the HP bar.", tags: new ConfigurationManagerAttributes() { Order = 8 })); - - NamePlateScale = Config.Bind("Coop | Custom", "Name Plate Scale", 0.22f, new ConfigDescription("Size of the name plates", new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 7 })); - UsePingSystem = Config.Bind("Coop | Custom", "Ping System", false, new ConfigDescription("Toggle Ping System. If enabled you can receive and send pings by pressing the ping key.", tags: new ConfigurationManagerAttributes() { Order = 6 })); PingButton = Config.Bind("Coop | Custom", "Ping Button", new KeyboardShortcut(KeyCode.U), new ConfigDescription("Button used to send pings.", tags: new ConfigurationManagerAttributes() { Order = 5 })); From 369bbca114728a26c868943fee0746d67fc68233 Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 15:23:32 -0400 Subject: [PATCH 02/10] peripheral checks now properly handle up/down scaling --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 121 +++++++++++-------------- 1 file changed, 51 insertions(+), 70 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index f0eac703..a8c87c2a 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -82,99 +82,40 @@ protected void Update() private void UpdateScreenSpacePosition() { - Camera camera = CameraClass.Instance.Camera; - float opacityMultiplier = 1f; if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) { - // Scope scaling and positioning - if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) + if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic && FikaPlugin.HideNamePlateInOptic.Value) { - if (FikaPlugin.HideNamePlateInOptic.Value) { - playerPlate.ScalarObjectScreen.active = false; - return; - } + playerPlate.ScalarObjectScreen.active = false; + return; } - // Opacity in ADS opacityMultiplier = FikaPlugin.OpacityInADS.Value; } + Camera camera = CameraClass.Instance.Camera; float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); if (sqrDistance > maxDistanceToShow) { - // Disable the nameplate if the player is too far away playerPlate.ScalarObjectScreen.active = false; return; } - - if (playerPlate.ScalarObjectScreen.active == false) - { - playerPlate.ScalarObjectScreen.active = true; - } - - float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); - Vector3 position; - position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + playerPlate.ScalarObjectScreen.active = true; + float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); + Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); Vector3 screenPoint = camera.WorldToScreenPoint(position); - if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) + SSAA ssaa = CameraClass.Instance.SSAA; + if (ssaa != null && ssaa.isActiveAndEnabled) { - int outputWidth = CameraClass.Instance.SSAA.GetOutputWidth(); - float inputWidth = CameraClass.Instance.SSAA.GetInputWidth(); - screenScale = outputWidth / inputWidth; + screenScale = ssaa.GetOutputWidth() / ssaa.GetInputWidth(); } - if (screenPoint.z > 0) - { - playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - - // Less opaque when not looking at the player - float distFromCenterMultiplier = 1f; - if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) - { - Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0); - float sqrDistFromCenter = (screenCenter - screenPoint).sqrMagnitude; - float maxSqrDistFromCenter = Mathf.Pow(Mathf.Min(Screen.width, Screen.height) / 2, 2); - distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); - } - - float alpha = 1f; - float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; - float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); - alpha = Mathf.Lerp(alpha, 0, lerpValue); - namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); - namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - - // Setting the nameplate scale - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; - - // Setting the overall nameplate alpha - alpha *= opacityMultiplier; - alpha *= distFromCenterMultiplier; - alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); - - float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); - - float healthAlphaMultiplier = 1f; - if (FikaPlugin.HideHealthBar.Value) - { - healthAlphaMultiplier = 0; - } - - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); - UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.usecPlateScreen, alpha); - UpdateColorImage(playerPlate.bearPlateScreen, alpha); - } - else + if (screenPoint.z <= 0) { - // Hide the nameplate if the player is behind the camera UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); UpdateColorImage(playerPlate.healthBarScreen, 0); UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); @@ -182,7 +123,47 @@ private void UpdateScreenSpacePosition() UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); UpdateColorImage(playerPlate.usecPlateScreen, 0); UpdateColorImage(playerPlate.bearPlateScreen, 0); + return; } + + playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; + + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) + { + float screenWidth = ssaa != null && ssaa.isActiveAndEnabled ? ssaa.GetOutputWidth() : Screen.width; + float screenHeight = ssaa != null && ssaa.isActiveAndEnabled ? ssaa.GetOutputHeight() : Screen.height; + Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); + Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; + float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; + float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; + float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); + } + + float alpha = 1f; + float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; + float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); + alpha = Mathf.Lerp(alpha, 0, lerpValue); + namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + float healthAlphaMultiplier = FikaPlugin.HideHealthBar.Value ? 0 : 1f; + + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); } private void CreateHealthBar() From 144d9cd60d0175438b43d1bd39fe23dc21ecea3b Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 15:24:24 -0400 Subject: [PATCH 03/10] actually reverting some performance things to make sure i have a functional version to fall back to --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 131 +++++++++++++++---------- 1 file changed, 80 insertions(+), 51 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index a8c87c2a..0562a262 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -82,40 +82,109 @@ protected void Update() private void UpdateScreenSpacePosition() { + Camera camera = CameraClass.Instance.Camera; + float opacityMultiplier = 1f; if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) { - if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic && FikaPlugin.HideNamePlateInOptic.Value) + // Scope scaling and positioning + if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) { - playerPlate.ScalarObjectScreen.active = false; - return; + if (FikaPlugin.HideNamePlateInOptic.Value) { + playerPlate.ScalarObjectScreen.active = false; + return; + } } + // Opacity in ADS opacityMultiplier = FikaPlugin.OpacityInADS.Value; } - Camera camera = CameraClass.Instance.Camera; float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); if (sqrDistance > maxDistanceToShow) { + // Disable the nameplate if the player is too far away playerPlate.ScalarObjectScreen.active = false; return; } - - playerPlate.ScalarObjectScreen.active = true; + + if (playerPlate.ScalarObjectScreen.active == false) + { + playerPlate.ScalarObjectScreen.active = true; + } float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); - Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + Vector3 position; + + position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + Vector3 screenPoint = camera.WorldToScreenPoint(position); - SSAA ssaa = CameraClass.Instance.SSAA; - if (ssaa != null && ssaa.isActiveAndEnabled) + if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) { - screenScale = ssaa.GetOutputWidth() / ssaa.GetInputWidth(); + int outputWidth = CameraClass.Instance.SSAA.GetOutputWidth(); + float inputWidth = CameraClass.Instance.SSAA.GetInputWidth(); + screenScale = outputWidth / inputWidth; } - if (screenPoint.z <= 0) + if (screenPoint.z > 0) + { + playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; + + // Less opaque when not looking at the player + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) + { + float screenWidth = Screen.width; + float screenHeight = Screen.height; + if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) + { + screenWidth = CameraClass.Instance.SSAA.GetOutputWidth(); + screenHeight = CameraClass.Instance.SSAA.GetOutputHeight(); + } + Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); + Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; + float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; + float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; + float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; + + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); + } + + float alpha = 1f; + float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; + float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); + alpha = Mathf.Lerp(alpha, 0, lerpValue); + namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + + // Setting the nameplate scale + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + + // Setting the overall nameplate alpha + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + + float healthAlphaMultiplier = 1f; + if (FikaPlugin.HideHealthBar.Value) + { + healthAlphaMultiplier = 0; + } + + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); + } + else { + // Hide the nameplate if the player is behind the camera UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); UpdateColorImage(playerPlate.healthBarScreen, 0); UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); @@ -123,47 +192,7 @@ private void UpdateScreenSpacePosition() UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); UpdateColorImage(playerPlate.usecPlateScreen, 0); UpdateColorImage(playerPlate.bearPlateScreen, 0); - return; - } - - playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - - float distFromCenterMultiplier = 1f; - if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) - { - float screenWidth = ssaa != null && ssaa.isActiveAndEnabled ? ssaa.GetOutputWidth() : Screen.width; - float screenHeight = ssaa != null && ssaa.isActiveAndEnabled ? ssaa.GetOutputHeight() : Screen.height; - Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); - Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; - float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; - float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; - float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; - distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); } - - float alpha = 1f; - float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; - float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); - alpha = Mathf.Lerp(alpha, 0, lerpValue); - namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); - namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; - - alpha *= opacityMultiplier; - alpha *= distFromCenterMultiplier; - alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); - - float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); - float healthAlphaMultiplier = FikaPlugin.HideHealthBar.Value ? 0 : 1f; - - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); - UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.usecPlateScreen, alpha); - UpdateColorImage(playerPlate.bearPlateScreen, alpha); } private void CreateHealthBar() From 60f130169126ac793ef9a7b63886789ada64522d Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 17:07:48 -0400 Subject: [PATCH 04/10] cleanup/refactor + performance probably --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 151 +++++++++++-------------- Fika.sln | 10 +- 2 files changed, 70 insertions(+), 91 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 0562a262..39636f91 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -2,6 +2,7 @@ using Comfort.Common; using EFT; +using EFT.Animations; using EFT.UI; using Fika.Core.Bundles; using Fika.Core.Coop.Players; @@ -43,7 +44,8 @@ protected void Update() playerPlate.gameObject.SetActive(true); } UpdateScreenSpacePosition(); - if (!FikaPlugin.HideHealthBar.Value) { + if (!FikaPlugin.HideHealthBar.Value) + { float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; if (FikaPlugin.UseHealthNumber.Value) @@ -82,117 +84,94 @@ protected void Update() private void UpdateScreenSpacePosition() { - Camera camera = CameraClass.Instance.Camera; - float opacityMultiplier = 1f; - if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) + + ProceduralWeaponAnimation proceduralWeaponAnimation = mainPlayer.ProceduralWeaponAnimation; + if (mainPlayer.HealthController.IsAlive && proceduralWeaponAnimation.IsAiming) { - // Scope scaling and positioning - if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) + if (proceduralWeaponAnimation.CurrentScope.IsOptic && FikaPlugin.HideNamePlateInOptic.Value) { - if (FikaPlugin.HideNamePlateInOptic.Value) { - playerPlate.ScalarObjectScreen.active = false; - return; - } + playerPlate.ScalarObjectScreen.active = false; + return; } - // Opacity in ADS opacityMultiplier = FikaPlugin.OpacityInADS.Value; } + CameraClass cameraInstance = CameraClass.Instance; + Camera camera = cameraInstance.Camera; float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; - float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); + float maxDistanceToShow = FikaPlugin.MaxDistanceToShow.Value * FikaPlugin.MaxDistanceToShow.Value; if (sqrDistance > maxDistanceToShow) { - // Disable the nameplate if the player is too far away playerPlate.ScalarObjectScreen.active = false; return; } - - if (playerPlate.ScalarObjectScreen.active == false) - { - playerPlate.ScalarObjectScreen.active = true; - } - float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); - Vector3 position; - - position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + playerPlate.ScalarObjectScreen.active = true; + float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); + Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); Vector3 screenPoint = camera.WorldToScreenPoint(position); - if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) + if (screenPoint.z <= 0) { - int outputWidth = CameraClass.Instance.SSAA.GetOutputWidth(); - float inputWidth = CameraClass.Instance.SSAA.GetInputWidth(); - screenScale = outputWidth / inputWidth; + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); + UpdateColorImage(playerPlate.healthBarScreen, 0); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); + UpdateColorImage(playerPlate.usecPlateScreen, 0); + UpdateColorImage(playerPlate.bearPlateScreen, 0); + return; } - if (screenPoint.z > 0) + SSAA ssaa = cameraInstance.SSAA; + bool isSSAAEnabled = ssaa != null && ssaa.isActiveAndEnabled; + if (isSSAAEnabled) { - playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; + int outputWidth = ssaa.GetOutputWidth(); + float inputWidth = ssaa.GetInputWidth(); + screenScale = outputWidth / inputWidth; + } - // Less opaque when not looking at the player - float distFromCenterMultiplier = 1f; - if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) - { - float screenWidth = Screen.width; - float screenHeight = Screen.height; - if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) - { - screenWidth = CameraClass.Instance.SSAA.GetOutputWidth(); - screenHeight = CameraClass.Instance.SSAA.GetOutputHeight(); - } - Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); - Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; - float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; - float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; - float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; - - distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); - } + playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - float alpha = 1f; - float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; - float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); - alpha = Mathf.Lerp(alpha, 0, lerpValue); - namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); - namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) + { + float screenWidth = isSSAAEnabled ? ssaa.GetOutputWidth() : Screen.width; + float screenHeight = isSSAAEnabled ? ssaa.GetOutputHeight() : Screen.height; + Vector3 screenCenter = new(screenWidth / 2, screenHeight / 2, 0); + Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; + float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; + float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; + float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); + } - // Setting the nameplate scale - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + float alpha = 1f; + float halfMaxDistanceToShow = maxDistanceToShow / 2; + float lerpValue = Mathf.Clamp01((sqrDistance - halfMaxDistanceToShow) / (halfMaxDistanceToShow)); + alpha = Mathf.LerpUnclamped(alpha, 0, lerpValue); + float namePlateScaleMult = Mathf.LerpUnclamped(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - // Setting the overall nameplate alpha - alpha *= opacityMultiplier; - alpha *= distFromCenterMultiplier; - alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; - float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); - float healthAlphaMultiplier = 1f; - if (FikaPlugin.HideHealthBar.Value) - { - healthAlphaMultiplier = 0; - } + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + float healthAlphaMultiplier = FikaPlugin.HideHealthBar.Value ? 0 : 1f; - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); - UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.usecPlateScreen, alpha); - UpdateColorImage(playerPlate.bearPlateScreen, alpha); - } - else - { - // Hide the nameplate if the player is behind the camera - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); - UpdateColorImage(playerPlate.healthBarScreen, 0); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); - UpdateColorImage(playerPlate.usecPlateScreen, 0); - UpdateColorImage(playerPlate.bearPlateScreen, 0); - } + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); } private void CreateHealthBar() @@ -249,7 +228,7 @@ private void UpdateHealthBarColor(float normalizedHealth) playerPlate.healthBarScreen.color = color; } - private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) + private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) { @@ -258,7 +237,7 @@ private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) screenObject.color = color; } } - + private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) diff --git a/Fika.sln b/Fika.sln index ac0a030b..51ab95f4 100644 --- a/Fika.sln +++ b/Fika.sln @@ -8,16 +8,16 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU GoldMaster|Any CPU = GoldMaster|Any CPU + Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.Build.0 = Release|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.Build.0 = Release|Any CPU {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.ActiveCfg = GoldMaster|Any CPU {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.Build.0 = GoldMaster|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 0ebeefdb8644c10e9c98625e85caeea8885b67be Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 17:12:32 -0400 Subject: [PATCH 05/10] Revert "cleanup/refactor + performance probably" This reverts commit 60f130169126ac793ef9a7b63886789ada64522d. --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 151 ++++++++++++++----------- Fika.sln | 10 +- 2 files changed, 91 insertions(+), 70 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 39636f91..0562a262 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -2,7 +2,6 @@ using Comfort.Common; using EFT; -using EFT.Animations; using EFT.UI; using Fika.Core.Bundles; using Fika.Core.Coop.Players; @@ -44,8 +43,7 @@ protected void Update() playerPlate.gameObject.SetActive(true); } UpdateScreenSpacePosition(); - if (!FikaPlugin.HideHealthBar.Value) - { + if (!FikaPlugin.HideHealthBar.Value) { float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; if (FikaPlugin.UseHealthNumber.Value) @@ -84,94 +82,117 @@ protected void Update() private void UpdateScreenSpacePosition() { + Camera camera = CameraClass.Instance.Camera; + float opacityMultiplier = 1f; - - ProceduralWeaponAnimation proceduralWeaponAnimation = mainPlayer.ProceduralWeaponAnimation; - if (mainPlayer.HealthController.IsAlive && proceduralWeaponAnimation.IsAiming) + if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) { - if (proceduralWeaponAnimation.CurrentScope.IsOptic && FikaPlugin.HideNamePlateInOptic.Value) + // Scope scaling and positioning + if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) { - playerPlate.ScalarObjectScreen.active = false; - return; + if (FikaPlugin.HideNamePlateInOptic.Value) { + playerPlate.ScalarObjectScreen.active = false; + return; + } } + // Opacity in ADS opacityMultiplier = FikaPlugin.OpacityInADS.Value; } - CameraClass cameraInstance = CameraClass.Instance; - Camera camera = cameraInstance.Camera; float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; - float maxDistanceToShow = FikaPlugin.MaxDistanceToShow.Value * FikaPlugin.MaxDistanceToShow.Value; + float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); if (sqrDistance > maxDistanceToShow) { + // Disable the nameplate if the player is too far away playerPlate.ScalarObjectScreen.active = false; return; } - - playerPlate.ScalarObjectScreen.active = true; + + if (playerPlate.ScalarObjectScreen.active == false) + { + playerPlate.ScalarObjectScreen.active = true; + } float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); - Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + Vector3 position; + + position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + Vector3 screenPoint = camera.WorldToScreenPoint(position); - if (screenPoint.z <= 0) + if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) { - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); - UpdateColorImage(playerPlate.healthBarScreen, 0); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); - UpdateColorImage(playerPlate.usecPlateScreen, 0); - UpdateColorImage(playerPlate.bearPlateScreen, 0); - return; + int outputWidth = CameraClass.Instance.SSAA.GetOutputWidth(); + float inputWidth = CameraClass.Instance.SSAA.GetInputWidth(); + screenScale = outputWidth / inputWidth; } - SSAA ssaa = cameraInstance.SSAA; - bool isSSAAEnabled = ssaa != null && ssaa.isActiveAndEnabled; - if (isSSAAEnabled) + if (screenPoint.z > 0) { - int outputWidth = ssaa.GetOutputWidth(); - float inputWidth = ssaa.GetInputWidth(); - screenScale = outputWidth / inputWidth; - } + playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; + // Less opaque when not looking at the player + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) + { + float screenWidth = Screen.width; + float screenHeight = Screen.height; + if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) + { + screenWidth = CameraClass.Instance.SSAA.GetOutputWidth(); + screenHeight = CameraClass.Instance.SSAA.GetOutputHeight(); + } + Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); + Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; + float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; + float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; + float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; + + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); + } - float distFromCenterMultiplier = 1f; - if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) - { - float screenWidth = isSSAAEnabled ? ssaa.GetOutputWidth() : Screen.width; - float screenHeight = isSSAAEnabled ? ssaa.GetOutputHeight() : Screen.height; - Vector3 screenCenter = new(screenWidth / 2, screenHeight / 2, 0); - Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; - float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; - float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; - float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; - distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); - } + float alpha = 1f; + float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; + float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); + alpha = Mathf.Lerp(alpha, 0, lerpValue); + namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - float alpha = 1f; - float halfMaxDistanceToShow = maxDistanceToShow / 2; - float lerpValue = Mathf.Clamp01((sqrDistance - halfMaxDistanceToShow) / (halfMaxDistanceToShow)); - alpha = Mathf.LerpUnclamped(alpha, 0, lerpValue); - float namePlateScaleMult = Mathf.LerpUnclamped(1f, 0.5f, lerpValue); - namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + // Setting the nameplate scale + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + // Setting the overall nameplate alpha + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); - alpha *= opacityMultiplier; - alpha *= distFromCenterMultiplier; - alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); - float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); - float healthAlphaMultiplier = FikaPlugin.HideHealthBar.Value ? 0 : 1f; + float healthAlphaMultiplier = 1f; + if (FikaPlugin.HideHealthBar.Value) + { + healthAlphaMultiplier = 0; + } - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); - UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.usecPlateScreen, alpha); - UpdateColorImage(playerPlate.bearPlateScreen, alpha); + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); + } + else + { + // Hide the nameplate if the player is behind the camera + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); + UpdateColorImage(playerPlate.healthBarScreen, 0); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); + UpdateColorImage(playerPlate.usecPlateScreen, 0); + UpdateColorImage(playerPlate.bearPlateScreen, 0); + } } private void CreateHealthBar() @@ -228,7 +249,7 @@ private void UpdateHealthBarColor(float normalizedHealth) playerPlate.healthBarScreen.color = color; } - private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) + private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) { @@ -237,7 +258,7 @@ private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) screenObject.color = color; } } - + private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) diff --git a/Fika.sln b/Fika.sln index 51ab95f4..ac0a030b 100644 --- a/Fika.sln +++ b/Fika.sln @@ -8,16 +8,16 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - GoldMaster|Any CPU = GoldMaster|Any CPU Release|Any CPU = Release|Any CPU + GoldMaster|Any CPU = GoldMaster|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.ActiveCfg = Release|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.Build.0 = Release|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.ActiveCfg = GoldMaster|Any CPU - {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.Build.0 = GoldMaster|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.Build.0 = Debug|Any CPU {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.ActiveCfg = Release|Any CPU {79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.Build.0 = Release|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.ActiveCfg = GoldMaster|Any CPU + {79F0E889-A195-42B4-8656-4F35685BBB80}.GoldMaster|Any CPU.Build.0 = GoldMaster|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 16e918e10e188ae76100f46b70726b35ce136ffa Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sat, 4 May 2024 17:13:15 -0400 Subject: [PATCH 06/10] why are you like this git --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 151 +++++++++++-------------- 1 file changed, 65 insertions(+), 86 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 0562a262..39636f91 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -2,6 +2,7 @@ using Comfort.Common; using EFT; +using EFT.Animations; using EFT.UI; using Fika.Core.Bundles; using Fika.Core.Coop.Players; @@ -43,7 +44,8 @@ protected void Update() playerPlate.gameObject.SetActive(true); } UpdateScreenSpacePosition(); - if (!FikaPlugin.HideHealthBar.Value) { + if (!FikaPlugin.HideHealthBar.Value) + { float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; if (FikaPlugin.UseHealthNumber.Value) @@ -82,117 +84,94 @@ protected void Update() private void UpdateScreenSpacePosition() { - Camera camera = CameraClass.Instance.Camera; - float opacityMultiplier = 1f; - if (mainPlayer.HealthController.IsAlive && mainPlayer.ProceduralWeaponAnimation.IsAiming) + + ProceduralWeaponAnimation proceduralWeaponAnimation = mainPlayer.ProceduralWeaponAnimation; + if (mainPlayer.HealthController.IsAlive && proceduralWeaponAnimation.IsAiming) { - // Scope scaling and positioning - if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic) + if (proceduralWeaponAnimation.CurrentScope.IsOptic && FikaPlugin.HideNamePlateInOptic.Value) { - if (FikaPlugin.HideNamePlateInOptic.Value) { - playerPlate.ScalarObjectScreen.active = false; - return; - } + playerPlate.ScalarObjectScreen.active = false; + return; } - // Opacity in ADS opacityMultiplier = FikaPlugin.OpacityInADS.Value; } + CameraClass cameraInstance = CameraClass.Instance; + Camera camera = cameraInstance.Camera; float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; - float maxDistanceToShow = Mathf.Pow(FikaPlugin.MaxDistanceToShow.Value, 2); + float maxDistanceToShow = FikaPlugin.MaxDistanceToShow.Value * FikaPlugin.MaxDistanceToShow.Value; if (sqrDistance > maxDistanceToShow) { - // Disable the nameplate if the player is too far away playerPlate.ScalarObjectScreen.active = false; return; } - - if (playerPlate.ScalarObjectScreen.active == false) - { - playerPlate.ScalarObjectScreen.active = true; - } - float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); - Vector3 position; - - position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); + playerPlate.ScalarObjectScreen.active = true; + float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); + Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z); Vector3 screenPoint = camera.WorldToScreenPoint(position); - if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) + if (screenPoint.z <= 0) { - int outputWidth = CameraClass.Instance.SSAA.GetOutputWidth(); - float inputWidth = CameraClass.Instance.SSAA.GetInputWidth(); - screenScale = outputWidth / inputWidth; + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); + UpdateColorImage(playerPlate.healthBarScreen, 0); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); + UpdateColorImage(playerPlate.usecPlateScreen, 0); + UpdateColorImage(playerPlate.bearPlateScreen, 0); + return; } - if (screenPoint.z > 0) + SSAA ssaa = cameraInstance.SSAA; + bool isSSAAEnabled = ssaa != null && ssaa.isActiveAndEnabled; + if (isSSAAEnabled) { - playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; + int outputWidth = ssaa.GetOutputWidth(); + float inputWidth = ssaa.GetInputWidth(); + screenScale = outputWidth / inputWidth; + } - // Less opaque when not looking at the player - float distFromCenterMultiplier = 1f; - if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) - { - float screenWidth = Screen.width; - float screenHeight = Screen.height; - if (CameraClass.Instance.SSAA != null && CameraClass.Instance.SSAA.isActiveAndEnabled) - { - screenWidth = CameraClass.Instance.SSAA.GetOutputWidth(); - screenHeight = CameraClass.Instance.SSAA.GetOutputHeight(); - } - Vector3 screenCenter = new Vector3(screenWidth / 2, screenHeight / 2, 0); - Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; - float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; - float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; - float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; - - distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); - } + playerPlate.ScalarObjectScreen.transform.position = screenScale < 1 ? screenPoint : screenPoint * screenScale; - float alpha = 1f; - float namePlateScaleMult = FikaPlugin.NamePlateScale.Value; - float lerpValue = (sqrDistance - maxDistanceToShow / 2) / (maxDistanceToShow / 2); - alpha = Mathf.Lerp(alpha, 0, lerpValue); - namePlateScaleMult = Mathf.Lerp(1f, 0.5f, lerpValue); - namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); + float distFromCenterMultiplier = 1f; + if (FikaPlugin.DecreaseOpacityNotLookingAt.Value) + { + float screenWidth = isSSAAEnabled ? ssaa.GetOutputWidth() : Screen.width; + float screenHeight = isSSAAEnabled ? ssaa.GetOutputHeight() : Screen.height; + Vector3 screenCenter = new(screenWidth / 2, screenHeight / 2, 0); + Vector3 playerPosition = playerPlate.ScalarObjectScreen.transform.position; + float sqrDistFromCenter = (screenCenter - playerPosition).sqrMagnitude; + float minScreenSizeHalf = Mathf.Min(screenWidth, screenHeight) / 2; + float maxSqrDistFromCenter = minScreenSizeHalf * minScreenSizeHalf; + distFromCenterMultiplier = Mathf.Clamp01(1 - (sqrDistFromCenter / maxSqrDistFromCenter)); + } - // Setting the nameplate scale - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + float alpha = 1f; + float halfMaxDistanceToShow = maxDistanceToShow / 2; + float lerpValue = Mathf.Clamp01((sqrDistance - halfMaxDistanceToShow) / (halfMaxDistanceToShow)); + alpha = Mathf.LerpUnclamped(alpha, 0, lerpValue); + float namePlateScaleMult = Mathf.LerpUnclamped(1f, 0.5f, lerpValue); + namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - // Setting the overall nameplate alpha - alpha *= opacityMultiplier; - alpha *= distFromCenterMultiplier; - alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); + playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; - float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + alpha *= opacityMultiplier; + alpha *= distFromCenterMultiplier; + alpha = Mathf.Max(FikaPlugin.MinimumOpacity.Value, alpha); - float healthAlphaMultiplier = 1f; - if (FikaPlugin.HideHealthBar.Value) - { - healthAlphaMultiplier = 0; - } + float backgroundOpacity = Mathf.Clamp(alpha, 0f, 0.44f); + float healthAlphaMultiplier = FikaPlugin.HideHealthBar.Value ? 0 : 1f; - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); - UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); - UpdateColorImage(playerPlate.usecPlateScreen, alpha); - UpdateColorImage(playerPlate.bearPlateScreen, alpha); - } - else - { - // Hide the nameplate if the player is behind the camera - UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); - UpdateColorImage(playerPlate.healthBarScreen, 0); - UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, 0); - UpdateColorImage(playerPlate.healthBarBackgroundScreen, 0); - UpdateColorImage(playerPlate.healthNumberBackgroundScreen, 0); - UpdateColorImage(playerPlate.usecPlateScreen, 0); - UpdateColorImage(playerPlate.bearPlateScreen, 0); - } + UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, alpha); + UpdateColorImage(playerPlate.healthBarScreen, alpha * healthAlphaMultiplier); + UpdateColorTextMeshProUGUI(playerPlate.healthNumberScreen, alpha * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthBarBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.healthNumberBackgroundScreen, backgroundOpacity * healthAlphaMultiplier); + UpdateColorImage(playerPlate.usecPlateScreen, alpha); + UpdateColorImage(playerPlate.bearPlateScreen, alpha); } private void CreateHealthBar() @@ -249,7 +228,7 @@ private void UpdateHealthBarColor(float normalizedHealth) playerPlate.healthBarScreen.color = color; } - private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) + private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) { @@ -258,7 +237,7 @@ private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) screenObject.color = color; } } - + private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) From ee5f6989dc8a3465d40df923da52f945cef39bde Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sun, 5 May 2024 04:03:35 -0400 Subject: [PATCH 07/10] basic nameplate occlusion using existing isVisible check --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 7 +++++++ Fika.Core/FikaPlugin.cs | 25 ++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 39636f91..b7b34965 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -84,6 +84,13 @@ protected void Update() private void UpdateScreenSpacePosition() { + // Check if we should occlude the name plate + if (FikaPlugin.OccludeNamePlates.Value && !currentPlayer.IsVisible) + { + playerPlate.ScalarObjectScreen.active = false; + return; + } + float opacityMultiplier = 1f; ProceduralWeaponAnimation proceduralWeaponAnimation = mainPlayer.ProceduralWeaponAnimation; diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index f4a52b5f..4cd46a20 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -108,6 +108,7 @@ public class FikaPlugin : BaseUnityPlugin // Coop | NamePlates public static ConfigEntry UseNamePlates { get; set; } + public static ConfigEntry OccludeNamePlates { get; set; } public static ConfigEntry HideHealthBar { get; set; } public static ConfigEntry UseHealthNumber { get; set; } public static ConfigEntry UsePlateFactionSide { get; set; } @@ -264,31 +265,33 @@ private void SetupConfig() FasterInventoryScrollSpeed = Config.Bind("Coop", "Faster Inventory Scroll Speed", 63, new ConfigDescription("The speed at which the inventory scrolls at. Default is 63.", new AcceptableValueRange(63, 500), new ConfigurationManagerAttributes() { Order = 2 })); ExtractKey = Config.Bind("Coop", "Extract Key", new KeyboardShortcut(KeyCode.F8), new ConfigDescription("The key used to extract from the raid.", tags: new ConfigurationManagerAttributes() { Order = 1 })); - + // Coop | NamePlates - UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); - + UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 11 })); + + OccludeNamePlates = Config.Bind("Coop | NamePlates", "Occlude Name Plates", false, new ConfigDescription("Hides name plates for players that are not visible.", tags: new ConfigurationManagerAttributes() { Order = 10 })); + HideHealthBar = Config.Bind("Coop | NamePlates", "Hide Health Bar", false, new ConfigDescription("Completely hides the health bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); - + UseHealthNumber = Config.Bind("Coop | NamePlates", "Show HP% instead of bar", false, new ConfigDescription("Shows health in % amount instead of using the bar.", tags: new ConfigurationManagerAttributes() { Order = 8 })); - + UsePlateFactionSide = Config.Bind("Coop | NamePlates", "Show Player Faction Icon", true, new ConfigDescription("Shows the player faction icon next to the HP bar.", tags: new ConfigurationManagerAttributes() { Order = 7 })); - + HideNamePlateInOptic = Config.Bind("Coop | NamePlates", "Hide Name Plate in Optic", true, new ConfigDescription("Hides the name plate when viewing through PiP scopes since it's kinda janky.", tags: new ConfigurationManagerAttributes() { Order = 6 })); - + DecreaseOpacityNotLookingAt = Config.Bind("Coop | NamePlates", "Decrease Opacity In Peripheral", true, new ConfigDescription("Decreases the opacity of the name plates when not looking at a player.", tags: new ConfigurationManagerAttributes() { Order = 5 })); NamePlateScale = Config.Bind("Coop | NamePlates", "Name Plate Scale", 0.22f, new ConfigDescription("Size of the name plates", new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 4 })); - + OpacityInADS = Config.Bind("Coop | NamePlates", "Opacity in ADS", 0.75f, new ConfigDescription("The opacity of the name plates when aiming down sights.", new AcceptableValueRange(0.1f, 1f), new ConfigurationManagerAttributes() { Order = 3 })); - + MaxDistanceToShow = Config.Bind("Coop | NamePlates", "Max Distance to Show", 500f, new ConfigDescription("The maximum distance at which name plates will become invisible, starts to fade at half the input value.", new AcceptableValueRange(10f, 1000f), new ConfigurationManagerAttributes() { Order = 2 })); - + MinimumOpacity = Config.Bind("Coop | NamePlates", "Minimum Opacity", 0.1f, new ConfigDescription("The minimum opacity of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); MinimumNamePlateScale = Config.Bind("Coop | NamePlates", "Minimum Name Plate Scale", 0.01f, new ConfigDescription("The minimum scale of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 0 })); - + // Coop | Custom UsePingSystem = Config.Bind("Coop | Custom", "Ping System", false, new ConfigDescription("Toggle Ping System. If enabled you can receive and send pings by pressing the ping key.", tags: new ConfigurationManagerAttributes() { Order = 6 })); From 75872235c55627167f5b697c5068e14b9bd746fb Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sun, 5 May 2024 05:45:44 -0400 Subject: [PATCH 08/10] Removed occlusion setting, implemented throttled updates, all elements actively respect config --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 103 ++++++++++++++++--------- Fika.Core/FikaPlugin.cs | 5 +- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index b7b34965..7bc85660 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -22,6 +22,9 @@ public class FikaHealthBar : MonoBehaviour private CoopPlayer mainPlayer; private PlayerPlateUI playerPlate; private float screenScale = 1f; + private int layerMask; + private int frameCounter = 0; + private readonly int throttleInterval = 60; // throttle to 1 update per 60 frames protected void Awake() { @@ -34,17 +37,24 @@ protected void Update() { if (currentPlayer != null) { - if (!FikaPlugin.UseNamePlates.Value) + bool throttleUpdate = IsThrottleUpdate(); + if (throttleUpdate) { - playerPlate.gameObject.SetActive(false); - return; - } - else if (playerPlate.gameObject.active == false) - { - playerPlate.gameObject.SetActive(true); + // Handling the visibility of elements + if (!FikaPlugin.UseNamePlates.Value) + { + playerPlate.gameObject.SetActive(false); + return; + } + else if (playerPlate.gameObject.active == false) + { + playerPlate.gameObject.SetActive(true); + } + SetPlayerPlateFactionVisibility(FikaPlugin.UsePlateFactionSide.Value); + SetPlayerPlateHealthVisibility(FikaPlugin.HideHealthBar.Value); } - UpdateScreenSpacePosition(); - if (!FikaPlugin.HideHealthBar.Value) + // Updating the health bar + if (playerPlate.healthBarScreen.gameObject.activeSelf) { float currentHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Current; float maxHealth = currentPlayer.HealthController.GetBodyPartHealth(EBodyPart.Common, true).Maximum; @@ -71,6 +81,9 @@ protected void Update() UpdateHealthBarColor(normalizedHealth); } } + // Finally, update the screen space position + UpdateScreenSpacePosition(throttleUpdate); + // Destroy if this player is dead if (!currentPlayer.HealthController.IsAlive) { Destroy(this); @@ -82,17 +95,10 @@ protected void Update() } } - private void UpdateScreenSpacePosition() + private void UpdateScreenSpacePosition(bool throttleUpdate) { - // Check if we should occlude the name plate - if (FikaPlugin.OccludeNamePlates.Value && !currentPlayer.IsVisible) - { - playerPlate.ScalarObjectScreen.active = false; - return; - } - + // ADS opacity handling float opacityMultiplier = 1f; - ProceduralWeaponAnimation proceduralWeaponAnimation = mainPlayer.ProceduralWeaponAnimation; if (mainPlayer.HealthController.IsAlive && proceduralWeaponAnimation.IsAiming) { @@ -106,7 +112,9 @@ private void UpdateScreenSpacePosition() CameraClass cameraInstance = CameraClass.Instance; Camera camera = cameraInstance.Camera; - float sqrDistance = (camera.transform.position - currentPlayer.Position).sqrMagnitude; + // Distance check + Vector3 direction = camera.transform.position - currentPlayer.Position; + float sqrDistance = direction.sqrMagnitude; float maxDistanceToShow = FikaPlugin.MaxDistanceToShow.Value * FikaPlugin.MaxDistanceToShow.Value; if (sqrDistance > maxDistanceToShow) { @@ -114,6 +122,7 @@ private void UpdateScreenSpacePosition() return; } + // If we're here, we can show the name plate playerPlate.ScalarObjectScreen.active = true; float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f); @@ -189,24 +198,6 @@ private void CreateHealthBar() GameObject uiGameObj = Instantiate(uiPrefab); playerPlate = uiGameObj.GetComponent(); playerPlate.SetNameText(currentPlayer.Profile.Info.MainProfileNickname); - if (FikaPlugin.UsePlateFactionSide.Value) - { - if (currentPlayer.Profile.Side == EPlayerSide.Usec) - { - playerPlate.usecPlateScreen.gameObject.SetActive(true); - } - else if (currentPlayer.Profile.Side == EPlayerSide.Bear) - { - playerPlate.bearPlateScreen.gameObject.SetActive(true); - } - } - if (FikaPlugin.HideHealthBar.Value) - { - playerPlate.healthBarScreen.gameObject.SetActive(false); - playerPlate.healthNumberScreen.gameObject.SetActive(false); - playerPlate.healthBarBackgroundScreen.gameObject.SetActive(false); - playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(false); - } if (FikaPlugin.DevelopersList.ContainsKey(currentPlayer.Profile.Nickname.ToLower())) { playerPlate.playerNameScreen.color = new Color(0, 0.6091f, 1, 1); @@ -225,6 +216,9 @@ private void CreateHealthBar() playerPlate.usecPlateScreen.GetComponent().sprite = specialIcons.IconsSettings[2].IconSprite; playerPlate.usecPlateScreen.transform.localPosition = new Vector3(0f, 24.9f, 0); } + // Start the plates both disabled, the visibility will be set in the update loop + playerPlate.usecPlateScreen.gameObject.SetActive(false); + playerPlate.bearPlateScreen.gameObject.SetActive(false); } } @@ -235,7 +229,7 @@ private void UpdateHealthBarColor(float normalizedHealth) playerPlate.healthBarScreen.color = color; } - private void UpdateColorImage(UnityEngine.UI.Image screenObject, float alpha) + private void UpdateColorImage(Image screenObject, float alpha) { if (screenObject.gameObject.activeInHierarchy) { @@ -255,6 +249,39 @@ private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, floa } } + private void SetPlayerPlateHealthVisibility(bool hidden) + { + playerPlate.healthNumberScreen.gameObject.SetActive(!hidden && FikaPlugin.UseHealthNumber.Value); + playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(!hidden && FikaPlugin.UseHealthNumber.Value); + playerPlate.healthBarScreen.gameObject.SetActive(!hidden && !FikaPlugin.UseHealthNumber.Value); + playerPlate.healthBarBackgroundScreen.gameObject.SetActive(!hidden && !FikaPlugin.UseHealthNumber.Value); + } + + + private void SetPlayerPlateFactionVisibility(bool visible) + { + if (currentPlayer.Profile.Side == EPlayerSide.Usec) + { + playerPlate.usecPlateScreen.gameObject.SetActive(visible); + } + else if (currentPlayer.Profile.Side == EPlayerSide.Bear) + { + playerPlate.bearPlateScreen.gameObject.SetActive(visible); + } + } + + private bool IsThrottleUpdate() + { + // For throttling updates to various elements + frameCounter++; + bool throttleUpdate = frameCounter >= throttleInterval; + if (throttleUpdate) + { + frameCounter = 0; + } + return throttleUpdate; + } + private void OnDestroy() { playerPlate.gameObject.SetActive(false); diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 4cd46a20..23666ccb 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -108,7 +108,6 @@ public class FikaPlugin : BaseUnityPlugin // Coop | NamePlates public static ConfigEntry UseNamePlates { get; set; } - public static ConfigEntry OccludeNamePlates { get; set; } public static ConfigEntry HideHealthBar { get; set; } public static ConfigEntry UseHealthNumber { get; set; } public static ConfigEntry UsePlateFactionSide { get; set; } @@ -268,9 +267,7 @@ private void SetupConfig() // Coop | NamePlates - UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 11 })); - - OccludeNamePlates = Config.Bind("Coop | NamePlates", "Occlude Name Plates", false, new ConfigDescription("Hides name plates for players that are not visible.", tags: new ConfigurationManagerAttributes() { Order = 10 })); + UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); HideHealthBar = Config.Bind("Coop | NamePlates", "Hide Health Bar", false, new ConfigDescription("Completely hides the health bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); From 4d19a380e3156550f0d95a8e28c6570bea4b05b8 Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sun, 5 May 2024 05:47:26 -0400 Subject: [PATCH 09/10] remove unused int --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 7bc85660..6564eb61 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -22,7 +22,6 @@ public class FikaHealthBar : MonoBehaviour private CoopPlayer mainPlayer; private PlayerPlateUI playerPlate; private float screenScale = 1f; - private int layerMask; private int frameCounter = 0; private readonly int throttleInterval = 60; // throttle to 1 update per 60 frames From 0427165b15fa1fe2fb0541b22bf815bcb31dc455 Mon Sep 17 00:00:00 2001 From: NickMillion <37994255+NickMillion@users.noreply.github.com> Date: Sun, 5 May 2024 07:45:56 -0400 Subject: [PATCH 10/10] NamePlate -> Name Plate to make Lacy happy --- Fika.Core/FikaPlugin.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 23666ccb..3667d613 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -106,7 +106,7 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry FasterInventoryScrollSpeed { get; set; } public static ConfigEntry ExtractKey { get; set; } - // Coop | NamePlates + // Coop | Name Plates public static ConfigEntry UseNamePlates { get; set; } public static ConfigEntry HideHealthBar { get; set; } public static ConfigEntry UseHealthNumber { get; set; } @@ -265,29 +265,29 @@ private void SetupConfig() ExtractKey = Config.Bind("Coop", "Extract Key", new KeyboardShortcut(KeyCode.F8), new ConfigDescription("The key used to extract from the raid.", tags: new ConfigurationManagerAttributes() { Order = 1 })); - // Coop | NamePlates + // Coop | Name Plates - UseNamePlates = Config.Bind("Coop | NamePlates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); + UseNamePlates = Config.Bind("Coop | Name Plates", "Show Player Name Plates", false, new ConfigDescription("Toggle Health-Bars & Names.", tags: new ConfigurationManagerAttributes() { Order = 10 })); - HideHealthBar = Config.Bind("Coop | NamePlates", "Hide Health Bar", false, new ConfigDescription("Completely hides the health bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); + HideHealthBar = Config.Bind("Coop | Name Plates", "Hide Health Bar", false, new ConfigDescription("Completely hides the health bar.", tags: new ConfigurationManagerAttributes() { Order = 9 })); - UseHealthNumber = Config.Bind("Coop | NamePlates", "Show HP% instead of bar", false, new ConfigDescription("Shows health in % amount instead of using the bar.", tags: new ConfigurationManagerAttributes() { Order = 8 })); + UseHealthNumber = Config.Bind("Coop | Name Plates", "Show HP% instead of bar", false, new ConfigDescription("Shows health in % amount instead of using the bar.", tags: new ConfigurationManagerAttributes() { Order = 8 })); - UsePlateFactionSide = Config.Bind("Coop | NamePlates", "Show Player Faction Icon", true, new ConfigDescription("Shows the player faction icon next to the HP bar.", tags: new ConfigurationManagerAttributes() { Order = 7 })); + UsePlateFactionSide = Config.Bind("Coop | Name Plates", "Show Player Faction Icon", true, new ConfigDescription("Shows the player faction icon next to the HP bar.", tags: new ConfigurationManagerAttributes() { Order = 7 })); - HideNamePlateInOptic = Config.Bind("Coop | NamePlates", "Hide Name Plate in Optic", true, new ConfigDescription("Hides the name plate when viewing through PiP scopes since it's kinda janky.", tags: new ConfigurationManagerAttributes() { Order = 6 })); + HideNamePlateInOptic = Config.Bind("Coop | Name Plates", "Hide Name Plate in Optic", true, new ConfigDescription("Hides the name plate when viewing through PiP scopes since it's kinda janky.", tags: new ConfigurationManagerAttributes() { Order = 6 })); - DecreaseOpacityNotLookingAt = Config.Bind("Coop | NamePlates", "Decrease Opacity In Peripheral", true, new ConfigDescription("Decreases the opacity of the name plates when not looking at a player.", tags: new ConfigurationManagerAttributes() { Order = 5 })); + DecreaseOpacityNotLookingAt = Config.Bind("Coop | Name Plates", "Decrease Opacity In Peripheral", true, new ConfigDescription("Decreases the opacity of the name plates when not looking at a player.", tags: new ConfigurationManagerAttributes() { Order = 5 })); - NamePlateScale = Config.Bind("Coop | NamePlates", "Name Plate Scale", 0.22f, new ConfigDescription("Size of the name plates", new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 4 })); + NamePlateScale = Config.Bind("Coop | Name Plates", "Name Plate Scale", 0.22f, new ConfigDescription("Size of the name plates", new AcceptableValueRange(0.05f, 1f), new ConfigurationManagerAttributes() { Order = 4 })); - OpacityInADS = Config.Bind("Coop | NamePlates", "Opacity in ADS", 0.75f, new ConfigDescription("The opacity of the name plates when aiming down sights.", new AcceptableValueRange(0.1f, 1f), new ConfigurationManagerAttributes() { Order = 3 })); + OpacityInADS = Config.Bind("Coop | Name Plates", "Opacity in ADS", 0.75f, new ConfigDescription("The opacity of the name plates when aiming down sights.", new AcceptableValueRange(0.1f, 1f), new ConfigurationManagerAttributes() { Order = 3 })); - MaxDistanceToShow = Config.Bind("Coop | NamePlates", "Max Distance to Show", 500f, new ConfigDescription("The maximum distance at which name plates will become invisible, starts to fade at half the input value.", new AcceptableValueRange(10f, 1000f), new ConfigurationManagerAttributes() { Order = 2 })); + MaxDistanceToShow = Config.Bind("Coop | Name Plates", "Max Distance to Show", 500f, new ConfigDescription("The maximum distance at which name plates will become invisible, starts to fade at half the input value.", new AcceptableValueRange(10f, 1000f), new ConfigurationManagerAttributes() { Order = 2 })); - MinimumOpacity = Config.Bind("Coop | NamePlates", "Minimum Opacity", 0.1f, new ConfigDescription("The minimum opacity of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); + MinimumOpacity = Config.Bind("Coop | Name Plates", "Minimum Opacity", 0.1f, new ConfigDescription("The minimum opacity of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); - MinimumNamePlateScale = Config.Bind("Coop | NamePlates", "Minimum Name Plate Scale", 0.01f, new ConfigDescription("The minimum scale of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 0 })); + MinimumNamePlateScale = Config.Bind("Coop | Name Plates", "Minimum Name Plate Scale", 0.01f, new ConfigDescription("The minimum scale of the name plates.", new AcceptableValueRange(0.0f, 1f), new ConfigurationManagerAttributes() { Order = 0 })); // Coop | Custom