Decompiled source of AskaPerformanceBooster v1.2.0
BepInEx\plugins\AskaPerformanceBooster\AskaPerformanceBooster.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using HarmonyLib.Tools; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AskaPerformanceBooster { internal static class DiagnosticsHelper { private static float _smoothedFps; private static float _smoothedFrameTime; private const float FpsSmoothFactor = 0.05f; private static bool _fpsInitialized; private static float _diagnosticTimer; private static int _fixedUpdateCountThisFrame; private static int _fixedUpdateCountLastFrame; private static int _captureWarmupFrames; private const int RequiredWarmupFrames = 120; private static bool _frameTimingFeatureChecked; private static bool _frameTimingFeatureAvailable; private static bool _inGameplay; private static readonly Regex CloneAndSuffixRegex = new Regex("[\\s_]*\\(Clone\\)$|[\\s_]*\\(\\d+\\)$|[\\s_]*\\d+$", RegexOptions.Compiled); private static readonly FrameTiming[] _frameTimings = (FrameTiming[])(object)new FrameTiming[1]; internal static void OnUpdate() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown if (!PerformancePlugin.CfgEnableDiagnostics.Value) { return; } try { float unscaledDeltaTime = Time.unscaledDeltaTime; UpdateFpsSmoothing(unscaledDeltaTime); if (PerformancePlugin.CfgLogFrameTimings.Value && _frameTimingFeatureAvailable) { try { FrameTimingManager.CaptureFrameTimings(); _captureWarmupFrames++; } catch { } } _fixedUpdateCountLastFrame = _fixedUpdateCountThisFrame; _fixedUpdateCountThisFrame = 0; float value = PerformancePlugin.CfgDiagnosticIntervalSeconds.Value; _diagnosticTimer += unscaledDeltaTime; if (_diagnosticTimer >= value) { _diagnosticTimer = 0f; LogDiagnostics(); } } catch (Exception ex) { if (PerformancePlugin.CfgDebugLogging.Value) { ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Diag] OnUpdate error: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } } internal static void OnFixedUpdate() { if (PerformancePlugin.CfgEnableDiagnostics.Value) { _fixedUpdateCountThisFrame++; } } internal static void OnGameplayEntered() { _inGameplay = true; _diagnosticTimer = 0f; _fpsInitialized = false; _fixedUpdateCountThisFrame = 0; _fixedUpdateCountLastFrame = 0; _captureWarmupFrames = 0; CheckFrameTimingFeature(); } internal static void OnGameplayExited() { _inGameplay = false; } private static void UpdateFpsSmoothing(float unscaledDeltaTime) { if (!(unscaledDeltaTime <= 0f)) { float num = 1f / unscaledDeltaTime; float num2 = unscaledDeltaTime * 1000f; if (!_fpsInitialized) { _smoothedFps = num; _smoothedFrameTime = num2; _fpsInitialized = true; } else { _smoothedFps += 0.05f * (num - _smoothedFps); _smoothedFrameTime += 0.05f * (num2 - _smoothedFrameTime); } } } private static void LogDiagnostics() { LogCoreStats(); if (PerformancePlugin.CfgLogFrameTimings.Value) { LogFrameTimings(); } if (_inGameplay) { LogShadowThresholdStats(); if (PerformancePlugin.CfgLogObjectBreakdown.Value) { LogObjectBreakdown(); } } } private static void LogCoreStats() { //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { int num = 0; int num2 = 0; int num3 = 0; try { Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>(); if (val != null) { num = val.Length; for (int i = 0; i < val.Length; i++) { try { Renderer val2 = val[i]; if (!((Object)(object)val2 == (Object)null)) { if (val2.isVisible) { num2++; } if ((int)val2.shadowCastingMode != 0) { num3++; } } } catch { } } } } catch { } int num4 = 0; int num5 = 0; try { Il2CppArrayBase<Rigidbody> val3 = Object.FindObjectsOfType<Rigidbody>(); if (val3 != null) { num4 = val3.Length; for (int j = 0; j < val3.Length; j++) { try { Rigidbody val4 = val3[j]; if (!((Object)(object)val4 == (Object)null) && !val4.IsSleeping()) { num5++; } } catch { } } } } catch { } ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(100, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Diag] FPS="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(_smoothedFps, "F1"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" frameTime="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(_smoothedFrameTime, "F1"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("ms"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" | renderers="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" visible="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" shadowCasters="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" | rigidbodies="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num4); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" awake="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num5); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" | fixedPerFrame="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(_fixedUpdateCountLastFrame); } log.LogInfo(val5); } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[Diag] Core stats error: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(ex.Message); } log2.LogWarning(val6); } } private static void LogFrameTimings() { //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown if (!_frameTimingFeatureAvailable) { PerformancePlugin.Log.LogInfo((object)"[Diag/Timing] FrameTimingManager not available (game built without Frame Timing Stats)."); return; } bool flag = default(bool); if (_captureWarmupFrames < 120) { ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Diag/Timing] Warming up ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_captureWarmupFrames); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(120); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames)..."); } log.LogInfo(val); return; } try { if (FrameTimingManager.GetLatestTimings(1u, Il2CppStructArray<FrameTiming>.op_Implicit(_frameTimings)) == 0) { PerformancePlugin.Log.LogInfo((object)"[Diag/Timing] No frame timings available."); return; } double cpuFrameTime = _frameTimings[0].cpuFrameTime; double gpuFrameTime = _frameTimings[0].gpuFrameTime; if (cpuFrameTime <= 0.0 && gpuFrameTime <= 0.0) { PerformancePlugin.Log.LogInfo((object)"[Diag/Timing] cpu=0.0ms gpu=0.0ms -> NOT SUPPORTED (game likely built without Frame Timing Stats in Player Settings)."); _frameTimingFeatureAvailable = false; return; } string text = ((gpuFrameTime <= 0.0) ? "GPU-TIME-UNAVAILABLE" : ((gpuFrameTime > cpuFrameTime * 1.1) ? "GPU-BOUND" : ((!(cpuFrameTime > gpuFrameTime * 1.1)) ? "BALANCED" : "CPU-BOUND"))); ManualLogSource log2 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Diag/Timing] cpu="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(cpuFrameTime, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms gpu="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(gpuFrameTime, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log2.LogInfo(val); } catch (Exception ex) { ManualLogSource log3 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Diag/Timing] Error: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } log3.LogWarning(val2); } } private static void CheckFrameTimingFeature() { if (_frameTimingFeatureChecked) { return; } _frameTimingFeatureChecked = true; try { if (!(_frameTimingFeatureAvailable = FrameTimingManager.IsFeatureEnabled())) { PerformancePlugin.Log.LogInfo((object)"[Diag/Timing] FrameTimingManager.IsFeatureEnabled()=false. Game was likely built without 'Enable Frame Timing Stats' in Player Settings."); } } catch { _frameTimingFeatureAvailable = true; } } private static void LogObjectBreakdown() { //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown try { Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>(); if (val == null || val.Length == 0) { PerformancePlugin.Log.LogInfo((object)"[Diag/Objects] No renderers found."); return; } Dictionary<string, int> dictionary = new Dictionary<string, int>(256); for (int i = 0; i < val.Length; i++) { try { Renderer val2 = val[i]; if (!((Object)(object)val2 == (Object)null)) { string text = ((Object)((Component)val2).gameObject).name; if (string.IsNullOrEmpty(text)) { text = "unnamed"; } string key = NormalizeObjectName(text); if (dictionary.ContainsKey(key)) { dictionary[key]++; } else { dictionary[key] = 1; } } } catch { } } List<(string, int)> list = new List<(string, int)>(dictionary.Count); foreach (KeyValuePair<string, int> item in dictionary) { list.Add((item.Key, item.Value)); } list.Sort(((string name, int count) a, (string name, int count) b) => b.count.CompareTo(a.count)); StringBuilder stringBuilder = new StringBuilder("[Diag/Objects] Top objects: "); int num = Math.Min(10, list.Count); for (int j = 0; j < num; j++) { if (j > 0) { stringBuilder.Append(' '); } stringBuilder.Append(list[j].Item1); stringBuilder.Append('('); stringBuilder.Append(list[j].Item2); stringBuilder.Append(')'); } PerformancePlugin.Log.LogInfo((object)stringBuilder.ToString()); } catch (Exception ex) { ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Diag/Objects] Error: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log.LogWarning(val3); } } private static string NormalizeObjectName(string name) { string text = name.Trim(); string text2; do { text2 = text; text = CloneAndSuffixRegex.Replace(text, "").TrimEnd('_', ' '); } while (text != text2 && text.Length > 0); if (text.Length <= 0) { return name.Trim(); } return text; } private static void LogShadowThresholdStats() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 bool flag = default(bool); try { float value = PerformancePlugin.CfgSmallShadowCasterThreshold.Value; Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>(); if (val == null || val.Length == 0) { return; } int num = 0; int num2 = 0; for (int i = 0; i < val.Length; i++) { try { Renderer val2 = val[i]; if ((Object)(object)val2 == (Object)null || (int)val2.shadowCastingMode == 0 || (int)val2.shadowCastingMode == 3) { continue; } try { if (((Component)val2).gameObject.CompareTag("Player")) { continue; } } catch { } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).magnitude < value) { num++; } else { num2++; } } catch { } } ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(60, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Diag/Shadows] belowThreshold="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" aboveThreshold="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (threshold="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(value, "F1"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("m)"); } log.LogInfo(val3); } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Diag/Shadows] Error: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } log2.LogWarning(val4); } } } internal static class HDRPReflectionHelper { internal static bool HdrpReflectionCached; internal static object HdrpAssetRef; internal static Type HdrpAssetType; internal static object RenderPipelineSettingsRef; internal static Type RenderPipelineSettingsType; internal static PropertyInfo PropCurrentPlatformRenderPipelineSettings; internal static PropertyInfo PropSupportSSR; internal static PropertyInfo PropSupportSSAO; internal static PropertyInfo PropSupportVolumetrics; internal static PropertyInfo PropSupportVolumetricClouds; internal static PropertyInfo PropSupportSubsurfaceScattering; internal static PropertyInfo PropSupportDecals; internal static PropertyInfo PropSupportDistortion; internal static PropertyInfo PropSupportSSRTransparent; internal static PropertyInfo PropSupportDataDrivenLensFlare; internal static PropertyInfo PropSupportScreenSpaceLensFlare; internal static object HdShadowInitParamsRef; internal static Type HdShadowInitParamsType; internal static PropertyInfo PropHdShadowInitParams; internal static PropertyInfo PropMaxShadowRequests; internal static PropertyInfo PropMaxDirectionalShadowMapResolution; internal static PropertyInfo PropMaxPunctualShadowMapResolution; internal static PropertyInfo PropMaxAreaShadowMapResolution; internal static PropertyInfo PropAreaShadowFilteringQuality; private static int _cachedHdrpAssetInstanceId = -1; private static bool Debug => PerformancePlugin.CfgDebugLogging.Value; private static void DebugLog(string msg) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (Debug) { ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Debug] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(msg); } log.LogInfo(val); } } internal static void CacheHDRPReflection() { //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown if (HdrpReflectionCached) { return; } HdrpReflectionCached = true; bool flag = default(bool); try { RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; if ((Object)(object)currentRenderPipeline == (Object)null) { PerformancePlugin.Log.LogWarning((object)"GraphicsSettings.currentRenderPipeline is null -- HDRP settings unavailable."); return; } HdrpAssetRef = currentRenderPipeline; Type type = ((object)currentRenderPipeline).GetType(); Type type2 = ResolveIl2CppConcreteType((Object)(object)currentRenderPipeline); if (type2 != null && type2 != type) { ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(79, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("IL2CPP type resolution: GetType()="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("concrete IL2CPP type="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type2.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Using concrete type."); } log.LogInfo(val); type = type2; object obj = RuntimeCastToConcreteType((Il2CppObjectBase)(object)currentRenderPipeline, type2); if (obj != null && obj != currentRenderPipeline) { HdrpAssetRef = obj; ManualLogSource log2 = PerformancePlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HDRP Asset re-wrapped: managed type now "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(obj.GetType().Name); } log2.LogInfo(val); } } HdrpAssetType = type; try { _cachedHdrpAssetInstanceId = ((Object)currentRenderPipeline).GetInstanceID(); ManualLogSource log3 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HDRP Asset cached: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)currentRenderPipeline).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (instanceID="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_cachedHdrpAssetInstanceId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log3.LogInfo(val); } catch { _cachedHdrpAssetInstanceId = -1; } PropCurrentPlatformRenderPipelineSettings = FindProp(type, "currentPlatformRenderPipelineSettings"); if (PropCurrentPlatformRenderPipelineSettings != null) { try { RenderPipelineSettingsRef = PropCurrentPlatformRenderPipelineSettings.GetValue(HdrpAssetRef); if (RenderPipelineSettingsRef != null) { RenderPipelineSettingsType = RenderPipelineSettingsRef.GetType(); ManualLogSource log4 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("RenderPipelineSettings resolved: type="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(RenderPipelineSettingsType.FullName); } log4.LogInfo(val); CacheSupportFlagProperties(); CacheShadowInitProperties(); } else { PerformancePlugin.Log.LogWarning((object)"currentPlatformRenderPipelineSettings returned null."); } } catch (Exception ex) { ManualLogSource log5 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to read currentPlatformRenderPipelineSettings: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } log5.LogWarning(val2); } } else { PerformancePlugin.Log.LogWarning((object)("currentPlatformRenderPipelineSettings property not found on " + type.FullName)); TryFindSettingsViaInternalField(type); } LogReflectionSummary(); } catch (Exception ex2) { ManualLogSource log6 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to cache HDRP reflection: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message); } log6.LogWarning(val2); } } private static void CacheSupportFlagProperties() { if (!(RenderPipelineSettingsType == null) && RenderPipelineSettingsRef != null) { Type renderPipelineSettingsType = RenderPipelineSettingsType; PropSupportSSR = FindProp(renderPipelineSettingsType, "supportSSR"); PropSupportSSAO = FindProp(renderPipelineSettingsType, "supportSSAO"); PropSupportVolumetrics = FindProp(renderPipelineSettingsType, "supportVolumetrics"); PropSupportVolumetricClouds = FindProp(renderPipelineSettingsType, "supportVolumetricClouds"); PropSupportSubsurfaceScattering = FindProp(renderPipelineSettingsType, "supportSubsurfaceScattering"); PropSupportDecals = FindProp(renderPipelineSettingsType, "supportDecals"); PropSupportDistortion = FindProp(renderPipelineSettingsType, "supportDistortion"); PropSupportSSRTransparent = FindProp(renderPipelineSettingsType, "supportSSRTransparent"); PropSupportDataDrivenLensFlare = FindProp(renderPipelineSettingsType, "supportDataDrivenLensFlare"); PropSupportScreenSpaceLensFlare = FindProp(renderPipelineSettingsType, "supportScreenSpaceLensFlare"); } } private static void CacheShadowInitProperties() { //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown if (RenderPipelineSettingsType == null || RenderPipelineSettingsRef == null) { return; } bool flag = default(bool); try { PropHdShadowInitParams = FindProp(RenderPipelineSettingsType, "hdShadowInitParams"); if (PropHdShadowInitParams == null) { DebugLog("hdShadowInitParams property not found on RenderPipelineSettings."); return; } HdShadowInitParamsRef = PropHdShadowInitParams.GetValue(RenderPipelineSettingsRef); if (HdShadowInitParamsRef == null) { DebugLog("hdShadowInitParams returned null."); return; } HdShadowInitParamsType = HdShadowInitParamsRef.GetType(); PropMaxShadowRequests = FindProp(HdShadowInitParamsType, "maxShadowRequests"); PropMaxDirectionalShadowMapResolution = FindProp(HdShadowInitParamsType, "maxDirectionalShadowMapResolution"); PropMaxPunctualShadowMapResolution = FindProp(HdShadowInitParamsType, "maxPunctualShadowMapResolution"); PropMaxAreaShadowMapResolution = FindProp(HdShadowInitParamsType, "maxAreaShadowMapResolution"); PropAreaShadowFilteringQuality = FindProp(HdShadowInitParamsType, "areaShadowFilteringQuality"); string text = ((PropMaxShadowRequests != null) ? SafeGetInt(PropMaxShadowRequests, HdShadowInitParamsRef).ToString() : "N/A"); string text2 = ((PropMaxDirectionalShadowMapResolution != null) ? SafeGetInt(PropMaxDirectionalShadowMapResolution, HdShadowInitParamsRef).ToString() : "N/A"); string text3 = ((PropMaxPunctualShadowMapResolution != null) ? SafeGetInt(PropMaxPunctualShadowMapResolution, HdShadowInitParamsRef).ToString() : "N/A"); string text4 = ((PropMaxAreaShadowMapResolution != null) ? SafeGetInt(PropMaxAreaShadowMapResolution, HdShadowInitParamsRef).ToString() : "N/A"); string text5 = ((PropAreaShadowFilteringQuality != null) ? SafeGetEnum(PropAreaShadowFilteringQuality, HdShadowInitParamsRef) : "N/A"); ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(121, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HDShadowInitParams cached: maxShadowRequests="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("maxDirShadowRes="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", maxPuncShadowRes="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("maxAreaShadowRes="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", areaFilterQuality="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text5); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to cache shadow init properties: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } log2.LogWarning(val2); } } private static void TryFindSettingsViaInternalField(Type assetType) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown try { FieldInfo fieldInfo = null; Type type = assetType; while (type != null && type != typeof(object)) { fieldInfo = type.GetField("m_RenderPipelineSettings", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo != null) { break; } type = type.BaseType; } if (fieldInfo != null && HdrpAssetRef != null) { RenderPipelineSettingsRef = fieldInfo.GetValue(HdrpAssetRef); if (RenderPipelineSettingsRef != null) { RenderPipelineSettingsType = RenderPipelineSettingsRef.GetType(); ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("RenderPipelineSettings resolved via m_RenderPipelineSettings field: "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("type="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(RenderPipelineSettingsType.FullName); } log.LogInfo(val); CacheSupportFlagProperties(); CacheShadowInitProperties(); } } else { PerformancePlugin.Log.LogWarning((object)"Neither currentPlatformRenderPipelineSettings property nor m_RenderPipelineSettings field found on HDRP Asset."); } } catch (Exception ex) { DebugLog("Fallback settings field search failed: " + ex.Message); } } private static void LogReflectionSummary() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown string text = "unknown"; try { Object val = (Object)HdrpAssetRef; text = (((int)val != 0) ? val.name : null) ?? "unknown"; } catch { } object obj2; bool flag = default(bool); if (!(PropSupportSSAO != null)) { obj2 = "N/A"; } else { flag = SafeGetBool(PropSupportSSAO, RenderPipelineSettingsRef); obj2 = flag.ToString(); } string text2 = (string)obj2; object obj3; if (!(PropSupportVolumetrics != null)) { obj3 = "N/A"; } else { flag = SafeGetBool(PropSupportVolumetrics, RenderPipelineSettingsRef); obj3 = flag.ToString(); } string text3 = (string)obj3; object obj4; if (!(PropSupportVolumetricClouds != null)) { obj4 = "N/A"; } else { flag = SafeGetBool(PropSupportVolumetricClouds, RenderPipelineSettingsRef); obj4 = flag.ToString(); } string text4 = (string)obj4; object obj5; if (!(PropSupportSubsurfaceScattering != null)) { obj5 = "N/A"; } else { flag = SafeGetBool(PropSupportSubsurfaceScattering, RenderPipelineSettingsRef); obj5 = flag.ToString(); } string text5 = (string)obj5; object obj6; if (!(PropSupportDecals != null)) { obj6 = "N/A"; } else { flag = SafeGetBool(PropSupportDecals, RenderPipelineSettingsRef); obj6 = flag.ToString(); } string text6 = (string)obj6; ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(159, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("HDRP Asset: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(HdrpAssetType?.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("). "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("RenderPipelineSettings: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((RenderPipelineSettingsRef != null) ? "resolved" : "NOT FOUND"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Key flags: supportSSAO="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("supportVolumetrics="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("supportVolumetricClouds="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("supportSubsurfaceScattering="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text5); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("supportDecals="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text6); } log.LogInfo(val2); } internal static int WriteSupportFlagBatch(List<(PropertyInfo prop, string name, bool value)> flags) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (RenderPipelineSettingsRef == null) { return 0; } int num = 0; bool flag3 = default(bool); foreach (var (propertyInfo, text, flag) in flags) { if (propertyInfo == null) { continue; } try { bool flag2 = SafeGetBool(propertyInfo, RenderPipelineSettingsRef); if (flag2 != flag) { propertyInfo.SetValue(RenderPipelineSettingsRef, flag); num++; ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HDRP Asset support flag: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not write support flag "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } log2.LogWarning(val2); } } if (num > 0) { WriteSettingsBackToAsset(); ManualLogSource log3 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 1, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HDRP Asset support flags: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" flag(s) changed, wrote settings back to asset."); } log3.LogInfo(val); } return num; } internal static void ApplyPipelineSupportFlagBatch(bool disableSSR, bool disableSSAO, bool disableVolumetrics, bool disableVolumetricClouds, bool disableSubsurfaceScattering, bool disableDecals, bool disableDistortion, bool disableSSRTransparent, bool disableScreenSpaceLensFlare, bool disableDataDrivenLensFlare) { if (RenderPipelineSettingsRef == null) { return; } if (!disableSSR && !disableSSAO && !disableVolumetrics && !disableVolumetricClouds && !disableSubsurfaceScattering && !disableDecals && !disableDistortion && !disableSSRTransparent && !disableScreenSpaceLensFlare && !disableDataDrivenLensFlare) { DebugLog("Pipeline support flags: no flags requested for disable, skipping."); return; } List<(PropertyInfo, string, bool)> list = new List<(PropertyInfo, string, bool)>(); if (disableSSR) { list.Add((PropSupportSSR, "supportSSR", false)); } if (disableSSAO) { list.Add((PropSupportSSAO, "supportSSAO", false)); } if (disableVolumetrics) { list.Add((PropSupportVolumetrics, "supportVolumetrics", false)); } if (disableVolumetricClouds) { list.Add((PropSupportVolumetricClouds, "supportVolumetricClouds", false)); } if (disableSubsurfaceScattering) { list.Add((PropSupportSubsurfaceScattering, "supportSubsurfaceScattering", false)); } if (disableDecals) { list.Add((PropSupportDecals, "supportDecals", false)); } if (disableDistortion) { list.Add((PropSupportDistortion, "supportDistortion", false)); } if (disableSSRTransparent) { list.Add((PropSupportSSRTransparent, "supportSSRTransparent", false)); } if (disableScreenSpaceLensFlare) { list.Add((PropSupportScreenSpaceLensFlare, "supportScreenSpaceLensFlare", false)); } if (disableDataDrivenLensFlare) { list.Add((PropSupportDataDrivenLensFlare, "supportDataDrivenLensFlare", false)); } if (WriteSupportFlagBatch(list) == 0) { DebugLog("Pipeline support flags: all requested flags already at target values."); } } internal static void WriteSettingsBackToAsset() { if (HdrpAssetRef == null || RenderPipelineSettingsRef == null) { return; } try { if (PropCurrentPlatformRenderPipelineSettings != null && PropCurrentPlatformRenderPipelineSettings.GetSetMethod(nonPublic: true) != null) { PropCurrentPlatformRenderPipelineSettings.SetValue(HdrpAssetRef, RenderPipelineSettingsRef); } else { if (!(HdrpAssetType != null)) { return; } Type type = HdrpAssetType; while (type != null && type != typeof(object)) { FieldInfo field = type.GetField("m_RenderPipelineSettings", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(HdrpAssetRef, RenderPipelineSettingsRef); break; } type = type.BaseType; } } } catch (Exception ex) { DebugLog("Could not write settings back to HDRP Asset: " + ex.Message); } } internal static void ApplyShadowInitParams(int maxShadowRequests, int maxDirectionalShadowMapResolution, int maxAreaShadowMapResolution, int areaShadowFilteringQuality) { if (HdShadowInitParamsRef == null || HdShadowInitParamsType == null) { DebugLog("Shadow init params: not cached, skipping."); return; } bool flag = false; if (maxShadowRequests > 0) { flag |= WriteShadowInt(PropMaxShadowRequests, "maxShadowRequests", maxShadowRequests); } if (maxDirectionalShadowMapResolution > 0) { flag |= WriteShadowInt(PropMaxDirectionalShadowMapResolution, "maxDirectionalShadowMapResolution", maxDirectionalShadowMapResolution); } if (maxAreaShadowMapResolution > 0) { flag |= WriteShadowInt(PropMaxAreaShadowMapResolution, "maxAreaShadowMapResolution", maxAreaShadowMapResolution); } if (areaShadowFilteringQuality >= 0) { flag |= WriteShadowEnum(PropAreaShadowFilteringQuality, "areaShadowFilteringQuality", areaShadowFilteringQuality); } if (flag) { WriteShadowInitParamsBack(); WriteSettingsBackToAsset(); PerformancePlugin.Log.LogInfo((object)"Shadow init params: wrote changes back to HDRP Asset."); } else { DebugLog("Shadow init params: all values already at target."); } } private static bool WriteShadowInt(PropertyInfo prop, string name, int targetValue) { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown if (prop == null) { DebugLog("Shadow param " + name + ": property not found, skipping."); return false; } bool flag = default(bool); try { int num = SafeGetInt(prop, HdShadowInitParamsRef); int num2 = Math.Min(num, targetValue); if (num == num2) { DebugLog($"Shadow param {name}: already {num} (<= target {targetValue}), no change."); return false; } prop.SetValue(HdShadowInitParamsRef, num2); ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Shadow param: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (target was "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(targetValue); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); return true; } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not write shadow param "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } log2.LogWarning(val2); return false; } } private static bool WriteShadowEnum(PropertyInfo prop, string name, int targetValue) { //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown if (prop == null) { DebugLog("Shadow param " + name + ": property not found, skipping."); return false; } bool flag = default(bool); try { object value = prop.GetValue(HdShadowInitParamsRef); string text = value?.ToString() ?? "null"; int val = targetValue; try { val = Convert.ToInt32(value); } catch { } int value2 = Math.Min(val, targetValue); object obj2 = Enum.ToObject(prop.PropertyType, value2); string text2 = obj2?.ToString() ?? "null"; if (string.Equals(text, text2, StringComparison.OrdinalIgnoreCase)) { DebugLog($"Shadow param {name}: already {text} (<= target {targetValue}), no change."); return false; } prop.SetValue(HdShadowInitParamsRef, obj2); ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(35, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shadow param: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" = "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (target was "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(targetValue); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } log.LogInfo(val2); return true; } catch (Exception ex) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Could not write shadow param "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log2.LogWarning(val3); return false; } } private static void WriteShadowInitParamsBack() { if (PropHdShadowInitParams == null || RenderPipelineSettingsRef == null || HdShadowInitParamsRef == null) { return; } try { if (PropHdShadowInitParams.GetSetMethod(nonPublic: true) != null) { PropHdShadowInitParams.SetValue(RenderPipelineSettingsRef, HdShadowInitParamsRef); DebugLog("Wrote HDShadowInitParams back via property setter."); } else if (RenderPipelineSettingsType != null) { FieldInfo field = RenderPipelineSettingsType.GetField("hdShadowInitParams", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(RenderPipelineSettingsRef, HdShadowInitParamsRef); DebugLog("Wrote HDShadowInitParams back via field."); } } } catch (Exception ex) { DebugLog("Could not write HDShadowInitParams back: " + ex.Message); } } internal static bool CheckHdrpAssetStale() { if (!HdrpReflectionCached || _cachedHdrpAssetInstanceId == -1) { return false; } try { RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; if ((Object)(object)currentRenderPipeline == (Object)null) { return false; } int instanceID = ((Object)currentRenderPipeline).GetInstanceID(); if (instanceID == _cachedHdrpAssetInstanceId) { DebugLog($"[AssetStaleCheck] Cache valid (instanceID={instanceID})."); return false; } string value = "unknown"; try { value = ((Object)currentRenderPipeline).name; } catch { } PerformancePlugin.Log.LogInfo((object)($"[AssetStaleCheck] HDRP Asset CHANGED! Cached instanceID={_cachedHdrpAssetInstanceId}, Current='{value}' (instanceID={instanceID}). " + "Invalidating cache.")); InvalidateCache(); return true; } catch (Exception ex) { DebugLog("CheckHdrpAssetStale failed: " + ex.Message); return false; } } internal static void InvalidateCache() { HdrpReflectionCached = false; HdrpAssetRef = null; HdrpAssetType = null; _cachedHdrpAssetInstanceId = -1; RenderPipelineSettingsRef = null; RenderPipelineSettingsType = null; PropCurrentPlatformRenderPipelineSettings = null; PropSupportSSR = null; PropSupportSSAO = null; PropSupportVolumetrics = null; PropSupportVolumetricClouds = null; PropSupportSubsurfaceScattering = null; PropSupportDecals = null; PropSupportDistortion = null; PropSupportSSRTransparent = null; PropSupportDataDrivenLensFlare = null; PropSupportScreenSpaceLensFlare = null; HdShadowInitParamsRef = null; HdShadowInitParamsType = null; PropHdShadowInitParams = null; PropMaxShadowRequests = null; PropMaxDirectionalShadowMapResolution = null; PropMaxPunctualShadowMapResolution = null; PropMaxAreaShadowMapResolution = null; PropAreaShadowFilteringQuality = null; DebugLog("HDRP reflection cache invalidated."); } internal static void DumpShadowProperties() { //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown if (RenderPipelineSettingsRef == null || RenderPipelineSettingsType == null) { PerformancePlugin.Log.LogInfo((object)"[ShadowDiscover] RenderPipelineSettings not available."); return; } PerformancePlugin.Log.LogInfo((object)"[ShadowDiscover] === RenderPipelineSettings shadow-related properties ==="); bool flag = default(bool); try { PropertyInfo[] properties = RenderPipelineSettingsType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name.IndexOf("shadow", StringComparison.OrdinalIgnoreCase) < 0 && propertyInfo.Name.IndexOf("Shadow", StringComparison.Ordinal) < 0) { continue; } string text = "?"; try { text = propertyInfo.GetValue(RenderPipelineSettingsRef)?.ToString() ?? "null"; } catch (Exception ex) { text = "<error: " + ex.Message + ">"; } ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShadowDiscover] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(RenderPipelineSettingsType.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(propertyInfo.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(propertyInfo.PropertyType.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log.LogInfo(val); if (propertyInfo.PropertyType.IsPrimitive || !(propertyInfo.PropertyType != typeof(string)) || !(propertyInfo.PropertyType != typeof(bool))) { continue; } try { object value = propertyInfo.GetValue(RenderPipelineSettingsRef); if (value != null) { DumpNestedShadowProps(value, propertyInfo.Name); } } catch { } } } catch (Exception ex2) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShadowDiscover] Error enumerating properties: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message); } log2.LogWarning(val2); } PerformancePlugin.Log.LogInfo((object)"[ShadowDiscover] === End shadow property dump ==="); } private static void DumpNestedShadowProps(object obj, string parentName) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown if (obj == null) { return; } Type type = obj.GetType(); try { PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); bool flag = default(bool); foreach (PropertyInfo propertyInfo in properties) { string text = "?"; try { text = propertyInfo.GetValue(obj)?.ToString() ?? "null"; } catch (Exception ex) { text = "<error: " + ex.Message + ">"; } ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShadowDiscover] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(parentName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(propertyInfo.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(propertyInfo.PropertyType.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log.LogInfo(val); } } catch { } } internal static PropertyInfo FindProp(Type type, string name) { if (type == null) { return null; } try { Type type2 = type; while (type2 != null && type2 != typeof(object)) { PropertyInfo property = type2.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { return property; } type2 = type2.BaseType; } return type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); } catch { } return null; } internal static Type ResolveIl2CppConcreteType(Object il2cppObj) { try { string fullName = il2cppObj.GetIl2CppType().FullName; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetType(fullName); if (type != null) { return type; } } catch { } } if (fullName.Contains('.')) { string text = fullName.Substring(fullName.LastIndexOf('.') + 1); assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { try { Type[] types = assembly2.GetTypes(); foreach (Type type2 in types) { if (type2.Name == text && type2.IsClass) { return type2; } } } catch { } } } } catch { } return null; } internal static object RuntimeCastToConcreteType(Il2CppObjectBase il2cppObj, Type concreteType) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (il2cppObj == null || concreteType == null) { return il2cppObj; } if (concreteType.IsInstanceOfType(il2cppObj)) { return il2cppObj; } try { IntPtr pointer = il2cppObj.Pointer; if (pointer == IntPtr.Zero) { return il2cppObj; } ConstructorInfo constructor = concreteType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(IntPtr) }, null); if (constructor == null) { return il2cppObj; } object result = constructor.Invoke(new object[1] { pointer }); DebugLog("RuntimeCast: " + ((object)il2cppObj).GetType().Name + " -> " + concreteType.Name); return result; } catch (Exception ex) { ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("RuntimeCast failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((object)il2cppObj).GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(concreteType.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); return il2cppObj; } } internal static bool SafeGetBool(PropertyInfo prop, object target) { if (prop == null) { return false; } try { object value = prop.GetValue(target); if (value is bool result) { return result; } return Convert.ToBoolean(value); } catch { return false; } } internal static int SafeGetInt(PropertyInfo prop, object target) { if (prop == null) { return 0; } try { object value = prop.GetValue(target); if (value is int result) { return result; } return Convert.ToInt32(value); } catch { return 0; } } internal static string SafeGetEnum(PropertyInfo prop, object target) { if (prop == null) { return "N/A"; } try { return prop.GetValue(target)?.ToString() ?? "null"; } catch { return "error"; } } } public class PerformanceBehaviour : MonoBehaviour { private bool _globalSettingsApplied; private float _reapplyTimer; private bool _shadowPropertyDumpDone; private bool _wasInGameplay; private bool _smallShadowCastersDone; private float _smallShadowCasterTimer; private int _smallShadowCastersDisabledCount; private int _resourceShadowCastersDisabledCount; private int _environmentShadowCastersDisabledCount; private float _gameplayTimer; private static readonly string[] ResourceNamePrefixes = new string[8] { "stick", "resource_firewood", "small_stone", "resource_resin", "resource_bark", "long_stick", "log_raw", "os_fragments" }; private static readonly string[] EnvironmentShadowPrefixes = new string[2] { "grass_highlands", "cave_creep" }; private static bool Debug => PerformancePlugin.CfgDebugLogging.Value; private static void DebugLog(string msg) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (Debug) { ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Debug] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(msg); } log.LogInfo(val); } } private void Update() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown bool flag = IsInGameplay(); if (_wasInGameplay && !flag) { ClearCachedReferences(); DiagnosticsHelper.OnGameplayExited(); PerformancePlugin.Log.LogInfo((object)"Left gameplay -- cleared optimization cache."); } else if (!_wasInGameplay && flag) { _globalSettingsApplied = false; _gameplayTimer = 0f; _smallShadowCastersDone = false; _smallShadowCasterTimer = 0f; _smallShadowCastersDisabledCount = 0; _resourceShadowCastersDisabledCount = 0; _environmentShadowCastersDisabledCount = 0; DiagnosticsHelper.OnGameplayEntered(); PerformancePlugin.Log.LogInfo((object)"Entered gameplay -- will re-apply optimizations."); } _wasInGameplay = flag; if (QualityLevelPatch.QualityLevelChanged) { QualityLevelPatch.QualityLevelChanged = false; int lastSetLevel = QualityLevelPatch.LastSetLevel; PerformancePlugin.Log.LogInfo((object)($"Quality level changed to {lastSetLevel} -- invalidating HDRP cache " + "and reapplying all optimizations.")); HDRPReflectionHelper.InvalidateCache(); _globalSettingsApplied = false; _reapplyTimer = 0f; } if (flag) { _gameplayTimer += Time.unscaledDeltaTime; } if (!_globalSettingsApplied) { ApplyGlobalSettings(); _globalSettingsApplied = true; ManualLogSource log = PerformancePlugin.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Performance optimizations applied (scene="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(GetActiveSceneName()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); } if (flag && (PerformancePlugin.CfgDisableSmallShadowCasters.Value || PerformancePlugin.CfgDisableResourceShadowCasters.Value || PerformancePlugin.CfgDisableEnvironmentShadowCasters.Value)) { if (!_smallShadowCastersDone) { if (_gameplayTimer >= 5f) { ApplySmallShadowCasterOptimization(); _smallShadowCastersDone = true; _smallShadowCasterTimer = 0f; } } else { _smallShadowCasterTimer += Time.unscaledDeltaTime; if (_smallShadowCasterTimer >= 30f) { _smallShadowCasterTimer = 0f; ApplySmallShadowCasterOptimization(); } } } float value = PerformancePlugin.CfgReapplyInterval.Value; if (value > 0f) { _reapplyTimer += Time.unscaledDeltaTime; if (_reapplyTimer >= value) { _reapplyTimer = 0f; ApplyGlobalSettings(); } } DiagnosticsHelper.OnUpdate(); } private void FixedUpdate() { DiagnosticsHelper.OnFixedUpdate(); } private void ApplyGlobalSettings() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown bool flag = default(bool); try { ApplyTargetFrameRate(); } catch (Exception ex) { ManualLogSource log = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error applying targetFrameRate: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } try { ApplyLodBias(); } catch (Exception ex2) { ManualLogSource log2 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error applying LOD bias: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message); } log2.LogWarning(val); } try { ApplyHDRPAssetSettings(); } catch (Exception ex3) { ManualLogSource log3 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error applying HDRP Asset settings: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message); } log3.LogWarning(val); } } private static void ApplyTargetFrameRate() { int value = PerformancePlugin.CfgTargetFrameRate.Value; if (value != 0) { int targetFrameRate = Application.targetFrameRate; if (targetFrameRate != value) { Application.targetFrameRate = value; DebugLog($"Application.targetFrameRate: {targetFrameRate} -> {value}"); } } } private static void ApplyLodBias() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown float value = PerformancePlugin.CfgLodBias.Value; if (value <= 0f) { return; } float lodBias = QualitySettings.lodBias; float num = Math.Min(lodBias, value); if (Math.Abs(lodBias - num) > 0.01f) { QualitySettings.lodBias = num; ManualLogSource log = PerformancePlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LOD bias: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(lodBias, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (target was "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } else { DebugLog($"LOD bias: already {lodBias:F2} (<= target {value:F2})."); } } private void ApplyHDRPAssetSettings() { HDRPReflectionHelper.CheckHdrpAssetStale(); HDRPReflectionHelper.CacheHDRPReflection(); if (HDRPReflectionHelper.HdrpAssetRef == null) { return; } if (PerformancePlugin.CfgForceSRPBatcher.Value) { try { if (!GraphicsSettings.useScriptableRenderPipelineBatching) { GraphicsSettings.useScriptableRenderPipelineBatching = true; PerformancePlugin.Log.LogInfo((object)"SRP Batcher: false -> true"); } else { DebugLog("SRP Batcher: already enabled."); } } catch (Exception ex) { DebugLog("Could not access SRP Batcher: " + ex.Message); } } ApplyPipelineSupportFlags(); ApplyShadowInitParams(); if (Debug && !_shadowPropertyDumpDone) { _shadowPropertyDumpDone = true; HDRPReflectionHelper.DumpShadowProperties(); } DebugLog("HDRP Asset settings pass complete."); } private static void ApplyPipelineSupportFlags() { HDRPReflectionHelper.ApplyPipelineSupportFlagBatch(PerformancePlugin.CfgPipelineDisableSSR.Value, PerformancePlugin.CfgPipelineDisableSSAO.Value, PerformancePlugin.CfgPipelineDisableVolumetrics.Value, PerformancePlugin.CfgPipelineDisableVolumetricClouds.Value, PerformancePlugin.CfgPipelineDisableSubsurfaceScattering.Value, PerformancePlugin.CfgPipelineDisableDecals.Value, PerformancePlugin.CfgPipelineDisableDistortion.Value, PerformancePlugin.CfgPipelineDisableSSRTransparent.Value, PerformancePlugin.CfgPipelineDisableScreenSpaceLensFlare.Value, PerformancePlugin.CfgPipelineDisableDataDrivenLensFlare.Value); } private static void ApplyShadowInitParams() { HDRPReflectionHelper.ApplyShadowInitParams(PerformancePlugin.CfgShadowMaxShadowRequests.Value, PerformancePlugin.CfgShadowMaxDirectionalResolution.Value, PerformancePlugin.CfgShadowMaxAreaResolution.Value, PerformancePlugin.CfgShadowAreaFilteringQuality.Value); } private static bool IsResourceObject(string goName) { for (int i = 0; i < ResourceNamePrefixes.Length; i++) { if (goName.StartsWith(ResourceNamePrefixes[i], StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static bool IsEnvironmentObject(string goName) { for (int i = 0; i < EnvironmentShadowPrefixes.Length; i++) { if (goName.StartsWith(EnvironmentShadowPrefixes[i], StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private void ApplySmallShadowCasterOptimization() { //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { bool value = PerformancePlugin.CfgDisableSmallShadowCasters.Value; bool value2 = PerformancePlugin.CfgDisableResourceShadowCasters.Value; bool value3 = PerformancePlugin.CfgDisableEnvironmentShadowCasters.Value; float value4 = PerformancePlugin.CfgSmallShadowCasterThreshold.Value; float value5 = PerformancePlugin.CfgResourceShadowCasterThreshold.Value; float value6 = PerformancePlugin.CfgEnvironmentShadowCasterThreshold.Value; int num = 0; int num2 = 0; int num3 = 0; Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>(); if (val == null || val.Length == 0) { DebugLog("ShadowCasters: no renderers found."); return; } foreach (Renderer item in val) { if ((Object)(object)item == (Object)null) { continue; } try { if ((int)item.shadowCastingMode == 0 || (int)item.shadowCastingMode == 3 || ((Component)item).gameObject.CompareTag("Player")) { continue; } Bounds bounds = item.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref size)).magnitude; if (value && magnitude < value4) { item.shadowCastingMode = (ShadowCastingMode)0; num++; } else { if (!(value2 || value3) || !(magnitude < Math.Max(value5, value6))) { continue; } string name = ((Object)((Component)item).gameObject).name; if (name != null) { if (value2 && magnitude < value5 && IsResourceObject(name)) { item.shadowCastingMode = (ShadowCastingMode)0; num2++; } else if (value3 && magnitude < value6 && IsEnvironmentObject(name)) { item.shadowCastingMode = (ShadowCastingMode)0; num3++; } } continue; } } catch { } } _smallShadowCastersDisabledCount += num; _resourceShadowCastersDisabledCount += num2; _environmentShadowCastersDisabledCount += num3; if (num > 0) { ManualLogSource log = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(72, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Disabled shadows on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" small renderers "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(< "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(value4, "F1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("m bounds). Total this session: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_smallShadowCastersDisabledCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogInfo(val2); } if (num2 > 0) { ManualLogSource log2 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(73, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Disabled shadows on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" resource objects "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(< "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(value5, "F1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("m bounds). Total this session: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_resourceShadowCastersDisabledCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); } if (num3 > 0) { ManualLogSource log3 = PerformancePlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(76, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Disabled shadows on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" environment objects "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(< "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(value6, "F1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("m bounds). Total this session: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_environmentShadowCastersDisabledCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log3.LogInfo(val2); } if (num == 0 && num2 == 0 && num3 == 0) { DebugLog("ShadowCasters: no new shadow casters found this pass."); } } catch (Exception ex) { ManualLogSource log4 = PerformancePlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error in ApplySmallShadowCasterOptimization: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log4.LogWarning(val3); } } private void ClearCachedReferences() { HDRPReflectionHelper.InvalidateCache(); _globalSettingsApplied = false; _smallShadowCastersDone = false; _smallShadowCasterTimer = 0f; _smallShadowCastersDisabledCount = 0; _resourceShadowCastersDisabledCount = 0; _environmentShadowCastersDisabledCount = 0; _gameplayTimer = 0f; } private static bool IsInGameplay() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name == "StreamingWorld"; } catch { return false; } } private static string GetActiveSceneName() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name ?? "unknown"; } catch { return "unknown"; } } } [BepInPlugin("com.community.askaperformancebooster", "Aska Performance Booster", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PerformancePlugin : BasePlugin { public const string PluginGuid = "com.community.askaperformancebooster"; public const string PluginName = "Aska Performance Booster"; public const string PluginVersion = "1.2.0"; internal static ManualLogSource Log; public static ConfigEntry<PerformancePreset> CfgPreset; public static ConfigEntry<bool> CfgDebugLogging; public static ConfigEntry<bool> CfgPipelineDisableSSR; public static ConfigEntry<bool> CfgPipelineDisableSSAO; public static ConfigEntry<bool> CfgPipelineDisableVolumetrics; public static ConfigEntry<bool> CfgPipelineDisableVolumetricClouds; public static ConfigEntry<bool> CfgPipelineDisableSubsurfaceScattering; public static ConfigEntry<bool> CfgPipelineDisableDecals; public static ConfigEntry<bool> CfgPipelineDisableDistortion; public static ConfigEntry<bool> CfgPipelineDisableSSRTransparent; public static ConfigEntry<bool> CfgPipelineDisableScreenSpaceLensFlare; public static ConfigEntry<bool> CfgPipelineDisableDataDrivenLensFlare; public static ConfigEntry<bool> CfgDisableSmallShadowCasters; public static ConfigEntry<float> CfgSmallShadowCasterThreshold; public static ConfigEntry<bool> CfgDisableResourceShadowCasters; public static ConfigEntry<float> CfgResourceShadowCasterThreshold; public static ConfigEntry<bool> CfgDisableEnvironmentShadowCasters; public static ConfigEntry<float> CfgEnvironmentShadowCasterThreshold; public static ConfigEntry<int> CfgShadowMaxShadowRequests; public static ConfigEntry<int> CfgShadowMaxDirectionalResolution; public static ConfigEntry<int> CfgShadowMaxAreaResolution; public static ConfigEntry<int> CfgShadowAreaFilteringQuality; public static ConfigEntry<bool> CfgForceSRPBatcher; public static ConfigEntry<int> CfgTargetFrameRate; public static ConfigEntry<float> CfgReapplyInterval; public static ConfigEntry<float> CfgLodBias; public static ConfigEntry<bool> CfgEnableDiagnostics; public static ConfigEntry<float> CfgDiagnosticIntervalSeconds; public static ConfigEntry<bool> CfgLogObjectBreakdown; public static ConfigEntry<bool> CfgLogFrameTimings; public override void Load() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown Log = ((BasePlugin)this).Log; BindConfig(); Harmony harmony = new Harmony("com.community.askaperformancebooster"); List<string> list = new List<string>(); LogChannel channelFilter = Logger.ChannelFilter; Logger.ChannelFilter = (LogChannel)(channelFilter & -9); try { if (TryPatchClass(harmony, typeof(QualityLevelPatch))) { list.Add("QualityLevel"); } if (TryPatchClass(harmony, typeof(TargetFrameRatePatch))) { list.Add("TargetFrameRate"); } } finally { Logger.ChannelFilter = channelFilter; } ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches active: ["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(string.Join(", ", list)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]"); } log.LogInfo(val); ((BasePlugin)this).AddComponent<PerformanceBehaviour>(); ProbeRenderPipeline(); ManualLogSource log2 = Log; val = new BepInExInfoLogInterpolatedStringHandler(31, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Aska Performance Booster"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded (preset: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PerformancePreset>(CfgPreset.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", reapply="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(CfgReapplyInterval.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s)"); } log2.LogInfo(val); } private void ProbeRenderPipeline() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown try { RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; if ((Object)(object)currentRenderPipeline == (Object)null) { Log.LogInfo((object)"[Pipeline] No render pipeline asset detected (Built-in RP or not yet loaded)."); return; } string fullName = ((object)currentRenderPipeline).GetType().FullName; string text = "unknown"; try { Type il2CppType = ((Object)currentRenderPipeline).GetIl2CppType(); text = ((il2CppType != null) ? il2CppType.FullName : null) ?? "unknown"; } catch { } bool flag = text.Contains("HighDefinition") || fullName.Contains("HighDefinition") || text.Contains("HDRenderPipeline") || fullName.Contains("HDRenderPipeline"); Log.LogInfo((object)($"[Pipeline] Detected: {((Object)currentRenderPipeline).name} (managed={fullName}, il2cpp={text}). " + (flag ? "HDRP confirmed." : "WARNING: Expected HDRP but type does not match. Optimizations may not apply."))); } catch (Exception ex) { ManualLogSource log = Log; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Pipeline] Early probe failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } private void BindConfig() { //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Expected O, but got Unknown //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Expected O, but got Unknown //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Expected O, but got Unknown //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Expected O, but got Unknown //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown CfgPreset = ((BasePlugin)this).Config.Bind<PerformancePreset>("0. Preset", "Preset", PerformancePreset.Moderate, "Select a performance optimization preset to auto-configure all settings below.\n Moderate (default) = disables expensive HDRP pipeline features the game menu\n does not expose, removes the 60 FPS cap, disables shadows on small objects,\n and forces SRP Batcher on. Confirmed 4-5+ FPS gain.\n Vanilla = all optimizations disabled, stock game behavior.\n Custom = use your manually edited values below.\nPresets are sticky: the chosen preset re-applies its values on every launch.\nTo tweak individual settings manually, set this to Custom first."); CfgDebugLogging = ((BasePlugin)this).Config.Bind<bool>("0. Preset", "DebugLogging", false, "Enable verbose debug logging showing every setting applied, including the game's current value vs the value we're setting."); CfgPipelineDisableSSR = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableSSR", false, "PIPELINE-LEVEL disable of Screen Space Reflections. Sets supportSSR=false on the HDRP Asset. WARNING: Causes a stale-texture artifact (screen image stamped onto reflective objects). Kept false in all presets."); CfgPipelineDisableSSAO = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableSSAO", false, "PIPELINE-LEVEL disable of Screen Space Ambient Occlusion. Sets supportSSAO=false on the HDRP Asset. Removes all ambient occlusion. Noticeable visual change but saves GPU time."); CfgPipelineDisableVolumetrics = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableVolumetrics", false, "PIPELINE-LEVEL disable of volumetric fog/lighting. Sets supportVolumetrics=false on the HDRP Asset. Removes all fog and volumetric lighting. Major visual change."); CfgPipelineDisableVolumetricClouds = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableVolumetricClouds", false, "PIPELINE-LEVEL disable of volumetric clouds. Sets supportVolumetricClouds=false on the HDRP Asset."); CfgPipelineDisableSubsurfaceScattering = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableSubsurfaceScattering", false, "PIPELINE-LEVEL disable of subsurface scattering. Sets supportSubsurfaceScattering=false on the HDRP Asset. Affects skin and foliage translucency rendering."); CfgPipelineDisableDecals = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableDecals", false, "PIPELINE-LEVEL disable of decal rendering. Sets supportDecals=false on the HDRP Asset. WARNING: Aska uses HDRP DecalProjectors for the terraforming grid overlay (green/red placement squares). Enabling this WILL hide that grid. Kept false in all presets."); CfgPipelineDisableDistortion = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableDistortion", false, "PIPELINE-LEVEL disable of distortion effects (heat haze, refraction). Sets supportDistortion=false on the HDRP Asset. WARNING: Like PipelineDisableSSR, can cause stale-texture artifacts. Kept false."); CfgPipelineDisableSSRTransparent = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableSSRTransparent", false, "PIPELINE-LEVEL disable of SSR on transparent objects. Sets supportSSRTransparent=false on the HDRP Asset. WARNING: Like PipelineDisableSSR, can cause stale-texture artifacts. Kept false."); CfgPipelineDisableScreenSpaceLensFlare = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableScreenSpaceLensFlare", false, "PIPELINE-LEVEL disable of screen-space lens flares. Sets supportScreenSpaceLensFlare=false on the HDRP Asset."); CfgPipelineDisableDataDrivenLensFlare = ((BasePlugin)this).Config.Bind<bool>("1. Pipeline", "PipelineDisableDataDrivenLensFlare", false, "PIPELINE-LEVEL disable of data-driven lens flares. Sets supportDataDrivenLensFlare=false on the HDRP Asset."); CfgDisableSmallShadowCasters = ((BasePlugin)this).Config.Bind<bool>("2. Shadows", "DisableSmallShadowCasters", true, "Disable shadow casting on small renderers (rocks, plants, debris). 831+ objects confirmed disabled per session. Each costs a draw call in the shadow depth pass but produces barely visible shadows."); CfgSmallShadowCasterThreshold = ((BasePlugin)this).Config.Bind<float>("2. Shadows", "SmallShadowCasterThreshold", 1f, new ConfigDescription("Bounds size magnitude threshold (metres) below which renderers have their shadow casting disabled. Only used when DisableSmallShadowCasters is true.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); CfgDisableResourceShadowCasters = ((BasePlugin)this).Config.Bind<bool>("2. Shadows", "DisableResourceShadowCasters", true, "Disable shadow casting on player-accumulable resource objects (sticks, firewood, stones, resin, bark, logs, bone fragments). These pile up in the hundreds/thousands as the player chops and gathers, and their shadows are imperceptible. 5,100+ objects confirmed in late-game sessions. Uses a higher bounds threshold than small shadow casters since many resource objects (e.g. logs) exceed 1.0m but still don't need shadows."); CfgResourceShadowCasterThreshold = ((BasePlugin)this).Config.Bind<float>("2. Shadows", "ResourceShadowCasterThreshold", 5f, new ConfigDescription("Bounds size magnitude threshold (metres) for resource shadow caster disabling. Resource objects below this size have shadows disabled. Higher than SmallShadowCasterThreshold because resource objects like logs can be large but still don't produce meaningful shadows. Only used when DisableResourceShadowCasters is true.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), Array.Empty<object>())); CfgDisableEnvironmentShadowCasters = ((BasePlugin)this).Config.Bind<bool>("2. Shadows", "DisableEnvironmentShadowCasters", true, "Disable shadow casting on environment objects that produce imperceptible shadows (grass clumps, cave flora). Grass shadows fall on other grass creating uniform darkening that looks nearly identical without them. ~1,500+ objects in typical scenes."); CfgEnvironmentShadowCasterThreshold = ((BasePlugin)this).Config.Bind<float>("2. Shadows", "EnvironmentShadowCasterThreshold", 5f, new ConfigDescription("Bounds size magnitude threshold (metres) for environment shadow caster disabling. Environment objects below this size have shadows disabled. Only used when DisableEnvironmentShadowCasters is true.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), Array.Empty<object>())); CfgShadowMaxShadowRequests = ((BasePlugin)this).Config.Bind<int>("2. Shadows", "ShadowMaxShadowRequests", 0, new ConfigDescription("HDRP Asset: maximum shadow map render requests per frame. Each shadow-casting light consumes one or more requests (directional cascades use 4). Game default is 128. Reducing to 48 cuts GPU shadow workload while covering typical Aska scenes. 0 = don't override (use game default).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 128), Array.Empty<object>())); CfgShadowMaxDirectionalResolution = ((BasePlugin)this).Config.Bind<int>("2. Shadows", "ShadowMaxDirectionalResolution", 0, new ConfigDescription("HDRP Asset: maximum resolution per directional shadow cascade. Game default is 2048. Reducing to 1024 cuts directional shadow fill rate by 75% (4 cascades x 2048^2 -> 4 x 1024^2). Shadow edges become softer but filtering is already Low. 0 = don't override. Must be power of 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4096), Array.Empty<object>())); CfgShadowMaxAreaResolution = ((BasePlugin)this).Config.Bind<int>("2. Shadows", "ShadowMaxAreaResolution", 0, new ConfigDescription("HDRP Asset: maximum area light shadow map resolution. Game default is 2048. Reducing to 1024 saves GPU fill rate on area light shadows. Area shadows are inherently soft so the quality loss is minimal. 0 = don't override. Must be power of 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4096), Array.Empty<object>())); CfgShadowAreaFilteringQuality = ((BasePlugin)this).Config.Bind<int>("2. Shadows", "ShadowAreaFilteringQuality", -1, new ConfigDescription("HDRP Asset: area light shadow filtering quality. Game default is Medium (1). Low (0) reduces PCF filter taps, matching the punctual and directional filtering which are already Low. -1 = don't override. Values: 0=Low, 1=Medium, 2=High.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 2), Array.Empty<object>())); CfgForceSRPBatcher = ((BasePlugin)this).Config.Bind<bool>("3. Draw Calls", "ForceSRPBatcher", true, "Force the SRP Batcher on. Log confirmed Aska ships with it off (false -> true). No visual change."); CfgTargetFrameRate = ((BasePlugin)this).Config.Bind<int>("4. Frame Rate", "TargetFrameRate", -1, new ConfigDescription("Target frame rate when VSync is off. Aska sets Application.targetFrameRate = 60 at startup, hard-capping all VSync-off users to 60 FPS regardless of GPU headroom. A Harmony patch blocks the game from overriding this value. -1 = unlimited (removes the 60 FPS cap), 0 = don't override, >0 = cap at that FPS. When VSync is on, Unity ignores targetFrameRate entirely.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 300), Array.Empty<object>())); CfgLodBias = ((BasePlugin)this).Config.Bind<float>("5. Misc", "LodBias", 0f, new ConfigDescription("Override LOD bias to force lower-poly LOD levels sooner. Reduces vertex count for distant objects across 9,000-10,000+ renderers. Game default is typically 1.0-2.0. Reducing to 0.75 forces LOD transitions closer to the camera with subtle visual change at medium distance. 0 = don't override (use game default).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); CfgReapplyInterval = ((BasePlugin)this).Config.Bind<float>("5. Misc", "ReapplyIntervalSeconds", 10f, new ConfigDescription("How often (seconds) to re-apply settings as a safety net. Quality level changes are detected instantly via Harmony patch. 0 = apply once only.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>())); CfgEnableDiagnostics = ((BasePlugin)this).Config.Bind<bool>("6. Diagnostics", "EnableDiagnostics", false, "Master toggle for runtime diagnostics logging. When enabled, logs FPS, renderer counts, rigidbody counts, and shadow stats to BepInEx/LogOutput.log at a configurable interval. Zero cost when disabled."); CfgDiagnosticIntervalSeconds = ((BasePlugin)this).Config.Bind<float>("6. Diagnostics", "DiagnosticIntervalSeconds", 10f, new ConfigDescription("How often (seconds) to log diagnostic stats. Lower values give more granular data but produce more log output.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 120f), Array.Empty<object>())); CfgLogObjectBreakdown = ((BasePlugin)this).Config.Bind<bool>("6. Diagnostics", "LogObjectBreakdown", false, "EXPENSIVE: Categorize all renderers by GameObject name and log the top 10 categories by count. Useful for identifying which object types dominate the scene. Only runs on the diagnostic interval."); CfgLogFrameTimings = ((BasePlugin)this).Config.Bind<bool>("6. Diagnostics", "LogFrameTimings", false, "Use Unity's FrameTimingManager to log CPU vs GPU frame times. Shows whether the game is CPU-bound or GPU-bound. CaptureFrameTimings() is called every frame (cheap); timings are only read and logged on the diagnostic interval."); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Config preset on load: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PerformancePreset>(CfgPreset.Value); } log.LogInfo(val); if (CfgPreset.Value != 0) { PerformancePreset value = CfgPreset.Value; PresetApplicator.Apply(value); ManualLogSource log2 = Log; val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Applied \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PerformancePreset>(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" preset."); } log2.LogInfo(val); } } private static bool TryPatchClass(Harmony harmony, Type type) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown try { harmony.CreateClassProcessor(type).Patch(); return true; } catch (Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipping Harmony patch "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); return false; } } } public enum PerformancePreset { Custom, Vanilla, Moderate } internal static class PresetApplicator { internal static void Apply(PerformancePreset preset) { switch (preset) { case PerformancePreset.Vanilla: ApplyVanilla(); break; case PerformancePreset.Moderate: ApplyModerate(); break; } } private static void ApplyVanilla() { PerformancePlugin.CfgPipelineDisableSSR.Value = false; PerformancePlugin.CfgPipelineDisableSSAO.Value = false; PerformancePlugin.CfgPipelineDisableVolumetrics.Value = false; PerformancePlugin.CfgPipelineDisableVolumetricClouds.Value = false; PerformancePlugin.CfgPipelineDisableSubsurfaceScattering.Value = false; PerformancePlugin.CfgPipelineDisableDecals.Value = false; PerformancePlugin.CfgPipelineDisableDistortion.Value = false; PerformancePlugin.CfgPipelineDisableSSRTransparent.Value = false; PerformancePlugin.CfgPipelineDisableScreenSpaceLensFlare.Value = false; PerformancePlugin.CfgPipelineDisableDataDrivenLensFlare.Value = false; PerformancePlugin.CfgDisableSmallShadowCasters.Value = false; PerformancePlugin.CfgSmallShadowCasterThreshold.Value = 1f; PerformancePlugin.CfgDisableResourceShadowCasters.Value = false; PerformancePlugin.CfgResourceShadowCasterThreshold.Value = 5f; PerformancePlugin.CfgDisableEnvironmentShadowCasters.Value = false; PerformancePlugin.CfgEnvironmentShadowCasterThreshold.Value = 5f; PerformancePlugin.CfgShadowMaxShadowRequests.Value = 0; PerformanceP