Skip to content

Commit

Permalink
改进优化设置相关逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
will258012 committed Dec 14, 2024
1 parent cc67168 commit e8eceb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
7 changes: 4 additions & 3 deletions FPSCamera/Code/Game/ShadowsManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AlgernonCommons;
using System;
using System.Collections;
using UnityEngine;
namespace FPSCamera.Game
{
public class ShadowsManager
Expand All @@ -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;
}
}

Expand Down
27 changes: 13 additions & 14 deletions FPSCamera/Code/Patches/LodPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);

}
}

Expand All @@ -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);

}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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;
Expand All @@ -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);
}
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}
}
Expand Down

0 comments on commit e8eceb3

Please sign in to comment.