Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Pathfinder/PathfinderPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class PathfinderPlugin : BaseUnityPlugin
public static ConfigEntry<float> ForestRadiusPenalty;
public static ConfigEntry<float> DaylightRadiusScale;
public static ConfigEntry<float> WeatherRadiusScale;
public static ConfigEntry<float> LandExploreRadiusMinimum;
public static ConfigEntry<float> SeaExploreRadiusMinimum;
public static ConfigEntry<bool> DisplayCurrentRadiusValue;

private static Harmony sMinimapHarmony;
Expand All @@ -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;

Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -194,6 +208,7 @@ private static IEnumerable<CodeInstruction> UpdateExplore_Transpiler(IEnumerable
private static float GetExploreRadius(Player player)
{
float result;
float minimumRadius;

if (player.InInterior())
{
Expand All @@ -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
Expand Down Expand Up @@ -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}";

Expand Down