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 QoL AllInOne v0.1.0
QoLAllInOne.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.Audio; using On.RoR2.Projectile; using On.RoR2.UI; using On.RoR2.UI.MainMenu; using RoR2; using RoR2.AsyncManagement; using RoR2.Audio; using RoR2.Projectile; using RoR2.UI; using RoR2.UI.MainMenu; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace QoLAllInOne { internal static class AutoSprint { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_PollButtonInput <>9__4_0; internal void <Init>b__4_0(orig_PollButtonInput orig, PlayerCharacterMasterController self) { orig.Invoke(self); try { Apply(self); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Auto sprint: " + ex.Message)); } } } private const float SkillCooldown = 0.2f; private static float skillBusyUntil; private static CharacterBody machinesBody; private static readonly List<EntityStateMachine> machines = new List<EntityStateMachine>(); internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown object obj = <>c.<>9__4_0; if (obj == null) { hook_PollButtonInput val = delegate(orig_PollButtonInput orig, PlayerCharacterMasterController self) { orig.Invoke(self); try { Apply(self); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Auto sprint: " + ex.Message)); } }; <>c.<>9__4_0 = val; obj = (object)val; } PlayerCharacterMasterController.PollButtonInput += (hook_PollButtonInput)obj; } private static void Apply(PlayerCharacterMasterController pcmc) { if (!Settings.AutoSprint.Value || !Object.op_Implicit((Object)(object)pcmc) || !pcmc.hasEffectiveAuthority) { return; } CharacterBody body = pcmc.body; InputBankTest bodyInputs = pcmc.bodyInputs; if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)bodyInputs) && !pcmc.bodyIsFlier && !(((Vector3)(ref bodyInputs.moveVector)).sqrMagnitude < 0.01f)) { float time = Time.time; if (bodyInputs.skill1.down || bodyInputs.skill2.down || bodyInputs.skill3.down || bodyInputs.skill4.down || IsSkillStateBusy(body)) { skillBusyUntil = time + 0.2f; } else if (!(time < skillBusyUntil) && !bodyInputs.sprint.down) { ((ButtonState)(ref bodyInputs.sprint)).PushState(true); } } } private static bool IsSkillStateBusy(CharacterBody body) { if ((Object)(object)machinesBody != (Object)(object)body) { machinesBody = body; machines.Clear(); EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>(); foreach (EntityStateMachine val in components) { if (Object.op_Implicit((Object)(object)val) && (val.customName == "Weapon" || val.customName == "Weapon2")) { machines.Add(val); } } } for (int j = 0; j < machines.Count; j++) { EntityStateMachine val2 = machines[j]; if (Object.op_Implicit((Object)(object)val2) && val2.state != null) { Type stateType = ((SerializableEntityStateType)(ref val2.mainStateType)).stateType; if (stateType != null && ((object)val2.state).GetType() != stateType) { return true; } } } return false; } } internal static class ChestHighlighter { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Awake <>9__5_0; public static hook_SetAvailable <>9__5_1; public static hook_Start <>9__5_2; public static hook_Start <>9__5_3; public static Predicate<PurchaseInteraction> <>9__6_0; public static Predicate<BarrelInteraction> <>9__6_1; public static Predicate<MultiShopController> <>9__7_0; public static Predicate<PurchaseInteraction> <>9__7_1; public static Predicate<BarrelInteraction> <>9__7_2; internal void <Init>b__5_0(orig_Awake orig, PurchaseInteraction self) { orig.Invoke(self); purchases.Add(self); if (Settings.HighlightChests.Value && self.available) { SetHighlight(((Component)self).gameObject, on: true); } } internal void <Init>b__5_1(orig_SetAvailable orig, PurchaseInteraction self, bool newAvailable) { orig.Invoke(self, newAvailable); if (Settings.HighlightChests.Value && !newAvailable) { SetHighlight(((Component)self).gameObject, on: false); } } internal void <Init>b__5_2(orig_Start orig, BarrelInteraction self) { orig.Invoke(self); barrels.Add(self); if (Settings.HighlightChests.Value && !self.opened) { SetHighlight(((Component)self).gameObject, on: true); } } internal void <Init>b__5_3(orig_Start orig, MultiShopController self) { orig.Invoke(self); if (!shops.Contains(self)) { shops.Add(self); } } internal bool <OnSettingChanged>b__6_0(PurchaseInteraction p) { return !Object.op_Implicit((Object)(object)p); } internal bool <OnSettingChanged>b__6_1(BarrelInteraction b) { return !Object.op_Implicit((Object)(object)b); } internal bool <Poll>b__7_0(MultiShopController s) { return !Object.op_Implicit((Object)(object)s); } internal bool <Poll>b__7_1(PurchaseInteraction p) { return !Object.op_Implicit((Object)(object)p); } internal bool <Poll>b__7_2(BarrelInteraction b) { return !Object.op_Implicit((Object)(object)b); } } private const float PollInterval = 0.25f; private static readonly List<PurchaseInteraction> purchases = new List<PurchaseInteraction>(); private static readonly List<BarrelInteraction> barrels = new List<BarrelInteraction>(); private static readonly List<MultiShopController> shops = new List<MultiShopController>(); private static float nextPoll; internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //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_0067: Expected O, but got Unknown //IL_0080: 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) //IL_008b: Expected O, but got Unknown object obj = <>c.<>9__5_0; if (obj == null) { hook_Awake val = delegate(orig_Awake orig, PurchaseInteraction self) { orig.Invoke(self); purchases.Add(self); if (Settings.HighlightChests.Value && self.available) { SetHighlight(((Component)self).gameObject, on: true); } }; <>c.<>9__5_0 = val; obj = (object)val; } PurchaseInteraction.Awake += (hook_Awake)obj; object obj2 = <>c.<>9__5_1; if (obj2 == null) { hook_SetAvailable val2 = delegate(orig_SetAvailable orig, PurchaseInteraction self, bool newAvailable) { orig.Invoke(self, newAvailable); if (Settings.HighlightChests.Value && !newAvailable) { SetHighlight(((Component)self).gameObject, on: false); } }; <>c.<>9__5_1 = val2; obj2 = (object)val2; } PurchaseInteraction.SetAvailable += (hook_SetAvailable)obj2; object obj3 = <>c.<>9__5_2; if (obj3 == null) { hook_Start val3 = delegate(orig_Start orig, BarrelInteraction self) { orig.Invoke(self); barrels.Add(self); if (Settings.HighlightChests.Value && !self.opened) { SetHighlight(((Component)self).gameObject, on: true); } }; <>c.<>9__5_2 = val3; obj3 = (object)val3; } BarrelInteraction.Start += (hook_Start)obj3; object obj4 = <>c.<>9__5_3; if (obj4 == null) { hook_Start val4 = delegate(orig_Start orig, MultiShopController self) { orig.Invoke(self); if (!shops.Contains(self)) { shops.Add(self); } }; <>c.<>9__5_3 = val4; obj4 = (object)val4; } MultiShopController.Start += (hook_Start)obj4; RoR2Application.onUpdate += Poll; } internal static void OnSettingChanged(object sender, EventArgs e) { purchases.RemoveAll((PurchaseInteraction p) => !Object.op_Implicit((Object)(object)p)); barrels.RemoveAll((BarrelInteraction b) => !Object.op_Implicit((Object)(object)b)); bool value = Settings.HighlightChests.Value; foreach (PurchaseInteraction purchase in purchases) { SetHighlight(((Component)purchase).gameObject, value && IsUsable(purchase)); } foreach (BarrelInteraction barrel in barrels) { SetHighlight(((Component)barrel).gameObject, value && !barrel.opened); } } private static void Poll() { if (Time.unscaledTime < nextPoll) { return; } nextPoll = Time.unscaledTime + 0.25f; shops.RemoveAll((MultiShopController s) => !Object.op_Implicit((Object)(object)s)); if (!Settings.HighlightChests.Value) { purchases.RemoveAll((PurchaseInteraction p) => !Object.op_Implicit((Object)(object)p)); barrels.RemoveAll((BarrelInteraction b) => !Object.op_Implicit((Object)(object)b)); return; } for (int num = barrels.Count - 1; num >= 0; num--) { BarrelInteraction val = barrels[num]; if (!Object.op_Implicit((Object)(object)val)) { barrels.RemoveAt(num); } else { SetHighlight(((Component)val).gameObject, !val.opened && ((Behaviour)val).isActiveAndEnabled); } } for (int num2 = purchases.Count - 1; num2 >= 0; num2--) { PurchaseInteraction val2 = purchases[num2]; if (!Object.op_Implicit((Object)(object)val2)) { purchases.RemoveAt(num2); } else { SetHighlight(((Component)val2).gameObject, IsUsable(val2)); } } } private static bool IsUsable(PurchaseInteraction p) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!p.available || !((Behaviour)p).isActiveAndEnabled) { return false; } ShopTerminalBehavior component = ((Component)p).GetComponent<ShopTerminalBehavior>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } if (component.hasBeenPurchased) { return false; } if (component.hasStarted && component.CurrentPickupIndex() == PickupIndex.none) { return false; } if (Object.op_Implicit((Object)(object)component.serverMultiShopController) && !component.serverMultiShopController.available) { return false; } for (int i = 0; i < shops.Count; i++) { MultiShopController val = shops[i]; if (Object.op_Implicit((Object)(object)val) && !val.available && val.terminalGameObjects != null && Array.IndexOf(val.terminalGameObjects, ((Component)p).gameObject) >= 0) { return false; } } return true; } private static void SetHighlight(GameObject go, bool on) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)go)) { return; } Highlight val = go.GetComponent<Highlight>(); if (!on) { if (Object.op_Implicit((Object)(object)val) && val.isOn) { val.isOn = false; } } else { if (Object.op_Implicit((Object)(object)val) && val.isOn) { return; } if (!Object.op_Implicit((Object)(object)val)) { val = go.AddComponent<Highlight>(); } val.highlightColor = (HighlightColor)0; val.strength = 1f; if (!Object.op_Implicit((Object)(object)val.targetRenderer)) { Renderer componentInChildren = (Renderer)(object)go.GetComponentInChildren<MeshRenderer>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren = (Renderer)(object)go.GetComponentInChildren<SkinnedMeshRenderer>(); } if (Object.op_Implicit((Object)(object)componentInChildren)) { val.targetRenderer = componentInChildren; } } val.isOn = true; } } } internal static class DamageNumberBudget { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_SpawnDamageNumber <>9__2_0; internal void <Init>b__2_0(orig_SpawnDamageNumber orig, DamageNumberManager self, float amount, Vector3 position, bool crit, TeamIndex teamIndex, DamageColorIndex damageColorIndex) { //IL_005c: 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_0062: Unknown result type (might be due to invalid IL or missing references) if (Settings.ReduceEffectsUnderLoad.Value) { float unscaledTime = Time.unscaledTime; while (shownTimes.Count > 0 && unscaledTime - shownTimes.Peek() >= 1f) { shownTimes.Dequeue(); } if (shownTimes.Count >= 30) { return; } shownTimes.Enqueue(unscaledTime); } orig.Invoke(self, amount, position, crit, teamIndex, damageColorIndex); } } private const int MaxPerSecond = 30; private static readonly Queue<float> shownTimes = new Queue<float>(31); internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { hook_SpawnDamageNumber val = delegate(orig_SpawnDamageNumber orig, DamageNumberManager self, float amount, Vector3 position, bool crit, TeamIndex teamIndex, DamageColorIndex damageColorIndex) { //IL_005c: 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_0062: Unknown result type (might be due to invalid IL or missing references) if (Settings.ReduceEffectsUnderLoad.Value) { float unscaledTime = Time.unscaledTime; while (shownTimes.Count > 0 && unscaledTime - shownTimes.Peek() >= 1f) { shownTimes.Dequeue(); } if (shownTimes.Count >= 30) { return; } shownTimes.Enqueue(unscaledTime); } orig.Invoke(self, amount, position, crit, teamIndex, damageColorIndex); }; <>c.<>9__2_0 = val; obj = (object)val; } DamageNumberManager.SpawnDamageNumber += (hook_SpawnDamageNumber)obj; } } internal static class DeathEffects { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action<Run> <>9__6_0; public static hook_SpawnEffect_EffectIndex_EffectData_bool <>9__6_1; internal void <Init>b__6_0(Run _) { Collect(); } internal void <Init>b__6_1(orig_SpawnEffect_EffectIndex_EffectData_bool orig, EffectIndex index, EffectData data, bool transmit) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) if (!Settings.ShowDeathEffects.Value || !deathEffects.Contains(index)) { orig.Invoke(index, data, transmit); return; } bool spawningDeathEffect = SpawningDeathEffect; SpawningDeathEffect = true; try { orig.Invoke(index, data, transmit); } finally { SpawningDeathEffect = spawningDeathEffect; } } } private static readonly HashSet<EffectIndex> deathEffects = new HashSet<EffectIndex>(); private static bool collected; internal static bool SpawningDeathEffect { get; private set; } internal static void Init() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown Run.onRunStartGlobal += delegate { Collect(); }; object obj = <>c.<>9__6_1; if (obj == null) { hook_SpawnEffect_EffectIndex_EffectData_bool val = delegate(orig_SpawnEffect_EffectIndex_EffectData_bool orig, EffectIndex index, EffectData data, bool transmit) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) if (!Settings.ShowDeathEffects.Value || !deathEffects.Contains(index)) { orig.Invoke(index, data, transmit); return; } bool spawningDeathEffect = SpawningDeathEffect; SpawningDeathEffect = true; try { orig.Invoke(index, data, transmit); } finally { SpawningDeathEffect = spawningDeathEffect; } }; <>c.<>9__6_1 = val; obj = (object)val; } EffectManager.SpawnEffect_EffectIndex_EffectData_bool += (hook_SpawnEffect_EffectIndex_EffectData_bool)obj; } private static void Collect() { if (collected) { return; } collected = true; try { Type[] stateIndexToType = EntityStateCatalog.stateIndexToType; foreach (Type type in stateIndexToType) { if (type == null || type.IsAbstract || !IsDeathState(type)) { continue; } object obj = null; try { obj = EntityStateCatalog.InstantiateState(type); } catch { } Type type2 = type; while (type2 != null && type2 != typeof(object)) { FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.IsStatic || obj != null) { try { AddPrefab(Resolve(fieldInfo.GetValue(fieldInfo.IsStatic ? null : obj))); } catch { } } } type2 = type2.BaseType; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not list enemy death effects: " + ex.Message)); } } private static bool IsDeathState(Type type) { if (!typeof(GenericCharacterDeath).IsAssignableFrom(type)) { return type.Name.IndexOf("Death", StringComparison.Ordinal) >= 0; } return true; } private static GameObject Resolve(object value) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { return val; } EntityStateGameObject val2 = (EntityStateGameObject)((value is EntityStateGameObject) ? value : null); if (val2 != null) { if (Object.op_Implicit((Object)(object)val2.directReference)) { return val2.directReference; } string gUID = val2.GetGUID(); if (string.IsNullOrEmpty(gUID)) { return null; } AsyncOperationHandle<GameObject> val3 = Addressables.LoadAssetAsync<GameObject>((object)gUID); GameObject result = val3.WaitForCompletion(); Addressables.Release<GameObject>(val3); return result; } return null; } private static void AddPrefab(GameObject prefab) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)prefab)) { EffectIndex val = EffectCatalog.FindEffectIndexFromPrefab(prefab); if ((int)val != -1) { deathEffects.Add(val); } } } } internal static class EffectBudget { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_CanAffordSpawn_VFXIntensity_VFXPriority <>9__3_0; internal bool <Init>b__3_0(orig_CanAffordSpawn_VFXIntensity_VFXPriority orig, VFXIntensity intensity, VFXPriority priority) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001e: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!Settings.ReduceEffectsUnderLoad.Value || DeathEffects.SpawningDeathEffect) { return orig.Invoke(intensity, priority); } if ((int)priority == 2) { float unscaledTime = Time.unscaledTime; while (alwaysTimes.Count > 0 && unscaledTime - alwaysTimes.Peek() >= 1f) { alwaysTimes.Dequeue(); } if (alwaysTimes.Count >= 80) { return false; } alwaysTimes.Enqueue(unscaledTime); return orig.Invoke(intensity, priority); } int num = (VFXBudget.realTotalCost = VFXBudget.totalCost + VFXBudget.GetIntensityScore(intensity) + VFXBudget.particleCostBias.value); float num2 = (((int)priority == 0) ? VFXBudget.lowPriorityCostThreshold.value : VFXBudget.mediumPriorityCostThreshold.value); return Mathf.Pow((num > 0) ? (num2 * 0.1f / (float)num) : 1f, VFXBudget.chanceFailurePower) > Random.value; } } private const float ThresholdScale = 0.1f; private const int AlwaysMaxPerSecond = 80; private static readonly Queue<float> alwaysTimes = new Queue<float>(81); internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown object obj = <>c.<>9__3_0; if (obj == null) { hook_CanAffordSpawn_VFXIntensity_VFXPriority val = delegate(orig_CanAffordSpawn_VFXIntensity_VFXPriority orig, VFXIntensity intensity, VFXPriority priority) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001e: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!Settings.ReduceEffectsUnderLoad.Value || DeathEffects.SpawningDeathEffect) { return orig.Invoke(intensity, priority); } if ((int)priority == 2) { float unscaledTime = Time.unscaledTime; while (alwaysTimes.Count > 0 && unscaledTime - alwaysTimes.Peek() >= 1f) { alwaysTimes.Dequeue(); } if (alwaysTimes.Count >= 80) { return false; } alwaysTimes.Enqueue(unscaledTime); return orig.Invoke(intensity, priority); } int num = (VFXBudget.realTotalCost = VFXBudget.totalCost + VFXBudget.GetIntensityScore(intensity) + VFXBudget.particleCostBias.value); float num2 = (((int)priority == 0) ? VFXBudget.lowPriorityCostThreshold.value : VFXBudget.mediumPriorityCostThreshold.value); return Mathf.Pow((num > 0) ? (num2 * 0.1f / (float)num) : 1f, VFXBudget.chanceFailurePower) > Random.value; }; <>c.<>9__3_0 = val; obj = (object)val; } VFXBudget.CanAffordSpawn_VFXIntensity_VFXPriority += (hook_CanAffordSpawn_VFXIntensity_VFXPriority)obj; } } internal static class ItemHints { [CompilerGenerated] private static class <>O { public static hook_SetItem <0>__OnSetItem; public static hook_SetEquipment <1>__OnSetEquipment; public static hook_SetContent <2>__OnTooltipSetContent; public static hook_SetTooltip <3>__OnSetTooltip; public static hook_UpdateButtonUI <4>__OnUpdateButtonUI; public static hook_SetCurrentPing <5>__OnPing; } private const float ExtraDescriptionHeight = 120f; private static Dictionary<string, string> descriptionByPickupToken; internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //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) //IL_003b: Expected O, but got Unknown //IL_0050: 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_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown object obj = <>O.<0>__OnSetItem; if (obj == null) { hook_SetItem val = OnSetItem; <>O.<0>__OnSetItem = val; obj = (object)val; } GenericNotification.SetItem += (hook_SetItem)obj; object obj2 = <>O.<1>__OnSetEquipment; if (obj2 == null) { hook_SetEquipment val2 = OnSetEquipment; <>O.<1>__OnSetEquipment = val2; obj2 = (object)val2; } GenericNotification.SetEquipment += (hook_SetEquipment)obj2; object obj3 = <>O.<2>__OnTooltipSetContent; if (obj3 == null) { hook_SetContent val3 = OnTooltipSetContent; <>O.<2>__OnTooltipSetContent = val3; obj3 = (object)val3; } TooltipProvider.SetContent += (hook_SetContent)obj3; object obj4 = <>O.<3>__OnSetTooltip; if (obj4 == null) { hook_SetTooltip val4 = OnSetTooltip; <>O.<3>__OnSetTooltip = val4; obj4 = (object)val4; } TooltipProvider.SetTooltip += (hook_SetTooltip)obj4; object obj5 = <>O.<4>__OnUpdateButtonUI; if (obj5 == null) { hook_UpdateButtonUI val5 = OnUpdateButtonUI; <>O.<4>__OnUpdateButtonUI = val5; obj5 = (object)val5; } PickupPickerPanel.UpdateButtonUI += (hook_UpdateButtonUI)obj5; object obj6 = <>O.<5>__OnPing; if (obj6 == null) { hook_SetCurrentPing val6 = OnPing; <>O.<5>__OnPing = val6; obj6 = (object)val6; } PingerController.SetCurrentPing += (hook_SetCurrentPing)obj6; } private static void OnSetItem(orig_SetItem orig, GenericNotification self, ItemDef itemDef) { orig.Invoke(self, itemDef); if (Settings.ItemHints.Value && Object.op_Implicit((Object)(object)itemDef)) { ShowDescription(self, itemDef.descriptionToken); } } private static void OnSetEquipment(orig_SetEquipment orig, GenericNotification self, EquipmentDef equipmentDef) { orig.Invoke(self, equipmentDef); if (Settings.ItemHints.Value && Object.op_Implicit((Object)(object)equipmentDef)) { ShowDescription(self, equipmentDef.descriptionToken); } } private static void ShowDescription(GenericNotification notification, string descriptionToken) { //IL_0040: 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_0054: 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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)notification) && Object.op_Implicit((Object)(object)notification.descriptionText) && IsValid(descriptionToken)) { notification.descriptionText.token = descriptionToken; Transform transform = ((Component)notification.descriptionText).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (val != null) { val.sizeDelta += new Vector2(0f, 120f); } Transform transform2 = ((Component)notification).transform; RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); if (val2 != null) { val2.sizeDelta += new Vector2(0f, 120f); } } } private static void OnTooltipSetContent(orig_SetContent orig, TooltipProvider self, TooltipContent content) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Settings.ItemHints.Value) { content.bodyToken = ExpandToken(content.bodyToken); } orig.Invoke(self, content); } private static void OnSetTooltip(orig_SetTooltip orig, TooltipProvider self, EventSystem eventSystem) { if (Settings.ItemHints.Value && Object.op_Implicit((Object)(object)self) && string.IsNullOrEmpty(self.overrideBodyText)) { self.bodyToken = ExpandToken(self.bodyToken); } orig.Invoke(self, eventSystem); } private static void OnUpdateButtonUI(orig_UpdateButtonUI orig, PickupPickerPanel self, int buttonIndex) { orig.Invoke(self, buttonIndex); if (Settings.ItemHints.Value && Object.op_Implicit((Object)(object)self) && self.pickupOptions != null && self.buttonAllocator != null && buttonIndex >= 0 && buttonIndex < self.pickupOptions.Length && buttonIndex < self.buttonAllocator.elements.Count) { MPButton val = self.buttonAllocator.elements[buttonIndex]; TooltipProvider val2 = default(TooltipProvider); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<TooltipProvider>(ref val2)) { ((Behaviour)val2).enabled = self.pickupOptions[buttonIndex].available; } } } private static string ExpandToken(string token) { if (string.IsNullOrEmpty(token)) { return token; } if (descriptionByPickupToken == null) { BuildLookup(); } if (!descriptionByPickupToken.TryGetValue(token, out var value)) { return token; } return value; } private static void BuildLookup() { descriptionByPickupToken = new Dictionary<string, string>(); for (int i = 0; i < ItemCatalog.itemCount; i++) { ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)i); if (Object.op_Implicit((Object)(object)itemDef)) { Add(itemDef.pickupToken, itemDef.descriptionToken); } } for (int j = 0; j < EquipmentCatalog.equipmentCount; j++) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)j); if (Object.op_Implicit((Object)(object)equipmentDef)) { Add(equipmentDef.pickupToken, equipmentDef.descriptionToken); } } } private static void Add(string pickupToken, string descriptionToken) { if (!string.IsNullOrEmpty(pickupToken) && IsValid(descriptionToken) && !descriptionByPickupToken.ContainsKey(pickupToken)) { descriptionByPickupToken[pickupToken] = descriptionToken; } } private static void OnPing(orig_SetCurrentPing orig, PingerController self, PingInfo newPingInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, newPingInfo); if (!Settings.ItemHints.Value || !Object.op_Implicit((Object)(object)newPingInfo.targetNetworkIdentity)) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(GetPingedPickup(((Component)newPingInfo.targetNetworkIdentity).gameObject)); if (pickupDef == null) { return; } string text = null; if ((int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (Object.op_Implicit((Object)(object)itemDef)) { text = itemDef.descriptionToken; } } else if ((int)pickupDef.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); if (Object.op_Implicit((Object)(object)equipmentDef)) { text = equipmentDef.descriptionToken; } } if (IsValid(text)) { string text2 = Language.GetString(text); if (!string.IsNullOrEmpty(text2)) { Chat.AddMessage("<style=cStack>" + text2 + "</style>"); } } } private static bool IsValid(string token) { if (!string.IsNullOrEmpty(token)) { return !Language.IsTokenInvalid(token); } return false; } private static PickupIndex GetPingedPickup(GameObject target) { //IL_0010: 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_0049: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) GenericPickupController component = target.GetComponent<GenericPickupController>(); if (Object.op_Implicit((Object)(object)component)) { return component.pickupIndex; } ShopTerminalBehavior component2 = target.GetComponent<ShopTerminalBehavior>(); if (Object.op_Implicit((Object)(object)component2)) { if (!component2.pickupIndexIsHidden) { return component2.CurrentPickupIndex(); } return PickupIndex.none; } PickupDisplay componentInChildren = target.GetComponentInChildren<PickupDisplay>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return PickupIndex.none; } return componentInChildren.GetPickupIndex(); } } [BepInPlugin("com.Blowntobytes.QoLAllInOne", "QoL All-in-One", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "com.Blowntobytes.QoLAllInOne"; public const string NAME = "QoL All-in-One"; public const string VERSION = "0.1.0"; private const string VRModGUID = "com.DrBibop.VRMod"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; if (Chainloader.PluginInfos.ContainsKey("com.DrBibop.VRMod")) { Log.LogInfo((object)"Resurrected VRMod is installed and already includes these features; QoL All-in-One is disabled."); return; } Settings.Init(((BaseUnityPlugin)this).Config); ChestHighlighter.Init(); ItemHints.Init(); EffectBudget.Init(); DeathEffects.Init(); ProjectileGhostBudget.Init(); DamageNumberBudget.Init(); SoundBudget.Init(); AutoSprint.Init(); SettingsTab.Init(); } } internal static class ProjectileGhostBudget { private sealed class HiddenParts { public readonly List<Renderer> renderers = new List<Renderer>(); public readonly List<Light> lights = new List<Light>(); } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Start <>9__7_0; public static hook_OnDisable <>9__7_1; public static EventHandler <>9__7_2; internal void <Init>b__7_0(orig_Start orig, ProjectileController self) { orig.Invoke(self); try { OnProjectileStarted(self); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Projectile visual cap: " + ex.Message)); } } internal void <Init>b__7_1(orig_OnDisable orig, ProjectileGhostController self) { Release(self); orig.Invoke(self); } internal void <Init>b__7_2(object _, EventArgs __) { if (!Settings.ReduceEffectsUnderLoad.Value) { RestoreAll(); } } } private const int MaxVisible = 150; private const float CleanupInterval = 10f; private static readonly LinkedList<ProjectileGhostController> visible = new LinkedList<ProjectileGhostController>(); private static readonly Dictionary<ProjectileGhostController, LinkedListNode<ProjectileGhostController>> nodes = new Dictionary<ProjectileGhostController, LinkedListNode<ProjectileGhostController>>(); private static readonly Dictionary<ProjectileGhostController, HiddenParts> hidden = new Dictionary<ProjectileGhostController, HiddenParts>(); private static float nextCleanup; internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown object obj = <>c.<>9__7_0; if (obj == null) { hook_Start val = delegate(orig_Start orig, ProjectileController self) { orig.Invoke(self); try { OnProjectileStarted(self); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Projectile visual cap: " + ex.Message)); } }; <>c.<>9__7_0 = val; obj = (object)val; } ProjectileController.Start += (hook_Start)obj; object obj2 = <>c.<>9__7_1; if (obj2 == null) { hook_OnDisable val2 = delegate(orig_OnDisable orig, ProjectileGhostController self) { Release(self); orig.Invoke(self); }; <>c.<>9__7_1 = val2; obj2 = (object)val2; } ProjectileGhostController.OnDisable += (hook_OnDisable)obj2; Settings.ReduceEffectsUnderLoad.SettingChanged += delegate { if (!Settings.ReduceEffectsUnderLoad.Value) { RestoreAll(); } }; } private static void RestoreAll() { foreach (HiddenParts value in hidden.Values) { foreach (Renderer renderer in value.renderers) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.enabled = true; } } foreach (Light light in value.lights) { if (Object.op_Implicit((Object)(object)light)) { ((Behaviour)light).enabled = true; } } } hidden.Clear(); visible.Clear(); nodes.Clear(); } private static void OnProjectileStarted(ProjectileController projectile) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 if (!Settings.ReduceEffectsUnderLoad.Value) { return; } ProjectileGhostController ghost = projectile.ghost; if (!Object.op_Implicit((Object)(object)ghost) || nodes.ContainsKey(ghost) || hidden.ContainsKey(ghost)) { return; } TeamFilter teamFilter = projectile.teamFilter; if (!Object.op_Implicit((Object)(object)teamFilter) || (int)teamFilter.teamIndex != 1) { return; } nodes[ghost] = visible.AddLast(ghost); while (visible.Count > 150) { ProjectileGhostController value = visible.First.Value; visible.RemoveFirst(); nodes.Remove(value); if (Object.op_Implicit((Object)(object)value)) { Hide(value); } } RemoveDestroyed(); } private static void Hide(ProjectileGhostController ghost) { HiddenParts hiddenParts = new HiddenParts(); Renderer[] componentsInChildren = ((Component)ghost).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val.enabled) { val.enabled = false; hiddenParts.renderers.Add(val); } } Light[] componentsInChildren2 = ((Component)ghost).GetComponentsInChildren<Light>(); foreach (Light val2 in componentsInChildren2) { if (((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; hiddenParts.lights.Add(val2); } } hidden[ghost] = hiddenParts; } private static void Release(ProjectileGhostController ghost) { if (nodes.TryGetValue(ghost, out var value)) { visible.Remove(value); nodes.Remove(ghost); } if (!hidden.TryGetValue(ghost, out var value2)) { return; } foreach (Renderer renderer in value2.renderers) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.enabled = true; } } foreach (Light light in value2.lights) { if (Object.op_Implicit((Object)(object)light)) { ((Behaviour)light).enabled = true; } } hidden.Remove(ghost); } private static void RemoveDestroyed() { float unscaledTime = Time.unscaledTime; if (unscaledTime < nextCleanup) { return; } nextCleanup = unscaledTime + 10f; LinkedListNode<ProjectileGhostController> linkedListNode = visible.First; while (linkedListNode != null) { LinkedListNode<ProjectileGhostController>? next = linkedListNode.Next; if (!Object.op_Implicit((Object)(object)linkedListNode.Value)) { nodes.Remove(linkedListNode.Value); visible.Remove(linkedListNode); } linkedListNode = next; } if (hidden.Count <= 0) { return; } List<ProjectileGhostController> list = new List<ProjectileGhostController>(); foreach (ProjectileGhostController key in hidden.Keys) { if (!Object.op_Implicit((Object)(object)key)) { list.Add(key); } } foreach (ProjectileGhostController item in list) { hidden.Remove(item); } } } internal static class Settings { internal static readonly Dictionary<string, ConfigEntry<bool>> ByKey = new Dictionary<string, ConfigEntry<bool>>(); internal static ConfigEntry<bool> HighlightChests { get; private set; } internal static ConfigEntry<bool> ItemHints { get; private set; } internal static ConfigEntry<bool> AutoSprint { get; private set; } internal static ConfigEntry<bool> ReduceEffectsUnderLoad { get; private set; } internal static ConfigEntry<bool> ReduceSoundsUnderLoad { get; private set; } internal static ConfigEntry<bool> ShowDeathEffects { get; private set; } internal static void Init(ConfigFile config) { HighlightChests = config.Bind<bool>("Features", "Chest highlights", false, "Highlights purchasable interactables (chests, drones, shrines, etc.) with a coloured outline so they are easier to spot."); HighlightChests.SettingChanged += ChestHighlighter.OnSettingChanged; ItemHints = config.Bind<bool>("Features", "Item stats", false, "Shows the full item description (stat details from the logbook) in pickup notifications and item tooltips instead of the short flavour text. Pinging a dropped item also prints its description in your chat (only you see it)."); AutoSprint = config.Bind<bool>("Features", "Auto sprint", false, "Sprint automatically whenever you move. Attacks are never cancelled: sprint waits while a skill button is held or a skill is still playing out."); ReduceEffectsUnderLoad = config.Bind<bool>("Performance", "Performance mode", false, "When many effects are on screen at once, far fewer new low/medium-priority effects are spawned on YOUR screen. Also caps new damage numbers at 30 per second, shows at most 150 of your team's projectiles at once (the rest still fly and hit) and puts a very high ceiling on 'always' effects. Visual only - gameplay and other players are not affected."); ShowDeathEffects = config.Bind<bool>("Performance", "Show full enemy death effects", true, "With Performance mode on, enemy death effects (wisp and robot explosions, drone bursts...) are not culled by it, so enemies without a corpse don't just vanish. The game's own effect limit still applies. No effect when Performance mode is off."); ReduceSoundsUnderLoad = config.Bind<bool>("Performance", "Reduce sounds under heavy load", false, "When more than 100 sounds a second are requested, the same sound plays at most once per 0.15 s and at most 10 sounds start per 0.1 s. Hit, crit and gold pickup sounds are only limited past 20 per second. Local only."); ByKey["qol_highlight_chests"] = HighlightChests; ByKey["qol_item_stats"] = ItemHints; ByKey["qol_auto_sprint"] = AutoSprint; ByKey["qol_performance_mode"] = ReduceEffectsUnderLoad; ByKey["qol_death_effects"] = ShowDeathEffects; ByKey["qol_reduce_sounds"] = ReduceSoundsUnderLoad; } } internal static class SettingsTab { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnEnter <>9__2_0; public static hook_OpenSettingsMenu <>9__2_1; public static hook_GetCurrentValue <>9__2_2; public static hook_SubmitSettingInternal <>9__2_3; public static hook_Awake <>9__2_4; public static hook_OnSelect <>9__2_5; public static Predicate<Header> <>9__4_0; internal void <Init>b__2_0(orig_OnEnter orig, SubmenuMainMenuScreen self, MainMenuController controller) { orig.Invoke(self, controller); if (LooksLikeSettingsPanel(self.submenuPanelInstance)) { Setup(self.submenuPanelInstance); } } internal void <Init>b__2_1(orig_OpenSettingsMenu orig, PauseScreenController self) { orig.Invoke(self); Setup(self.submenuObject); } internal string <Init>b__2_2(orig_GetCurrentValue orig, BaseSettingsControl self) { if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { if (!Settings.ByKey.TryGetValue(self.settingName, out var value) || !value.Value) { return "0"; } return "1"; } return orig.Invoke(self); } internal void <Init>b__2_3(orig_SubmitSettingInternal orig, BaseSettingsControl self, string newValue) { <>c__DisplayClass2_0 CS$<>8__locals5 = new <>c__DisplayClass2_0 { self = self }; if (((Object)((Component)CS$<>8__locals5.self).gameObject).name.StartsWith("QoLSetting")) { if (Settings.ByKey.TryGetValue(CS$<>8__locals5.self.settingName, out var value)) { value.Value = newValue == "1"; } RoR2Application.onNextUpdate += delegate { if (Object.op_Implicit((Object)(object)CS$<>8__locals5.self)) { CS$<>8__locals5.self.OnUpdateControls(); } }; } else { orig.Invoke(CS$<>8__locals5.self, newValue); } } internal void <Init>b__2_4(orig_Awake orig, BaseSettingsControl self) { if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { self.eventSystemLocator = ((Component)self).GetComponent<MPEventSystemLocator>(); if (Object.op_Implicit((Object)(object)self.nameLabel) && !string.IsNullOrEmpty(self.nameToken)) { self.nameLabel.token = self.nameToken; } } else { orig.Invoke(self); } } internal void <Init>b__2_5(orig_OnSelect orig, HGButton self, BaseEventData eventData) { orig.Invoke(self, eventData); if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { HGScrollRectHelper componentInParent = ((Component)self).GetComponentInParent<HGScrollRectHelper>(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.ScrollToShowMe((MPButton)(object)self); } } } internal bool <Setup>b__4_0(Header h) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return h.headerName == "QoL"; } } [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public BaseSettingsControl self; internal void <Init>b__6() { if (Object.op_Implicit((Object)(object)self)) { self.OnUpdateControls(); } } } private const string Marker = "QoLSetting"; private const string TabName = "QoL"; internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //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_0067: Expected O, but got Unknown //IL_0080: 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) //IL_008b: Expected O, but got Unknown //IL_00a4: 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_00af: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { hook_OnEnter val = delegate(orig_OnEnter orig, SubmenuMainMenuScreen self, MainMenuController controller) { orig.Invoke(self, controller); if (LooksLikeSettingsPanel(self.submenuPanelInstance)) { Setup(self.submenuPanelInstance); } }; <>c.<>9__2_0 = val; obj = (object)val; } SubmenuMainMenuScreen.OnEnter += (hook_OnEnter)obj; object obj2 = <>c.<>9__2_1; if (obj2 == null) { hook_OpenSettingsMenu val2 = delegate(orig_OpenSettingsMenu orig, PauseScreenController self) { orig.Invoke(self); Setup(self.submenuObject); }; <>c.<>9__2_1 = val2; obj2 = (object)val2; } PauseScreenController.OpenSettingsMenu += (hook_OpenSettingsMenu)obj2; object obj3 = <>c.<>9__2_2; if (obj3 == null) { ConfigEntry<bool> value; hook_GetCurrentValue val3 = (orig_GetCurrentValue orig, BaseSettingsControl self) => ((Object)((Component)self).gameObject).name.StartsWith("QoLSetting") ? ((!Settings.ByKey.TryGetValue(self.settingName, out value) || !value.Value) ? "0" : "1") : orig.Invoke(self); <>c.<>9__2_2 = val3; obj3 = (object)val3; } BaseSettingsControl.GetCurrentValue += (hook_GetCurrentValue)obj3; object obj4 = <>c.<>9__2_3; if (obj4 == null) { hook_SubmitSettingInternal val4 = delegate(orig_SubmitSettingInternal orig, BaseSettingsControl self, string newValue) { if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { if (Settings.ByKey.TryGetValue(self.settingName, out var value)) { value.Value = newValue == "1"; } RoR2Application.onNextUpdate += delegate { if (Object.op_Implicit((Object)(object)self)) { self.OnUpdateControls(); } }; } else { orig.Invoke(self, newValue); } }; <>c.<>9__2_3 = val4; obj4 = (object)val4; } BaseSettingsControl.SubmitSettingInternal += (hook_SubmitSettingInternal)obj4; object obj5 = <>c.<>9__2_4; if (obj5 == null) { hook_Awake val5 = delegate(orig_Awake orig, BaseSettingsControl self) { if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { self.eventSystemLocator = ((Component)self).GetComponent<MPEventSystemLocator>(); if (Object.op_Implicit((Object)(object)self.nameLabel) && !string.IsNullOrEmpty(self.nameToken)) { self.nameLabel.token = self.nameToken; } } else { orig.Invoke(self); } }; <>c.<>9__2_4 = val5; obj5 = (object)val5; } BaseSettingsControl.Awake += (hook_Awake)obj5; object obj6 = <>c.<>9__2_5; if (obj6 == null) { hook_OnSelect val6 = delegate(orig_OnSelect orig, HGButton self, BaseEventData eventData) { orig.Invoke(self, eventData); if (((Object)((Component)self).gameObject).name.StartsWith("QoLSetting")) { HGScrollRectHelper componentInParent = ((Component)self).GetComponentInParent<HGScrollRectHelper>(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.ScrollToShowMe((MPButton)(object)self); } } }; <>c.<>9__2_5 = val6; obj6 = (object)val6; } HGButton.OnSelect += (hook_OnSelect)obj6; } private static bool LooksLikeSettingsPanel(GameObject panel) { if (Object.op_Implicit((Object)(object)panel) && Object.op_Implicit((Object)(object)panel.GetComponent<HGHeaderNavigationController>())) { return Object.op_Implicit((Object)(object)panel.transform.Find("SafeArea/SubPanelArea")); } return false; } private static void Setup(GameObject panel) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) try { if (!Object.op_Implicit((Object)(object)panel)) { return; } HGHeaderNavigationController component = panel.GetComponent<HGHeaderNavigationController>(); if (Object.op_Implicit((Object)(object)component) && component.headers != null && !component.headers.Exists((Header h) => h.headerName == "QoL")) { Transform val = panel.transform.Find("SafeArea/HeaderContainer/Header (JUICED)"); Transform val2 = panel.transform.Find("SafeArea/SubPanelArea"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { Plugin.Log.LogWarning((object)"Settings panel layout not recognised; the QoL tab was not added."); return; } GameObject headerRoot = BuildSubPanel(val2); GameObject val3 = Object.Instantiate<GameObject>(((Component)val.Find("GenericHeaderButton (Graphics)")).gameObject, val); val3.transform.SetSiblingIndex(val.childCount - 2); ((Object)val3).name = "GenericHeaderButton (QoL)"; val3.GetComponent<LanguageTextMeshController>().token = "QoL"; component.headers.Add(new Header { headerButton = (MPButton)(object)val3.GetComponent<HGButton>(), headerName = "QoL", tmpHeaderText = (TextMeshProUGUI)(object)val3.GetComponentInChildren<HGTextMeshProUGUI>(), headerRoot = headerRoot }); } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not build the QoL tab: " + ex)); } } private static GameObject BuildSubPanel(Transform area) { //IL_006b: 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) GameObject gameObject = ((Component)area.Find("SettingsSubPanel, Controls (Gamepad)")).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.Find("Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Bool (Invert X)")).gameObject; LanguageTextMeshController component = ((Component)area.Find("GenericDescriptionPanel/ContentSizeFitter/DescriptionText")).GetComponent<LanguageTextMeshController>(); GameObject val = Object.Instantiate<GameObject>(gameObject, area); ((Object)val).name = "SettingsSubPanel, QoL"; Transform val2 = val.transform.Find("Scroll View/Viewport/VerticalLayout"); foreach (Transform item in val2) { Object.Destroy((Object)(object)((Component)item).gameObject); } bool defaultFallbackButton = true; foreach (KeyValuePair<string, ConfigEntry<bool>> item2 in Settings.ByKey) { BaseSettingsControl component2 = Object.Instantiate<GameObject>(gameObject2, val2).GetComponent<BaseSettingsControl>(); component2.settingSource = (SettingSource)0; component2.nameToken = ((ConfigEntryBase)item2.Value).Definition.Key; component2.settingName = item2.Key; ((Object)((Component)component2).gameObject).name = "QoLSetting, " + component2.nameToken; HGButton component3 = ((Component)component2).GetComponent<HGButton>(); if (Object.op_Implicit((Object)(object)component3)) { component3.updateTextOnHover = true; component3.hoverToken = ((ConfigEntryBase)item2.Value).Description.Description; component3.hoverLanguageTextMeshController = component; ((MPButton)component3).defaultFallbackButton = defaultFallbackButton; defaultFallbackButton = false; } } return val; } } internal static class SoundBudget { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_PlaySound_string_GameObject <>9__12_0; public static hook_EmitSoundLocal_string_Vector3 <>9__12_1; public static hook_EmitSoundLocal_AkEventIdArg_Vector3 <>9__12_2; public static Action<Stage> <>9__12_3; internal uint <Init>b__12_0(orig_PlaySound_string_GameObject orig, string soundString, GameObject gameObject) { if (Settings.ReduceSoundsUnderLoad.Value && !string.IsNullOrEmpty(soundString) && soundString.StartsWith("Play", StringComparison.OrdinalIgnoreCase) && !Allow(byName, soundString)) { return 0u; } return orig.Invoke(soundString, gameObject); } internal uint <Init>b__12_1(orig_EmitSoundLocal_string_Vector3 orig, string soundString, Vector3 position) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Settings.ReduceSoundsUnderLoad.Value && !string.IsNullOrEmpty(soundString) && !Allow(byName, soundString)) { return 0u; } return orig.Invoke(soundString, position); } internal uint <Init>b__12_2(orig_EmitSoundLocal_AkEventIdArg_Vector3 orig, AkEventIdArg akEventId, Vector3 position) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) if (Settings.ReduceSoundsUnderLoad.Value && akEventId.id != 0 && !Allow(byId, akEventId.id)) { return 0u; } return orig.Invoke(akEventId, position); } internal void <Init>b__12_3(Stage _) { byName.Clear(); byId.Clear(); } } private const int ActivationRate = 100; private const int MaxPerWindow = 1; private const float Window = 0.15f; private const int MaxTotalPerWindow = 10; private const float TotalWindow = 0.1f; private const int FeedbackMaxPerSecond = 20; private const int MaxTrackedEvents = 2000; private static readonly HashSet<string> FeedbackSounds = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Play_UI_hit", "Play_UI_crit", "Play_UI_coin" }; private static readonly Queue<float> requests = new Queue<float>(256); private static readonly Queue<float> allStarts = new Queue<float>(11); private static readonly Dictionary<string, Queue<float>> byName = new Dictionary<string, Queue<float>>(); private static readonly Dictionary<uint, Queue<float>> byId = new Dictionary<uint, Queue<float>>(); internal static void Init() { //IL_0014: 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_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //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_0067: Expected O, but got Unknown object obj = <>c.<>9__12_0; if (obj == null) { hook_PlaySound_string_GameObject val = (orig_PlaySound_string_GameObject orig, string soundString, GameObject gameObject) => (!Settings.ReduceSoundsUnderLoad.Value || string.IsNullOrEmpty(soundString) || !soundString.StartsWith("Play", StringComparison.OrdinalIgnoreCase) || Allow(byName, soundString)) ? orig.Invoke(soundString, gameObject) : 0u; <>c.<>9__12_0 = val; obj = (object)val; } Util.PlaySound_string_GameObject += (hook_PlaySound_string_GameObject)obj; object obj2 = <>c.<>9__12_1; if (obj2 == null) { hook_EmitSoundLocal_string_Vector3 val2 = (orig_EmitSoundLocal_string_Vector3 orig, string soundString, Vector3 position) => (!Settings.ReduceSoundsUnderLoad.Value || string.IsNullOrEmpty(soundString) || Allow(byName, soundString)) ? orig.Invoke(soundString, position) : 0u; <>c.<>9__12_1 = val2; obj2 = (object)val2; } PointSoundManager.EmitSoundLocal_string_Vector3 += (hook_EmitSoundLocal_string_Vector3)obj2; object obj3 = <>c.<>9__12_2; if (obj3 == null) { hook_EmitSoundLocal_AkEventIdArg_Vector3 val3 = (orig_EmitSoundLocal_AkEventIdArg_Vector3 orig, AkEventIdArg akEventId, Vector3 position) => (!Settings.ReduceSoundsUnderLoad.Value || akEventId.id == 0 || Allow(byId, akEventId.id)) ? orig.Invoke(akEventId, position) : 0u; <>c.<>9__12_2 = val3; obj3 = (object)val3; } PointSoundManager.EmitSoundLocal_AkEventIdArg_Vector3 += (hook_EmitSoundLocal_AkEventIdArg_Vector3)obj3; Stage.onStageStartGlobal += delegate { byName.Clear(); byId.Clear(); }; } private static bool Allow<T>(Dictionary<T, Queue<float>> table, T key) { float unscaledTime = Time.unscaledTime; if (key is string item && FeedbackSounds.Contains(item)) { return TryStart(table, key, 20, 1f, unscaledTime); } requests.Enqueue(unscaledTime); while (requests.Count > 0 && unscaledTime - requests.Peek() >= 1f) { requests.Dequeue(); } if (requests.Count < 100) { return true; } while (allStarts.Count > 0 && unscaledTime - allStarts.Peek() >= 0.1f) { allStarts.Dequeue(); } if (allStarts.Count >= 10) { return false; } if (!TryStart(table, key, 1, 0.15f, unscaledTime)) { return false; } allStarts.Enqueue(unscaledTime); return true; } private static bool TryStart<T>(Dictionary<T, Queue<float>> table, T key, int max, float window, float now) { if (!table.TryGetValue(key, out var value)) { if (table.Count >= 2000) { table.Clear(); } value = (table[key] = new Queue<float>(max + 1)); } while (value.Count > 0 && now - value.Peek() >= window) { value.Dequeue(); } if (value.Count >= max) { return false; } value.Enqueue(now); return true; } } }