From 88a63d7eddecfab8c5eedcf8f07cbe64c8f21915 Mon Sep 17 00:00:00 2001 From: Ejsstiil Date: Thu, 3 Feb 2022 03:23:53 +0100 Subject: [PATCH] Added possibility to clamp minimum radii for Land and Sea --- Pathfinder/PathfinderPlugin.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Pathfinder/PathfinderPlugin.cs b/Pathfinder/PathfinderPlugin.cs index 9b46adc..2468a8c 100644 --- a/Pathfinder/PathfinderPlugin.cs +++ b/Pathfinder/PathfinderPlugin.cs @@ -46,6 +46,8 @@ public class PathfinderPlugin : BaseUnityPlugin public static ConfigEntry ForestRadiusPenalty; public static ConfigEntry DaylightRadiusScale; public static ConfigEntry WeatherRadiusScale; + public static ConfigEntry LandExploreRadiusMinimum; + public static ConfigEntry SeaExploreRadiusMinimum; public static ConfigEntry DisplayCurrentRadiusValue; private static Harmony sMinimapHarmony; @@ -64,9 +66,15 @@ private void Awake() LandExploreRadius = Config.Bind("Base", nameof(LandExploreRadius), 200.0f, "The radius around the player to uncover while travelling on land near sea level. Higher values may cause performance issues. Max allowed is 2000. Game default is 100."); LandExploreRadius.SettingChanged += Config_SettingChanged; + LandExploreRadiusMinimum = Config.Bind("Base", nameof(LandExploreRadiusMinimum), 10.0f, "Defines a minimum radius (lower cap) you don't want to go under while on foot. Accepted range 10-" + nameof(LandExploreRadius) + ". Default is 10."); + LandExploreRadiusMinimum.SettingChanged += Config_SettingChanged; + SeaExploreRadius = Config.Bind("Base", nameof(SeaExploreRadius), 300.0f, "The radius around the player to uncover while travelling on a boat. Higher values may cause performance issues. Max allowed is 2000. Game default is 100."); SeaExploreRadius.SettingChanged += Config_SettingChanged; + SeaExploreRadiusMinimum = Config.Bind("Base", nameof(SeaExploreRadiusMinimum), 20.0f, "Defines a minimum radius (lower cap) you don't want to go under while on boat. Accepted range 20-" + nameof(SeaExploreRadius) + ". Default is 20."); + SeaExploreRadiusMinimum.SettingChanged += Config_SettingChanged; + AltitudeRadiusBonus = Config.Bind("Multipliers", nameof(AltitudeRadiusBonus), 0.5f, "Bonus multiplier to apply to land exploration radius based on altitude. For every 100 units above sea level (smooth scale), add this value multiplied by LandExploreRadius to the total. For example, with a radius of 200 and a multiplier of 0.5, radius is 200 at sea level, 250 at 50 altitude, 300 at 100 altitude, 400 at 200 altitude, etc. For reference, a typical mountain peak is around 170 altitude. Accepted range 0-2. Set to 0 to disable."); AltitudeRadiusBonus.SettingChanged += Config_SettingChanged; @@ -135,6 +143,12 @@ private static void ClampConfig() if (WeatherRadiusScale.Value < 0.0f) WeatherRadiusScale.Value = 0.0f; if (WeatherRadiusScale.Value > 1.0f) WeatherRadiusScale.Value = 1.0f; + + if (LandExploreRadiusMinimum.Value < 10.0f) LandExploreRadiusMinimum.Value = 10.0f; + if (LandExploreRadiusMinimum.Value > LandExploreRadius.Value) LandExploreRadiusMinimum.Value = 10.0f; + + if (SeaExploreRadiusMinimum.Value < 20.0f) SeaExploreRadiusMinimum.Value = 20.0f; + if (SeaExploreRadiusMinimum.Value > SeaExploreRadius.Value) SeaExploreRadiusMinimum.Value = 20.0f; } [HarmonyPatch(typeof(Minimap))] @@ -194,6 +208,7 @@ private static IEnumerable UpdateExplore_Transpiler(IEnumerable private static float GetExploreRadius(Player player) { float result; + float minimumRadius; if (player.InInterior()) { @@ -216,10 +231,12 @@ private static float GetExploreRadius(Player player) if (players.Any(p => p.IsAttachedToShip())) { baseRadius = SeaExploreRadius.Value; + minimumRadius = SeaExploreRadiusMinimum.Value; } else { baseRadius = LandExploreRadius.Value; + minimumRadius = LandExploreRadiusMinimum.Value; } // Take the higher of directional or ambient light, subtract 1 to turn this into a value we can add to our multiplier @@ -279,7 +296,7 @@ private static float GetExploreRadius(Player player) } #endif - result = Mathf.Clamp(baseRadius * multiplier, 20.0f, 2000.0f); + result = Mathf.Clamp(baseRadius * multiplier, minimumRadius, 2000.0f); sHudText.text = $"Pathfinder: radius={result:0.0}";