From 52523e6e16ec39741c800fbb91a74bcb1299c89e Mon Sep 17 00:00:00 2001 From: qqrz997 <156676353+qqrz997@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:11:12 +0100 Subject: [PATCH] depth texture fix --- Behaviours/Cam.cs | 2 +- HarmonyPatches/HookSettingsManager.cs | 13 +++++++++++++ HarmonyPatches/InitOnMainAvailable.cs | 4 ---- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 HarmonyPatches/HookSettingsManager.cs diff --git a/Behaviours/Cam.cs b/Behaviours/Cam.cs index 8655b70..222511b 100644 --- a/Behaviours/Cam.cs +++ b/Behaviours/Cam.cs @@ -103,7 +103,7 @@ internal void ShowWorldCamIfNecessary() { internal void UpdateDepthTextureActive() { if(UCamera != null) - UCamera.depthTextureMode = InitOnMainAvailable.useDepthTexture || settings?.PostProcessing.forceDepthTexture == true ? DepthTextureMode.Depth : DepthTextureMode.None; + UCamera.depthTextureMode = HookSettingsManager.useDepthTexture || settings?.PostProcessing.forceDepthTexture == true ? DepthTextureMode.Depth : DepthTextureMode.None; } static readonly HashSet CameraBehavioursToDestroy = new HashSet() { diff --git a/HarmonyPatches/HookSettingsManager.cs b/HarmonyPatches/HookSettingsManager.cs new file mode 100644 index 0000000..98cec64 --- /dev/null +++ b/HarmonyPatches/HookSettingsManager.cs @@ -0,0 +1,13 @@ +using HarmonyLib; + +namespace Camera2.HarmonyPatches { + [HarmonyPatch(typeof(DepthTextureController), nameof(DepthTextureController.Init))] + static class HookSettingsManager { + public static SettingsManager settingsManager { get; private set; } + public static bool useDepthTexture { get; private set; } + static void Postfix(SettingsManager settingsManager) { + HookSettingsManager.settingsManager = settingsManager; + useDepthTexture = settingsManager.settings.quality.smokeGraphics; + } + } +} diff --git a/HarmonyPatches/InitOnMainAvailable.cs b/HarmonyPatches/InitOnMainAvailable.cs index e88dd7c..1887c92 100644 --- a/HarmonyPatches/InitOnMainAvailable.cs +++ b/HarmonyPatches/InitOnMainAvailable.cs @@ -8,12 +8,8 @@ namespace Camera2.HarmonyPatches { [HarmonyPatch(typeof(SmoothCameraController), nameof(SmoothCameraController.ActivateSmoothCameraIfNeeded))] static class InitOnMainAvailable { static bool isInited = false; - public static bool useDepthTexture { get; private set; } static void Postfix(SmoothCameraController __instance) { if(!isInited) { - // IDK - useDepthTexture = SceneUtil.GetMainCameraButReally().GetComponent()._settingsManager.settings.quality.smokeGraphics; - if(CamManager.baseCullingMask == 0) CamManager.baseCullingMask = Camera.main.cullingMask;