From 7080a19f3b85a5f5c6fd40f16dbb2072badf38ac Mon Sep 17 00:00:00 2001 From: Shynd Date: Sat, 25 May 2024 19:51:42 -0400 Subject: [PATCH 1/4] add ability to toggle whether name plates and pings are displayed with pip optic --- Fika.Core/Coop/Custom/FikaHealthBar.cs | 2 +- Fika.Core/Coop/Factories/PingFactory.cs | 2 +- Fika.Core/FikaPlugin.cs | 2 +- Fika.Core/Utils/WorldToScreen.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index cb2dc73a..e638956a 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -100,7 +100,7 @@ private void UpdateScreenSpacePosition(bool throttleUpdate) 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); - if (!WorldToScreen.GetScreenPoint(position, mainPlayer, out Vector3 screenPoint)) + if (!WorldToScreen.GetScreenPoint(position, mainPlayer, out Vector3 screenPoint, FikaPlugin.NamePlateUseOpticZoom.Value)) { UpdateColorTextMeshProUGUI(playerPlate.playerNameScreen, 0); UpdateColorImage(playerPlate.healthBarScreen, 0); diff --git a/Fika.Core/Coop/Factories/PingFactory.cs b/Fika.Core/Coop/Factories/PingFactory.cs index 3a47c5b5..ef011555 100644 --- a/Fika.Core/Coop/Factories/PingFactory.cs +++ b/Fika.Core/Coop/Factories/PingFactory.cs @@ -83,7 +83,7 @@ protected void Update() screenScale = outputWidth / inputWidth; } - if (WorldToScreen.GetScreenPoint(hitPoint, mainPlayer, out Vector3 screenPoint)) + if (WorldToScreen.GetScreenPoint(hitPoint, mainPlayer, out Vector3 screenPoint, FikaPlugin.PingUseOpticZoom.Value)) { float distanceToCenter = Vector3.Distance(screenPoint, new Vector3(Screen.width, Screen.height, 0) / 2); diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index daf2a0ce..b0cadd98 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -292,7 +292,7 @@ private void SetupConfig() 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 | 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 })); + NamePlateUseOpticZoom = Config.Bind("Coop | Name Plates", "Name Plates Use Optic Zoom", true, new ConfigDescription("If name plate location should be displayed using the PiP optic camera.", tags: new ConfigurationManagerAttributes() { Order = 6, IsAdvanced = true })); 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 })); diff --git a/Fika.Core/Utils/WorldToScreen.cs b/Fika.Core/Utils/WorldToScreen.cs index d40b6b98..b93f212d 100644 --- a/Fika.Core/Utils/WorldToScreen.cs +++ b/Fika.Core/Utils/WorldToScreen.cs @@ -8,7 +8,7 @@ namespace Fika.Core.Utils { public static class WorldToScreen { - public static bool GetScreenPoint(Vector3 worldPosition, CoopPlayer mainPlayer, out Vector3 screenPoint) + public static bool GetScreenPoint(Vector3 worldPosition, CoopPlayer mainPlayer, out Vector3 screenPoint, bool useOpticCamera = true) { CameraClass worldCameraInstance = CameraClass.Instance; Camera worldCamera = worldCameraInstance.Camera; @@ -22,7 +22,7 @@ public static bool GetScreenPoint(Vector3 worldPosition, CoopPlayer mainPlayer, ProceduralWeaponAnimation weaponAnimation = mainPlayer.ProceduralWeaponAnimation; - if (weaponAnimation != null) + if (useOpticCamera && weaponAnimation != null) { if (weaponAnimation.IsAiming && weaponAnimation.CurrentScope.IsOptic) { From 442c27902155b92199ddc83183b079eff5f2fbd9 Mon Sep 17 00:00:00 2001 From: Shynd Date: Sat, 25 May 2024 19:52:38 -0400 Subject: [PATCH 2/4] add option for minimum ping opacity --- Fika.Core/Coop/Factories/PingFactory.cs | 2 +- Fika.Core/FikaPlugin.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Fika.Core/Coop/Factories/PingFactory.cs b/Fika.Core/Coop/Factories/PingFactory.cs index ef011555..207c4e25 100644 --- a/Fika.Core/Coop/Factories/PingFactory.cs +++ b/Fika.Core/Coop/Factories/PingFactory.cs @@ -89,7 +89,7 @@ protected void Update() if (distanceToCenter < 200) { - image.color = new Color(_pingColor.r, _pingColor.g, _pingColor.b, Mathf.Max(0.05f, distanceToCenter / 200)); + image.color = new Color(_pingColor.r, _pingColor.g, _pingColor.b, Mathf.Max(FikaPlugin.PingMinimumOpacity.Value, distanceToCenter / 200)); } else { diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index b0cadd98..f9547ba8 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -320,7 +320,7 @@ private void SetupConfig() PlayPingAnimation = Config.Bind("Coop | Custom", "Play Ping Animation", false, new ConfigDescription("Plays the pointing animation automatically when pinging. Can interfere with gameplay.", tags: new ConfigurationManagerAttributes() { Order = 2 })); - ShowPingDuringOptics = Config.Bind("Coop | Custom", "Show Ping During Optics", false, new ConfigDescription("If pings should be displayed while aiming down an optics scope.", tags: new ConfigurationManagerAttributes() { Order = 1 })); + PingMinimumOpacity = Config.Bind("Coop | Custom", "Ping Minimum Opacity", 0.05f, new ConfigDescription("The minimum opacity of pings when looking straight at them.", new AcceptableValueRange(0f, 0.5f), new ConfigurationManagerAttributes() { Order = 0, IsAdvanced = true })); // Coop | Debug From acac5435bc0c566715950d941c964de460cc57da Mon Sep 17 00:00:00 2001 From: Shynd Date: Sat, 25 May 2024 19:53:42 -0400 Subject: [PATCH 3/4] add option to disable ping scaling with distance --- Fika.Core/Coop/Factories/PingFactory.cs | 11 ++++++++++- Fika.Core/FikaPlugin.cs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Fika.Core/Coop/Factories/PingFactory.cs b/Fika.Core/Coop/Factories/PingFactory.cs index 207c4e25..d53604d0 100644 --- a/Fika.Core/Coop/Factories/PingFactory.cs +++ b/Fika.Core/Coop/Factories/PingFactory.cs @@ -108,7 +108,16 @@ public virtual void Initialize(ref Vector3 point, Object userObject, Color pingC float distance = Mathf.Clamp(Vector3.Distance(CameraClass.Instance.Camera.transform.position, transform.position) / 100, 0.4f, 0.6f); float pingSize = FikaPlugin.PingSize.Value; - image.rectTransform.localScale = new Vector3(pingSize, pingSize, pingSize) * distance; + Vector3 scaledSize = new Vector3(pingSize, pingSize, pingSize); + if (FikaPlugin.PingScaleWithDistance.Value == true) + { + scaledSize *= distance; + } + else + { + scaledSize *= 0.5f; + } + image.rectTransform.localScale = scaledSize; } } diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index f9547ba8..840d9f92 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -318,7 +318,7 @@ private void SetupConfig() PingTime = Config.Bind("Coop | Custom", "Ping Time", 3, new ConfigDescription("How long pings should be displayed.", new AcceptableValueRange(2, 10), new ConfigurationManagerAttributes() { Order = 3 })); - PlayPingAnimation = Config.Bind("Coop | Custom", "Play Ping Animation", false, new ConfigDescription("Plays the pointing animation automatically when pinging. Can interfere with gameplay.", tags: new ConfigurationManagerAttributes() { Order = 2 })); + PingScaleWithDistance = Config.Bind("Coop | Custom", "Ping Scale With Distance", true, new ConfigDescription("If ping size should scale with distance from player.", tags: new ConfigurationManagerAttributes() { Order = 1, IsAdvanced = true })); PingMinimumOpacity = Config.Bind("Coop | Custom", "Ping Minimum Opacity", 0.05f, new ConfigDescription("The minimum opacity of pings when looking straight at them.", new AcceptableValueRange(0f, 0.5f), new ConfigurationManagerAttributes() { Order = 0, IsAdvanced = true })); From 92cec3744d836e6ea60a587ae93dad0a4d5775f7 Mon Sep 17 00:00:00 2001 From: Shynd Date: Sat, 25 May 2024 19:54:12 -0400 Subject: [PATCH 4/4] reorder plugin options --- Fika.Core/FikaPlugin.cs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 840d9f92..f7486fad 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -115,6 +115,7 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry UseHealthNumber { get; set; } public static ConfigEntry UsePlateFactionSide { get; set; } public static ConfigEntry HideNamePlateInOptic { get; set; } + public static ConfigEntry NamePlateUseOpticZoom { get; set; } public static ConfigEntry DecreaseOpacityNotLookingAt { get; set; } public static ConfigEntry NamePlateScale { get; set; } public static ConfigEntry OpacityInADS { get; set; } @@ -130,6 +131,9 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry PingTime { get; set; } public static ConfigEntry PlayPingAnimation { get; set; } public static ConfigEntry ShowPingDuringOptics { get; set; } + public static ConfigEntry PingUseOpticZoom { get; set; } + public static ConfigEntry PingScaleWithDistance { get; set; } + public static ConfigEntry PingMinimumOpacity { get; set; } // Coop | Debug public static ConfigEntry FreeCamButton { get; set; } @@ -284,13 +288,15 @@ private void SetupConfig() // Coop | Name Plates - UseNamePlates = Config.Bind("Coop | Name Plates", "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 = 11 })); - HideHealthBar = Config.Bind("Coop | Name Plates", "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 = 10 })); - 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 })); + 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 = 9 })); - 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 })); + 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 = 8 })); + + HideNamePlateInOptic = Config.Bind("Coop | Name Plates", "Hide Name Plate in Optic", true, new ConfigDescription("Hides the name plate when viewing through PiP scopes.", tags: new ConfigurationManagerAttributes() { Order = 7 })); NamePlateUseOpticZoom = Config.Bind("Coop | Name Plates", "Name Plates Use Optic Zoom", true, new ConfigDescription("If name plate location should be displayed using the PiP optic camera.", tags: new ConfigurationManagerAttributes() { Order = 6, IsAdvanced = true })); @@ -308,15 +314,21 @@ private void SetupConfig() // 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 = 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 = 9 })); + + PingButton = Config.Bind("Coop | Custom", "Ping Button", new KeyboardShortcut(KeyCode.U), new ConfigDescription("Button used to send pings.", tags: new ConfigurationManagerAttributes() { Order = 8 })); + + PingColor = Config.Bind("Coop | Custom", "Ping Color", Color.white, new ConfigDescription("The color of your pings when displayed for other players.", tags: new ConfigurationManagerAttributes() { Order = 7 })); + + PingSize = Config.Bind("Coop | Custom", "Ping Size", 1f, new ConfigDescription("The multiplier of the ping size.", new AcceptableValueRange(0.1f, 2f), 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 = 6 })); + PingTime = Config.Bind("Coop | Custom", "Ping Time", 3, new ConfigDescription("How long pings should be displayed.", new AcceptableValueRange(2, 10), new ConfigurationManagerAttributes() { Order = 5 })); - PingColor = Config.Bind("Coop | Custom", "Ping Color", Color.white, new ConfigDescription("The color of your pings when displayed for other players.", tags: new ConfigurationManagerAttributes() { Order = 5 })); + PlayPingAnimation = Config.Bind("Coop | Custom", "Play Ping Animation", false, new ConfigDescription("Plays the pointing animation automatically when pinging. Can interfere with gameplay.", tags: new ConfigurationManagerAttributes() { Order = 4 })); - PingSize = Config.Bind("Coop | Custom", "Ping Size", 1f, new ConfigDescription("The multiplier of the ping size.", new AcceptableValueRange(0.1f, 2f), new ConfigurationManagerAttributes() { Order = 4 })); + ShowPingDuringOptics = Config.Bind("Coop | Custom", "Show Ping During Optics", false, new ConfigDescription("If pings should be displayed while aiming down an optics scope.", tags: new ConfigurationManagerAttributes() { Order = 3 })); - PingTime = Config.Bind("Coop | Custom", "Ping Time", 3, new ConfigDescription("How long pings should be displayed.", new AcceptableValueRange(2, 10), new ConfigurationManagerAttributes() { Order = 3 })); + PingUseOpticZoom = Config.Bind("Coop | Custom", "Ping Use Optic Zoom", true, new ConfigDescription("If ping location should be displayed using the PiP optic camera.", tags: new ConfigurationManagerAttributes() { Order = 2, IsAdvanced = true })); PingScaleWithDistance = Config.Bind("Coop | Custom", "Ping Scale With Distance", true, new ConfigDescription("If ping size should scale with distance from player.", tags: new ConfigurationManagerAttributes() { Order = 1, IsAdvanced = true }));