Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Empress RealismOverhaul v1.0.1
TrueRealism.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TrueRealism")] [assembly: AssemblyTitle("TrueRealism")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Empress.RealismOverhaul { [BepInPlugin("Empress.RealismOverhaul", "RealismOverhaul", "1.1.0")] public class RealismOverhaul : BaseUnityPlugin { [CompilerGenerated] private sealed class <DeferredGMRefresh>d__63 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RealismOverhaul <>4__this; private float <t>5__1; private GraphicsManager <gmi>5__2; private GraphicsManager <gm>5__3; private PostProcessing <pp>5__4; private Exception <e>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DeferredGMRefresh>d__63(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <gmi>5__2 = null; <gm>5__3 = null; <pp>5__4 = null; <e>5__5 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <t>5__1 = 0f; break; case 1: <>1__state = -1; <gm>5__3 = null; <pp>5__4 = null; break; } if (<t>5__1 < 5f) { <gm>5__3 = GraphicsManager.instance; <pp>5__4 = PostProcessing.Instance; if (!((Object)(object)<gm>5__3 != (Object)null) || !((Object)(object)<pp>5__4 != (Object)null) || !((Object)(object)<pp>5__4.volume != (Object)null)) { <t>5__1 += Time.unscaledDeltaTime; <>2__current = null; <>1__state = 1; return true; } } <gmi>5__2 = GraphicsManager.instance; if ((Object)(object)<gmi>5__2 != (Object)null) { try { <gmi>5__2.UpdateAll(); } catch (Exception ex) { <e>5__5 = ex; Logger.LogWarning((object)("Deferred UpdateAll failed: " + <e>5__5.Message)); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGuid = "Empress.RealismOverhaul"; public const string PluginName = "RealismOverhaul"; public const string PluginVersion = "1.1.0"; private static PostProcessResources? _ppResourcesCache; private static bool _missingResourcesLogged; private ConfigEntry<bool> _enableOverhaul = null; private ConfigEntry<bool> _respectGameSliders = null; private ConfigEntry<bool> _disableStylizedFX = null; private ConfigEntry<bool> _disablePostProcessingOverlay = null; private ConfigEntry<bool> _enableAmbientOcclusion = null; private ConfigEntry<bool> _enableBloom = null; private ConfigEntry<bool> _enableDepthOfField = null; private ConfigEntry<string> _antialiasingMode = null; private ConfigEntry<float> _aoIntensity = null; private ConfigEntry<float> _aoRadius = null; private ConfigEntry<float> _bloomIntensity = null; private ConfigEntry<float> _bloomThreshold = null; private ConfigEntry<float> _dofFocusDistance = null; private ConfigEntry<float> _dofAperture = null; private ConfigEntry<float> _dofFocalLength = null; private ConfigEntry<float> _postExposure = null; private ConfigEntry<int> _shadowCascades = null; private ConfigEntry<float> _shadowDistance = null; private ConfigEntry<string> _shadowResolution = null; private ConfigEntry<float> _lodBias = null; private ConfigEntry<bool> _motionBlur = null; private ConfigEntry<float> _motionBlurShutter = null; private float _dynTimer; private float _dynScale = 1f; private float _largeW; private float _largeH; private bool _noPixActive; private readonly Queue<float> _frameTimes = new Queue<float>(120); private bool _overlayHandledThisScene; private const string OverlayName = "Post Processing Overlay"; internal static RealismOverhaul Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BindConfig(); Patch(); SceneManager.sceneLoaded += delegate { _overlayHandledThisScene = false; SafeApplyAll("sceneLoaded"); ApplyForcedGameSettings(); TryDisablePostProcessingOverlay(); ((MonoBehaviour)this).StartCoroutine(DeferredGMRefresh()); }; ((MonoBehaviour)this).InvokeRepeating("EnsureCamerasHavePPLayer", 1f, 3f); ((MonoBehaviour)this).InvokeRepeating("TryDisablePostProcessingOverlay", 0.25f, 2f); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} engaged."); } private void BindConfig() { _enableOverhaul = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableOverhaul", true, ""); _respectGameSliders = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RespectGameSliders", false, ""); _disableStylizedFX = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableStylizedFX", true, ""); _disablePostProcessingOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisablePostProcessingOverlay", true, "If true, finds the GameObject named \"Post Processing Overlay\" and disables it. Exact mimic of the other mod."); _antialiasingMode = ((BaseUnityPlugin)this).Config.Bind<string>("PostFX", "Antialiasing", "TAA", ""); _enableAmbientOcclusion = ((BaseUnityPlugin)this).Config.Bind<bool>("PostFX", "AmbientOcclusion", true, ""); _aoIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "AOIntensity", 0.9f, ""); _aoRadius = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "AORadius", 0.35f, ""); _enableBloom = ((BaseUnityPlugin)this).Config.Bind<bool>("PostFX", "Bloom", false, ""); _bloomIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "BloomIntensity", 3.5f, ""); _bloomThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "BloomThreshold", 1.08f, ""); _enableDepthOfField = ((BaseUnityPlugin)this).Config.Bind<bool>("PostFX", "DepthOfField", true, ""); _dofFocusDistance = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "DOFFocusDistance", 3.5f, ""); _dofAperture = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "DOFAperture", 4f, ""); _dofFocalLength = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "DOFFocalLength", 50f, ""); _postExposure = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "PostExposureEV", 0f, ""); _motionBlur = ((BaseUnityPlugin)this).Config.Bind<bool>("PostFX", "MotionBlur", false, ""); _motionBlurShutter = ((BaseUnityPlugin)this).Config.Bind<float>("PostFX", "MotionBlurShutter", -3.576279E-08f, ""); _shadowCascades = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "ShadowCascades", 4, ""); _shadowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Quality", "ShadowDistance", 180f, ""); _shadowResolution = ((BaseUnityPlugin)this).Config.Bind<string>("Quality", "ShadowResolution", "VeryHigh", ""); _lodBias = ((BaseUnityPlugin)this).Config.Bind<float>("Quality", "LODBias", 2f, ""); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(typeof(RealismOverhaul)); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Start() { SafeApplyAll("start"); ApplyForcedGameSettings(); TryDisablePostProcessingOverlay(); ((MonoBehaviour)this).StartCoroutine(DeferredGMRefresh()); } private void Update() { if (!_enableOverhaul.Value) { return; } _frameTimes.Enqueue(Time.deltaTime); if (_frameTimes.Count > 120) { _frameTimes.Dequeue(); } _dynTimer += Time.unscaledDeltaTime; if (!(_dynTimer >= 0.5f)) { return; } _dynTimer = 0f; if (!_noPixActive || !((Object)(object)RenderTextureMain.instance != (Object)null) || !(_largeW > 0f) || !(_largeH > 0f)) { return; } float num = 0f; foreach (float frameTime in _frameTimes) { num += frameTime; } num /= (float)Mathf.Max(1, _frameTimes.Count); float num2 = ((num > 0f) ? (1f / num) : 300f); int num3 = ((Application.targetFrameRate > 0) ? Application.targetFrameRate : 60); if (num2 < (float)(num3 - 2)) { _dynScale = Mathf.Max(0.8f, _dynScale - 0.05f); } else if (num2 > (float)(num3 + 5)) { _dynScale = Mathf.Min(1f, _dynScale + 0.05f); } float num4 = Mathf.Round(_largeW * _dynScale); float num5 = Mathf.Round(_largeH * _dynScale); RenderTextureMain.instance.ChangeResolution(num4, num5, 0.6f); } private void TryDisablePostProcessingOverlay() { if (!_disablePostProcessingOverlay.Value || _overlayHandledThisScene) { return; } GameObject val = GameObject.Find("Post Processing Overlay"); if ((Object)(object)val != (Object)null) { if (val.activeSelf) { val.SetActive(false); Logger.LogInfo((object)"Disabled \"Post Processing Overlay\" GameObject."); } _overlayHandledThisScene = true; } } private static void SafeApplyAll(string reason) { if (!Instance._enableOverhaul.Value) { return; } try { ApplyQualitySettings(); Instance.EnsureCamerasHavePPLayer(); ApplyPostProcessingProfile(); Instance.EnsureNoPixelationAndCaptureBaseSize(); } catch (Exception ex) { Logger.LogWarning((object)$"Apply failed ({reason}): {ex.Message}\n{ex}"); } } private static PostProcessResources? ResolvePPResources() { if ((Object)(object)_ppResourcesCache != (Object)null) { return _ppResourcesCache; } try { _ppResourcesCache = Resources.Load<PostProcessResources>("PostProcessResources"); if ((Object)(object)_ppResourcesCache == (Object)null) { PostProcessLayer val = ((IEnumerable<PostProcessLayer>)Resources.FindObjectsOfTypeAll<PostProcessLayer>()).FirstOrDefault((Func<PostProcessLayer, bool>)((PostProcessLayer l) => (Object)(object)l != (Object)null)); if ((Object)(object)val != (Object)null) { FieldInfo fieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(PostProcessLayer).GetField("resources", BindingFlags.Instance | BindingFlags.Public); if (fieldInfo != null) { object? value = fieldInfo.GetValue(val); _ppResourcesCache = (PostProcessResources?)((value is PostProcessResources) ? value : null); } } } } catch { } if ((Object)(object)_ppResourcesCache == (Object)null && !_missingResourcesLogged) { _missingResourcesLogged = true; Logger.LogWarning((object)"PostProcessResources not found."); } return _ppResourcesCache; } private static bool LayerHasResources(PostProcessLayer layer) { try { FieldInfo fieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(PostProcessLayer).GetField("resources", BindingFlags.Instance | BindingFlags.Public); if (fieldInfo == null) { return false; } object? value = fieldInfo.GetValue(layer); return (Object)((value is PostProcessResources) ? value : null) != (Object)null; } catch { return false; } } private static void EnsureLayerHasResources(PostProcessLayer layer, PostProcessResources? res) { if ((Object)(object)res == (Object)null) { return; } try { FieldInfo fieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(PostProcessLayer).GetField("resources", BindingFlags.Instance | BindingFlags.Public); if (fieldInfo != null) { fieldInfo.SetValue(layer, res); } } catch { } } private void EnsureCamerasHavePPLayer() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) PostProcessResources res = ResolvePPResources(); Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); foreach (Camera val in array) { if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || (int)val.cameraType != 1) { continue; } PostProcessLayer val2 = ((Component)val).GetComponent<PostProcessLayer>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).gameObject.AddComponent<PostProcessLayer>(); val2.volumeTrigger = ((Component)val).transform; EnsureLayerHasResources(val2, res); } else { if ((Object)(object)val2.volumeTrigger == (Object)null) { val2.volumeTrigger = ((Component)val).transform; } if (!LayerHasResources(val2)) { EnsureLayerHasResources(val2, res); } } val2.volumeLayer = LayerMask.op_Implicit(-1); string text = _antialiasingMode.Value.ToUpperInvariant(); string text2 = text; if (!(text2 == "TAA")) { if (text2 == "FXAA") { val2.antialiasingMode = (Antialiasing)1; QualitySettings.antiAliasing = 0; val.allowMSAA = false; } else { val2.antialiasingMode = (Antialiasing)0; } continue; } val2.antialiasingMode = (Antialiasing)3; TemporalAntialiasing temporalAntialiasing = val2.temporalAntialiasing; if (temporalAntialiasing != null) { temporalAntialiasing.jitterSpread = 0.65f; temporalAntialiasing.motionBlending = 0.7f; temporalAntialiasing.stationaryBlending = 0.95f; } QualitySettings.antiAliasing = 0; val.allowMSAA = false; } } private static void ApplyQualitySettings() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Invalid comparison between Unknown and I4 //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Invalid comparison between Unknown and I4 //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 QualitySettings.anisotropicFiltering = (AnisotropicFiltering)2; QualitySettings.realtimeReflectionProbes = true; QualitySettings.billboardsFaceCameraPosition = true; QualitySettings.lodBias = Mathf.Max(1f, Instance._lodBias.Value); QualitySettings.shadowDistance = Mathf.Max(20f, Instance._shadowDistance.Value); QualitySettings.shadowCascades = Mathf.Clamp(Instance._shadowCascades.Value, 0, 4); QualitySettings.softParticles = true; switch (Instance._shadowResolution.Value.ToLowerInvariant()) { case "veryhigh": QualitySettings.shadowResolution = (ShadowResolution)3; break; case "high": QualitySettings.shadowResolution = (ShadowResolution)2; break; case "medium": QualitySettings.shadowResolution = (ShadowResolution)1; break; default: QualitySettings.shadowResolution = (ShadowResolution)0; break; } Light[] array = Resources.FindObjectsOfTypeAll<Light>(); foreach (Light val in array) { if (!((Object)(object)val == (Object)null)) { if ((int)val.type == 1) { val.shadows = (LightShadows)2; } else if (((int)val.type == 2 || (int)val.type == 0) && (int)val.shadows == 0) { val.shadows = (LightShadows)2; } } } } private static void ApplyPostProcessingProfile() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) PostProcessing instance = PostProcessing.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.volume == (Object)null) { return; } PostProcessVolume volume = instance.volume; PostProcessProfile val = volume.profile ?? ScriptableObject.CreateInstance<PostProcessProfile>(); if ((Object)(object)volume.profile == (Object)null) { volume.profile = val; } PostProcessResources val2 = ResolvePPResources(); AmbientOcclusion val3 = default(AmbientOcclusion); if ((Object)(object)val2 == (Object)null && val.TryGetSettings<AmbientOcclusion>(ref val3)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val3).enabled).value = false; } ColorGrading val4 = default(ColorGrading); if (!val.TryGetSettings<ColorGrading>(ref val4)) { val4 = val.AddSettings<ColorGrading>(); } ((ParameterOverride<Tonemapper>)(object)val4.tonemapper).value = (Tonemapper)2; ((ParameterOverride<float>)(object)val4.postExposure).value = Instance._postExposure.Value; ((ParameterOverride<float>)(object)val4.saturation).value = 0f; ((ParameterOverride<float>)(object)val4.contrast).value = 10f; ((ParameterOverride<Vector4>)(object)val4.gamma).value = new Vector4(0f, 0f, 0f, 0f); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val4).enabled).value = true; AmbientOcclusion val6 = default(AmbientOcclusion); if (Instance._enableAmbientOcclusion.Value) { AmbientOcclusion val5 = default(AmbientOcclusion); if (!val.TryGetSettings<AmbientOcclusion>(ref val5)) { val5 = val.AddSettings<AmbientOcclusion>(); } ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val5).enabled).value = true; ((ParameterOverride<AmbientOcclusionMode>)(object)val5.mode).value = (AmbientOcclusionMode)0; ((ParameterOverride<AmbientOcclusionQuality>)(object)val5.quality).value = (AmbientOcclusionQuality)3; ((ParameterOverride<float>)(object)val5.thicknessModifier).value = 1f; ((ParameterOverride<float>)(object)val5.intensity).value = Mathf.Clamp(Instance._aoIntensity.Value, 0f, 4f); ((ParameterOverride<float>)(object)val5.radius).value = Mathf.Clamp(Instance._aoRadius.Value, 0.05f, 1f); } else if (val.TryGetSettings<AmbientOcclusion>(ref val6)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val6).enabled).value = false; } Bloom val8 = default(Bloom); if (Instance._enableBloom.Value) { Bloom val7 = default(Bloom); if (!val.TryGetSettings<Bloom>(ref val7)) { val7 = val.AddSettings<Bloom>(); } ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val7).enabled).value = true; ((ParameterOverride<float>)(object)val7.intensity).value = Mathf.Clamp(Instance._bloomIntensity.Value, 0f, 20f); ((ParameterOverride<float>)(object)val7.threshold).value = Mathf.Clamp(Instance._bloomThreshold.Value, 0f, 10f); ((ParameterOverride<bool>)(object)val7.fastMode).value = true; } else if (val.TryGetSettings<Bloom>(ref val8)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val8).enabled).value = false; } DepthOfField val10 = default(DepthOfField); if (Instance._enableDepthOfField.Value) { DepthOfField val9 = default(DepthOfField); if (!val.TryGetSettings<DepthOfField>(ref val9)) { val9 = val.AddSettings<DepthOfField>(); } ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val9).enabled).value = true; ((ParameterOverride<float>)(object)val9.focusDistance).value = Mathf.Max(0.1f, Instance._dofFocusDistance.Value); ((ParameterOverride<float>)(object)val9.aperture).value = Mathf.Clamp(Instance._dofAperture.Value, 0.7f, 32f); ((ParameterOverride<float>)(object)val9.focalLength).value = Mathf.Clamp(Instance._dofFocalLength.Value, 1f, 300f); ((ParameterOverride<KernelSize>)(object)val9.kernelSize).value = (KernelSize)1; } else if (val.TryGetSettings<DepthOfField>(ref val10)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val10).enabled).value = false; } MotionBlur val11 = default(MotionBlur); if (val.TryGetSettings<MotionBlur>(ref val11)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val11).enabled).value = false; ((ParameterOverride<float>)(object)val11.shutterAngle).value = 0f; ((ParameterOverride<int>)(object)val11.sampleCount).value = 0; } if (Instance._disableStylizedFX.Value) { ChromaticAberration val12 = default(ChromaticAberration); if (val.TryGetSettings<ChromaticAberration>(ref val12)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val12).enabled).value = false; ((ParameterOverride<float>)(object)val12.intensity).value = 0f; } LensDistortion val13 = default(LensDistortion); if (val.TryGetSettings<LensDistortion>(ref val13)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val13).enabled).value = false; ((ParameterOverride<float>)(object)val13.intensity).value = 0f; } Vignette val14 = default(Vignette); if (val.TryGetSettings<Vignette>(ref val14)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val14).enabled).value = false; ((ParameterOverride<float>)(object)val14.intensity).value = 0f; } Grain val15 = default(Grain); if (val.TryGetSettings<Grain>(ref val15)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val15).enabled).value = false; ((ParameterOverride<float>)(object)val15.intensity).value = 0f; ((ParameterOverride<float>)(object)val15.size).value = 1f; } } } private void EnsureNoPixelationAndCaptureBaseSize() { RenderTextureMain instance = RenderTextureMain.instance; if (!((Object)(object)instance == (Object)null)) { instance.textureWidthOriginal = instance.textureWidthLarge; instance.textureHeightOriginal = instance.textureHeightLarge; instance.ResetResolution(); _largeW = instance.textureWidthLarge; _largeH = instance.textureHeightLarge; _noPixActive = true; } } private static void ApplyForcedGameSettings() { DataDirector instance = DataDirector.instance; if (!((Object)(object)instance == (Object)null)) { instance.SettingValueSet((Setting)24, 0); instance.SettingValueSet((Setting)12, 0); instance.SettingValueSet((Setting)29, 41); instance.SettingValueSet((Setting)19, 90); instance.SettingValueSet((Setting)15, 4); instance.SettingValueSet((Setting)20, 3); instance.SettingValueSet((Setting)21, 4); instance.SettingValueSet((Setting)18, 0); instance.SettingValueSet((Setting)17, 0); instance.SettingValueSet((Setting)16, 0); instance.SettingValueSet((Setting)22, 0); instance.SettingValueSet((Setting)23, 0); instance.SettingValueSet((Setting)26, 0); instance.SettingValueSet((Setting)25, 2); instance.SaveSettings(); } } [IteratorStateMachine(typeof(<DeferredGMRefresh>d__63))] private IEnumerator DeferredGMRefresh() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DeferredGMRefresh>d__63(0) { <>4__this = this }; } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateAll")] private static void GM_UpdateAll_Postfix() { SafeApplyAll("GraphicsManager.UpdateAll"); Instance?.TryDisablePostProcessingOverlay(); } [HarmonyPrefix] [HarmonyPatch(typeof(GraphicsManager), "UpdateMotionBlur")] private static bool GM_UpdateMotionBlur_Prefix() { PostProcessing instance = PostProcessing.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.motionBlur != (Object)null) { ((PostProcessEffectSettings)instance.motionBlur).active = false; } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateBloom")] private static void GM_UpdateBloom_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { PostProcessing instance = PostProcessing.Instance; Bloom val = default(Bloom); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.volume == (Object)null) && instance.volume.profile.TryGetSettings<Bloom>(ref val)) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val).enabled).value = Instance._enableBloom.Value; ((ParameterOverride<float>)(object)val.intensity).value = Mathf.Clamp(Instance._bloomIntensity.Value, 0f, 20f); ((ParameterOverride<float>)(object)val.threshold).value = Mathf.Clamp(Instance._bloomThreshold.Value, 0f, 10f); } } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateGrain")] private static void GM_UpdateGrain_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { PostProcessing instance = PostProcessing.Instance; Grain val = default(Grain); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.volume == (Object)null) && instance.volume.profile.TryGetSettings<Grain>(ref val) && Instance._disableStylizedFX.Value) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val).enabled).value = false; ((ParameterOverride<float>)(object)val.intensity).value = 0f; ((ParameterOverride<float>)(object)val.size).value = 1f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateChromaticAberration")] private static void GM_UpdateCA_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { PostProcessing instance = PostProcessing.Instance; ChromaticAberration val = default(ChromaticAberration); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.volume == (Object)null) && instance.volume.profile.TryGetSettings<ChromaticAberration>(ref val) && Instance._disableStylizedFX.Value) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val).enabled).value = false; ((ParameterOverride<float>)(object)val.intensity).value = 0f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateLensDistortion")] private static void GM_UpdateLensDist_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { PostProcessing instance = PostProcessing.Instance; LensDistortion val = default(LensDistortion); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.volume == (Object)null) && instance.volume.profile.TryGetSettings<LensDistortion>(ref val) && Instance._disableStylizedFX.Value) { ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val).enabled).value = false; ((ParameterOverride<float>)(object)val.intensity).value = 0f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateShadowDistance")] private static void GM_UpdateShadowDistance_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { QualitySettings.shadowDistance = Mathf.Max(20f, Instance._shadowDistance.Value); } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateShadowQuality")] private static void GM_UpdateShadowQuality_Postfix() { if (Instance._enableOverhaul.Value && !Instance._respectGameSliders.Value) { switch (Instance._shadowResolution.Value.ToLowerInvariant()) { case "veryhigh": QualitySettings.shadowResolution = (ShadowResolution)3; break; case "high": QualitySettings.shadowResolution = (ShadowResolution)2; break; case "medium": QualitySettings.shadowResolution = (ShadowResolution)1; break; default: QualitySettings.shadowResolution = (ShadowResolution)0; break; } QualitySettings.shadowCascades = Mathf.Clamp(Instance._shadowCascades.Value, 0, 4); } } [HarmonyPostfix] [HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")] private static void GM_UpdateRenderSize_Postfix() { if (Instance._enableOverhaul.Value) { Instance.EnsureNoPixelationAndCaptureBaseSize(); } } } }