diff --git a/FPSCamera/Code/Game/ShadowsManager.cs b/FPSCamera/Code/Game/ShadowsManager.cs index 5446832..524b65b 100644 --- a/FPSCamera/Code/Game/ShadowsManager.cs +++ b/FPSCamera/Code/Game/ShadowsManager.cs @@ -1,6 +1,7 @@ using AlgernonCommons; using System; using System.Collections; +using UnityEngine; namespace FPSCamera.Game { public class ShadowsManager @@ -12,12 +13,12 @@ public static IEnumerator ToggleShadowsOpt(bool status) Logging.Message("-- Setting shadows distance"); if (status) { - _cachedDist = UnityEngine.QualitySettings.shadowDistance; - UnityEngine.QualitySettings.shadowDistance = Opt; + _cachedDist = QualitySettings.shadowDistance; + QualitySettings.shadowDistance = Mathf.Min(Opt, _cachedDist); } else { - UnityEngine.QualitySettings.shadowDistance = _cachedDist; + QualitySettings.shadowDistance = _cachedDist; } } diff --git a/FPSCamera/Code/Patches/LodPatches.cs b/FPSCamera/Code/Patches/LodPatches.cs index 8b735b3..88779a5 100644 --- a/FPSCamera/Code/Patches/LodPatches.cs +++ b/FPSCamera/Code/Patches/LodPatches.cs @@ -22,8 +22,8 @@ private static void BuildingInfoBaseRefreshLOD(BuildingInfoBase __instance) { // If we're applying the saved LOD configuration: __instance.m_minLodDistance = ActiveConfig == Saved ? - // Apply the greater LOD distance. - Mathf.Max(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance) : + // Apply the saved LOD distance. + ActiveConfig.BuildingLodDistance : // Otherwise, apply the smaller LOD distance. Mathf.Min(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance); } @@ -38,9 +38,8 @@ private static void BuildingRefreshLOD(BuildingInfo __instance) if (__instance.m_lodMesh != null) { __instance.m_minLodDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance) : + ActiveConfig.BuildingLodDistance : Mathf.Min(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance); - } } @@ -53,7 +52,7 @@ private static void BuildingSubRefreshLOD(BuildingInfoSub __instance) if (__instance.m_lodMesh != null) { __instance.m_minLodDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance) : + ActiveConfig.BuildingLodDistance : Mathf.Min(__instance.m_minLodDistance, ActiveConfig.BuildingLodDistance); } @@ -68,7 +67,7 @@ private static void CitizenRefreshLOD(CitizenInfo __instance) if (__instance.m_lodMesh != null) { __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.CitizenLodDistance) : + ActiveConfig.CitizenLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.CitizenLodDistance); } } @@ -88,7 +87,7 @@ private static void NetRefreshLOD(NetInfo __instance) if (segments[i].m_lodMesh != null) { segments[i].m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(segments[i].m_lodRenderDistance, ActiveConfig.NetworkLodDistance) : + ActiveConfig.NetworkLodDistance : Mathf.Min(segments[i].m_lodRenderDistance, ActiveConfig.NetworkLodDistance); } } @@ -104,7 +103,7 @@ private static void NetRefreshLOD(NetInfo __instance) if (nodes[i].m_lodMesh != null) { nodes[i].m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(nodes[i].m_lodRenderDistance, ActiveConfig.NetworkLodDistance) : + ActiveConfig.NetworkLodDistance : Mathf.Min(nodes[i].m_lodRenderDistance, ActiveConfig.NetworkLodDistance); } } @@ -120,7 +119,7 @@ private static void PropRefreshLOD(PropInfo __instance) if (__instance.m_isDecal && __instance.m_material && __instance.m_material.shader.name.Equals("Custom/Props/Decal/Blend")) { var distence = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.DecalPropFadeDistance) : + ActiveConfig.DecalPropFadeDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.DecalPropFadeDistance); // Apply visibility. __instance.m_lodRenderDistance = distence; @@ -130,7 +129,7 @@ private static void PropRefreshLOD(PropInfo __instance) { // Non-decal prop. __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.PropLodDistance) : + ActiveConfig.PropLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.PropLodDistance); } } @@ -141,7 +140,7 @@ private static void TreeRefreshLOD(TreeInfo __instance) { if (ActiveConfig == null) return; __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.TreeLodDistance) : + ActiveConfig.TreeLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.TreeLodDistance); } @@ -151,7 +150,7 @@ private static void VehicleRefreshLOD(VehicleInfo __instance) { if (ActiveConfig == null) return; __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance) : + ActiveConfig.VehicleLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance); } @@ -161,7 +160,7 @@ private static void VehicleSubRefreshLOD(VehicleInfoBase __instance) { if (ActiveConfig == null) return; __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance) : + ActiveConfig.VehicleLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance); } @@ -171,7 +170,7 @@ private static void VehicleSubRefreshLOD(VehicleInfoSub __instance) { if (ActiveConfig == null) return; __instance.m_lodRenderDistance = ActiveConfig == Saved ? - Mathf.Max(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance) : + ActiveConfig.VehicleLodDistance : Mathf.Min(__instance.m_lodRenderDistance, ActiveConfig.VehicleLodDistance); } }