using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using ReksikPerformance.Rejoin; using ReksikPerformance.Reliability; using ReksikPerformance.ReliabilityGuards; using TMPro; using UnboundLib; using UnboundLib.GameModes; using UnboundLib.Utils.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ReksikPerformance")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f6034f7bbf3bfa1247464cb333b4b126defee508")] [assembly: AssemblyProduct("ReksikPerformance")] [assembly: AssemblyTitle("ReksikPerformance")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ReksikPerformance { internal sealed class AdaptivePerformanceController { private const int MaximumTier = 3; private const float MinimumTierHoldSeconds = 3.5f; private float _pressureSeconds; private float _recoverySeconds; private float _lastTierChangeAt = -1000f; private int _statusTier = -1; private string _statusState = string.Empty; public int Tier { get; private set; } public string StatusText { get; private set; } = "T0 STABLE"; public void Tick(PerformanceSettings settings, MetricsSampler metrics, VfxBudgetController vfx, CompatibilityGuard compatibility) { if (!settings.AdaptiveEnabled.Value || !settings.Enabled.Value || settings.Profile.Value == PerformanceProfile.Vanilla || compatibility.PerformanceImprovementsDetected || !metrics.HasSnapshot) { Reset(vfx, compatibility.PerformanceImprovementsDetected ? "DEFERRED" : "OFF"); return; } float num = ResolveTargetFps(settings.TargetFrameRate.Value); float num2 = num * 0.88f; float num3 = num * 0.97f; float num4 = Mathf.Min(Time.unscaledDeltaTime, 0.25f); bool flag = metrics.FramesPerSecond < num2 || metrics.OnePercentLowFps < num * 0.68f; bool flag2 = metrics.FramesPerSecond >= num3 && metrics.OnePercentLowFps >= num * 0.84f; if (Time.unscaledTime - _lastTierChangeAt < 3.5f) { _pressureSeconds = Mathf.Max(0f, _pressureSeconds - num4); _recoverySeconds = Mathf.Max(0f, _recoverySeconds - num4); UpdateStatus("HOLD"); return; } if (flag) { _pressureSeconds += num4; _recoverySeconds = Mathf.Max(0f, _recoverySeconds - num4 * 2f); } else if (flag2) { _recoverySeconds += num4; _pressureSeconds = Mathf.Max(0f, _pressureSeconds - num4); } else { _pressureSeconds = Mathf.Max(0f, _pressureSeconds - num4 * 0.5f); _recoverySeconds = Mathf.Max(0f, _recoverySeconds - num4 * 0.5f); } float num5 = Clamp(settings.AdaptivePressureSeconds.Value, 2f, 20f); float num6 = Clamp(settings.AdaptiveRecoverySeconds.Value, 5f, 60f); if (_pressureSeconds >= num5 && Tier < 3) { Tier++; OnTierChanged(vfx); } else if (_recoverySeconds >= num6 && Tier > 0) { Tier--; OnTierChanged(vfx); } UpdateStatus(flag ? "PRESSURE" : (flag2 ? "RECOVERING" : "STABLE")); } public void Reset(VfxBudgetController vfx, string reason = "OFF") { _pressureSeconds = 0f; _recoverySeconds = 0f; _lastTierChangeAt = -1000f; Tier = 0; vfx.SetAdaptiveTier(0); UpdateStatus(reason); } private void OnTierChanged(VfxBudgetController vfx) { _pressureSeconds = 0f; _recoverySeconds = 0f; _lastTierChangeAt = Time.unscaledTime; vfx.SetAdaptiveTier(Tier); } private void UpdateStatus(string state) { if (_statusTier != Tier || !string.Equals(_statusState, state, StringComparison.Ordinal)) { _statusTier = Tier; _statusState = state; StatusText = $"T{Tier} {state}"; } } private static float ResolveTargetFps(int configuredTarget) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (configuredTarget >= 30) { return configuredTarget; } Resolution currentResolution = Screen.currentResolution; int refreshRate = ((Resolution)(ref currentResolution)).refreshRate; if (refreshRate < 30) { return 60f; } return refreshRate; } private static float Clamp(float value, float min, float max) { if (float.IsNaN(value) || float.IsInfinity(value)) { return min; } if (!(value < min)) { if (!(value > max)) { return value; } return max; } return min; } } internal sealed class CompatibilityGuard { public const string PerformanceImprovementsGuid = "pykess.rounds.plugins.performanceimprovements"; public bool PerformanceImprovementsDetected { get; } public string StatusText { get { if (!PerformanceImprovementsDetected) { return "NATIVE MODE | NO OVERLAPPING PERFORMANCE PLUGIN DETECTED"; } return "COMPATIBILITY MODE | EXISTING PERFORMANCE IMPROVEMENTS DETECTED"; } } public CompatibilityGuard() { PerformanceImprovementsDetected = Chainloader.PluginInfos.ContainsKey("pykess.rounds.plugins.performanceimprovements"); } } internal sealed class GraphicsController { private readonly struct Snapshot { private bool RunInBackground { get; } private int TargetFrameRate { get; } private int VSyncCount { get; } private int AntiAliasing { get; } private ShadowQuality Shadows { get; } private float ShadowDistance { get; } private int PixelLightCount { get; } private AnisotropicFiltering AnisotropicFiltering { get; } private int MasterTextureLimit { get; } private float LodBias { get; } private Snapshot(bool runInBackground, int targetFrameRate, int vSyncCount, int antiAliasing, ShadowQuality shadows, float shadowDistance, int pixelLightCount, AnisotropicFiltering anisotropicFiltering, int masterTextureLimit, float lodBias) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) RunInBackground = runInBackground; TargetFrameRate = targetFrameRate; VSyncCount = vSyncCount; AntiAliasing = antiAliasing; Shadows = shadows; ShadowDistance = shadowDistance; PixelLightCount = pixelLightCount; AnisotropicFiltering = anisotropicFiltering; MasterTextureLimit = masterTextureLimit; LodBias = lodBias; } public static Snapshot Capture() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return new Snapshot(Application.runInBackground, Application.targetFrameRate, QualitySettings.vSyncCount, QualitySettings.antiAliasing, QualitySettings.shadows, QualitySettings.shadowDistance, QualitySettings.pixelLightCount, QualitySettings.anisotropicFiltering, QualitySettings.masterTextureLimit, QualitySettings.lodBias); } public void Restore() { //IL_002d: 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) Application.runInBackground = RunInBackground; Application.targetFrameRate = TargetFrameRate; QualitySettings.vSyncCount = VSyncCount; QualitySettings.antiAliasing = AntiAliasing; QualitySettings.shadows = Shadows; QualitySettings.shadowDistance = ShadowDistance; QualitySettings.pixelLightCount = PixelLightCount; QualitySettings.anisotropicFiltering = AnisotropicFiltering; QualitySettings.masterTextureLimit = MasterTextureLimit; QualitySettings.lodBias = LodBias; } } private readonly ManualLogSource _logger; private readonly Snapshot _startup; public GraphicsController(ManualLogSource logger) { _logger = logger; _startup = Snapshot.Capture(); } public void Apply(PerformanceSettings settings, CompatibilityGuard compatibility) { Restore(); if (settings.ReliabilityEnabled.Value && settings.RunInBackgroundForReliability.Value) { Application.runInBackground = true; } if (settings.Enabled.Value && settings.Profile.Value != PerformanceProfile.Vanilla) { Application.targetFrameRate = NormalizeTargetFrameRate(settings.TargetFrameRate.Value); QualitySettings.vSyncCount = Clamp(settings.VSyncCount.Value, 0, 4); QualitySettings.antiAliasing = NormalizeAntiAliasing(settings.AntiAliasing.Value); QualitySettings.masterTextureLimit = Clamp(settings.TextureLimit.Value, 0, 3); QualitySettings.lodBias = Clamp(settings.LodBias.Value, 0.1f, 5f); QualitySettings.anisotropicFiltering = (AnisotropicFiltering)(settings.AnisotropicFiltering.Value ? 2 : 0); if (!compatibility.PerformanceImprovementsDetected) { QualitySettings.shadows = (ShadowQuality)(settings.Shadows.Value ? 2 : 0); QualitySettings.shadowDistance = Clamp(settings.ShadowDistance.Value, 0f, 500f); QualitySettings.pixelLightCount = Clamp(settings.PixelLightCount.Value, 0, 32); } _logger.LogDebug((object)($"Applied local profile {settings.Profile.Value}; target={Application.targetFrameRate}, " + $"vSync={QualitySettings.vSyncCount}, compatibility={compatibility.PerformanceImprovementsDetected}.")); } } public void Restore() { _startup.Restore(); } private static int NormalizeTargetFrameRate(int value) { if (value >= 0) { return Clamp(value, 30, 1000); } return -1; } private static int NormalizeAntiAliasing(int value) { if (value < 8) { if (value < 4) { if (value < 2) { return 0; } return 2; } return 4; } return 8; } private static int Clamp(int value, int min, int max) { if (value >= min) { if (value <= max) { return value; } return max; } return min; } private static float Clamp(float value, float min, float max) { if (!(value < min)) { if (!(value > max)) { return value; } return max; } return min; } } internal sealed class MetricsOverlay { private GUIStyle? _style; private Texture2D? _background; public void Draw(string text) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) EnsureStyle(); if (_style != null) { GUI.Label(new Rect((float)Screen.width - 390f, 18f, 372f, 76f), text, _style); } } public void Dispose() { if ((Object)(object)_background != (Object)null) { Object.Destroy((Object)(object)_background); _background = null; } _style = null; } private void EnsureStyle() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if (_style == null) { _background = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; _background.SetPixel(0, 0, new Color(0.035f, 0.04f, 0.065f, 0.92f)); _background.Apply(false, true); GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, fontSize = 13, padding = new RectOffset(12, 12, 7, 7) }; val.normal.background = _background; val.normal.textColor = new Color(0.9f, 0.94f, 1f, 1f); _style = val; } } } internal sealed class MetricsSampler { private const int WindowCapacity = 600; private readonly float[] _frameTimes = new float[600]; private readonly float[] _sortBuffer = new float[600]; private int _count; private int _cursor; private float _nextSnapshotAt; private int _lastGcCollections; public float FramesPerSecond { get; private set; } public float AverageFrameMilliseconds { get; private set; } public float OnePercentLowFps { get; private set; } public float ManagedMemoryMegabytes { get; private set; } public int GcCollectionsSinceLastSnapshot { get; private set; } public bool HasSnapshot { get; private set; } public string OverlayText { get; private set; } = "Sampling..."; public MetricsSampler() { _lastGcCollections = TotalGcCollections(); } public void Tick(PerformanceProfile profile, int particles, int trails, string compatibility, string adaptiveStatus) { float unscaledDeltaTime = Time.unscaledDeltaTime; if (unscaledDeltaTime > 0f && unscaledDeltaTime < 5f && !float.IsNaN(unscaledDeltaTime)) { _frameTimes[_cursor] = unscaledDeltaTime; _cursor = (_cursor + 1) % 600; if (_count < 600) { _count++; } } if (!(Time.unscaledTime < _nextSnapshotAt) && _count != 0) { _nextSnapshotAt = Time.unscaledTime + 0.5f; Recalculate(profile, particles, trails, compatibility, adaptiveStatus); } } private void Recalculate(PerformanceProfile profile, int particles, int trails, string compatibility, string adaptiveStatus) { float num = 0f; for (int i = 0; i < _count; i++) { float num2 = _frameTimes[i]; _sortBuffer[i] = num2; num += num2; } Array.Sort(_sortBuffer, 0, _count); float num3 = num / (float)_count; int num4 = Math.Max(0, Math.Min(_count - 1, (int)Math.Ceiling((float)_count * 0.99f) - 1)); float num5 = _sortBuffer[num4]; AverageFrameMilliseconds = num3 * 1000f; FramesPerSecond = ((num3 > 0f) ? (1f / num3) : 0f); OnePercentLowFps = ((num5 > 0f) ? (1f / num5) : 0f); ManagedMemoryMegabytes = (float)GC.GetTotalMemory(forceFullCollection: false) / 1048576f; int num6 = TotalGcCollections(); GcCollectionsSinceLastSnapshot = Math.Max(0, num6 - _lastGcCollections); _lastGcCollections = num6; HasSnapshot = true; string text = (compatibility.StartsWith("COMPATIBILITY", StringComparison.Ordinal) ? "COMPAT" : "NATIVE"); OverlayText = "REKSIK PERFORMANCE | " + profile.ToString().ToUpperInvariant() + " | " + text + " | ADAPT " + adaptiveStatus + "\n" + $"FPS {FramesPerSecond:0} | 1% LOW {OnePercentLowFps:0} | {AverageFrameMilliseconds:0.0} ms\n" + $"MEM {ManagedMemoryMegabytes:0} MB | GC +{GcCollectionsSinceLastSnapshot} | VFX {particles}/{trails}"; } private static int TotalGcCollections() { return GC.CollectionCount(0) + GC.CollectionCount(1) + GC.CollectionCount(2); } } internal static class PerformanceMenu { private sealed class View { private sealed class TogglePresentation { public string BaseLabel { get; } public TextMeshProUGUI Label { get; } public TogglePresentation(string baseLabel, TextMeshProUGUI label) { BaseLabel = baseLabel; Label = label; } } private readonly ReksikPerformancePlugin _plugin; private readonly Dictionary _profiles = new Dictionary(); private readonly Dictionary _togglePresentations = new Dictionary(); private Toggle? _enabled; private Toggle? _overlay; private Toggle? _reliabilityEnabled; private Toggle? _writeDiagnostics; private Toggle? _runInBackground; private Toggle? _commonGuards; private Toggle? _experimentalRejoin; private Toggle? _adaptive; private Toggle? _shadows; private Toggle? _anisotropic; private TextMeshProUGUI? _compatibility; private TextMeshProUGUI? _reliabilityLive; private TextMeshProUGUI? _live; private TMP_InputField? _fps; private TMP_InputField? _vSync; private TMP_InputField? _aa; private TMP_InputField? _particles; private TMP_InputField? _trail; private bool _refreshing; public GameObject Root { get; } public View(GameObject root, ReksikPerformancePlugin plugin) { Root = root; _plugin = plugin; } public void Build() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) AddText("REKSIK PERFORMANCE / LOCAL CONTROL", 33, Accent, 42f); AddText("SESSION RELIABILITY | SQUEEZE FPS | LIVE EVIDENCE", 18, Muted, 27f); _compatibility = AddText(string.Empty, 18, Muted, 36f); AddText("PILLAR 1 / SESSION RELIABILITY", 22, Accent, 30f); _reliabilityEnabled = AddToggle("ENABLE PASSIVE SESSION RELIABILITY", _plugin.Settings.ReliabilityEnabled.Value, _plugin.Settings.SetReliabilityEnabled); _writeDiagnostics = AddToggle("WRITE BOUNDED DISCONNECT DIAGNOSTICS", _plugin.Settings.WriteReliabilityDiagnostics.Value, _plugin.Settings.SetWriteReliabilityDiagnostics); _runInBackground = AddToggle("KEEP CLIENT ACTIVE WHILE UNFOCUSED", _plugin.Settings.RunInBackgroundForReliability.Value, _plugin.Settings.SetRunInBackgroundForReliability); _commonGuards = AddToggle("COMMON DISCONNECT GUARDS (RESTART REQUIRED)", _plugin.Settings.CommonDisconnectGuards.Value, _plugin.Settings.SetCommonDisconnectGuards); _experimentalRejoin = AddToggle("EXPERIMENTAL NON-HOST REJOIN (RESTART / HOST + CLIENT)", _plugin.Settings.ExperimentalRejoinEnabled.Value, _plugin.Settings.SetExperimentalRejoinEnabled); _reliabilityLive = AddText(string.Empty, 17, Muted, 118f); AddText("PILLAR 2 / SQUEEZE FPS", 22, Accent, 30f); _enabled = AddToggle("ENABLE LOCAL PERFORMANCE PROFILE", _plugin.Settings.Enabled.Value, _plugin.Settings.SetEnabled); _adaptive = AddToggle("ADAPTIVE VFX PRESSURE CONTROL (DEFAULT ON)", _plugin.Settings.AdaptiveEnabled.Value, _plugin.Settings.SetAdaptiveEnabled); _overlay = AddToggle("SHOW LIVE METRICS OVERLAY", _plugin.Settings.ShowOverlay.Value, _plugin.Settings.SetOverlay); AddText("FPS / VISUAL PROFILE", 21, Text, 29f); AddProfile(PerformanceProfile.Vanilla, "VANILLA - RESTORE STARTUP VALUES"); AddProfile(PerformanceProfile.MaxFps, "MAX FPS - SQUEEZE EVERY LOCAL FRAME"); AddProfile(PerformanceProfile.Balanced, "BALANCED - LONG SESSION DEFAULT"); AddProfile(PerformanceProfile.Competitive, "COMPETITIVE - FRAME PACING FIRST"); AddProfile(PerformanceProfile.Potato, "POTATO - MAXIMUM LOCAL RELIEF"); AddProfile(PerformanceProfile.Cinematic, "CINEMATIC - VISUAL QUALITY"); _shadows = AddToggle("LOCAL SHADOWS", _plugin.Settings.Shadows.Value, _plugin.Settings.SetShadows); _anisotropic = AddToggle("ANISOTROPIC FILTERING", _plugin.Settings.AnisotropicFiltering.Value, _plugin.Settings.SetAnisotropicFiltering); _fps = AddNumberInput("MAX FPS (-1 = PLATFORM DEFAULT)", delegate(float value) { _plugin.Settings.SetTargetFrameRate((int)value); }); _vSync = AddNumberInput("VSYNC INTERVAL (0-4)", delegate(float value) { _plugin.Settings.SetVSyncCount((int)value); }); _aa = AddNumberInput("MSAA SAMPLES (0/2/4/8)", delegate(float value) { _plugin.Settings.SetAntiAliasing((int)value); }); _particles = AddNumberInput("PARTICLES PER SYSTEM (16-10000)", delegate(float value) { _plugin.Settings.SetParticleLimit((int)value); }); _trail = AddNumberInput("TRAIL LIFETIME MULTIPLIER (0-1.5)", _plugin.Settings.SetTrailLifetimeMultiplier); AddText("VFX MODE", 21, Text, 29f); AddButton("FULL - NO VFX CHANGES", delegate { _plugin.Settings.SetVfxBudget(LocalVfxBudget.Full); }); AddButton("REDUCED - SOFT PARTICLE / TRAIL BUDGET", delegate { _plugin.Settings.SetVfxBudget(LocalVfxBudget.Reduced); }); AddButton("MINIMAL - AGGRESSIVE LOCAL VFX BUDGET", delegate { _plugin.Settings.SetVfxBudget(LocalVfxBudget.Minimal); }); _live = AddText(string.Empty, 18, Muted, 72f); AddText("Reliability is passive and evidence-first. Graphics changes are client-local and restorable.", 16, Muted, 34f); } public void Refresh() { //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_enabled == (Object)null || (Object)(object)_overlay == (Object)null || (Object)(object)_shadows == (Object)null || (Object)(object)_anisotropic == (Object)null || (Object)(object)_reliabilityEnabled == (Object)null || (Object)(object)_writeDiagnostics == (Object)null || (Object)(object)_runInBackground == (Object)null || (Object)(object)_commonGuards == (Object)null || (Object)(object)_experimentalRejoin == (Object)null || (Object)(object)_adaptive == (Object)null || (Object)(object)_reliabilityLive == (Object)null || (Object)(object)_compatibility == (Object)null || (Object)(object)_live == (Object)null || (Object)(object)_fps == (Object)null || (Object)(object)_vSync == (Object)null || (Object)(object)_aa == (Object)null || (Object)(object)_particles == (Object)null || (Object)(object)_trail == (Object)null) { return; } _refreshing = true; try { PerformanceSettings settings = _plugin.Settings; SetToggleState(_enabled, settings.Enabled.Value); SetToggleState(_overlay, settings.ShowOverlay.Value); SetToggleState(_reliabilityEnabled, settings.ReliabilityEnabled.Value); SetToggleState(_writeDiagnostics, settings.WriteReliabilityDiagnostics.Value); SetToggleState(_runInBackground, settings.RunInBackgroundForReliability.Value); SetToggleState(_commonGuards, settings.CommonDisconnectGuards.Value); SetToggleState(_experimentalRejoin, settings.ExperimentalRejoinEnabled.Value); SetToggleState(_adaptive, settings.AdaptiveEnabled.Value); SetToggleState(_shadows, settings.Shadows.Value); SetToggleState(_anisotropic, settings.AnisotropicFiltering.Value); _fps.SetTextWithoutNotify(settings.TargetFrameRate.Value.ToString(CultureInfo.InvariantCulture)); _vSync.SetTextWithoutNotify(settings.VSyncCount.Value.ToString(CultureInfo.InvariantCulture)); _aa.SetTextWithoutNotify(settings.AntiAliasing.Value.ToString(CultureInfo.InvariantCulture)); _particles.SetTextWithoutNotify(settings.ParticleLimit.Value.ToString(CultureInfo.InvariantCulture)); _trail.SetTextWithoutNotify(settings.TrailLifetimeMultiplier.Value.ToString("0.##", CultureInfo.InvariantCulture)); foreach (KeyValuePair profile in _profiles) { ((Graphic)((Component)profile.Value).GetComponentInChildren()).color = ((profile.Key == settings.Profile.Value) ? Accent : Text); } bool performanceImprovementsDetected = _plugin.Compatibility.PerformanceImprovementsDetected; ((TMP_Text)_compatibility).text = _plugin.Compatibility.StatusText + (performanceImprovementsDetected ? "\nVFX AND SHADOW/LIGHT KNOBS ARE DEFERRED TO AVOID DOUBLE CONTROL." : string.Empty); ((Graphic)_compatibility).color = (performanceImprovementsDetected ? Warning : Accent); MetricsSampler metrics = _plugin.Metrics; SessionReliabilitySummary sessionReliabilitySummary = SessionReliabilitySummary.FromLatest(); ReliabilityGuardStatus status = ReliabilityGuard.GetStatus(); ExperimentalRejoinStatus status2 = ExperimentalRejoin.Status; long num = status.EntityLagRoundEndsSuppressed + status.NetworkPhysicsUpdatesSkipped + status.FollowPlayerUpdatesSkipped + status.SetPlayerSpriteLayerStartsSkipped + status.RwfFollowPlayerUpdatesSkipped + status.ModdingUtilsDestroyedPlayersSkipped + status.StaleProjectileHitsDropped + status.GearUpLifeforceTerminalCallsGuarded + status.GearUpArcaneNullHitsDropped; ((TMP_Text)_reliabilityLive).text = sessionReliabilitySummary.CompactLine + "\n" + string.Format("GUARDS: {0} | PATCHED {1} | INTERVENTIONS {2}\n", status.Installed ? "ACTIVE" : "OFF", status.InstalledPatchCount, num) + $"REJOIN: {status2.State} | ATTEMPTS {status2.AttemptsStarted} | SUCCESS {status2.SuccessfulRejoins}\n" + "WARM STATE: " + ExperimentalRejoinController.StatusText + (status2.NeedsWarmStateRestore ? "\nWAITING FOR SAFE POINT-BOUNDARY VALIDATION." : string.Empty); ((TMP_Text)_live).text = "LIVE | RELIABILITY " + (settings.ReliabilityEnabled.Value ? "ON" : "OFF") + " | " + settings.Profile.Value.ToString().ToUpperInvariant() + " | ADAPT " + _plugin.Adaptive.StatusText + " | " + $"FPS {metrics.FramesPerSecond:0} | 1% LOW {metrics.OnePercentLowFps:0} | " + $"{metrics.AverageFrameMilliseconds:0.0} ms\n" + $"MEM {metrics.ManagedMemoryMegabytes:0} MB | GC +{metrics.GcCollectionsSinceLastSnapshot} | " + $"TRACKED VFX {_plugin.Vfx.TrackedParticleSystems}/{_plugin.Vfx.TrackedTrails}"; } finally { _refreshing = false; } } private void AddProfile(PerformanceProfile profile, string label) { Button value = AddButton(label, delegate { _plugin.Settings.ApplyProfile(profile); }); _profiles.Add(profile, value); } private Toggle AddToggle(string label, bool initialValue, Action action) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = MenuHandler.CreateToggle(initialValue, label, Root, (UnityAction)delegate(bool value) { if (!_refreshing) { action(value); } }, 22, false, (Color?)Text, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Compact(obj, 38f); Toggle component = obj.GetComponent(); TextMeshProUGUI componentInChildren = obj.GetComponentInChildren(); _togglePresentations[component] = new TogglePresentation(label, componentInChildren); StyleToggle(component); SetToggleState(component, initialValue); return component; } private Button AddButton(string label, Action action) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown GameObject obj = MenuHandler.CreateButton(label, Root, (UnityAction)delegate { if (!_refreshing) { action(); } }, 20, false, (Color?)Text, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null); Compact(obj, 36f); Button component = obj.GetComponent