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 Winnowing Quickstart v1.0.1
plugins/WinnowingTrialPrep/WinnowingTrialPrep.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.SprintDamage; using On.RoR2; using RiskOfOptions; using RiskOfOptions.Components.Options; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Items; using RoR2.Quests.TrialQuests; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WinnowingTrialPrep")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WinnowingTrialPrep")] [assembly: AssemblyTitle("WinnowingTrialPrep")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace WinnowingTrialPrep; internal sealed class LinkedPercentage : IDisposable { private bool updating; private float lastCustom = 50f; public ConfigEntry<bool> Maximum { get; } public ConfigEntry<float> Percent { get; } public LinkedPercentage(ConfigEntry<bool> maximum, ConfigEntry<float> percent) { Maximum = maximum; Percent = percent; SetFromPercent(); Maximum.SettingChanged += MaximumChanged; Percent.SettingChanged += PercentChanged; } private void MaximumChanged(object sender, EventArgs args) { if (updating) { return; } updating = true; try { if (Maximum.Value) { if (Percent.Value < 100f) { lastCustom = PercentMath.Normalize(Percent.Value); } Percent.Value = 100f; } else if (Percent.Value >= 100f) { Percent.Value = lastCustom; } } finally { updating = false; } } private void PercentChanged(object sender, EventArgs args) { if (!updating) { SetFromPercent(); } } private void SetFromPercent() { updating = true; try { Percent.Value = PercentMath.Normalize(Percent.Value); Maximum.Value = Percent.Value >= 100f; if (!Maximum.Value) { lastCustom = Percent.Value; } } finally { updating = false; } } public void Dispose() { Maximum.SettingChanged -= MaximumChanged; Percent.SettingChanged -= PercentChanged; } } [BepInPlugin("com.winnowingtrialprep", "Winnowing Quickstart", "1.0.0")] [BepInDependency("com.rune580.riskofoptions", "2.8.6")] public sealed class Plugin : BaseUnityPlugin { [Serializable] private sealed class MenuPresentationData { public string name = "Winnowing Quickstart"; public string description = "Skip preparation time in Winnowing trials. Uses host settings. Automatic preparation ends when you leave the starting circle and the trial timer begins."; } internal const string DefaultMenuDescription = "Skip preparation time in Winnowing trials. Uses host settings. Automatic preparation ends when you leave the starting circle and the trial timer begins."; private Texture2D menuIconTexture; private Sprite menuIcon; public const string Guid = "com.winnowingtrialprep"; public const string Name = "Winnowing Quickstart"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static Settings Settings; private readonly Dictionary<TrialController, TrialPreparation> trials = new Dictionary<TrialController, TrialPreparation>(); internal static string MenuName { get; private set; } = "Winnowing Quickstart"; private void LoadMenuPresentation() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_011b: 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) string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); MenuPresentationData menuPresentationData = new MenuPresentationData(); try { string path = Path.Combine(directoryName, "mod-options.json"); if (File.Exists(path)) { JsonUtility.FromJsonOverwrite(File.ReadAllText(path), (object)menuPresentationData); } } catch (Exception ex) { menuPresentationData = new MenuPresentationData(); ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not read mod-options.json; using the default menu name and description. " + ex.Message)); } MenuName = (string.IsNullOrWhiteSpace(menuPresentationData.name) ? "Winnowing Quickstart" : menuPresentationData.name.Trim()); ModSettingsManager.SetModDescription(menuPresentationData.description ?? "Skip preparation time in Winnowing trials. Uses host settings. Automatic preparation ends when you leave the starting circle and the trial timer begins.", "com.winnowingtrialprep", MenuName); try { string path2 = Path.Combine(directoryName, "options-icon.png"); if (File.Exists(path2)) { menuIconTexture = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(menuIconTexture, File.ReadAllBytes(path2), true)) { throw new InvalidDataException("options-icon.png is not a supported image."); } menuIcon = Sprite.Create(menuIconTexture, new Rect(0f, 0f, (float)((Texture)menuIconTexture).width, (float)((Texture)menuIconTexture).height), new Vector2(0.5f, 0.5f)); ModSettingsManager.SetModIcon(menuIcon, "com.winnowingtrialprep", MenuName); } } catch (Exception ex2) { DestroyMenuIcon(); ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load options-icon.png; gameplay settings are still available. " + ex2.Message)); } } private void DestroyMenuIcon() { if (Object.op_Implicit((Object)(object)menuIcon)) { Object.Destroy((Object)(object)menuIcon); } if (Object.op_Implicit((Object)(object)menuIconTexture)) { Object.Destroy((Object)(object)menuIconTexture); } menuIcon = null; menuIconTexture = null; } private void Awake() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Settings = new Settings(((BaseUnityPlugin)this).Config); LoadMenuPresentation(); OptionsUi.Register(Settings); TrialController.onInstanceDiscovered += Discovered; TrialController.onInstanceLost += Lost; TrialController.BeginTrial += new hook_BeginTrial(BeginTrial); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Winnowing Quickstart 1.0.0 loaded. Gameplay preparation uses host settings."); } private void Discovered(TrialController controller) { if (Object.op_Implicit((Object)(object)controller) && NetworkServer.active && !trials.ContainsKey(controller)) { TrialPreparation trialPreparation = ((Component)controller).gameObject.GetComponent<TrialPreparation>(); if (!Object.op_Implicit((Object)(object)trialPreparation)) { trialPreparation = ((Component)controller).gameObject.AddComponent<TrialPreparation>(); } trialPreparation.Initialize(controller); trials[controller] = trialPreparation; } } private void Lost(TrialController controller) { if (!((Object)(object)controller == (Object)null)) { if (trials.TryGetValue(controller, out var value) && Object.op_Implicit((Object)(object)value)) { value.Close(); } trials.Remove(controller); } } private void BeginTrial(orig_BeginTrial original, TrialController controller) { if (NetworkServer.active && Object.op_Implicit((Object)(object)controller)) { Discovered(controller); if (trials.TryGetValue(controller, out var value) && Object.op_Implicit((Object)(object)value)) { try { value.Prepare(finalPass: true); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Final trial preparation failed: " + ex)); } finally { value.Close(); } } } original.Invoke(controller); } private void OnDestroy() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown TrialController.onInstanceDiscovered -= Discovered; TrialController.onInstanceLost -= Lost; TrialController.BeginTrial -= new hook_BeginTrial(BeginTrial); foreach (TrialPreparation value in trials.Values) { if (Object.op_Implicit((Object)(object)value)) { value.Close(); } } trials.Clear(); Settings?.Dispose(); DestroyMenuIcon(); } } internal static class OptionsUi { private sealed class LiveCheckBox : CheckBoxOption { private readonly ConfigEntry<bool> entry; public LiveCheckBox(ConfigEntry<bool> entry, CheckBoxConfig config) : base(entry, config) { this.entry = entry; } public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent) { GameObject val = ((CheckBoxOption)this).CreateOptionGameObject(prefab, parent); val.AddComponent<LinkedControlRefresh>().Initialize((ModSetting)(object)val.GetComponentInChildren<ModSettingsBool>(), () => entry.Value); return val; } } private sealed class LiveSlider : StepSliderOption { private readonly ConfigEntry<float> entry; public LiveSlider(ConfigEntry<float> entry, StepSliderConfig config) : base(entry, config) { this.entry = entry; } public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent) { GameObject val = ((StepSliderOption)this).CreateOptionGameObject(prefab, parent); val.AddComponent<LinkedControlRefresh>().Initialize((ModSetting)(object)val.GetComponentInChildren<ModSettingsStepSlider>(), () => entry.Value); return val; } } public static void Register(Settings settings) { AddCheck(settings.FullHealth); AddCheck(settings.Seeker); AddCheck(settings.FaradayEnabled); AddCheck(settings.FaradayExcludeAbyss, () => !settings.FaradayEnabled.Value); AddCheck(settings.Faraday.Maximum, () => !settings.FaradayEnabled.Value); AddSlider(settings.Faraday.Percent, () => !settings.FaradayEnabled.Value); AddCheck(settings.HelmetEnabled); AddCheck(settings.HelmetExcludeAbyss, () => !settings.HelmetEnabled.Value); AddCheck(settings.Helmet.Maximum, () => !settings.HelmetEnabled.Value); AddSlider(settings.Helmet.Percent, () => !settings.HelmetEnabled.Value); } private static void AddCheck(ConfigEntry<bool> entry, Func<bool> disabled = null) { //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_002a: 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) //IL_004c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)(object)new LiveCheckBox(entry, new CheckBoxConfig { category = ((ConfigEntryBase)entry).Definition.Section.Substring(3), checkIfDisabled = ((disabled == null) ? ((IsDisabledDelegate)null) : ((IsDisabledDelegate)(() => disabled()))) }), "com.winnowingtrialprep", Plugin.MenuName); } private static void AddSlider(ConfigEntry<float> entry, Func<bool> disabled) { //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_002a: 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_0040: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0074: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)(object)new LiveSlider(entry, new StepSliderConfig { category = ((ConfigEntryBase)entry).Definition.Section.Substring(3), min = 0f, max = 100f, increment = 1f, FormatString = "{0:0}", remapManualInputToStep = true, checkIfDisabled = (IsDisabledDelegate)(() => disabled()) }), "com.winnowingtrialprep", Plugin.MenuName); } } public sealed class LinkedControlRefresh : MonoBehaviour { private ModSetting control; private Func<object> read; private object previous; private MethodInfo refresh; internal void Initialize(ModSetting target, Func<object> readValue) { control = target; read = readValue; if (Object.op_Implicit((Object)(object)control)) { refresh = ((object)control).GetType().GetMethod("UpdateControls", BindingFlags.Instance | BindingFlags.NonPublic); } } private void LateUpdate() { if (!Object.op_Implicit((Object)(object)control) || read == null) { return; } control.CheckIfDisabled(); object objA = read(); if (!object.Equals(objA, previous)) { previous = objA; if (refresh != null) { refresh.Invoke(control, null); } else { ((Behaviour)this).enabled = false; } } } } internal static class PercentMath { public static float Normalize(float value) { if (float.IsNaN(value)) { return 100f; } return (float)Math.Round(Math.Max(0f, Math.Min(100f, value)), MidpointRounding.AwayFromZero); } public static int Stacks(float percent, int limit) { if (limit <= 0) { return 0; } return (int)Math.Round((double)(Normalize(percent) * (float)limit) / 100.0, MidpointRounding.AwayFromZero); } } internal sealed class PreparationWindow { private readonly HashSet<int> healthPrepared = new HashSet<int>(); private readonly HashSet<int> seekerPrepared = new HashSet<int>(); public bool Closed { get; private set; } public bool Observe(bool hasStarted, bool isIdle) { if (hasStarted || !isIdle) { Closed = true; } return !Closed; } public void Close() { Closed = true; } public bool HasPreparedHealth(int player) { return healthPrepared.Contains(player); } public bool HasPreparedSeeker(int player) { return seekerPrepared.Contains(player); } public void MarkHealthPrepared(int player) { healthPrepared.Add(player); } public void MarkSeekerPrepared(int player) { seekerPrepared.Add(player); } } internal static class QualitySupport { private static readonly Dictionary<ItemIndex, ItemIndex[]> families = new Dictionary<ItemIndex, ItemIndex[]>(); public static bool HasEffectiveRental(Inventory inventory, ItemDef item) { //IL_0029: 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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) if (!Object.op_Implicit((Object)(object)inventory) || !Object.op_Implicit((Object)(object)item) || inventory.GetItemCountEffective(item) <= 0) { return false; } if (inventory.GetItemCountRented(item) > 0) { return true; } ItemIndex[] family = GetFamily(item.itemIndex); foreach (ItemIndex val in family) { if (val != item.itemIndex && inventory.GetItemCountRented(val) > 0 && inventory.GetItemCountEffective(val) > 0) { return true; } } return false; } private static ItemIndex[] GetFamily(ItemIndex baseIndex) { //IL_0005: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) //IL_0129: Invalid comparison between Unknown and I4 //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (families.TryGetValue(baseIndex, out var value)) { return value; } List<ItemIndex> list = new List<ItemIndex> { baseIndex }; foreach (PluginInfo value2 in Chainloader.PluginInfos.Values) { if (!Object.op_Implicit((Object)(object)value2.Instance)) { continue; } Assembly assembly = ((object)value2.Instance).GetType().Assembly; Type type = assembly.GetType("ItemQualities.QualityCatalog", throwOnError: false); if (type == null) { continue; } Type type2 = assembly.GetType("ItemQualities.QualityTier", throwOnError: false); if (type2 == null) { continue; } MethodInfo method = type.GetMethod("GetItemIndexOfQuality", new Type[2] { typeof(ItemIndex), type2 }); if (method == null) { continue; } string[] array = new string[4] { "Uncommon", "Rare", "Epic", "Legendary" }; foreach (string text in array) { try { ItemIndex val = (ItemIndex)method.Invoke(null, new object[2] { baseIndex, Enum.Parse(type2, text) }); if ((int)val != -1 && !list.Contains(val)) { list.Add(val); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Unable to resolve Quality item tier " + text + ": " + ex.Message)); } } break; } value = list.ToArray(); families[baseIndex] = value; return value; } } internal sealed class Settings : IDisposable { public ConfigEntry<bool> FullHealth { get; } public ConfigEntry<bool> Seeker { get; } public ConfigEntry<bool> FaradayEnabled { get; } public ConfigEntry<bool> FaradayExcludeAbyss { get; } public LinkedPercentage Faraday { get; } public ConfigEntry<bool> HelmetEnabled { get; } public ConfigEntry<bool> HelmetExcludeAbyss { get; } public LinkedPercentage Helmet { get; } public Settings(ConfigFile config) { FullHealth = config.Bind<bool>("01 Health", "Full health (excluding Acolyte)", true, "Start each Winnowing trial at full HP in Eclipse. Excludes Acolyte."); Seeker = config.Bind<bool>("02 Seeker", "Prepare Seeker (Meditate only)", true, "Start each trial with 6 Tranquility + 1 Saving Grace. Requires Meditate in your loadout."); FaradayEnabled = config.Bind<bool>("03 Faraday Spur", "Enable Faraday preparation", true, "Faraday Spur starts with the selected charge. Adjust the starting percentage with the slider. Supports all Quality tiers."); FaradayExcludeAbyss = config.Bind<bool>("03 Faraday Spur", "Exclude Trial of the Abyss", true, "Skip automatic Faraday charging for the Trial of the Abyss."); Faraday = new LinkedPercentage(config.Bind<bool>("03 Faraday Spur", "100% charge", true, "Faraday Spur starts at full charge. Adjust the exact starting percentage with the slider."), Percent(config, "03 Faraday Spur", "Starting charge (%)", "Minimum starting charge, from 0–100%. Normal movement can build more.")); HelmetEnabled = config.Bind<bool>("04 Ritual Helmet", "Enable Ritual Helmet preparation", true, "Prepare Ritual Helmet’s sprint charges and speed ramp. Adjust the starting speed percentage with the slider."); HelmetExcludeAbyss = config.Bind<bool>("04 Ritual Helmet", "Exclude Trial of the Abyss", true, "Skip automatic Ritual Helmet preparation for the Trial of the Abyss."); Helmet = new LinkedPercentage(config.Bind<bool>("04 Ritual Helmet", "Maximum sprint speed (100%)", true, "Ritual Helmet starts at its maximum speed ramp. Adjust the exact starting percentage with the slider."), Percent(config, "04 Ritual Helmet", "Starting speed ramp (%)", "Percentage of the normal maximum speed ramp for your helmet count. 0% disables preparation.")); } private static ConfigEntry<float> Percent(ConfigFile config, string section, string name, string description) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown return config.Bind<float>(section, name, 100f, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); } public void Dispose() { Faraday.Dispose(); Helmet.Dispose(); } } public sealed class TrialPreparation : MonoBehaviour { private TrialController controller; private readonly PreparationWindow window = new PreparationWindow(); private readonly Dictionary<int, float> firstSeen = new Dictionary<int, float>(); private readonly HashSet<string> reported = new HashSet<string>(); private float nextTick; internal void Initialize(TrialController value) { controller = value; } internal void Close() { window.Close(); ((Behaviour)this).enabled = false; } private void FixedUpdate() { if (window.Closed) { ((Behaviour)this).enabled = false; } else if (!(Time.fixedTime < nextTick)) { nextTick = Time.fixedTime + 0.08f; Prepare(finalPass: false); } } internal void Prepare(bool finalPass) { if (window.Closed) { return; } try { PrepareCore(finalPass); } catch (Exception ex) { Close(); Plugin.Log.LogError((object)("Trial preparation stopped for this trial after a setup failure; the error will not be repeated every update: " + ex)); } } private void PrepareCore(bool finalPass) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 if (!NetworkServer.active || !Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)Run.instance) || !((Behaviour)controller).isActiveAndEnabled || !window.Observe(controller.hasTrialStarted, (int)controller.trialControllerState == 0) || (Object.op_Implicit((Object)(object)controller.inventorySafekeepController) && !controller.inventorySafekeepController.hasSafekeptInventories)) { return; } foreach (CharacterBody body in CharacterBody.readOnlyInstancesList) { if (!Object.op_Implicit((Object)(object)body) || !body.isPlayerControlled || !Object.op_Implicit((Object)(object)body.master) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive) { continue; } int player = ((Object)body.master).GetInstanceID(); if (!firstSeen.TryGetValue(player, out var value)) { value = (firstSeen[player] = Time.fixedTime); } if (finalPass || !(Time.fixedTime - value < 0.12f)) { TryFeature("Seeker", delegate { PrepareSeeker(body, player); }); TryFeature("Health", delegate { PrepareHealth(body, player); }); TryFeature("Faraday", delegate { PrepareFaraday(body); }); TryFeature("Helmet", delegate { PrepareHelmet(body); }); } } if (finalPass && ((Plugin.Settings.FaradayEnabled.Value && Plugin.Settings.FaradayExcludeAbyss.Value) || (Plugin.Settings.HelmetEnabled.Value && Plugin.Settings.HelmetExcludeAbyss.Value)) && !TrialVariantFilter.IsResolved(controller)) { Plugin.Log.LogWarning((object)"Could not identify the chosen trial's configured objective before the timer started. Item preparation with 'Exclude Trial of the Abyss' checked was left off for this trial. Health and Seeker preparation are independent of this check."); } } private void TryFeature(string name, Action action) { try { action(); } catch (Exception ex) { if (reported.Add(name)) { Plugin.Log.LogError((object)(name + " preparation failed; other options remain active: " + ex)); } } } private void PrepareHealth(CharacterBody body, int player) { //IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.FullHealth.Value || window.HasPreparedHealth(player)) { return; } DifficultyIndex selectedDifficulty = Run.instance.selectedDifficulty; if ((int)selectedDifficulty >= 3 && (int)selectedDifficulty <= 10 && !Object.op_Implicit((Object)(object)((Component)body).GetComponent<AcolyteFormController>()) && !Object.op_Implicit((Object)(object)((Component)body).GetComponent<AcolyteBodySwapController>()) && (!Object.op_Implicit((Object)(object)BodyPrefabs.AcolyteBody) || (body.bodyIndex != BodyPrefabs.AcolyteBody.bodyIndex && !((Object)(object)body.master.bodyPrefab == (Object)(object)((Component)BodyPrefabs.AcolyteBody).gameObject)))) { body.RecalculateStats(); if (!(body.healthComponent.fullHealth <= 0f)) { body.healthComponent.Networkhealth = body.healthComponent.fullHealth; window.MarkHealthPrepared(player); } } } private void PrepareSeeker(CharacterBody body, int player) { if (!Plugin.Settings.Seeker.Value || window.HasPreparedSeeker(player)) { return; } SeekerController component = ((Component)body).GetComponent<SeekerController>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.specialSkillSlot) || !Object.op_Implicit((Object)(object)component.meditateSkillDef) || (Object)(object)component.specialSkillSlot.baseSkill != (Object)(object)component.meditateSkillDef) { return; } for (int i = 0; i < 7; i++) { int num = Gates(body); if (num >= 7) { break; } component.CmdIncrementChakraGate(); if (Gates(body) <= num) { if (reported.Add("SeekerProgress")) { Plugin.Log.LogWarning((object)"Seeker's Meditate gate command made no progress; not forcing buff icons. Check for a Seeker rework mod."); } return; } } if (Gates(body) >= 7) { window.MarkSeekerPrepared(player); } } private static int Gates(CharacterBody body) { return body.GetBuffCount(Buffs.ChakraBuff) + (body.HasBuff(Buffs.RevitalizeBuff) ? 1 : 0); } private void PrepareFaraday(CharacterBody body) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.FaradayEnabled.Value || !TrialVariantFilter.AllowsPreparation(controller, Plugin.Settings.FaradayExcludeAbyss.Value) || !QualitySupport.HasEffectiveRental(body.inventory, Items.JumpDamageStrike)) { return; } int num = PercentMath.Stacks(Plugin.Settings.Faraday.Percent.Value, 100); if (body.GetBuffCount(Buffs.JumpDamageStrikeCharge) < num) { body.SetBuffCount(Buffs.JumpDamageStrikeCharge.buffIndex, num); JumpDamageStrikeBodyBehavior component = ((Component)body).GetComponent<JumpDamageStrikeBodyBehavior>(); if (Object.op_Implicit((Object)(object)component)) { component.auraDirty = true; component.displaysDirty = true; } } } private void PrepareHelmet(CharacterBody body) { //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.HelmetEnabled.Value || Plugin.Settings.Helmet.Percent.Value <= 0f || !TrialVariantFilter.AllowsPreparation(controller, Plugin.Settings.HelmetExcludeAbyss.Value) || !QualitySupport.HasEffectiveRental(body.inventory, Items.SprintDamage)) { return; } SprintDamageBodyBehavior component = ((Component)body).GetComponent<SprintDamageBodyBehavior>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.attachmentInstance)) { return; } EntityStateMachine component2 = component.attachmentInstance.GetComponent<EntityStateMachine>(); if (!Object.op_Implicit((Object)(object)component2)) { return; } EntityState state = component2.state; Inactive val = (Inactive)(object)((state is Inactive) ? state : null); if (val != null) { int num = Math.Max(1, Inactive.maxCharges); for (int i = 0; i < num; i++) { if ((object)component2.state != val) { break; } int buffCount = body.GetBuffCount(Buffs.SprintDamageCooldown); if (buffCount >= num) { break; } val.distanceMoved = Math.Max(val.distanceMoved, val.maxDistancePerCharge * (float)(num + 1)); val.UpdateChargeServer(); if (body.GetBuffCount(Buffs.SprintDamageCooldown) <= buffCount) { break; } } } EntityState state2 = component2.state; Active val2 = (Active)(object)((state2 is Active) ? state2 : null); if (val2 != null) { int maxSpeedBuffs = val2.GetMaxSpeedBuffs(); int num2 = PercentMath.Stacks(Plugin.Settings.Helmet.Percent.Value, maxSpeedBuffs); if (body.GetBuffCount(Buffs.SprintDamageSpeed) < num2) { body.SetBuffCount(Buffs.SprintDamageSpeed.buffIndex, num2); } } } } internal static class TrialVariantFilter { private enum Variant { Unresolved, Other, Abyss } internal static bool AllowsPreparation(TrialController controller, bool excludeAbyss) { if (excludeAbyss) { return Classify(controller) == Variant.Other; } return true; } internal static bool IsResolved(TrialController controller) { return Classify(controller) != Variant.Unresolved; } private static Variant Classify(TrialController controller) { if (!Object.op_Implicit((Object)(object)controller) || controller.trialVariants == null) { return Variant.Unresolved; } int networkvariantIndex = controller.NetworkvariantIndex; if (networkvariantIndex < 0 || networkvariantIndex >= controller.trialVariants.Length) { return Variant.Unresolved; } TrialVariantEventRelay val = controller.trialVariants[networkvariantIndex]; if (!Object.op_Implicit((Object)(object)val) || !val.chosen) { return Variant.Unresolved; } Variant variant = ClassifyEvent((UnityEventBase)(object)val.onVariantBegin); Variant variant2 = ClassifyEvent((UnityEventBase)(object)val.prepareSceneForVariant); if (variant == Variant.Abyss || variant2 == Variant.Abyss) { return Variant.Abyss; } if (variant != Variant.Other && variant2 != Variant.Other) { return Variant.Unresolved; } return Variant.Other; } private static Variant ClassifyEvent(UnityEventBase events) { //IL_000d: 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) if (events == null) { return Variant.Unresolved; } Variant result = Variant.Unresolved; for (int i = 0; i < events.GetPersistentEventCount(); i++) { if ((int)events.GetPersistentListenerState(i) == 0) { continue; } Object persistentTarget = events.GetPersistentTarget(i); QuestStarter val = (QuestStarter)(object)((persistentTarget is QuestStarter) ? persistentTarget : null); if (val == null || !Object.op_Implicit((Object)(object)val)) { continue; } Type type = (Type)val.quest; if (!(type == null)) { if (typeof(TrialQuestSurvivorMonstersOffMap).IsAssignableFrom(type)) { return Variant.Abyss; } if (typeof(BaseTrialQuest).IsAssignableFrom(type)) { result = Variant.Other; } } } return result; } }