Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ROR O v1.2.0
plugins/ror-o/ROR-O.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; 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.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates.Assassin.Weapon; using EntityStates.ClaymanMonster; using EntityStates.FalseSon; using EntityStates.FalseSonBoss; using EntityStates.FriendUnit; using EntityStates.GolemMonster; using EntityStates.GrandParentBoss; using EntityStates.LemurianBruiserMonster; using EntityStates.Loader; using EntityStates.LunarWisp; using EntityStates.Mage.Weapon; using EntityStates.Merc; using EntityStates.NewtMonster; using EntityStates.Paladin; using EntityStates.Seeker; using EntityStates.SolusAmalgamator; using EntityStates.Tanker; using EntityStates.Toolbot; using EntityStates.VagrantMonster.Weapon; using Facepunch.Steamworks; using Grumpy; using HG; using HarmonyLib; using KinematicCharacterController; using LeTai.Asset.TranslucentImage; using LookingGlass.BuffTimers; using LookingGlass.ItemStatsNameSpace; using LookingGlass.StatsDisplay; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using ROR_O.patches; using ROR_O.patches.mods; using RoR2; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.ConVar; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2.Networking; using RoR2.PostProcessing; using RoR2.Projectile; using RoR2.UI; using RoR2.UI.SkinControllers; using TMPro; using Unity.Collections; using Unity.Jobs; using Unity.Profiling; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Jobs; using UnityEngine.LowLevel; using UnityEngine.Networking; using UnityEngine.PlayerLoop; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("LookingGlass")] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ROR-O")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+da485d0dbc0ea674efd1dabd82c30e7c1bc441dc")] [assembly: AssemblyProduct("ROR-O")] [assembly: AssemblyTitle("ROR-O")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] 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 ROR_O { internal static class AssetLoadAhead { private sealed class Slot { public AssetReference? Reference; public AsyncOperationHandle<Object> Handle; public bool Started; } private static readonly Dictionary<string, Slot> slots = new Dictionary<string, Slot>(); private static readonly Queue<string> order = new Queue<string>(); private static bool startFailed; internal static void Enqueue(AssetReference? reference) { if (reference != null && reference.RuntimeKeyIsValid()) { string text = reference.RuntimeKey.ToString(); if (!slots.ContainsKey(text)) { slots[text] = new Slot { Reference = reference }; order.Enqueue(text); } } } internal static void Release(AssetReference? reference) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (reference == null || !reference.RuntimeKeyIsValid()) { return; } string key = reference.RuntimeKey.ToString(); if (slots.TryGetValue(key, out Slot value) && value != null) { slots.Remove(key); if (value.Started && value.Handle.IsValid()) { Addressables.Release<Object>(value.Handle); } } } internal static bool IsSettled(AssetReference? reference) { if (reference == null || !reference.RuntimeKeyIsValid()) { return true; } if (!slots.TryGetValue(reference.RuntimeKey.ToString(), out Slot value) || value == null || !value.Started) { return false; } if (!value.Handle.IsValid()) { return true; } return value.Handle.IsDone; } internal static void ReleaseAll() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<string, Slot> slot in slots) { Slot value = slot.Value; if (value != null && value.Started && value.Handle.IsValid()) { Addressables.Release<Object>(value.Handle); } } slots.Clear(); order.Clear(); } internal static void Pump(long frameStart, int alreadyProcessed) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) int num = alreadyProcessed; while (order.Count > 0 && !LoadingPhase.BudgetExpired(frameStart, num)) { string key = order.Dequeue(); if (!slots.TryGetValue(key, out Slot value) || value == null || value.Started || value.Reference == null) { continue; } try { value.Handle = Addressables.LoadAssetAsync<Object>((object)value.Reference); value.Started = true; value.Reference = null; } catch (Exception ex) { value.Started = true; value.Handle = default(AsyncOperationHandle<Object>); value.Reference = null; if (!startFailed) { startFailed = true; ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Asset load did not start: " + ex.Message)); } } continue; } num++; if (LoadingPhase.BudgetExpired(frameStart, num)) { break; } } } } internal sealed class EffectRuntime : MonoBehaviour { private const float CalmFrameSeconds = 0.012f; private const float HitchFrameSeconds = 0.033f; private const float BusyWarmIntervalSeconds = 0.5f; private const float ExpensiveWarmMs = 3f; private static readonly Vector3 Park = new Vector3(0f, -5000f, 0f); private static readonly Vector3 CullBounds = new Vector3(12f, 12f, 12f); private static readonly Plane[] Frustum = (Plane[])(object)new Plane[6]; private static ConfigEntry<bool>? warmEffects; private static ConfigEntry<bool>? keepPools; private static ConfigEntry<bool>? keepCopiesActive; private static ConfigEntry<int>? activeParkLimit; private static ConfigEntry<bool>? warmFullPeak; private static ConfigEntry<bool>? warmShaders; private static ConfigEntry<int>? warmPeakCopies; private static ConfigEntry<bool>? cullSecondary; private static ConfigEntry<float>? cullDistance; private static ConfigEntry<bool>? cullOffScreen; private static ConfigEntry<int>? cullInterval; private static ConfigEntry<bool>? showStatus; private static ConfigEntry<bool>? showShaderStatus; private static ConfigEntry<bool>? logStatus; private static float nextLogTime; private static readonly StringBuilder statusBuilder = new StringBuilder(384); private static readonly Dictionary<VFXAttributes, EffectCullState> gates = new Dictionary<VFXAttributes, EffectCullState>(); private static readonly Queue<int> warmQueue = new Queue<int>(); private static readonly List<EffectManagerHelper> heldHelpers = new List<EffectManagerHelper>(4); private static AsyncOperationHandle<GameObject>[] handles = Array.Empty<AsyncOperationHandle<GameObject>>(); private static bool[] directPins = Array.Empty<bool>(); private static AssetReferenceT<GameObject>?[] addresses = Array.Empty<AssetReferenceT<GameObject>>(); private static GameObject?[] prefabs = Array.Empty<GameObject>(); private static byte[] warmed = Array.Empty<byte>(); private static bool[] settled = Array.Empty<bool>(); private static int[] peakInUse = Array.Empty<int>(); private static bool[] queued = Array.Empty<bool>(); private static int pinCursor; private static bool directPinFailed; private static int warmedPrefabs; private static int instancesBuilt; private static int shaderCursor; private static readonly List<Shader> pinnedShaders = new List<Shader>(); private static readonly List<AsyncOperationHandle<GameObject>> shaderHolds = new List<AsyncOperationHandle<GameObject>>(); private static readonly List<GameObject> shaderHoldPrefabs = new List<GameObject>(); private static bool[] shaderHeld = Array.Empty<bool>(); private static readonly List<string> shaderTraceLines = new List<string>(6); private static readonly List<Material> drawMaterials = new List<Material>(8); private static int shaderWarmCalls; private static int shaderSlowRenders; private static long shaderWarmMicroseconds; private static EffectRuntime? runtime; private static Transform? warmRoot; private static Camera? warmCamera; private static RenderTexture? warmTarget; private static Mesh? warmMesh; private const int WarmLayer = 31; private static readonly Vector3 WarmSpot = new Vector3(0f, -8000f, 0f); private static float shaderStatusRefresh; private static string shaderStatusText = "Shader compile status is not ready yet."; private static int culledEffects; private static int frame; private static float lastWarmTime; private static float warmNotBefore; private static bool frustumReady; private static float sceneReadyTime; private static Camera? gameplayCamera; private static bool cullWasEnabled; private static Run? observedRun; private static float lastStatusRefresh; private static string statusText = "Effect status is not ready yet."; private static GUIStyle? statusStyle; private static GUIStyle? shaderStyle; internal const float ShaderStatusBlockHeight = 250f; internal static ConfigEntry<SettingsProfiles.Profile>? Profile { get; private set; } internal static ConfigEntry<bool>? WarmEffects => warmEffects; internal static ConfigEntry<bool>? KeepPoolsEntry => keepPools; internal static ConfigEntry<bool>? KeepCopiesActiveEntry => keepCopiesActive; internal static ConfigEntry<int>? ActiveParkLimitEntry => activeParkLimit; internal static ConfigEntry<bool>? WarmFullPeakEntry => warmFullPeak; internal static ConfigEntry<bool>? WarmShadersEntry => warmShaders; internal static ConfigEntry<int>? WarmPeakCopiesEntry => warmPeakCopies; internal static ConfigEntry<bool>? CullSecondary => cullSecondary; internal static ConfigEntry<float>? CullDistanceEntry => cullDistance; internal static ConfigEntry<bool>? CullOffScreenEntry => cullOffScreen; internal static ConfigEntry<int>? CullIntervalEntry => cullInterval; internal static ConfigEntry<bool>? ShowStatusEntry => showStatus; internal static ConfigEntry<bool>? ShowShaderStatusEntry => showShaderStatus; internal static bool ShowShaderStatus => showShaderStatus?.Value ?? false; internal static ConfigEntry<bool>? LogStatusEntry => logStatus; internal static bool KeepPools => keepPools?.Value ?? false; internal static bool KeepCopiesActive => keepCopiesActive?.Value ?? false; internal static int ActiveParkLimit { get { if (activeParkLimit == null) { return 96; } return Clamp(activeParkLimit.Value, 0, 192); } } internal static void Bind(ConfigFile config) { warmEffects = config.Bind<bool>("Effects", "Warm Effect Prefabs", false, OptionCopy.EffectWarm); keepPools = config.Bind<bool>("Effects", "Keep Effect Pools", false, OptionCopy.KeepPools); keepCopiesActive = config.Bind<bool>("Effects", "Keep Effect Copies Active", false, OptionCopy.KeepCopiesActive); activeParkLimit = config.Bind<int>("Effects", "Active Parked Copies", 96, OptionCopy.ParkLimit); warmFullPeak = config.Bind<bool>("Effects", "Warm Full Observed Peak", false, OptionCopy.WarmFullPeak); warmShaders = config.Bind<bool>("Effects", "Warm Effect Shaders", false, OptionCopy.WarmShaders); warmPeakCopies = config.Bind<int>("Effects", "Warm Peak Copies", 4, OptionCopy.WarmPeakCopies); cullSecondary = config.Bind<bool>("Effects", "Cull Secondary Effects", true, OptionCopy.CullSecondary); cullDistance = config.Bind<float>("Effects", "Cull Distance", 55f, OptionCopy.CullDistance); cullOffScreen = config.Bind<bool>("Effects", "Cull Off Screen", true, OptionCopy.CullOffScreen); cullInterval = config.Bind<int>("Effects", "Cull Interval", 4, OptionCopy.CullInterval); showStatus = config.Bind<bool>("Effects", "Show Effect Status", false, OptionCopy.EffectStatus); showShaderStatus = config.Bind<bool>("Effects", "Show Shader Compile", false, OptionCopy.ShaderStatus); logStatus = config.Bind<bool>("Effects", "Log Effect Status", false, OptionCopy.EffectLog); Profile = SettingsProfiles.Begin(config, "Effects", OptionCopy.EffectProfile); SettingsProfiles.Add(warmEffects, lossless: true, performance: true, potato: true); SettingsProfiles.Add(keepPools, lossless: true, performance: true, potato: true); SettingsProfiles.Add(keepCopiesActive, lossless: true, performance: true, potato: true); SettingsProfiles.Add(activeParkLimit, 96, 96, 96); SettingsProfiles.Add(warmFullPeak, lossless: false, performance: false, potato: false); SettingsProfiles.Add(warmShaders, lossless: false, performance: false, potato: false); SettingsProfiles.Add(warmPeakCopies, 2, 4, 6); SettingsProfiles.Add(cullSecondary, lossless: false, performance: true, potato: true); SettingsProfiles.Add(cullDistance, 80f, 55f, 28f); SettingsProfiles.Add(cullOffScreen, lossless: false, performance: true, potato: true); SettingsProfiles.Add(cullInterval, 8, 4, 2); SettingsProfiles.End(); } private static void LogStatus() { RefreshStatus(); ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogInfo((object)statusText.Replace('\n', ' ')); } } internal static void NoteEffectDisabled(VFXAttributes attributes) { if (!Object.op_Implicit((Object)(object)attributes) || !gates.TryGetValue(attributes, out EffectCullState value) || value == null) { return; } gates.Remove(attributes); if (value.secondaryStopped) { RestoreLights(attributes.optionalLights, value); value.secondaryStopped = false; if (culledEffects > 0) { culledEffects--; } } } internal static void NoteEffectSpawned(EffectIndex effectIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown int num = (int)effectIndex; ConfigEntry<bool>? obj = warmEffects; if (obj == null || !obj.Value || num < 0 || num >= peakInUse.Length) { return; } long started = (HitchProbes.Armed ? Stopwatch.GetTimestamp() : 0); try { NoteSpawn(num); } finally { HitchProbes.Note(HitchProbes.Id.EffectPeak, started); } } private static void NoteSpawn(int index) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) GameObject val = prefabs[index]; if (!Object.op_Implicit((Object)(object)val)) { AsyncOperationHandle<GameObject> val2 = handles[index]; if (!val2.IsValid() || !val2.IsDone) { return; } val = val2.Result; if (!Object.op_Implicit((Object)(object)val)) { return; } prefabs[index] = val; } GameObject prefab = val; EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)index); if (effectDef != null && Object.op_Implicit((Object)(object)effectDef.prefab)) { prefab = effectDef.prefab; } EffectPools.NotePrefabSpawn(prefab); int num = EffectPools.CheckoutCount(prefab); if (num > peakInUse[index]) { peakInUse[index] = num; EnqueueWarm(index); } } private static void EnqueueWarm(int index) { if (index >= 0 && index < queued.Length && !queued[index]) { queued[index] = true; warmQueue.Enqueue(index); } } private void OnEnable() { runtime = this; SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; Run.onRunDestroyGlobal += OnRunDestroy; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; Run.onRunDestroyGlobal -= OnRunDestroy; if ((Object)(object)runtime == (Object)(object)this) { runtime = null; } ReleaseDirectPins(); ReleaseShaderHolds(); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)mode != 0) { return; } EffectPools.ResetParkedActive(); pinCursor = 0; warmedPrefabs = 0; instancesBuilt = 0; warmNotBefore = 0f; sceneReadyTime = Time.unscaledTime; Array.Clear(warmed, 0, warmed.Length); Array.Clear(settled, 0, settled.Length); Array.Clear(prefabs, 0, prefabs.Length); warmQueue.Clear(); Array.Clear(queued, 0, queued.Length); for (int i = 0; i < peakInUse.Length; i++) { if (peakInUse[i] > 0) { EnqueueWarm(i); } } } private static void OnSceneUnloaded(Scene scene) { gates.Clear(); culledEffects = 0; cullWasEnabled = false; gameplayCamera = null; } private void Update() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) MaybeLogStatus(); ConfigEntry<bool>? obj = warmEffects; if (obj == null || !obj.Value || !((ResourceAvailability)(ref EffectCatalog.availability)).available || EffectManager.DisableAllEffectSpawning) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (LoadingPhase.BlocksWarmup(((Scene)(ref activeScene)).name)) { return; } int num = EnsureCatalog(); if (num == 0) { return; } bool isLoading = LoadingPhase.IsLoading; float unscaledDeltaTime = Time.unscaledDeltaTime; bool flag = !isLoading && (unscaledDeltaTime > 0.033f || Time.unscaledTime < warmNotBefore); if (!flag && pinCursor < num) { int effectLoadsPerFrame = WarmPaceSettings.EffectLoadsPerFrame; int num2 = 0; long timestamp = Stopwatch.GetTimestamp(); while (num2 < effectLoadsPerFrame && pinCursor < num && Pin(pinCursor)) { pinCursor++; num2++; if (!isLoading) { float num3 = (float)((double)(Stopwatch.GetTimestamp() - timestamp) * 1000.0 / (double)Stopwatch.Frequency); if (num3 > 3f) { float num4 = num3 * 0.008f; warmNotBefore = Time.unscaledTime + ((num4 > 1f) ? 1f : num4); break; } } else if (LoadingPhase.BudgetExpired(timestamp, num2)) { break; } } HitchProbes.Note(HitchProbes.Id.EffectPin, timestamp); } LoadingProgress.Set("Effect prefabs", pinCursor, num, pinCursor < num); ConfigEntry<bool>? obj2 = warmShaders; if (obj2 != null && obj2.Value && shaderCursor < num && (isLoading || !flag)) { WarmShaderStep(num, isLoading); } if (isLoading) { return; } Run instance = Run.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } if ((Object)(object)observedRun != (Object)(object)instance) { observedRun = instance; Array.Clear(peakInUse, 0, peakInUse.Length); Array.Clear(warmed, 0, warmed.Length); warmQueue.Clear(); Array.Clear(queued, 0, queued.Length); } int count = warmQueue.Count; if (count == 0) { PublishCopyProgress(0); return; } bool flag2 = Time.unscaledTime - sceneReadyTime < 15f; if (flag) { PublishCopyProgress(count); return; } bool flag3 = CharacterBody.readOnlyInstancesList.Count > 1; bool flag4 = unscaledDeltaTime <= 0.012f; bool num5 = Time.unscaledTime - lastWarmTime < 0.5f; bool flag5 = !flag2 && flag3; if (num5 && (flag5 || !flag4)) { PublishCopyProgress(count); return; } int effectWarmsPerFrame = WarmPaceSettings.EffectWarmsPerFrame; int num6 = 0; int num7 = count; long timestamp2 = Stopwatch.GetTimestamp(); int num8 = 0; while (num7-- > 0 && warmQueue.Count > 0 && num6 < effectWarmsPerFrame) { int num9 = warmQueue.Dequeue(); num8++; if (num9 < queued.Length) { queued[num9] = false; if (TryWarm(num9)) { num6++; lastWarmTime = Time.unscaledTime; } else if (!settled[num9] && warmed[num9] < PeakTarget(num9)) { EnqueueWarm(num9); } } } if (num8 > 0) { HitchProbes.Note(HitchProbes.Id.EffectWarm, timestamp2); } PublishCopyProgress(warmQueue.Count); } private static void PublishCopyProgress(int waiting) { int num = warmedPrefabs; int total = warmedPrefabs + waiting; if (num < 0) { num = 0; } LoadingProgress.Set("Effect copies", num, total, waiting > 0); } private static void MaybeLogStatus() { ConfigEntry<bool>? obj = logStatus; if (obj == null || !obj.Value) { nextLogTime = 0f; return; } float unscaledTime = Time.unscaledTime; if (nextLogTime == 0f || !(unscaledTime < nextLogTime)) { nextLogTime = unscaledTime + 1f; LogStatus(); } } private void LateUpdate() { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Run.instance)) { ConfigEntry<bool>? obj = cullSecondary; if (obj != null && obj.Value) { cullWasEnabled = true; int num = Clamp(cullInterval?.Value ?? 4, 1, 30); frame++; if (frame % num != 0) { return; } if (!Object.op_Implicit((Object)(object)gameplayCamera)) { gameplayCamera = Camera.main; } long started = (HitchProbes.Armed ? Stopwatch.GetTimestamp() : 0); Camera val = gameplayCamera; if (!Object.op_Implicit((Object)(object)val)) { HitchProbes.Note(HitchProbes.Id.EffectCull, started); return; } float num2 = Mathf.Max(5f, cullDistance?.Value ?? 55f); float stopSqr = num2 * num2; float num3 = num2 * 0.75f; float resumeSqr = num3 * num3; bool offScreen = cullOffScreen?.Value ?? false; frustumReady = false; Vector3 position = ((Component)val).transform.position; ReadOnlyCollection<VFXAttributes> readonlyVFXList = VFXAttributes.readonlyVFXList; for (int i = 0; i < readonlyVFXList.Count; i++) { VFXAttributes val2 = readonlyVFXList[i]; if (Object.op_Implicit((Object)(object)val2)) { Consider(val2, position, stopSqr, resumeSqr, offScreen); } } HitchProbes.Note(HitchProbes.Id.EffectCull, started); return; } } if (cullWasEnabled || culledEffects > 0) { ResumeAll(); cullWasEnabled = false; } } private void OnGUI() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0061: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<bool>? obj = showShaderStatus; if (obj != null && obj.Value) { if (Time.unscaledTime - shaderStatusRefresh >= 0.5f) { shaderStatusRefresh = Time.unscaledTime; RefreshShaderStatus(); } if (shaderStyle == null) { shaderStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = true }; } shaderStyle.normal.textColor = Color.white; float num = 740f; GUI.Label(new Rect((float)Screen.width - num - 16f, 16f + LoadingProgressView.BlockHeight, num, 250f), shaderStatusText, shaderStyle); } ConfigEntry<bool>? obj2 = showStatus; if (obj2 != null && obj2.Value) { if (Time.unscaledTime - lastStatusRefresh >= 0.5f) { lastStatusRefresh = Time.unscaledTime; RefreshStatus(); } if (statusStyle == null) { statusStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = false }; statusStyle.normal.textColor = Color.white; } GUI.Label(new Rect(16f, 16f + LoadingProgressView.BlockHeight, 720f, 180f), statusText, statusStyle); } } private static int EnsureCatalog() { int effectCount = EffectCatalog.effectCount; if (effectCount == handles.Length && effectCount == directPins.Length) { return effectCount; } ReleaseDirectPins(); handles = new AsyncOperationHandle<GameObject>[effectCount]; directPins = new bool[effectCount]; addresses = new AssetReferenceT<GameObject>[effectCount]; prefabs = (GameObject?[])(object)new GameObject[effectCount]; warmed = new byte[effectCount]; settled = new bool[effectCount]; peakInUse = new int[effectCount]; queued = new bool[effectCount]; warmQueue.Clear(); pinCursor = 0; warmedPrefabs = 0; instancesBuilt = 0; ForgetShaderWarmup(releaseHolds: true); shaderHeld = new bool[effectCount]; return effectCount; } private static bool Pin(int index) { if (settled[index] || Object.op_Implicit((Object)(object)prefabs[index]) || handles[index].IsValid()) { return true; } AssetReferenceT<GameObject> val = addresses[index]; if (val != null) { return StartPin(index, val); } EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)index); if (effectDef == null) { settled[index] = true; return true; } AssetOrDirectReference<GameObject> val2 = EffectPools.PrefabReference(effectDef); if (val2 == null) { settled[index] = true; return true; } AssetReferenceT<GameObject> address = val2.address; if (address != null && ((AssetReference)address).RuntimeKeyIsValid()) { addresses[index] = address; return StartPin(index, address); } if (Object.op_Implicit((Object)(object)val2.directRef)) { prefabs[index] = val2.directRef; return true; } settled[index] = true; return true; } private static bool StartPin(int index, AssetReferenceT<GameObject> address) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) if (!LoadingPhase.IsLoading) { handles[index] = EffectPools.PinAddress(address); return true; } try { AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)address); if (!val.IsValid()) { return false; } handles[index] = val; directPins[index] = true; return true; } catch (Exception ex) { if (!directPinFailed) { directPinFailed = true; ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Effect prefab load did not start: " + ex.Message)); } } return false; } } private static void OnRunDestroy(Run run) { int num = ReleaseDirectPins(); if (num >= 0 && num < pinCursor) { pinCursor = num; } } private static int ReleaseDirectPins() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) int num = -1; int num2 = ((directPins.Length < handles.Length) ? directPins.Length : handles.Length); for (int i = 0; i < num2; i++) { if (directPins[i]) { directPins[i] = false; AsyncOperationHandle<GameObject> val = handles[i]; handles[i] = default(AsyncOperationHandle<GameObject>); if (val.IsValid()) { Addressables.Release<GameObject>(val); } if (num < 0) { num = i; } } } return num; } private static void WarmShaderStep(int count, bool rush) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (ShadersWereEvicted()) { ForgetShaderWarmup(releaseHolds: true); shaderHeld = new bool[count]; } long timestamp = Stopwatch.GetTimestamp(); int num = 0; while (shaderCursor < count) { EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)shaderCursor); if (effectDef == null || !effectDef.shouldPool) { shaderCursor++; continue; } GameObject val = prefabs[shaderCursor]; if (!Object.op_Implicit((Object)(object)val)) { AsyncOperationHandle<GameObject> val2 = handles[shaderCursor]; if (!val2.IsValid()) { if (shaderCursor >= pinCursor) { break; } shaderCursor++; continue; } if (!val2.IsDone) { break; } val = val2.Result; prefabs[shaderCursor] = val; } int index = shaderCursor; shaderCursor++; num++; if (Object.op_Implicit((Object)(object)val)) { RenderPrefabShaders(val, index); } if (rush) { if (!LoadingPhase.BudgetExpired(timestamp, num)) { continue; } break; } float num2 = (float)((double)(Stopwatch.GetTimestamp() - timestamp) * 1000.0 / (double)Stopwatch.Frequency); if (num >= WarmPaceSettings.ShaderPrefabsPerFrame || num2 > 3f) { break; } } if (!rush) { float num3 = (float)((double)(Stopwatch.GetTimestamp() - timestamp) * 1000.0 / (double)Stopwatch.Frequency); if (num3 > 3f) { float num4 = num3 * 0.008f; warmNotBefore = Time.unscaledTime + ((num4 > 1f) ? 1f : num4); } } LoadingProgress.Set("Effect shaders", shaderCursor, count, shaderCursor < count); } private static bool ShadersWereEvicted() { for (int i = 0; i < pinnedShaders.Count; i++) { if (!Object.op_Implicit((Object)(object)pinnedShaders[i])) { return true; } } return false; } private static void ForgetShaderWarmup(bool releaseHolds) { if (releaseHolds) { ReleaseShaderHolds(); } pinnedShaders.Clear(); shaderTraceLines.Clear(); drawMaterials.Clear(); shaderCursor = 0; shaderWarmCalls = 0; shaderSlowRenders = 0; shaderWarmMicroseconds = 0L; } private static void HoldPrefab(int index) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= shaderHeld.Length || shaderHeld[index]) { return; } AssetReferenceT<GameObject> val = addresses[index]; if (val != null && ((AssetReference)val).RuntimeKeyIsValid()) { try { AsyncOperationHandle<GameObject> item = Addressables.LoadAssetAsync<GameObject>((object)val); if (item.IsValid()) { shaderHolds.Add(item); shaderHeld[index] = true; } return; } catch (Exception ex) { ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Effect shader hold did not start: " + ex.Message)); } return; } } GameObject val2 = prefabs[index]; if (Object.op_Implicit((Object)(object)val2)) { shaderHoldPrefabs.Add(val2); shaderHeld[index] = true; } } private static void ReleaseShaderHolds() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < shaderHolds.Count; i++) { AsyncOperationHandle<GameObject> val = shaderHolds[i]; if (val.IsValid()) { Addressables.Release<GameObject>(val); } } shaderHolds.Clear(); shaderHoldPrefabs.Clear(); if (shaderHeld.Length != 0) { Array.Clear(shaderHeld, 0, shaderHeld.Length); } ReleaseRig(); } private static void PushTraceLine(string line) { shaderTraceLines.Insert(0, line); if (shaderTraceLines.Count > 6) { shaderTraceLines.RemoveAt(6); } } private static void RenderPrefabShaders(GameObject prefab, int index) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (!EnsureRig() || (Object)(object)warmRoot == (Object)null || (Object)(object)warmCamera == (Object)null || (Object)(object)warmMesh == (Object)null) { return; } GameObject val = null; try { val = Object.Instantiate<GameObject>(prefab, warmRoot); ((Object)val).name = ((Object)prefab).name; SilenceWarmCopy(val); ApplyOmni(val); SetWarmLayer(val.transform); MatchGameCamera(); ((Component)warmRoot).gameObject.SetActive(true); EnableVisibleRenderers(val); SimulateParticles(val); CollectForceDraws(val); if (NoteRenderedShaders(val, index) || drawMaterials.Count != 0) { Vector3 warmSpot = WarmSpot; for (int i = 0; i < drawMaterials.Count; i++) { Graphics.DrawMesh(warmMesh, warmSpot, Quaternion.identity, drawMaterials[i], 31, warmCamera); } long timestamp = Stopwatch.GetTimestamp(); warmCamera.Render(); int num = (int)((double)(Stopwatch.GetTimestamp() - timestamp) * 1000000.0 / (double)Stopwatch.Frequency); shaderWarmCalls++; shaderWarmMicroseconds += num; if (num >= 1000) { shaderSlowRenders++; PushTraceLine(((Object)prefab).name + " " + ((double)num / 1000.0).ToString("0.0", CultureInfo.InvariantCulture) + " мс"); } } } catch (Exception ex) { ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Effect shader render did not finish for " + ((Object)prefab).name + ": " + ex.Message)); } } finally { if ((Object)(object)warmRoot != (Object)null) { ((Component)warmRoot).gameObject.SetActive(false); } if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } private static bool EnsureRig() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)warmCamera != (Object)null && (Object)(object)warmTarget != (Object)null && (Object)(object)warmMesh != (Object)null && (Object)(object)warmRoot != (Object)null && (Object)(object)runtime != (Object)null) { return true; } ReleaseRig(); if ((Object)(object)runtime == (Object)null) { return false; } GameObject val = new GameObject("roro-shader-warm"); val.transform.SetParent(((Component)runtime).transform, false); val.transform.position = WarmSpot; val.SetActive(false); warmRoot = val.transform; GameObject val2 = new GameObject("roro-shader-warm-camera"); val2.transform.SetParent(((Component)runtime).transform, false); val2.transform.position = WarmSpot + new Vector3(0f, 0f, -8f); val2.transform.rotation = Quaternion.identity; Camera obj = val2.AddComponent<Camera>(); ((Behaviour)obj).enabled = false; obj.clearFlags = (CameraClearFlags)2; obj.backgroundColor = Color.black; obj.cullingMask = int.MinValue; obj.orthographic = true; obj.orthographicSize = 40f; obj.nearClipPlane = 0.01f; obj.farClipPlane = 80f; obj.depthTextureMode = (DepthTextureMode)1; warmTarget = new RenderTexture(4, 4, 16); obj.targetTexture = warmTarget; warmCamera = obj; Mesh val3 = new Mesh { name = "roro-shader-warm-quad" }; val3.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f), new Vector3(0.5f, 0.5f, 0f) }; val3.triangles = new int[6] { 0, 2, 1, 2, 3, 1 }; val3.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }; warmMesh = val3; return true; } private static void ReleaseRig() { if ((Object)(object)warmCamera != (Object)null) { Object.Destroy((Object)(object)((Component)warmCamera).gameObject); } if ((Object)(object)warmRoot != (Object)null) { Object.Destroy((Object)(object)((Component)warmRoot).gameObject); } if ((Object)(object)warmTarget != (Object)null) { Object.Destroy((Object)(object)warmTarget); } if ((Object)(object)warmMesh != (Object)null) { Object.Destroy((Object)(object)warmMesh); } warmCamera = null; warmRoot = null; warmTarget = null; warmMesh = null; } private static void MatchGameCamera() { //IL_001e: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0031: 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_002a: Invalid comparison between Unknown and I4 if ((Object)(object)warmCamera == (Object)null) { return; } Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { RenderingPath actualRenderingPath = main.actualRenderingPath; if ((int)actualRenderingPath == 3 || (int)actualRenderingPath == 1) { warmCamera.renderingPath = actualRenderingPath; } warmCamera.allowHDR = main.allowHDR; } } private static void SilenceWarmCopy(GameObject copy) { MonoBehaviour[] componentsInChildren = copy.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = false; } } AudioSource[] componentsInChildren2 = copy.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val2 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val2)) { val2.playOnAwake = false; ((Behaviour)val2).enabled = false; } } Light[] componentsInChildren3 = copy.GetComponentsInChildren<Light>(true); foreach (Light val3 in componentsInChildren3) { if (Object.op_Implicit((Object)(object)val3)) { ((Behaviour)val3).enabled = false; } } } private static void ApplyOmni(GameObject copy) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) OmniEffect[] componentsInChildren = copy.GetComponentsInChildren<OmniEffect>(true); foreach (OmniEffect val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } float x = ((Component)val).transform.localScale.x; OmniEffectGroup[] omniEffectGroups = val.omniEffectGroups; if (omniEffectGroups == null) { continue; } for (int j = 0; j < omniEffectGroups.Length; j++) { OmniEffectElement[] omniEffectElements = omniEffectGroups[j].omniEffectElements; if (omniEffectElements == null) { continue; } foreach (OmniEffectElement val2 in omniEffectElements) { if (val2 != null && !(val2.maximumValidRadius < x)) { ApplyOmniElement(val2); break; } } } } } private static void ApplyOmniElement(OmniEffectElement element) { ParticleSystem particleSystem = element.particleSystem; if (Object.op_Implicit((Object)(object)particleSystem)) { ParticleSystemRenderer val = default(ParticleSystemRenderer); if (Object.op_Implicit((Object)(object)element.particleSystemOverrideMaterial) && ((Component)particleSystem).TryGetComponent<ParticleSystemRenderer>(ref val) && Object.op_Implicit((Object)(object)val)) { ((Renderer)val).sharedMaterial = element.particleSystemOverrideMaterial; } ((Component)particleSystem).gameObject.SetActive(element.particleSystemEmitParticles); } } private static void SetWarmLayer(Transform transform) { ((Component)transform).gameObject.layer = 31; for (int i = 0; i < transform.childCount; i++) { SetWarmLayer(transform.GetChild(i)); } } private static void EnableVisibleRenderers(GameObject copy) { Renderer[] componentsInChildren = copy.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy) { val.enabled = true; } } } private static void SimulateParticles(GameObject copy) { ParticleSystem[] componentsInChildren = copy.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy) { try { val.Simulate(0.05f, false, true, false); } catch (Exception) { } } } } private static void CollectForceDraws(GameObject copy) { drawMaterials.Clear(); Renderer[] componentsInChildren = copy.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } ParticleSystemRenderer val2 = (ParticleSystemRenderer)(object)((val is ParticleSystemRenderer) ? val : null); if (val2 != null) { ParticleSystem component = ((Component)val2).GetComponent<ParticleSystem>(); if (!Object.op_Implicit((Object)(object)component) || !((Component)component).gameObject.activeInHierarchy || component.particleCount <= 0) { AddDraw(((Renderer)val2).sharedMaterial); } Material trailMaterial = val2.trailMaterial; Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; if (Object.op_Implicit((Object)(object)trailMaterial) && (sharedMaterials == null || !MaterialsContain(sharedMaterials, trailMaterial))) { AddDraw(trailMaterial); } } else { if (!(val is LineRenderer) && !(val is TrailRenderer) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { continue; } Material[] sharedMaterials2 = val.sharedMaterials; if (sharedMaterials2 != null) { for (int j = 0; j < sharedMaterials2.Length; j++) { AddDraw(sharedMaterials2[j]); } } } } OmniEffect[] componentsInChildren2 = copy.GetComponentsInChildren<OmniEffect>(true); for (int k = 0; k < componentsInChildren2.Length; k++) { OmniEffectGroup[] omniEffectGroups = componentsInChildren2[k].omniEffectGroups; if (omniEffectGroups == null) { continue; } for (int l = 0; l < omniEffectGroups.Length; l++) { OmniEffectElement[] omniEffectElements = omniEffectGroups[l].omniEffectElements; if (omniEffectElements == null) { continue; } foreach (OmniEffectElement val3 in omniEffectElements) { if (val3 != null) { AddDraw(val3.particleSystemOverrideMaterial); } } } } AssignRandomMaterial[] componentsInChildren3 = copy.GetComponentsInChildren<AssignRandomMaterial>(true); for (int n = 0; n < componentsInChildren3.Length; n++) { Material[] materials = componentsInChildren3[n].materials; if (materials != null) { for (int num = 0; num < materials.Length; num++) { AddDraw(materials[num]); } } } } private static void AddDraw(Material? material) { if (!Object.op_Implicit((Object)(object)material) || !Object.op_Implicit((Object)(object)material.shader)) { return; } for (int i = 0; i < drawMaterials.Count; i++) { if ((Object)(object)drawMaterials[i] == (Object)(object)material) { return; } } drawMaterials.Add(material); } private static bool MaterialsContain(Material[] materials, Material trail) { for (int i = 0; i < materials.Length; i++) { if ((Object)(object)materials[i] == (Object)(object)trail) { return true; } } return false; } private static bool NoteRenderedShaders(GameObject copy, int index) { bool flag = false; Renderer[] componentsInChildren = copy.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials != null) { for (int j = 0; j < sharedMaterials.Length; j++) { flag |= NoteMaterialShader(sharedMaterials[j], index); } ParticleSystemRenderer val2 = (ParticleSystemRenderer)(object)((val is ParticleSystemRenderer) ? val : null); if (val2 != null) { flag |= NoteMaterialShader(val2.trailMaterial, index); } } } for (int k = 0; k < drawMaterials.Count; k++) { flag |= NoteMaterialShader(drawMaterials[k], index); } return flag; } private static bool NoteMaterialShader(Material? material, int index) { if (!Object.op_Implicit((Object)(object)material) || !Object.op_Implicit((Object)(object)material.shader)) { return false; } if (!RememberShader(material.shader)) { return true; } HoldPrefab(index); return true; } private static bool RememberShader(Shader shader) { int instanceID = ((Object)shader).GetInstanceID(); for (int i = 0; i < pinnedShaders.Count; i++) { Shader val = pinnedShaders[i]; if (Object.op_Implicit((Object)(object)val) && ((Object)val).GetInstanceID() == instanceID) { return false; } } pinnedShaders.Add(shader); return true; } private static bool TryWarm(int index) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if (settled[index]) { return false; } int num = PeakTarget(index); if (num == 0) { return false; } GameObject val = prefabs[index]; if (!Object.op_Implicit((Object)(object)val)) { AsyncOperationHandle<GameObject> val2 = handles[index]; if (!val2.IsValid()) { if (index < pinCursor) { settled[index] = true; } return false; } if (!val2.IsDone) { return false; } val = val2.Result; if (!Object.op_Implicit((Object)(object)val)) { settled[index] = true; return false; } prefabs[index] = val; } if (warmed[index] >= num) { return false; } EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)index); if (effectDef == null || !effectDef.shouldPool || !EffectManager.UsePools) { settled[index] = true; return false; } string name = ((Object)val).name; int num2 = EffectPools.PoolIdleCount(val); if (num2 >= num) { if (warmed[index] == 0) { warmedPrefabs++; } warmed[index] = (byte)num; return false; } int num3 = num - num2; int num4 = EffectPools.PoolTotalCount(val); int checkoutCountBefore = EffectPools.CheckoutCount(val); bool activeSelf = val.activeSelf; bool flag = false; heldHelpers.Clear(); long timestamp = Stopwatch.GetTimestamp(); try { if (activeSelf) { val.SetActive(false); } flag = true; for (int i = 0; i < num3; i++) { EffectManagerHelper pooledEffect = EffectManager.GetPooledEffect(val, Park, Quaternion.identity); if (!Object.op_Implicit((Object)(object)pooledEffect)) { settled[index] = true; ReturnHeld(name); return false; } heldHelpers.Add(pooledEffect); } } catch (Exception ex) { settled[index] = true; ReturnHeld(name); if (flag) { EffectPools.DiscardCheckoutGrowth(val, checkoutCountBefore); } ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Effect warmup skipped " + name + ": " + ex.Message)); } return false; } finally { if (activeSelf && Object.op_Implicit((Object)(object)val)) { val.SetActive(true); } } int num5 = EffectPools.PoolTotalCount(val) - num4; if (num5 < 0) { num5 = 0; } if (!ReturnHeld(name)) { settled[index] = true; return false; } if (warmed[index] == 0) { warmedPrefabs++; } warmed[index] = (byte)num; instancesBuilt += num5; float num6 = (float)((double)(Stopwatch.GetTimestamp() - timestamp) * 1000.0 / (double)Stopwatch.Frequency); if (num6 > 3f) { float num7 = num6 * 0.008f; warmNotBefore = Time.unscaledTime + ((num7 > 1f) ? 1f : num7); } return true; } private static bool ReturnHeld(string prefabName) { bool result = true; for (int i = 0; i < heldHelpers.Count; i++) { EffectManagerHelper val = heldHelpers[i]; try { val.ReturnToPool(); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(false); } EffectPools.Discard(val); result = false; ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Effect warmup could not park " + prefabName + ": " + ex.Message)); } } } heldHelpers.Clear(); return result; } private static int PeakCap() { ConfigEntry<bool>? obj = warmFullPeak; if (obj != null && obj.Value) { return 20; } return Clamp(warmPeakCopies?.Value ?? 4, 0, 20); } private static int PeakTarget(int index) { int num = PeakCap(); int num2 = ((index >= 0 && index < peakInUse.Length) ? peakInUse[index] : 0); if (num2 >= num) { return num; } return num2; } private static void Consider(VFXAttributes attributes, Vector3 cameraPosition, float stopSqr, float resumeSqr, bool offScreen) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] secondaryParticleSystem = attributes.secondaryParticleSystem; Light[] optionalLights = attributes.optionalLights; bool num = secondaryParticleSystem != null && secondaryParticleSystem.Length != 0; bool flag = optionalLights != null && optionalLights.Length != 0; if (!num && !flag) { return; } if (!gates.TryGetValue(attributes, out EffectCullState value) || value == null) { value = new EffectCullState(); gates[attributes] = value; } Vector3 val = ((Component)attributes).transform.position - cameraPosition; bool num2 = ((Vector3)(ref val)).sqrMagnitude > (value.secondaryStopped ? resumeSqr : stopSqr); bool flag2 = false; if (!num2 && offScreen) { if (!frustumReady) { Camera val2 = gameplayCamera; if (Object.op_Implicit((Object)(object)val2)) { GeometryUtility.CalculateFrustumPlanes(val2, Frustum); frustumReady = true; } } if (frustumReady) { flag2 = !GeometryUtility.TestPlanesAABB(Frustum, new Bounds(((Component)attributes).transform.position, CullBounds)); } } bool flag3 = num2 || flag2; if (flag3 == value.secondaryStopped) { return; } if (flag3) { StopSecondary(secondaryParticleSystem, optionalLights, value); value.secondaryStopped = true; culledEffects++; return; } PlaySecondary(secondaryParticleSystem, optionalLights, value); value.secondaryStopped = false; if (culledEffects > 0) { culledEffects--; } } private static void StopSecondary(ParticleSystem[]? systems, Light[]? lights, EffectCullState gate) { if (systems != null) { foreach (ParticleSystem val in systems) { if (Object.op_Implicit((Object)(object)val)) { val.Stop(false, (ParticleSystemStopBehavior)0); } } } if (lights == null) { return; } if (gate.lightWasEnabled == null || gate.lightWasEnabled.Length != lights.Length) { gate.lightWasEnabled = new bool[lights.Length]; } for (int j = 0; j < lights.Length; j++) { Light val2 = lights[j]; if (Object.op_Implicit((Object)(object)val2)) { gate.lightWasEnabled[j] = ((Behaviour)val2).enabled; ((Behaviour)val2).enabled = false; } } } private static void PlaySecondary(ParticleSystem[]? systems, Light[]? lights, EffectCullState gate) { if (systems != null) { foreach (ParticleSystem val in systems) { if (Object.op_Implicit((Object)(object)val)) { val.Play(false); } } } RestoreLights(lights, gate); } private static void RestoreLights(Light[]? lights, EffectCullState gate) { if (lights == null || gate.lightWasEnabled == null) { return; } int num = ((lights.Length < gate.lightWasEnabled.Length) ? lights.Length : gate.lightWasEnabled.Length); for (int i = 0; i < num; i++) { Light val = lights[i]; if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = gate.lightWasEnabled[i]; } } } private static void ResumeAll() { foreach (KeyValuePair<VFXAttributes, EffectCullState> gate in gates) { EffectCullState value = gate.Value; VFXAttributes key = gate.Key; if (value != null && value.secondaryStopped && Object.op_Implicit((Object)(object)key)) { PlaySecondary(key.secondaryParticleSystem, key.optionalLights, value); value.secondaryStopped = false; } } culledEffects = 0; } private static void RefreshStatus() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 int num = 0; int num2 = 0; for (int i = 0; i < handles.Length; i++) { if (Object.op_Implicit((Object)(object)prefabs[i]) || handles[i].IsValid()) { num2++; } if (Object.op_Implicit((Object)(object)prefabs[i]) || (handles[i].IsValid() && (int)handles[i].Status == 1)) { num++; } } EffectPools.CountPools(out var pools, out var idle, out var inUse); int value = PeakCap(); statusBuilder.Clear(); statusBuilder.Append("Effects ").Append(handles.Length); statusBuilder.Append("\nPinned ").Append(num2).Append(" loaded ") .Append(num); statusBuilder.Append("\nWarmed prefabs ").Append(warmedPrefabs).Append(" copies built ") .Append(instancesBuilt) .Append(" peak cap ") .Append(value) .Append(" queued ") .Append(warmQueue.Count); statusBuilder.Append("\nPools ").Append(pools).Append(" idle ") .Append(idle) .Append(" in use ") .Append(inUse); statusBuilder.Append("\nLive ").Append(VFXAttributes.readonlyVFXList.Count).Append(" secondary culled ") .Append(culledEffects); EffectPools.AppendParkReport(statusBuilder); statusText = statusBuilder.ToString(); } private static void RefreshShaderStatus() { int num = 0; for (int i = 0; i < pinnedShaders.Count; i++) { if (Object.op_Implicit((Object)(object)pinnedShaders[i])) { num++; } } statusBuilder.Clear(); StringBuilder stringBuilder = statusBuilder; ConfigEntry<bool>? obj = warmShaders; stringBuilder.Append((obj != null && obj.Value) ? "Шейдеры эффектов: скрытый рендер включён" : "Шейдеры эффектов: скрытый рендер выключен"); statusBuilder.Append("\nКурсор ").Append(shaderCursor).Append('/') .Append(prefabs.Length); statusBuilder.Append(" Camera.Render ").Append(shaderWarmCalls); statusBuilder.Append(", дольше 1 мс: ").Append(shaderSlowRenders); statusBuilder.Append(", сумма "); AppendMicros(statusBuilder, shaderWarmMicroseconds); statusBuilder.Append("\nЖивые шейдеры ").Append(num).Append('/') .Append(pinnedShaders.Count); statusBuilder.Append(" удержано префабов ").Append(shaderHolds.Count + shaderHoldPrefabs.Count); statusBuilder.Append("\nДольше 1 мс — драйвер собирал программу в этом вызове. Короче — этот draw её не собирал."); statusBuilder.Append("\nРелизный DX11 не пишет Shader.CreateGPUProgram."); EffectPools.AppendParkReport(statusBuilder); for (int j = 0; j < shaderTraceLines.Count; j++) { statusBuilder.Append('\n').Append(shaderTraceLines[j]); } shaderStatusText = statusBuilder.ToString(); } private static void AppendMicros(StringBuilder builder, long microseconds) { if (microseconds >= 1000) { builder.Append(((double)microseconds / 1000.0).ToString("0.0", CultureInfo.InvariantCulture)); builder.Append(" мс"); } else { builder.Append(microseconds); builder.Append(" мкс"); } } private static int Clamp(int value, int min, int max) { if (value < min) { return min; } if (value <= max) { return value; } return max; } } internal sealed class EffectCullState { internal bool secondaryStopped; internal bool[]? lightWasEnabled; } internal sealed class FrameTimeGraph : MonoBehaviour { private struct Sample { public float Ms; public bool Gpu; } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct FrameTimeFrameBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct FrameTimePresentEnd { } private const int Capacity = 160; private const float BarWidth = 3f; private const float BarGap = 1f; private const float PlotHeight = 86f; private const float PanelPad = 8f; private const float HeaderHeight = 20f; private const float LegendHeight = 16f; private const float WaitFloorMs = 1f; private const float ScaleCapMs = 100f; private static readonly Color Cool = new Color(0.2f, 0.78f, 0.34f, 1f); private static readonly Color Warm = new Color(0.96f, 0.78f, 0.16f, 1f); private static readonly Color Hot = new Color(0.92f, 0.22f, 0.16f, 1f); private static readonly Color GpuBound = new Color(0.25f, 0.52f, 1f, 1f); private static readonly Color Panel = new Color(0f, 0f, 0f, 0.62f); private static readonly Color Plot = new Color(0.05f, 0.06f, 0.07f, 0.9f); private static readonly Color Line = new Color(1f, 1f, 1f, 0.55f); private static readonly Sample[] samples = new Sample[160]; private static readonly float[] order = new float[160]; private static readonly StringBuilder headerBuilder = new StringBuilder(64); private static ConfigEntry<bool>? show; private static Texture2D? pixel; private static GUIStyle? headerStyle; private static GUIStyle? legendStyle; private static GUIStyle? scaleStyle; private static bool visible; private static bool hooked; private static bool hookLogged; private static int hookAttempts; private static double presentStamp; private static int write; private static int count; private static int refreshHz = 60; private static int statsFrame = -1; private static int headerFrame = -1; private static int shownHz = -1; private static int shownScaleMs = -1; private static float statLatest; private static float statAvg; private static float statP99; private static float statPeak; private static bool statGpu; private static string headerText = ""; private static string refreshText = "60 Hz"; private static string scaleText = ""; internal static ConfigEntry<bool>? ShowEntry => show; internal static void Bind(ConfigFile config) { show = config.Bind<bool>("General", "Show Frame Time", false, OptionCopy.FrameGraph); } private void Update() { //IL_001e: 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) visible = show?.Value ?? false; if (visible) { Resolution currentResolution = Screen.currentResolution; int refreshRate = ((Resolution)(ref currentResolution)).refreshRate; refreshHz = ((refreshRate < 30) ? 60 : refreshRate); if (!hooked && hookAttempts < 8) { hookAttempts++; hooked = Install(); } } } private void OnDestroy() { visible = false; if (hooked) { Remove(); hooked = false; } } private void OnGUI() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<bool>? obj = show; if (obj != null && obj.Value && (int)Event.current.type == 7) { EnsureStats(); BuildHeader(); EnsureStyles(); float num = 639f; float num2 = num + 16f; float num3 = 138f; float num4 = (float)Screen.width - num2 - 16f; float num5 = 16f + LoadingProgressView.BlockHeight; if (EffectRuntime.ShowShaderStatus) { num5 += 258f; } Rect rect = default(Rect); ((Rect)(ref rect))..ctor(num4, num5, num2, num3); Fill(rect, Panel); GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 4f, num, 20f), headerText, headerStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f + 20f, num, 86f); Fill(val, Plot); float num6 = 1000f / (float)refreshHz; float num7 = ((statPeak > num6 * 2f) ? statPeak : (num6 * 2f)); if (count > 0) { DrawBars(val, num7); } float num8 = ((Rect)(ref val)).yMax - ((Rect)(ref val)).height * (num6 / num7); Fill(new Rect(((Rect)(ref val)).x, num8, ((Rect)(ref val)).width, 1f), Line); RememberRefresh(refreshHz); RememberScale(num7); GUI.Label(new Rect(((Rect)(ref val)).xMax - 64f, num8 - 14f, 62f, 14f), refreshText, scaleStyle); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 64f, 14f), scaleText, legendStyle); float num9 = ((Rect)(ref val)).yMax + 4f; Fill(new Rect(((Rect)(ref rect)).x + 8f, num9 + 2f, 10f, 10f), GpuBound); GUI.Label(new Rect(((Rect)(ref rect)).x + 8f + 14f, num9 - 2f, 48f, 16f), "GPU", legendStyle); } } private static void DrawBars(Rect plot, float scale) { //IL_00c0: 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) int num = count; float num2 = 4f; float num3 = ((Rect)(ref plot)).xMax - (float)num * num2 + 1f; int num4 = ((num == 160) ? write : 0); float refreshMs = 1000f / (float)refreshHz; for (int i = 0; i < num; i++) { Sample sample = samples[(num4 + i) % 160]; float num5 = ((sample.Ms > 100f) ? 100f : sample.Ms); float num6 = ((Rect)(ref plot)).height * (num5 / scale); if (num6 < 1f) { num6 = 1f; } else if (num6 > ((Rect)(ref plot)).height) { num6 = ((Rect)(ref plot)).height; } Fill(new Rect(num3, ((Rect)(ref plot)).yMax - num6, 3f, num6), BarColor(sample.Ms, refreshMs, sample.Gpu)); num3 += num2; } } private static void EnsureStats() { if (statsFrame == Time.frameCount) { return; } statsFrame = Time.frameCount; int num = count; if (num <= 0) { statLatest = 0f; statAvg = 0f; statP99 = 0f; statPeak = 0f; statGpu = false; return; } int num2 = ((num == 160) ? write : 0); float num3 = 0f; float num4 = 0f; for (int i = 0; i < num; i++) { float ms = samples[(num2 + i) % 160].Ms; order[i] = ms; num3 += ms; float num5 = ((ms > 100f) ? 100f : ms); if (num5 > num4) { num4 = num5; } } Array.Sort(order, 0, num); int num6 = (int)Math.Ceiling((double)num * 0.99) - 1; if (num6 < 0) { num6 = 0; } else if (num6 >= num) { num6 = num - 1; } int num7 = (write + 160 - 1) % 160; statLatest = samples[num7].Ms; statGpu = samples[num7].Gpu; statAvg = num3 / (float)num; statP99 = order[num6]; statPeak = num4; } private static void BuildHeader() { if (headerFrame != Time.frameCount) { headerFrame = Time.frameCount; int value = ((statLatest > 0.05f) ? ((int)(1000f / statLatest + 0.5f)) : 0); headerBuilder.Clear(); headerBuilder.Append(value); headerBuilder.Append(" fps "); AppendTenths(statLatest); headerBuilder.Append(" ms avg "); AppendTenths(statAvg); headerBuilder.Append(" 1% "); AppendTenths(statP99); headerText = headerBuilder.ToString(); } } private static void AppendTenths(float value) { if (value < 0f) { value = 0f; } int num = (int)(value * 10f + 0.5f); headerBuilder.Append(num / 10); headerBuilder.Append('.'); headerBuilder.Append(num % 10); } private static void RememberRefresh(int hz) { if (hz != shownHz) { shownHz = hz; refreshText = hz + " Hz"; } } private static void RememberScale(float scale) { int num = (int)(scale + 0.5f); if (num != shownScaleMs) { shownScaleMs = num; scaleText = num + " ms"; } } private static Color BarColor(float frameMs, float refreshMs, bool gpu) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (gpu) { return GpuBound; } float num = ((refreshMs > 0.01f) ? (refreshMs * 2f) : 1f); float num2 = (frameMs - refreshMs) / num; if (num2 <= 0f) { return Cool; } if (num2 >= 1f) { return Hot; } if (num2 < 0.5f) { return Color.Lerp(Cool, Warm, num2 * 2f); } return Color.Lerp(Warm, Hot, (num2 - 0.5f) * 2f); } private static void OnPresentEnd() { presentStamp = Time.realtimeSinceStartupAsDouble; } private static void OnFrameBegin() { if (!visible || presentStamp <= 0.0) { return; } float num = (float)((Time.realtimeSinceStartupAsDouble - presentStamp) * 1000.0); float num2 = Time.unscaledDeltaTime * 1000f; if (!(num2 < 0.05f) && !(num2 > 5000f)) { if (num < 0f) { num = 0f; } else if (num > num2) { num = num2; } float num3 = num2 - num; float num4 = 1000f / (float)refreshHz; samples[write].Ms = num2; samples[write].Gpu = num >= 1f && (num3 <= num4 || num >= num3); write++; if (write == 160) { write = 0; } if (count < 160) { count++; } } } private static bool Install() { //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) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); PlayerLoopSystem[] subSystemList = currentPlayerLoop.subSystemList; if (subSystemList == null) { LogHookOnce("Frame time graph found no player loop."); return false; } bool flag = false; bool flag2 = false; for (int i = 0; i < subSystemList.Length; i++) { Type type = subSystemList[i].type; if (type == typeof(EarlyUpdate)) { subSystemList[i] = Insert(subSystemList[i], typeof(FrameTimeFrameBegin), new UpdateFunction(OnFrameBegin), atEnd: false); flag = true; } else if (type == typeof(PostLateUpdate)) { subSystemList[i] = Insert(subSystemList[i], typeof(FrameTimePresentEnd), new UpdateFunction(OnPresentEnd), atEnd: true); flag2 = true; } } if (!flag || !flag2) { LogHookOnce("Frame time graph could not find EarlyUpdate and PostLateUpdate."); return false; } currentPlayerLoop.subSystemList = subSystemList; PlayerLoop.SetPlayerLoop(currentPlayerLoop); return true; } private static void Remove() { //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) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); PlayerLoopSystem[] subSystemList = currentPlayerLoop.subSystemList; if (subSystemList != null) { for (int i = 0; i < subSystemList.Length; i++) { subSystemList[i] = Strip(subSystemList[i]); } currentPlayerLoop.subSystemList = subSystemList; PlayerLoop.SetPlayerLoop(currentPlayerLoop); } } private static PlayerLoopSystem Insert(PlayerLoopSystem stage, Type marker, UpdateFunction action, bool atEnd) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0022: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) PlayerLoopSystem[] subSystemList = stage.subSystemList; if (subSystemList != null) { for (int i = 0; i < subSystemList.Length; i++) { if (subSystemList[i].type == marker) { return stage; } } } List<PlayerLoopSystem> list = new List<PlayerLoopSystem>((subSystemList == null) ? 1 : (subSystemList.Length + 1)); if (subSystemList != null) { list.AddRange(subSystemList); } PlayerLoopSystem item = new PlayerLoopSystem { type = marker, updateDelegate = action }; if (atEnd) { list.Add(item); } else { list.Insert(0, item); } stage.subSystemList = list.ToArray(); return stage; } private static PlayerLoopSystem Strip(PlayerLoopSystem node) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) PlayerLoopSystem[] subSystemList = node.subSystemList; if (subSystemList == null) { return node; } List<PlayerLoopSystem> list = new List<PlayerLoopSystem>(subSystemList.Length); for (int i = 0; i < subSystemList.Length; i++) { if (!IsMarker(subSystemList[i].type)) { list.Add(Strip(subSystemList[i])); } } node.subSystemList = list.ToArray(); return node; } private static bool IsMarker(Type? type) { if (!(type == typeof(FrameTimeFrameBegin))) { return type == typeof(FrameTimePresentEnd); } return true; } private static void LogHookOnce(string message) { if (!hookLogged) { hookLogged = true; ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)message); } } } private static void EnsureStyles() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if (headerStyle == null) { headerStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3, richText = false }; headerStyle.normal.textColor = Color.white; legendStyle = new GUIStyle(headerStyle) { fontSize = 12 }; legendStyle.normal.textColor = new Color(0.82f, 0.86f, 0.9f, 1f); scaleStyle = new GUIStyle(legendStyle) { alignment = (TextAnchor)5 }; } } private static void Fill(Rect rect, Color color) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Pixel(), (ScaleMode)0, false); GUI.color = color2; } private static Texture2D Pixel() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0037: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pixel != (Object)null) { return pixel; } pixel = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)0 }; pixel.SetPixel(0, 0, Color.white); pixel.Apply(false, true); return pixel; } } internal static class HitchProbeHooks { private static class Probe { internal static void SpherePrefix(out long __state) { Begin(out __state); } internal static Exception SphereFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SphereRefresh, __state, __exception); } internal static void SortPrefix(out long __state) { Begin(out __state); } internal static Exception SortFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SphereSort, __state, __exception); } internal static void DistinctPrefix(out long __state) { Begin(out __state); } internal static Exception DistinctFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SphereDistinct, __state, __exception); } internal static void TeamPrefix(out long __state) { Begin(out __state); } internal static Exception TeamFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SphereTeam, __state, __exception); } internal static void RadialPrefix(out long __state) { Begin(out __state); } internal static Exception RadialFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.RadialSearch, __state, __exception); } internal static void PullPrefix(out long __state) { Begin(out __state); } internal static Exception PullFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.RadialPull, __state, __exception); } internal static void WarCryPrefix(out long __state) { Begin(out __state); } internal static Exception WarCryFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.WarCry, __state, __exception); } internal static void EffectPrefix(out long __state) { Begin(out __state); } internal static Exception EffectFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SpawnEffect, __state, __exception); } internal static void AiPrefix(out long __state) { Begin(out __state); } internal static Exception AiFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.AiTick, __state, __exception); } internal static void PathPrefix(out long __state) { Begin(out __state); } internal static Exception PathFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.PathAgent, __state, __exception); } internal static void TrailPrefix(out long __state) { Begin(out __state); } internal static Exception TrailFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.SmoothTrail, __state, __exception); } internal static void UNetPrefix(out long __state) { Begin(out __state); } internal static Exception UNetFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.UNetUpdate, __state, __exception); } internal static void OrbPrefix(out long __state) { Begin(out __state); } internal static Exception OrbFinalizer(long __state, Exception __exception) { return End(HitchProbes.Id.OrbUpdate, __state, __exception); } private static void Begin(out long state) { state = (HitchProbes.Armed ? Stopwatch.GetTimestamp() : 0); } private static Exception End(HitchProbes.Id id, long state, Exception exception) { if (state != 0L) { HitchProbes.Add(id, Stopwatch.GetTimestamp() - state); } return exception; } } private static bool installed; internal static void Install(Harmony harmony) { if (!installed) { installed = true; Try(harmony, typeof(SphereSearch), "RefreshCandidates", "Sphere"); Try(harmony, typeof(SphereSearch), "OrderCandidatesByDistance", "Sort"); Try(harmony, typeof(SphereSearch), "FilterCandidatesByDistinctHurtBoxEntities", "Distinct"); Try(harmony, typeof(SphereSearch), "FilterCandidatesByHurtBoxTeam", "Team"); Try(harmony, typeof(RadialForce), "SearchForTargets", "Radial"); Try(harmony, typeof(RadialForce), "ApplyPullToHurtBox", "Pull"); Try(harmony, typeof(EquipmentSlot), "FireTeamWarCry", "WarCry"); Try(harmony, typeof(EffectManager), "SpawnEffect", "Effect", typeof(EffectIndex), typeof(EffectData), typeof(bool)); Try(harmony, typeof(BaseAI), "ManagedFixedUpdate", "Ai"); Try(harmony, typeof(NodeGraphNavigationSystem), "UpdateAgent", "Path"); Try(harmony, typeof(SmoothTrailMesh), "LateUpdate", "Trail"); Try(harmony, typeof(NetworkIdentity), "UNetUpdate", "UNet"); Try(harmony, typeof(OrbEffectSingleton), "Update", "Orb"); } } internal static void Uninstall(Harmony harmony) { if (installed) { harmony.UnpatchSelf(); installed = false; } } private static void Try(Harmony harmony, Type type, string method, string probe, params Type[] args) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00b4: Expected O, but got Unknown MethodInfo methodInfo = ((args.Length == 0) ? AccessTools.Method(type, method, (Type[])null, (Type[])null) : AccessTools.Method(type, method, args, (Type[])null)); if (methodInfo == null) { ManualLogSource? globalLogger = RORO.GlobalLogger; if (globalLogger != null) { globalLogger.LogWarning((object)("Hitch probe skipped " + type.Name + "." + method + ": method was not found.")); } } else { MethodInfo methodInfo2 = AccessTools.Method(typeof(Probe), probe + "Prefix", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(Probe), probe + "Finalizer", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo3), (HarmonyMethod)null); } } } internal static class HitchProbes { internal enum Phase { Physics, Particles, Anim, Canvas, Skin, Finish, Renderers, Present, Scene, UiCam, Count } internal enum Id { SphereRefresh, SphereSort, SphereDistinct, SphereTeam, RadialSearch, RadialPull, WarCry, SpawnEffect, AiTick, PathAgent, Prewarm, DynBone, EffectPin, EffectWarm, EffectCull, EffectPeak, ElitePin, SpawnImmunity, ProgressRings, SmoothTrail, UNetUpdate, OrbUpdate, Count } private static readonly string[] PhaseNames = new string[10] { "n.phys", "n.part", "n.anim", "n.canvas", "n.skin", "n.finish", "n.rndrs", "n.present", "n.scene", "n.uicam" }; private static readonly string[] MethodNames = new string[22] { "SphereSearch.RefreshCandidates", "SphereSearch.OrderByDistance", "SphereSearch.DistinctHurtBoxes", "SphereSearch.FilterTeam", "RadialForce.SearchForTargets", "RadialForce.ApplyPull", "EquipmentSlot.FireTeamWarCry", "EffectManager.SpawnEffect", "BaseAI.ManagedFixedUpdate", "NodeGraphNavigation.UpdateAgent", "SpawnPrewarm.PreloadAssets", "DynamicBone.LateUpdate", "EffectRuntime.Pin", "EffectRuntime.Warm", "EffectRuntime.Cull", "EffectRuntime.NoteSpawn", "SpawnPrewarm.EliteDisplays", "SpawnPrewarm.LateImmunity", "LoadingProgress.Rings", "SmoothTrailMesh.LateUpdate", "NetworkIdentity.UNetUpdate", "OrbEffectSingleton.Update" }; private static readonly long[] PhaseLive = new long[10]; private static readonly long[] MethodLive = new long[22]; private static readonly int[] CallsLive = new int[22]; private static readonly long[] PhaseFrame = new long[10]; private static readonly long[] MethodFrame = new long[22]; private static readonly int[] CallsFrame = new int[22]; private static readonly long[] PhaseWindow = new long[10]; private static readonly long[] MethodWindow = new long[22]; private static readonly int[] CallsWindow = new int[22]; private static readonly long[] PhaseHeld = new long[10]; private static readonly long[] MethodHeld = new long[22]; private static readonly int[] CallsHeld = new int[22]; internal static bool Armed { get; set; } internal static void AddPhase(Phase phase, long ticks) { if (ticks > 0) { PhaseLive[(int)phase] += ticks; } } internal static void Add(Id id, long ticks) { CallsLive[(int)id]++; if (ticks > 0) { MethodLive[(int)id] += ticks; } } internal static void Note(Id id, long started) { if (Armed && started != 0L) { Add(id, Stopwatch.GetTimestamp() - started); } } internal static void PublishFrame() { for (int i = 0; i < PhaseLive.Length; i++) { PhaseFrame[i] = PhaseLive[i]; PhaseWindow[i] += PhaseLive[i]; PhaseLive[i] = 0L; } for (int j = 0; j < MethodLive.Length; j++) { MethodFrame[j] = MethodLive[j]; CallsFrame[j] = CallsLive[j]; MethodWindow[j] += MethodLive[j]; CallsWindow[j] += CallsLive[j]; MethodLive[j] = 0L; CallsLive[j] = 0; } } internal static float PublishedPhaseMs(Phase phase) { return (float)TicksToUs(PhaseFrame[(int)phase]) / 1000f; } internal static void Hold() { Array.Copy(PhaseFrame, PhaseHeld, PhaseHeld.Length); Array.Copy(MethodFrame, MethodHeld, MethodHeld.Length); Array.Copy(CallsFrame, CallsHeld, CallsHeld.Length); } internal static void AppendHeld(StringBuilder line) { AppendPhases(line, PhaseHeld, 1); AppendMethods(line, MethodHeld, CallsHeld, 1); } internal static void AppendWindow(StringBuilder line, int frames) { if (frames <= 0) { ClearWindow(); return; } AppendPhases(line, PhaseWindow, frames); AppendMethods(line, MethodWindow, CallsWindow, frames); ClearWindow(); } private static void ClearWindow() { Array.Clear(PhaseWindow, 0, PhaseWindow.Length); Array.Clear(MethodWindow, 0, MethodWindow.Length); Array.Clear(CallsWindow, 0, CallsWindow.Length); } private static void AppendPhases(StringBuilder line, long[] ticks, int frames) { bool flag = false; for (int i = 0; i < ticks.Length; i++) { long num = TicksToUs(ticks[i]) / frames; if (num > 0) { if (flag) { line.Append(';'); } flag = true; line.Append(PhaseNames[i]); line.Append(':'); line.Append(num); } } if (flag) { line.Append('|'); } } private static void AppendMethods(StringBuilder line, long[] ticks, int[] calls, int frames) { bool flag = false; for (int i = 0; i < ticks.Length; i++) { if (calls[i] <= 0 && ticks[i] <= 0) { continue; } long num = TicksToUs(ticks[i]) / frames; long num2 = (long)calls[i] * 100L / frames; if (num > 0 || num2 > 0) { if (flag) { line.Append(';'); } flag = true; line.Append(MethodNames[i]); line.Append(':'); line.Append(num); line.Append('/'); line.Append(num2 / 100); line.Append('.'); long num3 = num2 % 100; if (num3 < 10) { line.Append('0'); } line.Append(num3); } } } private static long TicksToUs(long ticks) { if (ticks <= 0) { return 0L; } return ticks * 1000000 / Stopwatch.Frequency; } } internal sealed class HitchWatch : MonoBehaviour { private enum Metric { Scripts, Late, Fixed, Physics, Render, Canvas, Anim, Particles, Gc, Wait, GcBytes, Count } private struct FrameSnapshot { public float FrameMs; public float CpuMs; public float RenderMs; public float ScriptsMs; public float LateMs; public float FixedMs; public float PhysicsMs; public float CanvasMs; public float AnimMs; public float ParticlesMs; public float GcMs; public float WaitMs; public long GcBytes; } private struct Totals { public int Frames; public int Hitches; public double FrameMs; public double CpuMs; public double RenderMs; public double ScriptsMs; public double LateMs; public double FixedMs; public double PhysicsMs; public double CanvasMs; public double AnimMs; public double ParticlesMs; public double GcMs; public double WaitMs; public long GcBytes; public FrameSnapshot Worst; public bool HasWorst; } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchFrameBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchUpdateStart { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchUpdateEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchLateEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchFixedStart { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchFixedEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchPostLateEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchPhysicsBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchPhysicsEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchParticlesBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchParticlesEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchParticlesSyncBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchParticlesSyncEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchAnimBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchAnimEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchAnimSyncBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchAnimSyncEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchCanvasBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchCanvasEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchSkinBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchSkinEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchFinishBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchFinishEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchRenderersBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchRenderersEnd { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchPresentBegin { } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HitchPresentEnd { } private const int RingSize = 4096; private const int WarmupFrames = 180; private const int ThresholdInterval = 120; private const float SummarySeconds = 10f; private const float LogSeconds = 30f; private const float FileFlushSeconds = 15f; private const float HitchFlushSeconds = 0.5f; private const float StallMs = 100f; private const int NoiseUs = 2000; private const float MedianDip = 1.1f; private static readonly ProfilerCategory[] Categories = (ProfilerCategory[])(object)new ProfilerCategory[8] { ProfilerCategory.Internal, ProfilerCategory.Scripts, ProfilerCategory.Render, ProfilerCategory.Physics, ProfilerCategory.Animation, ProfilerCategory.Particles, ProfilerCategory.Gui, ProfilerCategory.Memory }; private readonly ProfilerRecorder[] recorders = (ProfilerRecorder[])(object)new ProfilerRecorder[11]; private readonly bool[] recorderOn = new bool[11]; private readonly ProfilerMarkerDataUnit[] units = (ProfilerMarkerDataUnit[])(object)new ProfilerMarkerDataUnit[11]; private readonly string[] recorderNames = new string[11]; private readonly int[] frameUs = new int[4096]; private readonly int[] cpuUs = new int[4096]; private readonly int[] renderUs = new int[4096]; private readonly int[] scratch = new int[4096]; private readonly StringBuilder line = new StringBuilder(640); private bool running; private bool skipSample; private bool resumeSkip; private bool writeFailed; private StreamWriter? writer; private string? filePath; private int ringWrite; private int ringCount; private int sinceThreshold; private int frameMedianUs = int.MaxValue; private int frameP95Us = int.MaxValue; private int frameP99Us = int.MaxValue; private int frameP999Us = int.MaxValue; private int renderMedianUs = int.MaxValue; private int renderP95Us = int.MaxValue; private int renderP99Us = int.MaxValue; private int renderP999Us = int.MaxValue; private int cpuMedianUs = int.MaxValue; private int cpuP99Us = int.MaxValue; private int cpuP999Us = int.MaxValue; private float startedAt; private float summaryStart; private float logStart; private float hitchWindowStart; private float nextFileFlush; private bool haveHitch; private int hitchRank; private string hitchReason = string.Empty; private FrameSnapshot hitchFrame; private Totals summary; private Totals logWindow; private static readonly FrameTiming[] timingSlot = (FrameTiming[])(object)new FrameTiming[1]; private static bool phasesInstalled; private static bool frameClosed; private static bool gpuSeen; private static bool gpuMissingLogged; private static int fixedState; private static long lastManagedBytes; private static double stampUpdateStart; private static double stampUpdateEnd; private static double stampLateEnd; private static double stampFixedStart; private static double stampFixedEnd; private static double stampPostLateEnd; private static float publishedScripts; private static float publishedLate; private static float publishedFixed; private static float publishedRenderCpu; priva