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 AllBossRouteLite v1.1.5
20 Minute Ping.dll
Decompiled 2 hours agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using On.RoR2.UI; using R2API.Utils; using RoR2.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("20 Minute Ping")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("20 Minute Ping")] [assembly: AssemblyTitle("20 Minute Ping")] [assembly: AssemblyVersion("1.0.0.0")] namespace TwentyMinutePing; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.TeaBoneJones.TwentyMinutePing", "20 Minute Ping", "1.0.0")] public class TwentyMinutePing : BaseUnityPlugin { private static ConfigWrapper<int> minutes; public void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown minutes = ((BaseUnityPlugin)this).Config.Wrap<int>("Ping Indicator", "Minutes", "Set how long you want the ping to be enabled for, in minutes. Default = 20", 20); float seconds = minutes.Value * 60; PingIndicator.RebuildPing += (hook_RebuildPing)delegate(orig_RebuildPing orig, PingIndicator self) { orig.Invoke(self); Reflection.SetFieldValue<float>((object)self, "fixedTimer", seconds); }; } }
BazaarOverhaul.dll
Decompiled 2 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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 EntityStates.NewtMonster; using EntityStates.SolusVendor; using HarmonyLib; using RoR2; using RoR2.CharacterSpeech; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace BazaarOverhaul { [BepInPlugin("custom.BazaarOverhaul", "BazaarOverhaul", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BazaarOverhaulPlugin : BaseUnityPlugin { public const string QualityGUID = "com.Gorakh.ItemQualities"; internal static BazaarOverhaulPlugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<bool> GuaranteeBluePortal; internal static ConfigEntry<bool> FreeLunar; internal static ConfigEntry<bool> DisableLunarRecycler; internal static ConfigEntry<int> PrinterCount; internal static ConfigEntry<float> PrinterWhite; internal static ConfigEntry<float> PrinterGreen; internal static ConfigEntry<float> PrinterRed; internal static ConfigEntry<float> PrinterBoss; internal static ConfigEntry<int> QualityPrinterCount; internal static ConfigEntry<float> QualityWhite; internal static ConfigEntry<float> QualityGreen; internal static ConfigEntry<float> QualityRed; internal static ConfigEntry<float> QualityBoss; internal static ConfigEntry<int> ScrapperCount; internal static ConfigEntry<string> PrinterSpots; internal static ConfigEntry<string> QualityPrinterSpots; internal static ConfigEntry<string> ScrapperSpots; internal static ConfigEntry<bool> EssenceEnabled; internal static ConfigEntry<bool> EssenceOnLoops; internal static ConfigEntry<string> EssenceTiers; internal static ConfigEntry<string> EssenceFallbackPosition; internal static ConfigEntry<float> EssenceDistance; private static GameObject commandCubePrefab; internal static ConfigEntry<bool> NoKickOut; internal static ConfigEntry<float> NewtHealthMult; internal static ConfigEntry<float> NewtArmor; internal static ConfigEntry<bool> CompExchangeNoKickOut; private static BodyIndex newtIndex = (BodyIndex)(-1); private static bool suppressCompKick; private static Transform hiddenKickObject; private static bool compKickLogged; private static readonly string[] DuplicatorPaths = new string[4] { "RoR2/Base/Duplicator/iscDuplicator.asset", "RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset", "RoR2/Base/DuplicatorMilitary/iscDuplicatorMilitary.asset", "RoR2/Base/DuplicatorWild/iscDuplicatorWild.asset" }; private const string ScrapperPath = "RoR2/Base/Scrapper/iscScrapper.asset"; private static readonly string[] QualityFields = new string[4] { "QualityDuplicator", "QualityDuplicatorLarge", "QualityDuplicatorMilitary", "QualityDuplicatorWild" }; private static readonly InteractableSpawnCard[] duplicatorCards = (InteractableSpawnCard[])(object)new InteractableSpawnCard[4]; private static InteractableSpawnCard scrapperCard; private void Awake() { //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Expected O, but got Unknown //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Expected O, but got Unknown //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Expected O, but got Unknown //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Expected O, but got Unknown //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Expected O, but got Unknown //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Expected O, but got Unknown //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Expected O, but got Unknown //IL_069a: Expected O, but got Unknown //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Expected O, but got Unknown //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Expected O, but got Unknown //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; GuaranteeBluePortal = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "GuaranteeBluePortal", true, "Always spawn the Bazaar (blue) portal after every teleporter event."); FreeLunar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FreeLunarContent", true, "All Lunar Coin purchases cost 0 (lunar pods, bazaar shop, seers, newt altars, etc.)."); DisableLunarRecycler = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableLunarRecycler", true, "Block the Bazaar lunar shop reroll (Lunar Recycler)."); PrinterCount = ((BaseUnityPlugin)this).Config.Bind<int>("Printers", "Count", 4, "Regular printers added to the Bazaar (0-4)."); PrinterWhite = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "WhiteWeight", 60f, "Relative chance of a white printer."); PrinterGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "GreenWeight", 30f, "Relative chance of a green printer."); PrinterRed = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "RedWeight", 5f, "Relative chance of a red printer."); PrinterBoss = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "BossWeight", 5f, "Relative chance of a boss (yellow) printer."); QualityPrinterCount = ((BaseUnityPlugin)this).Config.Bind<int>("QualityPrinters", "Count", 2, "Quality printers added to the Bazaar when the Quality mod is installed (0-2)."); QualityWhite = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "WhiteWeight", 60f, "Relative chance of a white quality printer."); QualityGreen = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "GreenWeight", 30f, "Relative chance of a green quality printer."); QualityRed = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "RedWeight", 5f, "Relative chance of a red quality printer."); QualityBoss = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "BossWeight", 5f, "Relative chance of a boss quality printer."); ScrapperCount = ((BaseUnityPlugin)this).Config.Bind<int>("Scrappers", "Count", 4, "Scrappers added to the Bazaar (0-4)."); PrinterSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "PrinterPositions", "-133.3,-25.7,-17.9,72.6; -143.8,-24.7,-23.6,61; -110.7,-26.7,-46.4,32.2; -132,-25,-29.7,60", "Positions for regular printers as x,y,z,yaw separated by ';'. The y value is snapped to the floor."); QualityPrinterSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "QualityPrinterPositions", "-138.5,-25.2,-20.7,66; -121.4,-25.8,-38,45", "Positions for quality printers as x,y,z,yaw separated by ';'."); ScrapperSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "ScrapperPositions", "-87.1,-24,-7.2,72.6; -65.7,-23.5,-18.9,72.6; -82.1,-23.7,-5.2,72.6; -71.3,-24.7,-29.2,291", "Positions for scrappers as x,y,z,yaw separated by ';'."); EssenceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CommandEssence", "Enabled", true, "Spawn one Command Essence in front of the Newt when entering the Bazaar."); EssenceTiers = ((BaseUnityPlugin)this).Config.Bind<string>("CommandEssence", "TiersAfterStage", "white,green,green,red", "Tier of the essence when entering the Bazaar after stage 1,2,3,4 (white/green/red/boss/none). Stages beyond the list get nothing."); EssenceOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("CommandEssence", "ApplyOnLoops", false, "If true, the list repeats every loop (after stage 6-9 etc.). If false, only after the first 4 stages."); EssenceDistance = ((BaseUnityPlugin)this).Config.Bind<float>("CommandEssence", "ForwardDistanceFromCauldrons", 15f, "How far in front of the midpoint between the two Bazaar cauldrons the essence appears. Use a negative value to place it behind instead."); EssenceFallbackPosition = ((BaseUnityPlugin)this).Config.Bind<string>("CommandEssence", "FallbackPosition", "-81.5,-23.6,-46.3", "Used if the cauldrons cannot be found (x,y,z)."); NoKickOut = ((BaseUnityPlugin)this).Config.Bind<bool>("Newt", "DisableKickOut", true, "The Newt never kicks players out of the Bazaar."); NewtHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Newt", "HealthMultiplier", 10f, "Multiplier for the Newt's max health (1 = vanilla)."); NewtArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Newt", "Armor", 0f, "The Newt's armor. Vanilla is 100. Armor-reducing debuffs still lower it further."); CompExchangeNoKickOut = ((BaseUnityPlugin)this).Config.Bind<bool>("Computational Exchange", "DisableKickOut", true, "The Solus vendor's Extractor never kicks players out of the Computational Exchange after stealing (and no Karma is gained for it, same as the Bazaar no-kick)."); AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Command/CommandCube.prefab"); val.Completed += delegate(AsyncOperationHandle<GameObject> h) { commandCubePrefab = h.Result; }; for (int num = 0; num < 4; num++) { int idx = num; AsyncOperationHandle<InteractableSpawnCard> val2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)DuplicatorPaths[num]); val2.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> h) { duplicatorCards[idx] = h.Result; }; } AsyncOperationHandle<InteractableSpawnCard> val3 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Scrapper/iscScrapper.asset"); val3.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> h) { scrapperCard = h.Result; }; Harmony val4 = new Harmony("custom.BazaarOverhaul"); MethodInfo methodInfo = AccessTools.Method(typeof(TeleporterInteraction), "Start", (Type[])null, (Type[])null); HarmonyMethod val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "TeleporterStartPostfix", (Type[])null); val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(PurchaseInteraction), "Awake", (Type[])null, (Type[])null); val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "PurchaseCostPostfix", (Type[])null); val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(PurchaseInteraction), "Start", (Type[])null, (Type[])null); val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "PurchaseStartPostfix", (Type[])null); val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val4.Patch((MethodBase)AccessTools.Method(typeof(PurchaseInteraction), "GetInteractability", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "InteractabilityPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Type typeFromHandle = typeof(KickFromShop); val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickOnEnterPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "FixedUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickSkipPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnExit", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickSkipPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CharacterBody.onBodyStartGlobal += OnBodyStart; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetNewtArmor)); try { val4.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(BazaarOverhaulPlugin), "NewtArmorPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Log.LogError((object)("Newt armor hook failed: " + ex)); } try { val4.Patch((MethodBase)AccessTools.Method(typeof(StealItem), "OnExit", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "StealExitPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BazaarOverhaulPlugin), "StealExitFinalizer", (Type[])null), (HarmonyMethod)null); val4.Patch((MethodBase)AccessTools.Method(typeof(Util), "KarmaEventTrigger", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KarmaPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val4.Patch((MethodBase)AccessTools.Method(typeof(SolusVendorShrineSpeechDriver), "SayGetOut", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "SayGetOutPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex2) { Log.LogError((object)("Computational Exchange no-kick hook failed: " + ex2)); } TeleporterInteraction.onTeleporterBeginChargingGlobal += delegate(TeleporterInteraction tp) { ForceShopPortal(tp); }; Stage.onServerStageBegin += OnServerStageBegin; } private static void TeleporterStartPostfix(TeleporterInteraction __instance) { ForceShopPortal(__instance); } private static void ForceShopPortal(TeleporterInteraction tp) { if (!GuaranteeBluePortal.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)tp)) { return; } try { tp.shouldAttemptToSpawnShopPortal = true; } catch (Exception ex) { Log.LogError((object)ex); } } private static void PurchaseCostPostfix(PurchaseInteraction __instance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if (FreeLunar.Value && Object.op_Implicit((Object)(object)__instance) && (int)__instance.costType == 3) { __instance.cost = 0; } } private static void PurchaseStartPostfix(PurchaseInteraction __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (FreeLunar.Value && NetworkServer.active && Object.op_Implicit((Object)(object)__instance)) { if ((int)__instance.costType == 3 && __instance.cost != 0) { __instance.Networkcost = 0; } if (DisableLunarRecycler.Value && IsRecycler(__instance)) { __instance.SetAvailable(false); } } } private static bool IsRecycler(PurchaseInteraction pi) { if (Object.op_Implicit((Object)(object)pi)) { return ((Object)((Component)pi).gameObject).name.StartsWith("LunarRecycler", StringComparison.OrdinalIgnoreCase); } return false; } private static bool InteractabilityPrefix(PurchaseInteraction __instance, ref Interactability __result) { if (DisableLunarRecycler.Value && IsRecycler(__instance)) { __result = (Interactability)0; return false; } return true; } private static void OnServerStageBegin(Stage stage) { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && !(mostRecentSceneDef.cachedName != "bazaar")) { ((MonoBehaviour)Instance).StartCoroutine(SetUpBazaar()); } } private static IEnumerator SetUpBazaar() { yield return (object)new WaitForSeconds(0.5f); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance)) { yield break; } if (DisableLunarRecycler.Value) { PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>(); foreach (PurchaseInteraction val in array) { if (IsRecycler(val)) { val.SetAvailable(false); } } } Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.stageRng.nextUlong); for (int w = 0; w < 10; w++) { if (FindCauldrons().Count >= 2) { break; } yield return (object)new WaitForSeconds(0.5f); } try { SpawnCommandEssence(rng); } catch (Exception ex) { Log.LogError((object)ex); } List<GameObject> spawned = new List<GameObject>(); List<Vector4> list = ParseSpots(PrinterSpots.Value); int num = Mathf.Min(Mathf.Max(0, PrinterCount.Value), list.Count); for (int j = 0; j < num; j++) { SpawnAt(duplicatorCards[PickTier(rng, PrinterWhite.Value, PrinterGreen.Value, PrinterRed.Value, PrinterBoss.Value)], list[j], rng, spawned); } List<Vector4> list2 = ParseSpots(QualityPrinterSpots.Value); int num2 = Mathf.Min(Mathf.Max(0, QualityPrinterCount.Value), list2.Count); if (num2 > 0 && Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities")) { InteractableSpawnCard[] qualityCards = GetQualityCards(); for (int k = 0; k < num2; k++) { InteractableSpawnCard val2 = qualityCards[PickTier(rng, QualityWhite.Value, QualityGreen.Value, QualityRed.Value, QualityBoss.Value)]; if (!Object.op_Implicit((Object)(object)val2)) { Log.LogWarning((object)"Quality printer spawn card not found."); } else { SpawnAt(val2, list2[k], rng, spawned); } } } List<Vector4> list3 = ParseSpots(ScrapperSpots.Value); int num3 = Mathf.Min(Mathf.Max(0, ScrapperCount.Value), list3.Count); for (int l = 0; l < num3; l++) { SpawnAt(scrapperCard, list3[l], rng, spawned); } yield return (object)new WaitForSeconds(1f); foreach (GameObject item in spawned) { if (!Object.op_Implicit((Object)(object)item)) { continue; } ShopTerminalBehavior component = item.GetComponent<ShopTerminalBehavior>(); if (!Object.op_Implicit((Object)(object)component)) { continue; } try { if (component.CurrentPickupIndex() == PickupIndex.none) { component.GenerateNewPickupServer(); } } catch (Exception ex2) { Log.LogError((object)ex2); } } Log.LogInfo((object)("Bazaar: spawned " + spawned.Count + " interactables.")); } private static bool KickOnEnterPrefix(KickFromShop __instance) { if (!NoKickOut.Value) { return true; } try { if (Object.op_Implicit((Object)(object)((EntityState)__instance).outer)) { ((EntityState)__instance).outer.SetNextStateToMain(); } } catch (Exception ex) { Log.LogError((object)ex); } return false; } private static bool KickSkipPrefix() { return !NoKickOut.Value; } private static void SetNewtArmor() { //IL_0005: 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) try { newtIndex = BodyCatalog.FindBodyIndex("ShopkeeperBody"); GameObject val = BodyCatalog.FindBodyPrefab("ShopkeeperBody"); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val2)) { Log.LogInfo((object)("Newt armor " + val2.baseArmor + " (+" + val2.levelArmor + "/level) -> " + NewtArmor.Value)); val2.baseArmor = NewtArmor.Value; val2.levelArmor = 0f; } else { Log.LogWarning((object)"Newt body not found; its armor is unchanged."); } } catch (Exception ex) { Log.LogError((object)ex); } } private static void NewtArmorPostfix(CharacterBody __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((int)newtIndex != -1 && Object.op_Implicit((Object)(object)__instance) && __instance.bodyIndex == newtIndex && __instance.armor > NewtArmor.Value) { __instance.armor = NewtArmor.Value; } } private static void StealExitPrefix() { if (!CompExchangeNoKickOut.Value) { return; } suppressCompKick = true; try { Transform val = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? ((Component)SceneInfo.instance).transform.Find("KickOutOfShop") : null); if (Object.op_Implicit((Object)(object)val)) { ((Object)val).name = "KickOutOfShop (blocked by BazaarOverhaul)"; hiddenKickObject = val; } if (!compKickLogged) { compKickLogged = true; Log.LogInfo((object)"Computational Exchange: kick-out blocked."); } } catch (Exception ex) { Log.LogError((object)ex); } } private static Exception StealExitFinalizer(Exception __exception) { if (Object.op_Implicit((Object)(object)hiddenKickObject)) { ((Object)hiddenKickObject).name = "KickOutOfShop"; } hiddenKickObject = null; suppressCompKick = false; return __exception; } private static bool KarmaPrefix(string identifier, ref bool __result) { if (suppressCompKick && identifier == "KickedOutOfCompExchange") { __result = false; return false; } return true; } private static bool SayGetOutPrefix() { return !suppressCompKick; } private static void OnBodyStart(CharacterBody body) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master) || NewtHealthMult.Value <= 1f || body.bodyIndex != BodyCatalog.FindBodyIndex("ShopkeeperBody") || Object.op_Implicit((Object)(object)((Component)body.master).GetComponent<NewtBuffed>())) { return; } ((Component)body.master).gameObject.AddComponent<NewtBuffed>(); Inventory inventory = body.master.inventory; if (Object.op_Implicit((Object)(object)inventory)) { int itemCountPermanent = inventory.GetItemCountPermanent(Items.BoostHp); float num = 1f + 0.1f * (float)itemCountPermanent; int num2 = Mathf.RoundToInt((num * NewtHealthMult.Value - num) * 10f); if (num2 > 0) { inventory.GiveItemPermanent(Items.BoostHp, num2); } } } catch (Exception ex) { Log.LogError((object)ex); } } private unsafe static void SpawnCommandEssence(Xoroshiro128Plus rng) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0127: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!EssenceEnabled.Value) { return; } int stageClearCount = Run.instance.stageClearCount; if (stageClearCount < 1) { return; } string[] array = EssenceTiers.Value.Split(new char[1] { ',' }); int num = stageClearCount - 1; if (EssenceOnLoops.Value) { num %= 5; } if (num < array.Length) { List<PickupIndex> list; switch (array[num].Trim().ToLowerInvariant()) { default: return; case "white": list = Run.instance.availableTier1DropList; break; case "green": list = Run.instance.availableTier2DropList; break; case "red": list = Run.instance.availableTier3DropList; break; case "boss": list = Run.instance.availableBossDropList; break; } if (list != null && list.Count != 0) { PickupIndex pickupIndex = list[rng.RangeInt(0, list.Count)]; GetEssencePosition(out var pos, out var _); CreatePickupInfo val = default(CreatePickupInfo); ((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex; val.position = pos; val.rotation = Quaternion.identity; val.artifactFlag = (PickupArtifactFlag)1; PickupDropletController.CreatePickupDroplet(val, pos, Vector3.up * 10f); ManualLogSource log = Log; string text = array[num].Trim(); Vector3 val2 = pos; log.LogInfo((object)("Spawned " + text + " Command Essence at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString())); } } } private static List<Transform> FindCauldrons() { List<Transform> list = new List<Transform>(); PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>(); foreach (PurchaseInteraction val in array) { if (Object.op_Implicit((Object)(object)val) && ((Object)((Component)val).gameObject).name.IndexOf("LunarCauldron", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(((Component)val).gameObject.transform); } } return list; } private static void GetEssencePosition(out Vector3 pos, out Quaternion rot) { //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_0171: Unknown result type (might be due to invalid IL or missing references) List<Transform> list = FindCauldrons(); if (list.Count >= 2) { Transform val = list[0]; Transform val2 = list[1]; float num = float.MaxValue; for (int i = 0; i < list.Count; i++) { for (int j = i + 1; j < list.Count; j++) { Vector3 val3 = list[i].position - list[j].position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = list[i]; val2 = list[j]; } } } Vector3 val4 = (val.position + val2.position) * 0.5f; Vector3 val5 = val.forward + val2.forward; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.01f) { Vector3 val6 = val2.position - val.position; val6.y = 0f; val5 = Vector3.Cross(Vector3.up, val6); } ((Vector3)(ref val5)).Normalize(); Vector3 val7 = val4 + val5 * EssenceDistance.Value + Vector3.up * 5f; Vector3 val8 = val7; Vector3 down = Vector3.down; LayerIndex world = LayerIndex.world; RaycastHit val9 = default(RaycastHit); if (Physics.Raycast(val8, down, ref val9, 20f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1)) { val7 = ((RaycastHit)(ref val9)).point; } pos = val7 + Vector3.up * 1f; rot = Quaternion.LookRotation(-val5); Log.LogInfo((object)("Command Essence placed between cauldrons " + ((Object)((Component)val).gameObject).name + " and " + ((Object)((Component)val2).gameObject).name)); } else { Log.LogWarning((object)"Bazaar cauldrons not found; using fallback position."); pos = ParseVector(EssenceFallbackPosition.Value, new Vector3(-81.5f, -23.6f, -46.3f)); rot = Quaternion.identity; } } private static Vector3 ParseVector(string s, Vector3 fallback) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0040: Unknown result type (might be due to invalid IL or missing references) try { string[] array = s.Split(new char[1] { ',' }); CultureInfo invariantCulture = CultureInfo.InvariantCulture; return new Vector3(float.Parse(array[0], invariantCulture), float.Parse(array[1], invariantCulture), float.Parse(array[2], invariantCulture)); } catch { return fallback; } } private static GameObject Spawn(InteractableSpawnCard card, Vector3 pos, float yaw, Xoroshiro128Plus rng) { //IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001a: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001c: 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_002e: Unknown result type (might be due to invalid IL or missing references) try { DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)card, new DirectorPlacementRule { placementMode = (PlacementMode)0, position = pos }, rng); return ((SpawnCard)card).DoSpawn(pos, Quaternion.Euler(0f, yaw, 0f), val).spawnedInstance; } catch (Exception ex) { Log.LogError((object)ex); return null; } } private unsafe static void SpawnAt(InteractableSpawnCard card, Vector4 spot, Xoroshiro128Plus rng, List<GameObject> spawned) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0032: 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_0041: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) //IL_0073: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)card)) { Log.LogWarning((object)"Spawn card not loaded; skipped."); return; } Vector3 point = default(Vector3); ((Vector3)(ref point))..ctor(spot.x, spot.y, spot.z); Vector3 val = point + Vector3.up * 6f; Vector3 down = Vector3.down; LayerIndex world = LayerIndex.world; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, down, ref val2, 15f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1)) { point = ((RaycastHit)(ref val2)).point; } GameObject val3 = Spawn(card, point, spot.w, rng); if (Object.op_Implicit((Object)(object)val3)) { spawned.Add(val3); ManualLogSource log = Log; string name = ((Object)card).name; Vector3 val4 = point; log.LogInfo((object)("Spawned " + name + " at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString())); } else { ManualLogSource log2 = Log; string name2 = ((Object)card).name; Vector3 val4 = point; log2.LogWarning((object)("Failed to spawn " + name2 + " at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString())); } } private static List<Vector4> ParseSpots(string value) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) List<Vector4> list = new List<Vector4>(); CultureInfo invariantCulture = CultureInfo.InvariantCulture; string[] array = value.Split(new char[1] { ';' }); foreach (string text in array) { string[] array2 = text.Split(new char[1] { ',' }); if (array2.Length >= 3) { try { list.Add(new Vector4(float.Parse(array2[0].Trim(), invariantCulture), float.Parse(array2[1].Trim(), invariantCulture), float.Parse(array2[2].Trim(), invariantCulture), (array2.Length <= 3) ? 0f : float.Parse(array2[3].Trim(), invariantCulture))); } catch { Log.LogWarning((object)("Bad position entry: " + text)); } } } return list; } private static int PickTier(Xoroshiro128Plus rng, float w, float g, float r, float b) { float num = Mathf.Max(0f, w) + Mathf.Max(0f, g) + Mathf.Max(0f, r) + Mathf.Max(0f, b); if (num <= 0f) { return 0; } float num2 = rng.nextNormalizedFloat * num; if ((num2 -= Mathf.Max(0f, w)) < 0f) { return 0; } if ((num2 -= Mathf.Max(0f, g)) < 0f) { return 1; } if ((num2 -= Mathf.Max(0f, r)) < 0f) { return 2; } return 3; } private static InteractableSpawnCard[] GetQualityCards() { InteractableSpawnCard[] array = (InteractableSpawnCard[])(object)new InteractableSpawnCard[4]; try { Type type = Type.GetType("ItemQualities.ItemQualitiesContent+SpawnCards, ItemQualities"); if (type == null) { return array; } for (int i = 0; i < 4; i++) { FieldInfo field = type.GetField(QualityFields[i], BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { ref InteractableSpawnCard reference = ref array[i]; object? value = field.GetValue(null); reference = (InteractableSpawnCard)((value is InteractableSpawnCard) ? value : null); } } } catch (Exception ex) { Log.LogError((object)ex); } return array; } } public class NewtBuffed : MonoBehaviour { } }
EnemyCap20.dll
Decompiled 2 hours agousing System; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using RoR2; [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace EnemyCap20 { [BepInPlugin("custom.EnemyCap20", "EnemyCap20", "1.0.1")] public class EnemyCapPlugin : BaseUnityPlugin { private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("General", "EnemyCap", 15, "Max enemies alive per enemy team (vanilla: 40). Applies to Monster, Lunar and Void teams."); TeamIndex[] array = new TeamIndex[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); TeamIndex[] array2 = (TeamIndex[])(object)array; foreach (TeamIndex val2 in array2) { TeamDef teamDef = TeamCatalog.GetTeamDef(val2); if (teamDef != null) { teamDef.softCharacterLimit = val.Value; ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Concat(val2, " cap set to ", val.Value)); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } }
MithrixRunTweaks.dll
Decompiled 2 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.BrotherMonster; using EntityStates.BrotherMonster.Weapon; using EntityStates.Missions.BrotherEncounter; using EntityStates.Seeker; using HarmonyLib; using RoR2; using RoR2.Artifacts; using RoR2.Projectile; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace MithrixRunTweaks { [BepInPlugin("custom.MithrixRunTweaks", "MithrixRunTweaks", "1.5.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MithrixRunTweaksPlugin : BaseUnityPlugin { public const string GUID = "custom.MithrixRunTweaks"; public const string NAME = "MithrixRunTweaks"; public const string VERSION = "1.5.1"; internal static ManualLogSource Log; internal static MithrixRunTweaksPlugin Instance; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Instance = this; Harmony harmony = new Harmony("custom.MithrixRunTweaks"); if (Chainloader.PluginInfos.ContainsKey("custom.BossSuperArmor")) { Log.LogWarning((object)"BossSuperArmor is installed and already gives Mithrix these defenses; the Mithrix part of this mod is off."); } else { Safe("Mithrix defenses", delegate { MithrixDefenses.Init(((BaseUnityPlugin)this).Config, harmony); }); } if (Chainloader.PluginInfos.ContainsKey("custom.StageMountainShrines")) { Log.LogWarning((object)"StageMountainShrines is installed; the Mountain Shrine part of this mod is off."); } else { Safe("Mountain Shrines", delegate { MountainShrines.Init(((BaseUnityPlugin)this).Config, harmony); }); } if (Chainloader.PluginInfos.ContainsKey("custom.MiscellaneousBuffs")) { Log.LogWarning((object)"MiscellaneousBuffs is installed and already has the Seeker changes; the Seeker part of this mod is off."); } else { Safe("Seeker", delegate { SeekerChanges.Init(((BaseUnityPlugin)this).Config, harmony); }); } Safe("Mithrix phases", delegate { MithrixPhases.Init(((BaseUnityPlugin)this).Config, harmony); }); } private static void Safe(string what, Action a) { try { a(); } catch (Exception ex) { Log.LogError((object)(what + ": " + ex)); } } internal static MethodInfo TakeDamageMethod() { return AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null); } } internal static class MithrixDefenses { private class Rule { public ConfigEntry<bool> enabled; public ConfigEntry<float> thresholdPercent; public ConfigEntry<float> duration; public float Threshold => Mathf.Max(0.001f, thresholdPercent.Value / 100f); } private struct ArmorHit { public bool tracked; public bool addedNonLethal; public float preHealth; public float preShield; public float preBarrier; public float allowed; public float duration; } private struct CapHit { public float hp; public float adaptive; } internal class ItemReturnTimer : MonoBehaviour { public float next; } private enum P4Step { Shards, Slam, Pizza } internal class P4Pattern : MonoBehaviour { public int index; public int shardsThisBurst; public float lastShardTime; public float forcedAt = -100f; public float readyAt; public bool wasBusy; } internal class ArmorTracker : MonoBehaviour { public float damageAccumulated; public int phase = -1; public float readyAt; } private static class ArmorPatch { private static void Prefix(HealthComponent __instance, DamageInfo damageInfo, out ArmorHit __state) { ArmorPrefix(__instance, damageInfo, out __state); } private static void Postfix(HealthComponent __instance, DamageInfo damageInfo, ArmorHit __state) { ArmorPostfix(__instance, damageInfo, __state); } } private static class CapPatch { private static void Prefix(HealthComponent __instance, DamageInfo damageInfo, out CapHit __state) { CapPrefix(__instance, damageInfo, out __state); } private static void Postfix(HealthComponent __instance, CapHit __state) { CapPostfix(__instance, __state); } } private static readonly string[] MithrixBodies = new string[3] { "BrotherBody", "BrotherHurtBody", "BrotherHurtBodyP3" }; private static readonly HashSet<BodyIndex> mithrixIdx = new HashSet<BodyIndex>(); private static readonly Rule[] rules = new Rule[5]; private static ConfigEntry<bool> requireKarma; private static ConfigEntry<bool> adaptiveEnabled; private static ConfigEntry<int> adaptiveStacks; private static ConfigEntry<float> healthMult; private static ConfigEntry<bool> blockBarrier; private static ConfigEntry<bool> logHealth; private static float nextHealthLog; private static readonly HashSet<string> loggedSources = new HashSet<string>(); private static ConfigEntry<float> armorCooldown; private static ConfigEntry<float> phase4HealthMult; private static ConfigEntry<bool> pizzaInstakill; private static ConfigEntry<float> itemReturnInterval; private static ConfigEntry<string> p4PatternConfig; private static ConfigEntry<bool> p4SlamSelfDamage; private static ConfigEntry<float> p4Cooldown; private static P4Step[] p4Steps = new P4Step[0]; private static BodyIndex hurtBodyIndex = (BodyIndex)(-1); private static readonly string[] PizzaNames = new string[4] { "BrotherUltLineProjectile", "UmbralUltLine", "P4UltLine", "StaticUltLine" }; private static readonly string[] PizzaExclude = new string[1] { "BrotherUltLineProjectileStatic" }; private static ConfigEntry<bool> softCap; private static ConfigEntry<float> capPercent; private static ConfigEntry<float> excessMult; private static BuffDef armorBuff; private static int requiredKarma = 1; private static GameObject applicationEffect; private static int mithrixPhase; private static bool healthApplied; internal static void Init(ConfigFile cfg, Harmony h) { //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Expected O, but got Unknown //IL_02dd: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown //IL_031d: Expected O, but got Unknown //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Expected O, but got Unknown //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Expected O, but got Unknown //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Expected O, but got Unknown //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Expected O, but got Unknown //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Expected O, but got Unknown requireKarma = cfg.Bind<bool>("Mithrix Super Armor", "RequireKarma", false, "Off (default): Mithrix always has the super armor, whether or not Karma is on. On: only when the run's Karma meets his vanilla requirement (Karma 1)."); rules[1] = MakeRule(cfg, 1, 20f, 1f); rules[3] = MakeRule(cfg, 3, 10f, 1f); rules[4] = MakeRule(cfg, 4, 20f, 1f); healthMult = cfg.Bind<float>("Mithrix Health", "Phase1And3Multiplier", 2f, "Mithrix's max HP multiplier in phases 1 and 3 (phase 4 is unchanged): his base HP and HP per level are multiplied, so the game's own boss scaling multiplies on top. 1 = vanilla. Needs a restart."); blockBarrier = cfg.Bind<bool>("Mithrix Health", "BlockBarrier", true, "Mithrix can't have barrier (temporary HP) from anything: items that give enemies barrier, items he steals in phase 4, other mods, and so on."); logHealth = cfg.Bind<bool>("Debug", "LogMithrixHealth", false, "Write Mithrix's health, shield, barrier, buffs and items to the log when he spawns and every 10 seconds, and log what gave him barrier or pushed his health over max. Needs a restart."); phase4HealthMult = cfg.Bind<float>("Mithrix Health", "Phase4Multiplier", 2f, "Mithrix's max HP multiplier in phase 4 (base HP and HP per level, so the game's boss scaling multiplies on top). 1 = vanilla. Needs a restart."); pizzaInstakill = cfg.Bind<bool>("Mithrix Pizza", "AlwaysInstakill", true, "Mithrix's pizza (the rotating laser lines of his ultimate) kills whoever it hits outright, through every kind of invincibility, one-shot protection, Safer Spaces, Tougher Times, shields and barrier. Revive items still work afterwards."); itemReturnInterval = cfg.Bind<float>("Mithrix Phase 4", "ItemReturnInterval", 120f, "Every this many seconds in phase 4 (counted from when he has finished stealing), Mithrix gives one item back to the next player in line, on top of the items he gives back when he is hit. Stops softlocks. 0 = off."); p4PatternConfig = cfg.Bind<string>("Mithrix Phase 4", "AttackPattern", "shards,shards,slam,shards,shards,pizza", "Phase 4 Mithrix's attacks in this order, over and over: shards = a needle burst (his lunar shards until he runs out), slam = his lunar orb slam, pizza = his ultimate (the rotating laser lines, an instant kill). His other attacks are left alone. Empty = vanilla AI. Needs a restart."); p4Cooldown = cfg.Bind<float>("Mithrix Phase 4", "AttackCooldown", 3f, "Minimum seconds between the end of one attack and the start of the next in phase 4 (needle bursts, the lunar orb slam, the pizza and his other attacks). Only with an AttackPattern. 0 = none."); p4SlamSelfDamage = cfg.Bind<bool>("Mithrix Phase 4", "OrbSlamSelfDamage", false, "Vanilla: Mithrix's lunar orb slam costs him 8% of his current health. Off (default): it doesn't."); ParsePattern(); armorCooldown = cfg.Bind<float>("Mithrix Super Armor", "Cooldown", 5f, "Seconds after super armor ends before it can start again. Damage dealt in that time doesn't count towards the next one. 0 = no cooldown."); adaptiveEnabled = cfg.Bind<bool>("Mithrix Adaptive Armor", "Enabled", true, "Give Mithrix adaptive armor (vanilla Adaptive Armor with extra stacks and no cap). Each phase starts from zero."); adaptiveStacks = cfg.Bind<int>("Mithrix Adaptive Armor", "Stacks", 2, "Adaptive Armor stacks. Every stack gives +30 armor per 1% of max HP lost, with no cap; it all decays at 40 armor per second."); softCap = cfg.Bind<bool>("Mithrix Soft Damage Cap", "Enabled", true, "Damage from a single hit above CapPercent of Mithrix's max HP is reduced. Checked after armor."); capPercent = cfg.Bind<float>("Mithrix Soft Damage Cap", "CapPercent", 5f, "Soft cap threshold, percent of max HP."); excessMult = cfg.Bind<float>("Mithrix Soft Damage Cap", "ExcessMultiplier", 0.5f, "Multiplier for the part of a hit above the cap (0.5 = halved)."); AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherBody.prefab"); val.Completed += delegate(AsyncOperationHandle<GameObject> handle) { ReadMithrixArmor(handle.Result); }; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ResolveBodies)); Stage.onStageStartGlobal += delegate { mithrixPhase = 0; }; CharacterBody.onBodyStartGlobal += OnBodyStart; MethodInfo methodInfo = MithrixRunTweaksPlugin.TakeDamageMethod(); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ArmorPatch), "Prefix", (Type[])null), new HarmonyMethod(typeof(ArmorPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CapPatch), "Prefix", (Type[])null) { priority = 800 }, new HarmonyMethod(typeof(CapPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(BrotherSuperArmorController), "OnDamageDealtServer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MithrixDefenses), "VanillaArmorPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(HealthComponent), "AddBarrier", new Type[1] { typeof(float) }, (Type[])null), new HarmonyMethod(typeof(MithrixDefenses), "AddBarrierPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(MithrixDefenses), "PizzaPrefix", (Type[])null) { priority = 10000 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); RoR2Application.onFixedUpdate += Phase4Tick; RoR2Application.onFixedUpdate += HealthTick; RoR2Application.onFixedUpdate += P4PatternTick; if (p4Steps.Length != 0) { h.Patch((MethodBase)AccessTools.Method(typeof(GenericSkill), "IsReady", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MithrixDefenses), "SkillGatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(GenericSkill), "CanExecute", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MithrixDefenses), "SkillGatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } h.Patch((MethodBase)AccessTools.Method(typeof(FistSlam), "OnEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MithrixDefenses), "FistSlamEnterPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (logHealth.Value) { TryPatchSetter(h, "Networkbarrier", "BarrierSetterPrefix"); TryPatchSetter(h, "Networkhealth", "HealthSetterPrefix"); } h.Patch((MethodBase)AccessTools.Method(typeof(EntityStateMachine), "SetState", new Type[1] { typeof(EntityState) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MithrixDefenses), "SetStatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix defenses on: super armor every " + rules[1].thresholdPercent.Value + "% / " + rules[3].thresholdPercent.Value + "% / " + rules[4].thresholdPercent.Value + "% of max HP (phases 1 / 3 / 4), uncapped adaptive armor, soft damage cap, HP x" + healthMult.Value + " in phases 1 and 3.")); } private static Rule MakeRule(ConfigFile cfg, int phase, float threshold, float duration) { string text = "Mithrix Super Armor - Phase " + phase; return new Rule { enabled = cfg.Bind<bool>(text, "Enabled", true, "Give Mithrix super armor in phase " + phase + " (replaces his vanilla super armor values)."), thresholdPercent = cfg.Bind<float>(text, "HealthThresholdPercent", threshold, "Super armor starts every time this percent of max HP is lost."), duration = cfg.Bind<float>(text, "Duration", duration, "Super armor duration in seconds.") }; } private static void ResolveBodies() { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) mithrixIdx.Clear(); string[] mithrixBodies = MithrixBodies; for (int i = 0; i < mithrixBodies.Length; i++) { BodyIndex val = BodyCatalog.FindBodyIndex(mithrixBodies[i]); if ((int)val != -1) { mithrixIdx.Add(val); } } ApplyHealth(); } private static void ApplyHealth() { if (!healthApplied) { healthApplied = true; ScaleBody("BrotherBody", healthMult.Value, "phases 1 and 3"); ScaleBody("BrotherHurtBody", phase4HealthMult.Value, "phase 4"); } } private static void ScaleBody(string bodyName, float value, string label) { try { if (!(value <= 0f) && value != 1f) { GameObject val = BodyCatalog.FindBodyPrefab(bodyName); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null); if (!Object.op_Implicit((Object)(object)val2)) { MithrixRunTweaksPlugin.Log.LogWarning((object)(bodyName + " not found; Mithrix's " + label + " HP is unchanged.")); return; } float baseMaxHealth = val2.baseMaxHealth; float levelMaxHealth = val2.levelMaxHealth; val2.baseMaxHealth = baseMaxHealth * value; val2.levelMaxHealth = levelMaxHealth * value; MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix (" + label + ") HP x" + value + ": base " + baseMaxHealth + " -> " + val2.baseMaxHealth + ", per level " + levelMaxHealth + " -> " + val2.levelMaxHealth + ".")); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix " + label + " HP: " + ex.Message)); } } private static void ReadMithrixArmor(GameObject brotherPrefab) { try { BrotherSuperArmorController val = ((!Object.op_Implicit((Object)(object)brotherPrefab)) ? null : brotherPrefab.GetComponentInChildren<BrotherSuperArmorController>(true)); if (Object.op_Implicit((Object)(object)val)) { Traverse obj = Traverse.Create((object)val); BuffDef value = obj.Field("buffToApply").GetValue<BuffDef>(); if (Object.op_Implicit((Object)(object)value)) { armorBuff = value; } requiredKarma = obj.Field("requiredKarma").GetValue<int>(); applicationEffect = obj.Field("applicationEffectPrefab").GetValue<GameObject>(); } else { MithrixRunTweaksPlugin.Log.LogWarning((object)"Mithrix's vanilla super armor wasn't found; using defaults."); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)ex); } if (!Object.op_Implicit((Object)(object)armorBuff)) { armorBuff = Buffs.DamageReduction; } } internal static bool IsMithrix(CharacterBody b) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)b) && (int)b.bodyIndex != -1 && mithrixIdx.Contains(b.bodyIndex)) { if (Object.op_Implicit((Object)(object)b.teamComponent)) { return (int)b.teamComponent.teamIndex != 1; } return true; } return false; } private static int Phase(CharacterBody b) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (mithrixPhase > 0) { return mithrixPhase; } string bodyName = BodyCatalog.GetBodyName(b.bodyIndex); if (bodyName == "BrotherHurtBodyP3") { return 3; } if (!(bodyName == "BrotherHurtBody")) { return 1; } return 4; } private static Rule RuleFor(CharacterBody b) { int num = Phase(b); if (num < 1 || num >= rules.Length) { return null; } return rules[num]; } private static void SetStatePostfix(EntityState newState) { if (newState != null) { try { P4StateEntered(newState); } catch { } string fullName = ((object)newState).GetType().FullName; if (fullName != null && fullName.StartsWith("EntityStates.Missions.BrotherEncounter.Phase", StringComparison.Ordinal) && int.TryParse(fullName.Substring(fullName.Length - 1), out var result)) { mithrixPhase = result; } } } private static bool KarmaAllows() { if (!requireKarma.Value) { return true; } KarmaManager instance = KarmaManager.instance; if (!Object.op_Implicit((Object)(object)instance) || !instance.IsKarmaEnabled()) { return false; } return instance.GetEffectiveKarma() >= requiredKarma; } private static bool VanillaArmorPrefix(BrotherSuperArmorController __instance) { try { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } CharacterBody val = Traverse.Create((object)__instance).Field("body").GetValue<CharacterBody>(); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)__instance).GetComponent<CharacterBody>(); } if (IsMithrix(val)) { Rule rule = RuleFor(val); if (rule != null && rule.enabled.Value) { return false; } } } catch { } return true; } private static bool NameStarts(GameObject go, string[] prefixes) { if (!Object.op_Implicit((Object)(object)go)) { return false; } string name = ((Object)go).name; foreach (string value in prefixes) { if (name.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static bool PizzaPrefix(HealthComponent __instance, DamageInfo damageInfo) { //IL_011d: 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_0102: Unknown result type (might be due to invalid IL or missing references) try { if (!pizzaInstakill.Value || !NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)__instance) || !__instance.alive) { return true; } GameObject inflictor = damageInfo.inflictor; if (!NameStarts(inflictor, PizzaNames) || NameStarts(inflictor, PizzaExclude)) { return true; } if (Object.op_Implicit((Object)(object)damageInfo.attacker) && ((Object)damageInfo.attacker).name.IndexOf("BrotherHaunt", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } CharacterBody body = __instance.body; if (!Object.op_Implicit((Object)(object)body) || IsMithrix(body) || (Object)(object)damageInfo.attacker == (Object)(object)((Component)body).gameObject) { return true; } CharacterBody val = (Object.op_Implicit((Object)(object)damageInfo.attacker) ? damageInfo.attacker.GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.teamComponent) && Object.op_Implicit((Object)(object)body.teamComponent) && val.teamComponent.teamIndex == body.teamComponent.teamIndex) { return true; } damageInfo.rejected = true; __instance.Suicide(damageInfo.attacker, inflictor, damageInfo.damageType); return false; } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Pizza: " + ex.Message)); return true; } } private static void ParsePattern() { List<P4Step> list = new List<P4Step>(); string[] array = (p4PatternConfig.Value ?? string.Empty).Split(new char[2] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { switch (text.Trim().ToLowerInvariant()) { case "burst": case "shards": case "needles": list.Add(P4Step.Shards); break; case "orbs": case "slam": list.Add(P4Step.Slam); break; case "pizza": case "ult": list.Add(P4Step.Pizza); break; default: MithrixRunTweaksPlugin.Log.LogWarning((object)("Phase 4 pattern: unknown attack '" + text + "' (use shards, slam or pizza).")); break; } } p4Steps = list.ToArray(); if (p4Steps.Length != 0) { MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix phase 4 pattern: " + string.Join(", ", p4Steps.Select((P4Step x) => x.ToString().ToLowerInvariant()).ToArray()) + " (repeating).")); } } private static bool IsHurtMithrix(CharacterBody b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 if ((int)hurtBodyIndex == -1) { hurtBodyIndex = BodyCatalog.FindBodyIndex("BrotherHurtBody"); } if (Object.op_Implicit((Object)(object)b) && b.bodyIndex == hurtBodyIndex && (int)hurtBodyIndex != -1) { if (Object.op_Implicit((Object)(object)b.teamComponent)) { return (int)b.teamComponent.teamIndex != 1; } return true; } return false; } private static void Advance(P4Pattern p) { if (p4Steps[p.index] == P4Step.Shards) { p.readyAt = Time.fixedTime + Mathf.Max(0f, p4Cooldown.Value); } p.index = (p.index + 1) % p4Steps.Length; p.shardsThisBurst = 0; p.forcedAt = -100f; } private static bool SkillGatePrefix(GenericSkill __instance, ref bool __result) { try { if (p4Steps.Length == 0 || !NetworkServer.active) { return true; } CharacterBody characterBody = __instance.characterBody; if (!IsHurtMithrix(characterBody) || !Object.op_Implicit((Object)(object)characterBody.skillLocator)) { return true; } P4Pattern component = ((Component)characterBody).GetComponent<P4Pattern>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } bool flag = Time.fixedTime < component.readyAt; if ((Object)(object)__instance == (Object)(object)characterBody.skillLocator.primary) { if (p4Steps[component.index] != P4Step.Shards || (flag && component.shardsThisBurst == 0)) { __result = false; return false; } } else { if ((Object)(object)__instance == (Object)(object)characterBody.skillLocator.secondary) { __result = false; return false; } if (flag && ((Object)(object)__instance == (Object)(object)characterBody.skillLocator.utility || (Object)(object)__instance == (Object)(object)characterBody.skillLocator.special)) { __result = false; return false; } } } catch { } return true; } private static void P4StateEntered(EntityState newState) { if (p4Steps.Length == 0 || !NetworkServer.active) { return; } CharacterBody characterBody = newState.characterBody; if (!IsHurtMithrix(characterBody)) { return; } P4Pattern component = ((Component)characterBody).GetComponent<P4Pattern>(); if (!Object.op_Implicit((Object)(object)component)) { return; } P4Step p4Step = p4Steps[component.index]; if (newState is FireLunarShards) { if (p4Step == P4Step.Shards) { component.shardsThisBurst++; component.lastShardTime = Time.fixedTime; } } else if (newState is FistSlam) { if (p4Step == P4Step.Slam) { Advance(component); } } else if (newState is UltExitState && p4Step == P4Step.Pizza) { Advance(component); } } private static void P4PatternTick() { //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown if (p4Steps.Length == 0 || !NetworkServer.active) { return; } try { IList<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList; for (int num = readOnlyInstancesList.Count - 1; num >= 0; num--) { CharacterBody val = readOnlyInstancesList[num]; if (IsHurtMithrix(val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive && Object.op_Implicit((Object)(object)val.skillLocator)) { P4Pattern p4Pattern = ((Component)val).GetComponent<P4Pattern>() ?? ((Component)val).gameObject.AddComponent<P4Pattern>(); P4Step p4Step = p4Steps[p4Pattern.index]; EntityStateMachine val2 = EntityStateMachine.FindByCustomName(((Component)val).gameObject, "Body"); EntityStateMachine val3 = EntityStateMachine.FindByCustomName(((Component)val).gameObject, "Weapon"); bool flag = Object.op_Implicit((Object)(object)val2) && val2.IsInMainState() && (!Object.op_Implicit((Object)(object)val3) || val3.IsInMainState()); if (!flag) { if (p4Step != P4Step.Shards || p4Pattern.shardsThisBurst <= 0) { p4Pattern.wasBusy = true; } } else if (p4Pattern.wasBusy) { p4Pattern.wasBusy = false; p4Pattern.readyAt = Mathf.Max(p4Pattern.readyAt, Time.fixedTime + Mathf.Max(0f, p4Cooldown.Value)); } if (p4Step == P4Step.Shards) { GenericSkill primary = val.skillLocator.primary; if (p4Pattern.shardsThisBurst > 0 && ((Object.op_Implicit((Object)(object)primary) && primary.stock <= 0) || Time.fixedTime - p4Pattern.lastShardTime > 2.5f)) { Advance(p4Pattern); } } else if (!(Time.fixedTime - p4Pattern.forcedAt < 2f) && flag && !p4Pattern.wasBusy && !(Time.fixedTime < p4Pattern.readyAt)) { p4Pattern.forcedAt = Time.fixedTime; if (p4Step == P4Step.Slam) { val2.SetNextState((EntityState)new FistSlam()); } else { val2.SetNextState((EntityState)new UltEnterState()); } } } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Phase 4 pattern: " + ex.Message)); } } private static void FistSlamEnterPrefix() { if (!p4SlamSelfDamage.Value) { FistSlam.requiredKarmaForNoSelfDamage = -1; } } private static void Phase4Tick() { if (!NetworkServer.active || itemReturnInterval == null || itemReturnInterval.Value <= 0f) { return; } try { IList<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList; for (int num = readOnlyInstancesList.Count - 1; num >= 0; num--) { CharacterBody val = readOnlyInstancesList[num]; if (IsMithrix(val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { ReturnStolenItemsOnGettingHit component = ((Component)val).GetComponent<ReturnStolenItemsOnGettingHit>(); if (Object.op_Implicit((Object)(object)component) && component.damageTrackingInitialized && Object.op_Implicit((Object)(object)component.itemStealController) && component.returnOrder != null && component.returnOrder.Count != 0) { ItemReturnTimer component2 = ((Component)val).GetComponent<ItemReturnTimer>(); if (!Object.op_Implicit((Object)(object)component2)) { component2 = ((Component)val).gameObject.AddComponent<ItemReturnTimer>(); component2.next = Time.fixedTime + itemReturnInterval.Value; } else if (Time.fixedTime >= component2.next) { component2.next = Time.fixedTime + itemReturnInterval.Value; GiveOneBack(component); } } } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Phase 4 item return: " + ex.Message)); } } private static void GiveOneBack(ReturnStolenItemsOnGettingHit r) { int count = r.returnOrder.Count; for (int i = 0; i < count; i++) { int num = (r.nextReturnIndex + i) % count; Inventory val = r.returnOrder[num]; if (Object.op_Implicit((Object)(object)val) && r.itemStealController.ReclaimItemForInventory(val, int.MaxValue)) { r.nextReturnIndex = (num + 1) % count; CharacterMaster component = ((Component)val).GetComponent<CharacterMaster>(); MithrixRunTweaksPlugin.Log.LogInfo((object)("Phase 4: Mithrix gives an item back" + ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.playerCharacterMasterController) && Object.op_Implicit((Object)(object)component.playerCharacterMasterController.networkUser)) ? (" to " + component.playerCharacterMasterController.networkUser.userName) : "") + " (timer).")); break; } } } private static void TryPatchSetter(Harmony h, string property, string prefix) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.PropertySetter(typeof(HealthComponent), property); if (methodInfo != null) { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(MithrixDefenses), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Couldn't watch " + property + ": " + ex.Message)); } } private static void HealthTick() { if (!NetworkServer.active) { return; } try { bool flag = logHealth.Value && Time.fixedTime >= nextHealthLog; IList<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList; for (int num = readOnlyInstancesList.Count - 1; num >= 0; num--) { CharacterBody val = readOnlyInstancesList[num]; if (IsMithrix(val)) { HealthComponent healthComponent = val.healthComponent; if (Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive) { if (flag) { nextHealthLog = Time.fixedTime + 10f; MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix health: " + Describe(val))); } if (blockBarrier.Value && healthComponent.barrier > 0f) { Note("barrier", "Mithrix health: took away " + healthComponent.barrier.ToString("0") + " barrier. " + Describe(val)); healthComponent.Networkbarrier = 0f; } if (healthComponent.health > healthComponent.fullHealth + 1f) { Note("overhealth", "Mithrix health: health " + healthComponent.health.ToString("0") + " was over max " + healthComponent.fullHealth.ToString("0") + "; set back to max. " + Describe(val)); healthComponent.Networkhealth = healthComponent.fullHealth; } } } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix health check: " + ex.Message)); } } private static void Note(string key, string message) { if (logHealth.Value && loggedSources.Count < 40 && loggedSources.Add(key + "|tick|" + mithrixPhase)) { MithrixRunTweaksPlugin.Log.LogInfo((object)message); } } private static void BarrierSetterPrefix(HealthComponent __instance, float value) { WatchSetter(__instance, "barrier", value, Object.op_Implicit((Object)(object)__instance) && value > __instance.barrier + 0.5f && blockBarrier.Value); } private static void HealthSetterPrefix(HealthComponent __instance, float value) { WatchSetter(__instance, "health", value, Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.body) && value > __instance.fullHealth + 1f); } private static void WatchSetter(HealthComponent hc, string what, float value, bool suspicious) { try { if (suspicious && logHealth != null && logHealth.Value && IsMithrix(hc.body) && loggedSources.Count < 40) { string text = new StackTrace(2, fNeedFileInfo: false).ToString(); if (text.Length > 1500) { text = text.Substring(0, 1500); } if (loggedSources.Add(what + "|" + text)) { MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix health: " + what + " set to " + value.ToString("0") + " by:\n" + text)); } } } catch { } } private unsafe static string Describe(CharacterBody b) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Invalid comparison between Unknown and I4 //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); try { HealthComponent healthComponent = b.healthComponent; stringBuilder.Append(BodyCatalog.GetBodyName(b.bodyIndex)).Append(" (phase ").Append(mithrixPhase) .Append(", level ") .Append(b.level.ToString("0")) .Append("): health ") .Append(healthComponent.health.ToString("0")) .Append("/") .Append(healthComponent.fullHealth.ToString("0")) .Append(", shield ") .Append(healthComponent.shield.ToString("0")) .Append("/") .Append(healthComponent.fullShield.ToString("0")) .Append(", barrier ") .Append(healthComponent.barrier.ToString("0")) .Append(", boss bar ") .Append(healthComponent.combinedHealth.ToString("0")) .Append("/") .Append(healthComponent.fullCombinedHealth.ToString("0")) .Append(", armor ") .Append(b.armor.ToString("0")) .Append(" + adaptive ") .Append(healthComponent.adaptiveArmorValue.ToString("0")); List<string> list = new List<string>(); for (BuffIndex val = (BuffIndex)0; (int)val < BuffCatalog.buffCount; val = (BuffIndex)(val + 1)) { int buffCount = b.GetBuffCount(val); if (buffCount > 0) { BuffDef buffDef = BuffCatalog.GetBuffDef(val); list.Add((Object.op_Implicit((Object)(object)buffDef) ? ((Object)buffDef).name : ((object)(*(BuffIndex*)(&val))/*cast due to .constrained prefix*/).ToString()) + ((buffCount > 1) ? (" x" + buffCount) : "")); } } stringBuilder.Append(" | buffs: ").Append((list.Count > 0) ? string.Join(", ", list) : "none"); list.Clear(); if (Object.op_Implicit((Object)(object)b.inventory)) { foreach (ItemIndex item in b.inventory.itemAcquisitionOrder) { int itemCountEffective = b.inventory.GetItemCountEffective(item); ItemDef itemDef = ItemCatalog.GetItemDef(item); list.Add((Object.op_Implicit((Object)(object)itemDef) ? ((Object)itemDef).name : ((object)(*(ItemIndex*)(&item))/*cast due to .constrained prefix*/).ToString()) + " x" + itemCountEffective); } } stringBuilder.Append(" | items: ").Append((list.Count > 0) ? string.Join(", ", list) : "none"); } catch (Exception ex) { stringBuilder.Append(" (").Append(ex.Message).Append(")"); } return stringBuilder.ToString(); } private static bool AddBarrierPrefix(HealthComponent __instance) { try { if (blockBarrier.Value && Object.op_Implicit((Object)(object)__instance) && IsMithrix(__instance.body)) { return false; } } catch { } return true; } private static void ArmorPrefix(HealthComponent __instance, DamageInfo damageInfo, out ArmorHit __state) { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) __state = default(ArmorHit); try { if (!NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)__instance) || !__instance.alive) { return; } CharacterBody body = __instance.body; if (!IsMithrix(body)) { return; } Rule rule = RuleFor(body); if (rule == null || !rule.enabled.Value || !Object.op_Implicit((Object)(object)armorBuff) || !KarmaAllows() || body.HasBuff(armorBuff)) { return; } ArmorTracker armorTracker = ((Component)body).GetComponent<ArmorTracker>() ?? ((Component)body).gameObject.AddComponent<ArmorTracker>(); if (!(Time.time < armorTracker.readyAt)) { int num = Phase(body); if (num != armorTracker.phase) { armorTracker.phase = num; armorTracker.damageAccumulated = 0f; } float num2 = rule.Threshold * Mathf.Max(1f, __instance.fullCombinedHealth); __state.tracked = true; __state.allowed = Mathf.Max(0f, num2 - armorTracker.damageAccumulated); __state.duration = Mathf.Max(0.05f, rule.duration.Value); __state.preHealth = __instance.health; __state.preShield = __instance.shield; __state.preBarrier = __instance.barrier; if (__state.allowed < __state.preHealth + __state.preShield + __state.preBarrier && (damageInfo.damageType.damageType & 1) == 0) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType | 1u); __state.addedNonLethal = true; } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)ex); } } private static void ArmorPostfix(HealthComponent __instance, DamageInfo damageInfo, ArmorHit __state) { //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown if (!__state.tracked) { return; } try { if (__state.addedNonLethal) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType & 0xFFFFFFFEu); } if (!Object.op_Implicit((Object)(object)__instance)) { return; } CharacterBody body = __instance.body; ArmorTracker armorTracker = ((!Object.op_Implicit((Object)(object)body)) ? null : ((Component)body).GetComponent<ArmorTracker>()); if (!Object.op_Implicit((Object)(object)armorTracker)) { return; } float num = Mathf.Max(0f, __state.preHealth - __instance.health); float num2 = Mathf.Max(0f, __state.preShield - __instance.shield); float num3 = Mathf.Max(0f, __state.preBarrier - __instance.barrier); float num4 = num + num2 + num3; if (num4 <= 0f) { return; } if (num4 < __state.allowed) { armorTracker.damageAccumulated += num4; return; } float num5 = num4 - __state.allowed; if (__instance.alive && num5 > 0f) { float num6 = Mathf.Min(num5, num); num5 -= num6; float num7 = Mathf.Min(num5, num2); num5 -= num7; float num8 = Mathf.Min(num5, num3); if (num6 > 0f) { __instance.Networkhealth = __instance.health + num6; } if (num7 > 0f) { __instance.Networkshield = __instance.shield + num7; } if (num8 > 0f) { __instance.Networkbarrier = __instance.barrier + num8; } } armorTracker.damageAccumulated = 0f; armorTracker.readyAt = Time.time + __state.duration + Mathf.Max(0f, armorCooldown.Value); if (__instance.alive && Object.op_Implicit((Object)(object)body)) { body.AddTimedBuff(armorBuff, __state.duration); if (Object.op_Implicit((Object)(object)applicationEffect)) { EffectManager.SpawnEffect(applicationEffect, new EffectData { origin = body.corePosition, rootObject = ((Component)body).gameObject, scale = body.radius }, true); } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)ex); } } private static void CapPrefix(HealthComponent __instance, DamageInfo damageInfo, out CapHit __state) { //IL_00b2: 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) __state = new CapHit { hp = -1f, adaptive = 0f }; try { if (!NetworkServer.active || damageInfo == null || damageInfo.rejected || !Object.op_Implicit((Object)(object)__instance) || !__instance.alive) { return; } CharacterBody body = __instance.body; if (!IsMithrix(body)) { return; } __state.hp = __instance.health + __instance.shield + __instance.barrier; __state.adaptive = __instance.adaptiveArmorValue; if (softCap.Value && !(damageInfo.damage <= 0f)) { float num = 1f; if ((damageInfo.damageType.damageType & 2) == 0) { float num2 = body.armor + __instance.adaptiveArmorValue; num = ((num2 >= 0f) ? (100f / (100f + num2)) : (2f - 100f / (100f - num2))); } float num3 = damageInfo.damage * num; float num4 = __instance.fullCombinedHealth * Mathf.Max(0f, capPercent.Value) / 100f; if (num4 > 0f && num3 > num4 && num > 0f) { damageInfo.damage = (num4 + (num3 - num4) * Mathf.Clamp01(excessMult.Value)) / num; } } } catch { } } private static void CapPostfix(HealthComponent __instance, CapHit __state) { if (__state.hp < 0f || !Object.op_Implicit((Object)(object)__instance)) { return; } try { CharacterBody body = __instance.body; if (!adaptiveEnabled.Value || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory) || !Object.op_Implicit((Object)(object)Items.AdaptiveArmor) || __instance.fullCombinedHealth <= 0f) { return; } int itemCountEffective = body.inventory.GetItemCountEffective(Items.AdaptiveArmor); if (itemCountEffective > 0) { float num = __state.hp - (__instance.health + __instance.shield + __instance.barrier); float num2 = __instance.adaptiveArmorValue; if (num > 0f) { num2 = Mathf.Max(num2, __state.adaptive + num / __instance.fullCombinedHealth * 100f * 30f * (float)itemCountEffective); } if (num2 != __instance.adaptiveArmorValue) { __instance.adaptiveArmorValue = num2; } } } catch { } } private static void OnBodyStart(CharacterBody b) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsMithrix(b) || !Object.op_Implicit((Object)(object)b.inventory)) { return; } nextHealthLog = Time.fixedTime + 1f; try { if (adaptiveEnabled.Value && Object.op_Implicit((Object)(object)Items.AdaptiveArmor)) { int itemCountPermanent = b.inventory.GetItemCountPermanent(Items.AdaptiveArmor); int num = Mathf.Max(0, adaptiveStacks.Value); if (itemCountPermanent < num) { b.inventory.GiveItemPermanent(Items.AdaptiveArmor, num - itemCountPermanent); } MithrixRunTweaksPlugin.Log.LogInfo((object)("Adaptive armor on " + BodyCatalog.GetBodyName(b.bodyIndex) + ": " + Mathf.Max(itemCountPermanent, num) + " stacks, no cap.")); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Adaptive armor setup: " + ex.Message)); } } } internal static class MithrixPhases { private const string Phase2Name = "BrotherEncounter, Phase 2"; private static ConfigEntry<bool> p2Exact; private static ConfigEntry<int> p2Wisps; private static ConfigEntry<int> p2Golems; private static ConfigEntry<int> p2Exploders; private static ConfigEntry<bool> p2Perfected; private static ConfigEntry<bool> p3NoAdds; private static List<KeyValuePair<SpawnCard, Transform>> pendingExtras; private static Xoroshiro128Plus rng; internal static void Init(ConfigFile cfg, Harmony h) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00eb: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown p2Exact = cfg.Bind<bool>("Mithrix Phase 2", "ExactSpawns", true, "Phase 2 spawns exactly the Lunar Chimera below, once, and nothing else (no extra waves). Off = vanilla."); p2Wisps = cfg.Bind<int>("Mithrix Phase 2", "Wisps", 4, "Lunar Chimera wisps in phase 2."); p2Golems = cfg.Bind<int>("Mithrix Phase 2", "Golems", 4, "Lunar Chimera golems in phase 2."); p2Exploders = cfg.Bind<int>("Mithrix Phase 2", "Exploders", 8, "Lunar Chimera exploders (the little ball guys) in phase 2."); p2Perfected = cfg.Bind<bool>("Mithrix Phase 2", "Perfected", true, "Every phase 2 Lunar Chimera is Perfected (the lunar elite)."); p3NoAdds = cfg.Bind<bool>("Mithrix Phase 3", "NoAdds", true, "No Lunar Chimera spawn during phase 3: just Mithrix. Off = vanilla."); h.Patch((MethodBase)AccessTools.Method(typeof(ScriptedCombatEncounter), "BeginEncounter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MithrixPhases), "BeginEncounterPrefix", (Type[])null), new HarmonyMethod(typeof(MithrixPhases), "BeginEncounterPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(CombatSquad), "AddMember", new Type[1] { typeof(CharacterMaster) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MithrixPhases), "AddMemberPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Phase2), "OnEnter", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MithrixPhases), "Phase2EnterPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Phase3), "OnEnter", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MithrixPhases), "Phase3EnterPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix phases: " + (p2Exact.Value ? ("phase 2 = " + p2Wisps.Value + " wisps, " + p2Golems.Value + " golems, " + p2Exploders.Value + " exploders" + (p2Perfected.Value ? " (Perfected)" : "")) : "phase 2 vanilla") + "; " + (p3NoAdds.Value ? "no adds in phase 3." : "phase 3 vanilla."))); } private static SpawnCard LoadCard(string key, string name) { //IL_0001: 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) try { SpawnCard val = Addressables.LoadAssetAsync<SpawnCard>((object)key).WaitForCompletion(); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } CharacterSpawnCard[] array = Resources.FindObjectsOfTypeAll<CharacterSpawnCard>(); foreach (CharacterSpawnCard val2 in array) { if (Object.op_Implicit((Object)(object)val2) && ((Object)val2).name == name) { return (SpawnCard)(object)val2; } } MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 2: couldn't find " + name + ".")); return null; } private static void Plan(SpawnCard card, int count, List<Transform> points, List<Transform> fallbackPoints, List<SpawnInfo> direct, List<KeyValuePair<SpawnCard, Transform>> extras) { //IL_001a: 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 (!Object.op_Implicit((Object)(object)card)) { return; } for (int i = 0; i < count; i++) { if (i < points.Count) { direct.Add(new SpawnInfo { spawnCard = card, explicitSpawnPosition = points[i], cullChance = 0f }); } else { List<Transform> list = ((points.Count > 0) ? points : fallbackPoints); extras.Add(new KeyValuePair<SpawnCard, Transform>(card, (list.Count > 0) ? list[i % list.Count] : null)); } } } private static void BeginEncounterPrefix(ScriptedCombatEncounter __instance) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) pendingExtras = null; try { if (!NetworkServer.active || !p2Exact.Value || !Object.op_Implicit((Object)(object)__instance) || __instance.hasSpawnedServer || ((Object)((Component)__instance).gameObject).name != "BrotherEncounter, Phase 2" || __instance.spawns == null) { return; } SpawnCard val = null; SpawnCard val2 = null; List<Transform> list = new List<Transform>(); List<Transform> list2 = new List<Transform>(); SpawnInfo[] spawns = __instance.spawns; foreach (SpawnInfo val3 in spawns) { if (!Object.op_Implicit((Object)(object)val3.spawnCard)) { continue; } string text = ((Object)val3.spawnCard).name.ToLowerInvariant(); if (text.Contains("lunarwisp")) { val = val ?? val3.spawnCard; if (Object.op_Implicit((Object)(object)val3.explicitSpawnPosition)) { list.Add(val3.explicitSpawnPosition); } } else if (text.Contains("lunargolem")) { val2 = val2 ?? val3.spawnCard; if (Object.op_Implicit((Object)(object)val3.explicitSpawnPosition)) { list2.Add(val3.explicitSpawnPosition); } } } val = val ?? LoadCard("RoR2/Base/LunarWisp/cscLunarWisp.asset", "cscLunarWisp"); val2 = val2 ?? LoadCard("RoR2/Base/LunarGolem/cscLunarGolem.asset", "cscLunarGolem"); SpawnCard card = LoadCard("RoR2/Base/LunarExploder/cscLunarExploder.asset", "cscLunarExploder"); List<Transform> list3 = new List<Transform>(list); list3.AddRange(list2); List<SpawnInfo> list4 = new List<SpawnInfo>(); List<KeyValuePair<SpawnCard, Transform>> extras = new List<KeyValuePair<SpawnCard, Transform>>(); Plan(val, Mathf.Max(0, p2Wisps.Value), list, list3, list4, extras); Plan(val2, Mathf.Max(0, p2Golems.Value), list2, list3, list4, extras); Plan(card, Mathf.Max(0, p2Exploders.Value), new List<Transform>(), list3, list4, extras); __instance.spawns = list4.ToArray(); pendingExtras = extras; rng = new Xoroshiro128Plus(Run.instance.stageRng.nextUlong); MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix phase 2: " + p2Wisps.Value + " wisps, " + p2Golems.Value + " golems, " + p2Exploders.Value + " exploders.")); } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 2 spawns: " + ex.Message)); } } private static void BeginEncounterPostfix(ScriptedCombatEncounter __instance) { List<KeyValuePair<SpawnCard, Transform>> list = pendingExtras; pendingExtras = null; if (list == null || !Object.op_Implicit((Object)(object)__instance)) { return; } foreach (KeyValuePair<SpawnCard, Transform> item in list) { try { SpawnExtra(__instance, item.Key, item.Value); } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 2 spawn: " + ex.Message)); } } } private static void SpawnExtra(ScriptedCombatEncounter enc, SpawnCard card, Transform near) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_009a: 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_0059: 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) DirectorPlacementRule val = new DirectorPlacementRule { placementMode = (PlacementMode)1, spawnOnTarget = near, minDistance = 5f, maxDistance = 35f }; if (!Object.op_Implicit((Object)(object)near)) { val.placementMode = (PlacementMode)3; val.spawnOnTarget = null; val.position = ((Component)enc).transform.position; val.minDistance = 0f; val.maxDistance = enc.maximumDistance; } DirectorSpawnRequest val2 = new DirectorSpawnRequest(card, val, rng); val2.ignoreTeamMemberLimit = true; val2.teamIndexOverride = enc.teamIndex; val2.onSpawnedServer = (Action<SpawnResult>)Delegate.Combine(val2.onSpawnedServer, (Action<SpawnResult>)delegate(SpawnResult result) { //IL_0000: 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) CharacterMaster val3 = (Object.op_Implicit((Object)(object)result.spawnedInstance) ? result.spawnedInstance.GetComponent<CharacterMaster>() : null); if (Object.op_Implicit((Object)(object)val3)) { if (enc.grantUniqueBonusScaling) { val3.ScaleDifficultyAsBoss(2.5f, 30f, true); } if (!p2Perfected.Value) { EliteOnlyArtifactManager.PromoteIfHonor(val3, rng, (EliteDef[])null); } enc.combatSquad.AddMember(val3); } }); if (!Object.op_Implicit((Object)(object)DirectorCore.instance.TrySpawnObject(val2)) && Object.op_Implicit((Object)(object)near)) { SpawnExtra(enc, card, null); } } private static void AddMemberPostfix(CombatSquad __instance, CharacterMaster memberMaster) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active && p2Exact.Value && p2Perfected.Value && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)memberMaster) && Object.op_Implicit((Object)(object)memberMaster.inventory) && !(((Object)((Component)__instance).gameObject).name != "BrotherEncounter, Phase 2")) { EliteDef lunar = Elites.Lunar; if (Object.op_Implicit((Object)(object)lunar) && Object.op_Implicit((Object)(object)lunar.eliteEquipmentDef) && memberMaster.inventory.currentEquipmentIndex != lunar.eliteEquipmentDef.equipmentIndex) { EliteOnlyArtifactManager.PromoteAndApplyStats(memberMaster, (Xoroshiro128Plus)(((object)rng) ?? ((object)new Xoroshiro128Plus(0uL))), (EliteDef[])(object)new EliteDef[1] { lunar }); } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 2 Perfected: " + ex.Message)); } } private static void DisableDirectors(BrotherEncounterPhaseBaseState state, string label) { if (!NetworkServer.active || state == null || !Object.op_Implicit((Object)(object)state.phaseControllerSubObjectContainer)) { return; } int num = 0; CombatDirector[] componentsInChildren = state.phaseControllerSubObjectContainer.GetComponentsInChildren<CombatDirector>(true); foreach (CombatDirector val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).enabled) { ((Behaviour)val).enabled = false; num++; } } MithrixRunTweaksPlugin.Log.LogInfo((object)("Mithrix " + label + ": turned off " + num + " Lunar Chimera spawner(s).")); } private static void Phase2EnterPostfix(Phase2 __instance) { try { if (p2Exact.Value) { DisableDirectors((BrotherEncounterPhaseBaseState)(object)__instance, "phase 2"); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 2: " + ex.Message)); } } private static void Phase3EnterPostfix(Phase3 __instance) { try { if (p3NoAdds.Value) { DisableDirectors((BrotherEncounterPhaseBaseState)(object)__instance, "phase 3"); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Mithrix phase 3: " + ex.Message)); } } } internal static class MountainShrines { internal class AddedStacks : MonoBehaviour { public int count; public bool consumed; } private static ConfigEntry<int> stacks; private static ConfigEntry<bool> extraRewards; private static MethodInfo addShrineStack; internal static void Init(ConfigFile cfg, Harmony h) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown stacks = cfg.Bind<int>("Mountain Shrines", "StacksPerStage", 2, "Number of Mountain Shrine effects applied to every stage's teleporter (every loop too). 0 = off."); extraRewards = cfg.Bind<bool>("Mountain Shrines", "ExtraRewards", false, "If true, the added Mountain Shrine effects also grant their extra boss item drops. Shrines you activate yourself always give rewards."); addShrineStack = AccessTools.Method(typeof(TeleporterInteraction), "AddShrineStack", (Type[])null, (Type[])null); h.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MountainShrines), "TeleporterStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(BossGroup), "DropRewards", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MountainShrines), "DropRewardsPrefix", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MithrixRunTweaksPlugin.Log.LogInfo((object)("Mountain Shrines: " + stacks.Value + " on every stage's teleporter.")); } private static void TeleporterStartPostfix(TeleporterInteraction __instance) { if (NetworkServer.active && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)Run.instance) && stacks.Value > 0) { ((MonoBehaviour)MithrixRunTweaksPlugin.Instance).StartCoroutine(ApplyStacks(__instance, stacks.Value)); } } private static IEnumerator ApplyStacks(TeleporterInteraction tp, int n) { yield return null; if (!Object.op_Implicit((Object)(object)tp) || addShrineStack == null) { yield break; } int num = 0; for (int i = 0; i < n; i++) { try { addShrineStack.Invoke(tp, null); num++; } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)ex); break; } } (((Component)tp).GetComponent<AddedStacks>() ?? ((Component)tp).gameObject.AddComponent<AddedStacks>()).count += num; MithrixRunTweaksPlugin.Log.LogInfo((object)("Applied " + num + " Mountain Shrine stack(s) to the teleporter.")); } private static void DropRewardsPrefix(BossGroup __instance) { try { if (extraRewards.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)__instance)) { return; } TeleporterInteraction instance = TeleporterInteraction.instance; if (Object.op_Implicit((Object)(object)instance) && !((Object)(object)instance.bossGroup != (Object)(object)__instance)) { AddedStacks component = ((Component)instance).GetComponent<AddedStacks>(); if (Object.op_Implicit((Object)(object)component) && component.count > 0 && !component.consumed) { __instance.bonusRewardCount = Mathf.Max(0, __instance.bonusRewardCount - component.count); component.consumed = true; } } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)ex); } } } internal static class SeekerChanges { private class PalmClientScaled : MonoBehaviour { } private class UnseenHandPending { public float timer; public Vector3 position; public bool fired; } private static ConfigEntry<bool> updateDescriptions; private static ConfigEntry<float> palmSize; private static ConfigEntry<float> palmDamage; private static ConfigEntry<float> palmHealing; private static ConfigEntry<float> palmSpeed; private static ConfigEntry<float> palmRange; private static ConfigEntry<float> unseenHandCooldown; private static ConfigEntry<float> unseenHandDamage; private static ConfigEntry<bool> unseenHandTeleport; private static ConfigEntry<float> unseenHandFireDelay; private static FieldRef<PalmBlastProjectileController, float> palmHealRadius; private static FieldRef<PalmBlastProjectileController, float> palmHealingToApply; private static FieldRef<PalmBlastProjectileController, ProjectileOverlapAttack> palmOverlap; private static FieldRef<PalmBlastProjectileController, float> palmBaseSize; private static FieldRef<PalmBlastProjectileController, float> palmSizePerStack; private static FieldRef<PalmBlastProjectileController, float> palmFinalSpeed; private static FieldRef<PalmBlastProjectileController, ProjectileSimple> palmSimple; private static bool palmTravelLogged; private static FieldRef<UnseenHand, bool> uhReleased; private static FieldRef<UnseenHand, bool> uhGood; private static FieldRef<UnseenHand, GameObject> uhIndicator; private static readonly ConditionalWeakTable<UnseenHand, UnseenHandPending> uhPending = new ConditionalWeakTable<UnseenHand, UnseenHandPending>(); private static bool loadApplied; private static readonly Dictionary<string, string> originalText = new Dictionary<string, string>(); private static readonly Dictionary<string, string> writtenText = new Dictionary<string, string>(); internal static void Init(ConfigFile cfg, Harmony h) { //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Expected O, but got Unknown //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown updateDescriptions = cfg.Bind<bool>("Seeker", "UpdateDescriptions", true, "Rewrite Seeker's in-game skill descriptions to match the values below (also shown by LookingGlass)."); palmSize = cfg.Bind<float>("Seeker", "PalmBlastSizeMultiplier", 3.5f, "Palm Blast size multiplier (the hand and its healing radius). 1 = vanilla."); palmDamage = cfg.Bind<float>("Seeker", "PalmBlastDamageMultiplier", 3.5f, "Palm Blast damage multiplier. 1 = vanilla."); palmHealing = cfg.Bind<float>("Seeker", "PalmBlastHealingMultiplier", 3.5f, "Palm Blast ally healing multiplier. 1 = vanilla."); palmSpeed = cfg.Bind<float>("Seeker", "PalmBlastSpeedMultiplier", 1.5f, "Palm Blast travel speed multiplier. 1 = vanilla."); palmRange = cfg.Bind<float>("Seeker", "PalmBlastRange", 1500f, "How far Palm Blast travels (in metres) before it disappears. 1500 is enough to cross any stage. 0 = vanilla range."); unseenHandCooldown = cfg.Bind<float>("Seeker", "UnseenHandCooldown", 5f, "Unseen Hand cooldown in seconds. Vanilla is 6."); unseenHandDamage = cfg.Bind<float>("Seeker", "UnseenHandDamage", 900f, "Unseen Hand damage, in %. Vanilla is 600."); unseenHandTeleport = cfg.Bind<bool>("Seeker", "UnseenHandTeleport", true, "Seeker teleports to where the Unseen Hand comes out of the ground."); unseenHandFireDelay = cfg.Bind<float>("Seeker", "UnseenHandTeleportFireDelay", 0.1f, "With UnseenHandTeleport on: seconds between the teleport and the hand coming out, so the camera (where sounds are heard from) has caught up and the hand's sounds aren't lost. 0 = fire at once."); try { palmHealRadius = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("healRadius"); palmHealingToApply = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("healingToApply"); palmOverlap = AccessTools.FieldRefAccess<PalmBlastProjectileController, ProjectileOverlapAttack>("projectileOverlap"); palmBaseSize = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("projectileSize"); palmSizePerStack = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("bonusProjectileSizePerStack"); palmFinalSpeed = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("finalProjectileSpeed"); palmSimple = AccessTools.FieldRefAccess<PalmBlastProjectileController, ProjectileSimple>("projectileSimple"); h.Patch((MethodBase)AccessTools.Method(typeof(PalmBlastProjectileController), "Init", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SeekerChanges), "PalmBlastInitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(ProjectileController), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SeekerChanges), "ProjectileStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)("Palm Blast changes disabled: " + ex.Message)); } try { uhReleased = AccessTools.FieldRefAccess<UnseenHand, bool>("skillReleased"); uhGood = AccessTools.FieldRefAccess<UnseenHand, bool>("goodPlacement"); uhIndicator = AccessTools.FieldRefAccess<UnseenHand, GameObject>("areaIndicatorInstance"); h.Patch((MethodBase)AccessTools.Method(typeof(UnseenHand), "FixedUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SeekerChanges), "UnseenHandPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(UnseenHand), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SeekerChanges), "UnseenHandUpdatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex2) { MithrixRunTweaksPlugin.Log.LogError((object)("Unseen Hand teleport disabled: " + ex2.Message)); } RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded)); Language.onCurrentLanguageChanged += ApplyDescriptions; } private static void OnGameLoaded() { if (!loadApplied) { loadApplied = true; SetCooldown("SeekerBody", "SEEKER_SECONDARY_NAME", unseenHandCooldown.Value, "Seeker Unseen Hand"); try { float fistDamageCoefficient = UnseenHand.fistDamageCoefficient; UnseenHand.fistDamageCoefficient = unseenHandDamage.Value / 100f; MithrixRunTweaksPlugin.Log.LogInfo((object)("Unseen Hand damage " + Num(fistDamageCoefficient * 100f) + "% -> " + Num(unseenHandDamage.Value) + "%")); } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)("Unseen Hand: " + ex)); } } ApplyDescriptions(); } private static void SetCooldown(string bodyName, string nameToken, float seconds, string label) { try { SkillDef val = null; GameObject val2 = BodyCatalog.FindBodyPrefab(bodyName); if (Object.op_Implicit((Object)(object)val2)) { GenericSkill[] components = val2.GetComponents<GenericSkill>(); for (int i = 0; i < components.Length; i++) { if (Object.op_Implicit((Object)(object)val)) { break; } SkillFamily val3 = (Object.op_Implicit((Object)(object)components[i]) ? components[i].skillFamily : null); if (!Object.op_Implicit((Object)(object)val3) || val3.variants == null) { continue; } for (int j = 0; j < val3.variants.Length; j++) { SkillDef skillDef = val3.variants[j].skillDef; if (Object.op_Implicit((Object)(object)skillDef) && skillDef.skillNameToken == nameToken) { val = skillDef; break; } } } } if (!Object.op_Implicit((Object)(object)val)) { MithrixRunTweaksPlugin.Log.LogWarning((object)(label + " skill (" + nameToken + ") not found; its cooldown is unchanged.")); return; } MithrixRunTweaksPlugin.Log.LogInfo((object)(label + " cooldown " + val.baseRechargeInterval + "s -> " + seconds + "s")); val.baseRechargeInterval = seconds; } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogError((object)(label + ": " + ex)); } } private static void ProjectileStartPostfix(ProjectileController __instance) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active || !Object.op_Implicit((Object)(object)__instance) || palmBaseSize == null) { return; } try { PalmBlastProjectileController component = ((Component)__instance).GetComponent<PalmBlastProjectileController>(); if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)((Component)component).GetComponent<PalmClientScaled>())) { ((Component)component).gameObject.AddComponent<PalmClientScaled>(); float num = palmBaseSize.Invoke(component); CharacterBody val = (Object.op_Implicit((Object)(object)__instance.owner) ? __instance.owner.GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)Buffs.ChakraBuff)) { num += (float)val.GetBuffCount(Buffs.ChakraBuff) * palmSizePerStack.Invoke(component); } float num2 = ((palmSize.Value > 0f) ? palmSize.Value : 1f); Transform transform = ((Component)component).transform; transform.localScale *= num * num2; } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Palm Blast (client size): " + ex.Message)); } } private static void PalmBlastInitPostfix(PalmBlastProjectileController __instance) { //IL_0022: 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) try { float value = palmSize.Value; if (value > 0f && value != 1f) { Transform transform = ((Component)__instance).transform; transform.localScale *= value; palmHealRadius.Invoke(__instance) *= value; } palmHealingToApply.Invoke(__instance) *= palmHealing.Value; ProjectileOverlapAttack val = palmOverlap.Invoke(__instance); if (Object.op_Implicit((Object)(object)val)) { val.damageCoefficient *= palmDamage.Value; } SetPalmTravel(__instance); } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Palm Blast: " + ex.Message)); } } private static void SetPalmTravel(PalmBlastProjectileController palm) { if (palmFinalSpeed == null || palmSimple == null) { return; } ProjectileSimple val = palmSimple.Invoke(palm); if (!Object.op_Implicit((Object)(object)val)) { return; } float num = palmFinalSpeed.Invoke(palm); float lifetime = val.lifetime; float num2 = num; if (palmSpeed.Value > 0f && palmSpeed.Value != 1f && num2 > 0f) { num2 *= palmSpeed.Value; palmFinalSpeed.Invoke(palm) = num2; val.desiredForwardSpeed = num2; } if (palmRange.Value > 0f && num2 > 0f) { float num3 = palmRange.Value / num2; if (num3 > val.lifetime) { val.lifetime = num3; } } if (!palmTravelLogged) { palmTravelLogged = true; MithrixRunTweaksPlugin.Log.LogInfo((object)("Palm Blast speed " + num + " -> " + num2 + " m/s, lifetime " + lifetime + "s -> " + val.lifetime + "s.")); } } private static bool UnseenHandPrefix(UnseenHand __instance) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) try { if (!unseenHandTeleport.Value || !((EntityState)__instance).isAuthority) { return true; } if (uhPending.TryGetValue(__instance, out var value)) { if (value.fired) { return true; } GameObject val = uhIndicator.Invoke(__instance); if (Object.op_Implicit((Object)(object)val)) { val.transform.position = value.position; } uhGood.Invoke(__instance) = true; value.timer -= Time.fixedDeltaTime; if (value.timer > 0f) { return false; } value.fired = true; if (Object.op_Implicit((Object)(object)((EntityState)__instance).inputBank)) { ((EntityState)__instance).inputBank.skill2.down = false; } UpdateSoundPosition(((EntityState)__instance).characterBody); return true; } if (uhReleased.Invoke(__instance) || !uhGood.Invoke(__instance) || !Object.op_Implicit((Object)(object)((EntityState)__instance).inputBank) || ((EntityState)__instance).inputBank.skill2.down) { return true; } GameObject val2 = uhIndicator.Invoke(__instance); CharacterBody characterBody = ((EntityState)__instance).characterBody; if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)characterBody)) { return true; } Vector3 position = val2.transform.position; TeleportHelper.TeleportBody(characterBody, position, false); UpdateSoundPosition(characterBody); if (unseenHandFireDelay.Value <= 0f) { return true; } uhPending.Add(__instance, new UnseenHandPending { timer = unseenHandFireDelay.Value, position = position }); return false; } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Unseen Hand teleport: " + ex.Message)); return true; } } private static bool UnseenHandUpdatePrefix(UnseenHand __instance) { if (uhPending.TryGetValue(__instance, out var value)) { return value.fired; } return true; } private static void UpdateSoundPosition(CharacterBody body) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) try { if (Object.op_Implicit((Object)(object)body)) { AkSoundEngine.SetObjectPosition(((Component)body).gameObject, body.transform); } } catch { } } private static string Num(float value) { return value.ToString("0.##", CultureInfo.InvariantCulture); } private static void ApplyDescriptions() { try { if (updateDescriptions.Value && Language.currentLanguage != null) { Rewrite("SEEKER_SPECIAL_ALT1_DESCRIPTION", new string[4] { "400%-700% damage", Num(400f * palmDamage.Value) + "%-" + Num(700f * palmDamage.Value) + "% damage", "<style=cIsDamage>piercing</style>, spectral hand", "<style=cIsDamage>piercing</style>, " + ((palmSize.Value > 1f) ? "<style=cIsUtility>huge</style>, " : "") + ((palmSpeed.Value > 1f) ? "<style=cIsUtility>fast</style>, " : "") + ((palmRange.Value > 0f) ? "<style=cIsUtility>long-range</style> " : "") + "spectral hand" }); Rewrite("SEEKER_SECONDARY_DESCRIPTION", (!unseenHandTeleport.Value) ? new string[2] { "<style=cIsDamage>600% damage</style>", "<style=cIsDamage>" + Num(unseenHandDamage.Value) + "% damage</style>" } : new string[4] { "<style=cIsDamage>600% damage</style>", "<style=cIsDamage>" + Num(unseenHandDamage.Value) + "% damage</style>", "from the ground, dealing", "from the ground and <style=cIsUtility>teleport</style> to it, dealing" }); } } catch (Exception ex) { MithrixRunTweaksPlugin.Log.LogWarning((object)("Descriptions: " + ex.Message)); } } private static void Rewrite(string token, string[] pairs) { Language currentLanguage = Language.currentLanguage; string key = currentLanguage.name + "|" + token; string localizedStringByToken = currentLanguage.GetLocalizedStringByToken(token); if (!string.IsNullOrEmpty(localizedStringByToken) && !(localizedStringByToken == token)) { if (!writtenText.TryGetValue(key, out var value) || localizedStringByToken != value || !originalText.TryGetValue(key, out var value2)) { value2 = localizedStringByToken; originalText[key] = localizedStringByToken; } string text = value2; string[] array = new string[pairs.Length / 2]; for (int i = 0; i < pairs.Length; i += 2) { array[i / 2] = "\u0001" + i / 2 + "\u0001"; text = text.Replace(pairs[i], array[i / 2]); } for (int j = 0; j < array.Length; j++) { text = text.Replace(array[j], pairs[j * 2 + 1]); } if (text != value2) { currentLanguage.SetStringByToken(token, text); writtenText[key] = text; } } } } }
NoSonorousWhispers.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HG; using HarmonyLib; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace NoSonorousWhispers { [BepInPlugin("custom.NoSonorousWhispers", "NoSonorousWhispers", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class NoSonorousWhispersPlugin : BaseUnityPlugin { internal static ManualLogSource Log; private static readonly Dictionary<ItemIndex, int> bannedItems = new Dictionary<ItemIndex, int>(); private static readonly HashSet<PickupIndex> bannedPickups = new HashSet<PickupIndex>(); private static bool resolved; private static readonly Random rng = new Random(); private static MethodInfo qGetItemOfQuality; private static MethodInfo qGetPickupOfQuality; private static Type qTierType; private static readonly FieldInfo fAllRecipes = AccessTools.Field(typeof(CraftableCatalog), "allRecipes"); private static readonly FieldInfo fCraftableDefs = AccessTools.Field(typeof(CraftableCatalog), "craftableDefs"); private static readonly FieldInfo fIngredientTable = AccessTools.Field(typeof(CraftableCatalog), "pickupToIngredientSearchTable"); private static readonly FieldInfo fResultTable = AccessTools.Field(typeof(CraftableCatalog), "resultToRecipeSearchTable"); private static readonly FieldInfo fEntryResult = AccessTools.Field(typeof(RecipeEntry), "result"); private static readonly FieldInfo fEntrySlots = AccessTools.Field(typeof(RecipeEntry), "possibleIngredients"); private static readonly FieldInfo fSlotPickups = AccessTools.Field(typeof(IngredientSlotEntry), "pickups"); private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony h = new Harmony("custom.NoSonorousWhispers"); Postfix(h, AccessTools.Method(typeof(Run), "BuildDropTable", (Type[])null, (Type[])null), "BuildDropTablePostfix"); Prefix(h, AccessTools.Method(typeof(GenericPickupController), "CreatePickup", (Type[])null, (Type[])null), "CreatePickupPrefix"); Prefix(h, AccessTools.Method(typeof(PickupPickerController), "SetOptionsServer", (Type[])null, (Type[])null), "PickerOptionsPrefix"); Prefix(h, AccessTools.Method(typeof(PickupPickerController), "SetOptionsInternal", (Type[])null, (Type[])null), "PickerOptionsPrefix"); MethodInfo[] methods = typeof(ShopTerminalBehavior).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (methodInfo.Name == "SetPickupIndex" && parameters.Length > 0 && parameters[0].ParameterType == typeof(PickupIndex)) { Prefix(h, methodInfo, "ShopPickupIndexPrefix"); } else if (methodInfo.Name == "SetPickup" && parameters.Length > 0 && parameters[0].ParameterType == typeof(UniquePickup)) { Prefix(h, methodInfo, "ShopUniquePickupPrefix"); } } MethodInfo[] methods2 = typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo2 in methods2) { ParameterInfo[] parameters2 = methodInfo2.GetParameters(); if (methodInfo2.Name.StartsWith("GiveItem", StringComparison.Ordinal) && parameters2.Length > 0 && parameters2[0].ParameterType == typeof(ItemIndex)) { Prefix(h, methodInfo2, "GiveItemPrefix"); } } Type typeFromHandle = typeof(CraftableCatalog); Postfix(h, AccessTools.Method(typeFromHandle, "Init", (Type[])null, (Type[])null), "PurgeCraftingPostfix"); Postfix(h, AccessTools.Method(typeFromHandle, "SetCraftableDefs", (Type[])null, (Type[])null), "PurgeCraftingPostfix"); string[] array = new string[4] { "FindApplicableRecipesByIngredients", "FindRecipesThatCanAcceptIngredients", "FindAllRelatedRecipes", "GetAllRecipes" }; foreach (string text in array) { Postfix(h, AccessTools.Method(typeFromHandle, text, (Type[])null, (Type[])null), "FilterRecipeArrayPostfix"); } RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { Resolve(); PurgeCrafting(); }); Run.onRunStartGlobal += delegate(Run run) { Resolve(); PurgeCrafting(); PurgeRun(run); }; } private void Prefix(Harmony h, MethodBase m, string name) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if (m == null) { Log.LogWarning((object)("Hook target missing for " + name)); return; } try { h.Patch(m, new HarmonyMethod(typeof(NoSonorousWhispersPlugin), name, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Log.LogError((object)string.Concat("Hook failed ", m.DeclaringType, ".", m.Name, ": ", ex.Message)); } } private void Postfix(Harmony h, MethodBase m, string name) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (m == null) { Log.LogWarning((object)("Hook target missing for " + name)); return; } try { HarmonyMethod val = new HarmonyMethod(typeof(NoSonorousWhispersPlugin), name, (Type[])null); h.Patch(m, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Log.LogError((object)string.Concat("Hook failed ", m.DeclaringType, ".", m.Name, ": ", ex.Message)); } } private static void Resolve() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Invalid comparison between Unknown and I4 //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_019b: Invalid comparison between Unknown and I4 //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) try { ItemDef itemDropChanceOnKill = Items.ItemDropChanceOnKill; if (!Object.op_Implicit((Object)(object)itemDropChanceOnKill) || (int)itemDropChanceOnKill.itemIndex == -1 || (resolved && bannedItems.Count > 1)) { return; } bannedItems.Clear(); bannedPickups.Clear(); Ban(itemDropChanceOnKill.itemIndex, -1); Type type = AccessTools.TypeByName("ItemQualities.QualityCatalog"); qTierType = AccessTools.TypeByName("ItemQualities.QualityTier"); if (type != null && qTierType != null) { qGetItemOfQuality = AccessTools.Method(type, "GetItemIndexOfQuality", new Type[2] { typeof(ItemIndex), qTierType }, (Type[])null); qGetPickupOfQuality = AccessTools.Method(type, "GetPickupIndexOfQuality", new Type[2] { typeof(PickupIndex), qTierType }, (Type[])null); if (qGetItemOfQuality != null) { for (int i = 0; i <= 3; i++) { try { ItemIndex val = (ItemIndex)qGetItemOfQuality.Invoke(null, new object[2] { itemDropChanceOnKill.itemIndex, Enum.ToObject(qTierType, i) }); if ((int)val != -1 && val != itemDropChanceOnKill.itemIndex) { Ban(val, i); } } catch { } } } } Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemDef current = enumerator.Current; if (Object.op_Implicit((Object)(object)current) && (int)current.itemIndex != -1 && !bannedItems.ContainsKey(current.itemIndex) && ((Object)current).name != null && ((Object)current).name.StartsWith("ItemDropChanceOnKill", StringComparison.OrdinalIgnoreCase)) { Ban(current.itemIndex, -1); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } resolved = true; Log.LogInfo((object)("Banned " + bannedItems.Count + " Sonorous Whispers item(s).")); } catch (Exception ex) { Log.LogError((object)ex); } } private static void Ban(ItemIndex idx, int quality) { //IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0014: 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) bannedItems[idx] = quality; PickupIndex val = PickupCatalog.FindPickupIndex(idx); if (val != PickupIndex.none) { bannedPickups.Add(val); } } private static bool IsBanned(PickupIndex p) { //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_0024: Unknown result type (might be due to invalid IL or missing references) if (!resolved) { Resolve(); } return p != PickupIndex.none && bannedPickups.Contains(p); } private static bool IsBanned(ItemIndex i) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!resolved) { Resolve(); } return (int)i != -1 && bannedItems.ContainsKey(i); } private static List<PickupIndex> ListForTier(Run run, ItemTier tier) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown if (!Object.op_Implicit((Object)(object)run)) { return null; } return (int)tier switch { 0 => run.availableTier1DropList, 1 => run.availableTier2DropList, 2 => run.availableTier3DropList, 4 => run.availableBossDropList, 3 => run.availableLunarItemDropList, 6 => run.availableVoidTier1DropList, 7 => run.availableVoidTier2DropList, 8 => run.availableVoidTier3DropList, 9 => run.availableVoidBossDropList, _ => run.availableTier3DropList, }; } private static PickupIndex Replacement(ItemIndex banned) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) try { ItemDef itemDropChanceOnKill = Items.ItemDropChanceOnKill; ItemTier tier = (ItemTier)((!Object.op_Implicit((Object)(object)itemDropChanceOnKill)) ? 2 : ((int)itemDropChanceOnKill.tier)); List<PickupIndex> list = ListForTier(Run.instance, tier); if (list == null) { return PickupIndex.none; } List<PickupIndex> list2 = list.Where((PickupIndex p) => !IsBanned(p)).ToList(); if (list2.Count == 0) { return PickupIndex.none; } PickupIndex val = list2[rng.Next(list2.Count)]; if (bannedItems.TryGetValue(banned, out var value) && value >= 0 && qGetPickupOfQuality != null) { try { PickupIndex val2 = (PickupIndex)qGetPickupOfQuality.Invoke(null, new object[2] { val, Enum.ToObject(qTierType, value) }); if (val2 != PickupIndex.none && !IsBanned(val2)) { val = val2; } } catch { } } return val; } catch { return PickupIndex.none; } } private static ItemIndex ItemOf(PickupIndex p) { //IL_0000: 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) PickupDef pickupDef = PickupCatalog.GetPickupDef(p); return (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex)); } private static void BuildDropTablePostfix(Run __instance) { PurgeRun(__instance); } private static void PurgeRun(Run run) { //IL_00b9: 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_00c6: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)run)) { return; } Resolve(); if (bannedItems.Count == 0) { return; } try { FieldInfo[] fields = typeof(Run).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(List<PickupIndex>)) && fieldInfo.GetValue(run) is List<PickupIndex> list) { list.RemoveAll((PickupIndex p) => bannedPickups.Contains(p)); } } foreach (ItemIndex key in bannedItems.Keys) { try { run.availableItems.Remove(key); } catch { } } try { PickupDropTable.RegenerateAll(run); } catch { } } catch (Exception ex) { Log.LogError((object)ex); } } private static bool CreatePickupPrefix(ref CreatePickupInfo createPickupInfo) { //IL_0001: 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_0007: 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_001a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_003d: Unknown result type (might be due to invalid IL or missing references) try { PickupIndex pickupIndex = ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex; if (!IsBanned(pickupIndex)) { return true; } PickupIndex val = Replacement(ItemOf(pickupIndex)); if (val == PickupIndex.none) { return false; } ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex = val; } catch (Exception ex) { Log.LogError((object)ex); } return true; } private static void ShopPickupIndexPrefix(ref PickupIndex __0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_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) if (IsBanned(__0)) { __0 = Replacement(ItemOf(__0)); } } private static void ShopUniquePickupPrefix(ref UniquePickup __0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_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) if (IsBanned(__0.pickupIndex)) { __0.pickupIndex = Replacement(ItemOf(__0.pickupIndex)); } } private static void PickerOptionsPrefix(ref Option[] __0) { if (__0 != null && __0.Any((Option o) => IsBanned(o.pickup.pickupIndex))) { __0 = __0.Where((Option o) => !IsBanned(o.pickup.pickupIndex)).ToArray(); } } private static bool GiveItemPrefix(ref ItemIndex __0) { //IL_001a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected I4, but got Unknown if (!NetworkServer.active || !IsBanned(__0)) { return true; } ItemIndex val = ItemOf(Replacement(__0)); if ((int)val == -1) { return false; } __0 = (ItemIndex)(int)val; return true; } private static void PurgeCraftingPostfix() { PurgeCrafting(); } private static void FilterRecipeArrayPostfix(ref RecipeEntry[] __result) { if (__result != null && bannedPickups.Count != 0 && __result.Any(RecipeBanned)) { __result = __result.Where((RecipeEntry r) => !RecipeBanned(r)).ToArray(); } } private static bool RecipeBanned(RecipeEntry r) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (r == null) { return true; } try { if (IsBanned((PickupIndex)fEntryResult.GetValue(r))) { return true; } if (!(fEntrySlots.GetValue(r) is IngredientSlotEntry[] array)) { return false; } IngredientSlotEntry[] array2 = array; foreach (IngredientSlotEntry val in array2) { PickupIndex[] array3 = ((val == null) ? null : (fSlotPickups.GetValue(val) as PickupIndex[])); if (array3 != null && array3.Length > 0 && array3.All(IsBanned)) { return true; } } } catch { } return false; } private static void PurgeCrafting() { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) Resolve(); if (bannedPickups.Count == 0) { return; } int num = 0; try { List<RecipeEntry> list = ((!(fAllRecipes != null)) ? null : (fAllRecipes.GetValue(null) as List<RecipeEntry>)); if (list != null) { num += list.RemoveAll(RecipeBanned); foreach (RecipeEntry item in list) { if (!(fEntrySlots.GetValue(item) is IngredientSlotEntry[] array)) { continue; } IngredientSlotEntry[] array2 = array; foreach (IngredientSlotEntry val in array2) { PickupIndex[] array3 = ((val == null) ? null : (fSlotPickups.GetValue(val) as PickupIndex[])); if (array3 != null && array3.Any(IsBanned)) { fSlotPickups.SetValue(val, array3.Where((PickupIndex p) => !IsBanned(p)).ToArray()); } } } HashSet<RecipeEntry> keep = new HashSet<RecipeEntry>(list); FieldInfo[] array4 = new FieldInfo[2] { fIngredientTable, fResultTable }; foreach (FieldInfo fieldInfo in array4) { Dictionary<PickupIndex, List<RecipeEntry>> dictionary = ((!(fieldInfo != null)) ? null : (fieldInfo.GetValue(null) as Dictionary<PickupIndex, List<RecipeEntry>>)); if (dictionary == null) { continue; } foreach (PickupIndex bannedPickup in bannedPickups) { dictionary.Remove(bannedPickup); } foreach (KeyValuePair<PickupIndex, List<RecipeEntry>> item2 in dictionary) { item2.Value.RemoveAll((RecipeEntry e) => !keep.Contains(e)); } } } CraftableDef[] array5 = ((!(fCraftableDefs != null)) ? null : (fCraftableDefs.GetValue(null) as CraftableDef[])); if (array5 != null) { CraftableDef[] array6 = array5.Where((CraftableDef d) => Object.op_Implicit((Object)(object)d) && !IsBanned(d.itemIndex)).ToArray(); CraftableDef[] array7 = array6; foreach (CraftableDef val2 in array7) { if (val2.recipes == null) { continue; } val2.recipes = val2.recipes.Where((Recipe r) => r == null || r.ingredients == null || !r.ingredients.Any((RecipeIngredient val3) => val3 != null && IsBanned(val3.pickupIndex))).ToArray(); } if (array6.Length != array5.Length) { fCraftableDefs.SetValue(null, array6); num += array5.Length - array6.Length; } } } catch (Exception ex) { Log.LogError((object)("Crafting purge failed: " + ex)); } if (num > 0) { Log.LogInfo((object)("Removed " + num + " Sonorous Whispers recipe(s).")); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } }
OmniSprint.dll
Decompiled 2 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using Microsoft.CodeAnalysis; using RoR2; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OmniSprint")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OmniSprint")] [assembly: AssemblyTitle("OmniSprint")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 OmniSprint { [BepInPlugin("tpq.OmniSprint", "OmniSprint", "1.0.0")] public class OmniSprintPlugin : BaseUnityPlugin { public const string PluginGUID = "tpq.OmniSprint"; public const string PluginName = "OmniSprint"; public const string PluginVersion = "1.0.0"; private void Awake() { PlayerCharacterMasterController.onPlayerAdded += OnPlayerAdded; } private static void OnPlayerAdded(PlayerCharacterMasterController player) { player.master.onBodyStart += OnBodyStart; } private static void OnBodyStart(CharacterBody body) { //IL_0003: 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_000b: Unknown result type (might be due to invalid IL or missing references) body.bodyFlags = (BodyFlags)(body.bodyFlags | 0x20); } } }
OneShotRework.dll
Decompiled 2 hours agousing System; using System.Collections; 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.VoidRaidCrab; using HarmonyLib; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.Audio; using RoR2.ContentManagement; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace OneShotRework { internal static class AkStop { private static MethodInfo stop; private static MethodInfo stopAny; private static bool searched; internal static void Stop(uint id) { if (id == 0) { return; } try { if (!searched) { searched = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = null; try { type = assembly.GetType("AkSoundEngine", throwOnError: false); } catch { } if (!(type == null)) { stop = type.GetMethod("StopPlayingID", new Type[1] { typeof(uint) }); if (stop != null) { break; } } } } if (stop != null) { stop.Invoke(null, new object[1] { id }); return; } if (stopAny == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { Type type2 = null; try { type2 = assembly2.GetType("AkSoundEngine", throwOnError: false); } catch { } if (type2 == null) { continue; } MethodInfo[] methods = type2.GetMethods(); foreach (MethodInfo methodInfo in methods) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (methodInfo.Name == "StopPlayingID" && parameters.Length != 0 && parameters[0].ParameterType == typeof(uint)) { stopAny = methodInfo; break; } } if (stopAny != null) { break; } } } if (stopAny != null) { ParameterInfo[] parameters2 = stopAny.GetParameters(); object[] array = new object[parameters2.Length]; array[0] = id; for (int k = 1; k < parameters2.Length; k++) { array[k] = ((!(parameters2[k].ParameterType == typeof(int))) ? ((!parameters2[k].ParameterType.IsValueType) ? null : Activator.CreateInstance(parameters2[k].ParameterType)) : ((object)0)); } stopAny.Invoke(null, array); } } catch { } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("custom.OneShotRework", "OneShotRework", "1.6.4")] public class OneShotReworkPlugin : BaseUnityPlugin { private class Provider : IContentPackProvider { private readonly ContentPack pack = new ContentPack(); public string identifier => "custom.OneShotRework"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { try { AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.OneShotRework", null); } catch { } pack.buffDefs.Add((BuffDef[])(object)new BuffDef[4] { ReadyBuff, ActiveBuff, CooldownBuff, EmpowerBuff }); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(pack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } private struct HitState { public bool addedNonLethal; public OSPState state; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static CollectContentPackProvidersDelegate <>9__46_0; public static Action<AsyncOperationHandle<GameObject>> <>9__46_1; public static Func<Dictionary<string, string>> <>9__46_4; public static Func<string> <>9__46_5; public static EventHandler<SettingChangedEventArgs> <>9__46_6; public static Action<AsyncOperationHandle<BuffDef>> <>9__55_0; public static Action<AsyncOperationHandle<BuffDef>> <>9__55_1; internal void <Awake>b__46_0(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); } internal void <Awake>b__46_1(AsyncOperationHandle<GameObject> h) { try { EffectComponent val = ((!Object.op_Implicit((Object)(object)h.Result)) ? null : h.Result.GetComponent<EffectComponent>()); if (Object.op_Implicit((Object)(object)val) && !string.IsNullOrEmpty(val.soundName)) { ImplosionSound = val.soundName; } } catch (Exception ex) { Log.LogWarning((object)ex.Message); } } internal Dictionary<string, string> <Awake>b__46_4() { //IL_000b: 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) Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text = LGCompat.KeyName(ManualKey.Value); string text2 = LGCompat.KeyName(ShieldKey.Value); LGCompat.Add(dictionary, ReadyBuff, "One-Shot Protection Ready", "A fatal hit leaves you at <style=cIsHealing>1 HP</style> with <style=cIsUtility>" + InvincibleTime.Value + "s invincibility</style> and <style=cIsUtility>removes all curse</style>." + ((!ShieldKeyEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text2 + "]</style> to manually trigger the invincibility.")) + ((!ManualEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text + "]</style> to spend it on a significant damage boost instead."))); LGCompat.Add(dictionary, ActiveBuff, "One-Shot Protection Active", "<style=cIsUtility>Invincible.</style> Recharges afterwards."); LGCompat.Add(dictionary, EmpowerBuff, "Empowered", "Damage multiplier rises from <style=cIsDamage>" + ManualDamageMult.Value + "x</style> to <style=cIsDamage>" + ManualDamageMultEnd.Value + "x</style> over <style=cIsUtility>" + ManualDuration.Value + "s</style>."); LGCompat.Add(dictionary, CooldownBuff, "One-Shot Protection Recharging", "Recharges after <style=cIsUtility>" + CooldownTime.Value + "s</style> without getting hit while at <style=cIsHealing>full health</style>. Getting hit restarts the timer."); return dictionary; } internal string <Awake>b__46_5() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) string text = ((!ManualEnabled.Value) ? null : LGCompat.KeyName(ManualKey.Value)); string text2 = ((!ShieldKeyEnabled.Value) ? null : LGCompat.KeyName(ShieldKey.Value)); if (text != null && text2 != null) { return text + "/" + text2; } return text ?? text2 ?? string.Empty; } internal void <Awake>b__46_6(object <p0>, SettingChangedEventArgs <p1>) { LGCompat.Apply(); } internal void <CreateBuffs>b__55_0(AsyncOperationHandle<BuffDef> h) { if (!Object.op_Implicit((Object)(object)h.Result)) { Log.LogWarning((object)"bdImmune not found"); return; } ReadyBuff.iconSprite = h.Result.iconSprite; ActiveBuff.iconSprite = h.Result.iconSprite; EmpowerBuff.iconSprite = h.Result.iconSprite; } internal void <CreateBuffs>b__55_1(AsyncOperationHandle<BuffDef> h) { if (!Object.op_Implicit((Object)(object)h.Result)) { Log.LogWarning((object)"bdPermanentCurse not found"); } else { CooldownBuff.iconSprite = h.Result.iconSprite; } } } public const string GUID = "custom.OneShotRework"; internal static ManualLogSource Log; internal static ConfigEntry<bool> DisableVanilla; internal static ConfigEntry<bool> PlayersOnly; internal static ConfigEntry<bool> CountSelfDamage; internal static ConfigEntry<bool> ScreenTint; internal static ConfigEntry<float> TintStrength; internal static ConfigEntry<float> InvincibleTime; internal static ConfigEntry<float> CooldownTime; internal static ConfigEntry<string> SoundOverride; internal static ConfigEntry<string> ManualSound; internal static ConfigEntry<bool> RemoveCurse; internal static ConfigEntry<bool> ManualEnabled; internal static ConfigEntry<float> ManualDuration; internal static ConfigEntry<float> ManualDamageMult; internal static ConfigEntry<float> ManualDamageMultEnd; internal static readonly Dictionary<CharacterBody, float> empowerStart = new Dictionary<CharacterBody, float>(); private static readonly List<CharacterBody> empTmp = new List<CharacterBody>(); internal static ConfigEntry<KeyboardShortcut> ManualKey; internal static ConfigEntry<KeyboardShortcut> ShieldKey; internal static ConfigEntry<bool> ShieldKeyEnabled; internal static ConfigEntry<string> NoFullHpBodies; internal static ConfigEntry<bool> VoidEnabled; internal static ConfigEntry<string> VoidScenes; internal static ConfigEntry<float> VoidCooldown; internal static ConfigEntry<bool> VoidInstantFromPhase9; internal static ConfigEntry<float> InstantEmpowerVolume; private static PropertyInfo voidlingStage; private static bool voidlingLookedUp; private static string sceneCache; private static bool sceneIsVoid; internal static BuffDef ReadyBuff; internal static BuffDef ActiveBuff; internal static BuffDef CooldownBuff; internal static BuffDef EmpowerBuff; internal const string Cmd = "osp_empower"; internal const string ShieldCmd = "osp_shield"; internal static string ImplosionSound; private static Action<CharacterBody, float> setOspFraction; private static Action<CharacterBody, bool> setHasOsp; internal static bool InVoidScene() { if (!VoidEnabled.Value) { return false; } SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; string text = (Object.op_Implicit((Object)(object)mostRecentSceneDef) ? mostRecentSceneDef.cachedName : string.Empty); if (text != sceneCache) { sceneCache = text; sceneIsVoid = false; string[] array = VoidScenes.Value.Split(new char[1] { ',' }); foreach (string text2 in array) { if (text2.Trim().Length > 0 && string.Equals(text2.Trim(), text, StringComparison.OrdinalIgnoreCase)) { sceneIsVoid = true; break; } } } return sceneIsVoid; } internal static int VoidlingStage() { if (!voidlingLookedUp) { voidlingLookedUp = true; try { Type type = AccessTools.TypeByName("VoidlingRework.VoidlingReworkPlugin"); voidlingStage = ((type == null) ? null : type.GetProperty("FightStage", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); } catch { } } try { return (!(voidlingStage == null)) ? ((int)voidlingStage.GetValue(null, null)) : 0; } catch { return 0; } } internal static bool InstantRecharge() { if (VoidEnabled.Value && VoidInstantFromPhase9.Value && InVoidScene()) { return VoidlingStage() >= 40; } return false; } internal static float EffectiveCooldown() { if (!InVoidScene()) { return CooldownTime.Value; } return Mathf.Max(0f, VoidCooldown.Value); } private void Awake() { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Expected O, but got Unknown //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Expected O, but got Unknown //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Expected O, but got Unknown //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_04e1: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; DisableVanilla = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableVanillaOneShotProtection", true, "Remove the vanilla one-shot protection."); PlayersOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayersOnly", true, "Only player-controlled survivors get the reworked protection."); CountSelfDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SelfDamageCountsAsHit", false, "If true, damage you deal to yourself also resets the timers."); InvincibleTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "InvincibilityDuration", 3f, "Seconds of invincibility after the protection triggers."); CooldownTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "CooldownTime", 20f, "Seconds the protection takes to recharge. It only charges while your health is full (shields and barrier don't count; curse lowers the full mark) and restarts every time you are hit."); RemoveCurse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveCurseOnTrigger", true, "When the protection saves you from a fatal hit, all curse stacks are removed."); ManualEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Empower", "Enabled", true, "Press the key while the protection is ready to spend it on a damage boost instead."); ManualKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Empower", "Key", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Key to spend the ready protection on the damage boost."); ManualDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "Duration", 5f, "Seconds the damage boost lasts."); ManualDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "StartDamageMultiplier", 4f, "Damage multiplier when the boost starts. It rises linearly to EndDamageMultiplier over the boost duration."); ManualDamageMultEnd = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "EndDamageMultiplier", 24f, "Damage multiplier reached at the end of the boost."); NoFullHpBodies = ((BaseUnityPlugin)this).Config.Bind<string>("Timing", "NoFullHealthNeeded", "Acolyte", "Comma-separated survivors (body name or display name, partial match) that recharge without needing full health."); ShieldKeyEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("ManualShield", "Enabled", true, "Press the key while the protection is ready to trigger its invincibility (and curse removal) right away."); ShieldKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("ManualShield", "Key", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Key to trigger the ready protection's invincibility manually."); ManualSound = ((BaseUnityPlugin)this).Config.Bind<string>("Empower", "SoundEvent", "@voidling_spinbeam", "Sound played while the boost is active. @voidling_spinbeam = the voidling's giant sustained spinning laser (cut off when the boost ends). Any other value is played once as a Wwise event."); ScreenTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ScreenTint", true, "Tint your screen dark purple while the invincibility is active."); TintStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ScreenTintStrength", 0.55f, "Opacity of the screen tint (0-1)."); SoundOverride = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "SoundEventOverride", string.Empty, "Wwise sound event to play on activation. Empty = the Void Reaver implosion sound."); VoidEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Void", "Enabled", true, "In the void stages below the protection recharges faster and without full health, and from VoidlingRework's phase 9 on it recharges as soon as it ends."); VoidScenes = ((BaseUnityPlugin)this).Config.Bind<string>("Void", "Scenes", "arena,voidstage,voidraid", "Comma-separated scene names that count as void stages (Void Fields, Void Locus, Planetarium)."); VoidCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Void", "CooldownTime", 10f, "Recharge time in the void stages. Full health isn't needed there (getting hit still restarts it)."); VoidInstantFromPhase9 = ((BaseUnityPlugin)this).Config.Bind<bool>("Void", "InstantFromVoidlingPhase9", true, "From VoidlingRework's phase 9 on (through to the end of its final battle, phase 12), the protection is ready again as soon as its invincibility or the damage boost ends, and it works against every attack: void implosions (Voidling's and Void Reavers' black holes) and other instant kills trigger it like any fatal hit, and nothing gets through its invincibility."); InstantEmpowerVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Void", "EmpowerVolumeWithoutCooldown", 0.5f, "Volume of the damage boost's sound while the protection has no cooldown (VoidlingRework's phase 9 on). 1 = normal."); CreateBuffs(); object obj = <>c.<>9__46_0; if (obj == null) { CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); }; <>c.<>9__46_0 = val; obj = (object)val; } ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj; AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Nullifier/NullifierDeathBombExplosion.prefab"); val2.Completed += delegate(AsyncOperationHandle<GameObject> h) { try { EffectComponent val5 = ((!Object.op_Implicit((Object)(object)h.Result)) ? null : h.Result.GetComponent<EffectComponent>()); if (Object.op_Implicit((Object)(object)val5) && !string.IsNullOrEmpty(val5.soundName)) { ImplosionSound = val5.soundName; } } catch (Exception ex2) { Log.LogWarning((object)ex2.Message); } }; MethodInfo f = AccessTools.PropertySetter(typeof(CharacterBody), "oneShotProtectionFraction"); if (f != null) { setOspFraction = delegate(CharacterBody b, float v) { f.Invoke(b, new object[1] { v }); }; } MethodInfo hs = AccessTools.PropertySetter(typeof(CharacterBody), "hasOneShotProtection"); if (hs != null) { setHasOsp = delegate(CharacterBody b, bool v) { hs.Invoke(b, new object[1] { v }); }; } Harmony val3 = new Harmony("custom.OneShotRework"); MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null); HarmonyMethod val4 = new HarmonyMethod(typeof(OneShotReworkPlugin), "RecalcPostfix", (Type[])null); val3.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null); val3.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(OneShotReworkPlugin), "TakeDamagePrefix", (Type[])null) { priority = 200 }, new HarmonyMethod(typeof(OneShotReworkPlugin), "TakeDamagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CharacterBody.onBodyStartGlobal += OnBodyStart; LGCompat.Init(val3); LGCompat.Builder = delegate { //IL_000b: 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) Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text = LGCompat.KeyName(ManualKey.Value); string text2 = LGCompat.KeyName(ShieldKey.Value); LGCompat.Add(dictionary, ReadyBuff, "One-Shot Protection Ready", "A fatal hit leaves you at <style=cIsHealing>1 HP</style> with <style=cIsUtility>" + InvincibleTime.Value + "s invincibility</style> and <style=cIsUtility>removes all curse</style>." + ((!ShieldKeyEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text2 + "]</style> to manually trigger the invincibility.")) + ((!ManualEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text + "]</style> to spend it on a significant damage boost instead."))); LGCompat.Add(dictionary, ActiveBuff, "One-Shot Protection Active", "<style=cIsUtility>Invincible.</style> Recharges afterwards."); LGCompat.Add(dictionary, EmpowerBuff, "Empowered", "Damage multiplier rises from <style=cIsDamage>" + ManualDamageMult.Value + "x</style> to <style=cIsDamage>" + ManualDamageMultEnd.Value + "x</style> over <style=cIsUtility>" + ManualDuration.Value + "s</style>."); LGCompat.Add(dictionary, CooldownBuff, "One-Shot Protection Recharging", "Recharges after <style=cIsUtility>" + CooldownTime.Value + "s</style> without getting hit while at <style=cIsHealing>full health</style>. Getting hit restarts the timer."); return dictionary; }; LGCompat.IconText[ReadyBuff] = delegate { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) string text = ((!ManualEnabled.Value) ? null : LGCompat.KeyName(ManualKey.Value)); string text2 = ((!ShieldKeyEnabled.Value) ? null : LGCompat.KeyName(ShieldKey.Value)); return (text != null && text2 != null) ? (text + "/" + text2) : (text ?? text2 ?? string.Empty); }; ((BaseUnityPlugin)this).Config.SettingChanged += delegate { LGCompat.Apply(); }; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { try { RiskOfOptionsCompat.Init(); } catch (Exception ex) { Log.LogWarning((object)("Risk of Options: " + ex.Message)); } } } private void FixedUpdate() { if (empowerStart.Count == 0) { return; } empTmp.Clear(); empTmp.AddRange(empowerStart.Keys); foreach (CharacterBody item in empTmp) { if (!Object.op_Implicit((Object)(object)item)) { empowerStart.Remove(item); } else { item.MarkAllStatsDirty(); } } } private void Update() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_008e: 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_0095: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00bc: Expected O, but got Unknown try { Console instance = Console.instance; if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("osp_shield")) { instance.concommandCatalog["osp_shield"] = new ConCommand { flags = (ConVarFlags)1, helpText = "Trigger a ready one-shot protection's invincibility.", action = new ConCommandDelegate(ShieldCommand) }; } if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("osp_empower")) { instance.concommandCatalog["osp_empower"] = new ConCommand { flags = (ConVarFlags)1, helpText = "Spend a ready one-shot protection on a damage boost.", action = new ConCommandDelegate(EmpowerCommand) }; } } catch { } } private static void EmpowerCommand(ConCommandArgs args) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active && ManualEnabled.Value) { CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master); OSPState oSPState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<OSPState>()); if (Object.op_Implicit((Object)(object)oSPState)) { oSPState.Empower(); } } } catch (Exception ex) { Log.LogError((object)ex); } } private static void ShieldCommand(ConCommandArgs args) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active && ShieldKeyEnabled.Value) { CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master); OSPState oSPState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<OSPState>()); if (Object.op_Implicit((Object)(object)oSPState) && oSPState.phase == OSPState.Phase.Ready) { oSPState.Trigger(); } } } catch (Exception ex) { Log.LogError((object)ex); } } internal static bool Pressed(KeyboardShortcut k) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref k)).MainKey == 0) { return false; } IInputSystem current = UnityInput.Current; if (!current.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { if (!current.GetKey(modifier)) { return false; } } return true; } internal static void RequestEmpower(CharacterBody body) { Send(body, "osp_empower"); } internal static void RequestShield(CharacterBody body) { Send(body, "osp_shield"); } private static void Send(CharacterBody body, string cmd) { try { foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (readOnlyLocalUsers != null && !((Object)(object)readOnlyLocalUsers.cachedBody != (Object)(object)body) && Object.op_Implicit((Object)(object)readOnlyLocalUsers.currentNetworkUser)) { Console.instance.SubmitCmd(readOnlyLocalUsers.currentNetworkUser, cmd, false); break; } } } catch (Exception ex) { Log.LogError((object)ex); } } private void CreateBuffs() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) ReadyBuff = MakeBuff("bdOSPReady", new Color(0.8f, 0.7f, 1f), stacks: false, cooldown: false); ActiveBuff = MakeBuff("bdOSPActive", new Color(0.72f, 0.18f, 1f), stacks: false, cooldown: false); EmpowerBuff = MakeBuff("bdOSPEmpower", new Color(1f, 0.35f, 0.75f), stacks: false, cooldown: false); CooldownBuff = MakeBuff("bdOSPCooldown", new Color(0.86f, 0.8f, 0.94f), stacks: true, cooldown: true); AsyncOperationHandle<BuffDef> val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdImmune.asset"); val.Completed += delegate(AsyncOperationHandle<BuffDef> h) { if (!Object.op_Implicit((Object)(object)h.Result)) { Log.LogWarning((object)"bdImmune not found"); } else { ReadyBuff.iconSprite = h.Result.iconSprite; ActiveBuff.iconSprite = h.Result.iconSprite; EmpowerBuff.iconSprite = h.Result.iconSprite; } }; AsyncOperationHandle<BuffDef> val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/EclipseRun/bdPermanentCurse.asset"); val2.Completed += delegate(AsyncOperationHandle<BuffDef> h) { if (!Object.op_Implicit((Object)(object)h.Result)) { Log.LogWarning((object)"bdPermanentCurse not found"); } else { CooldownBuff.iconSprite = h.Result.iconSprite; } }; } private static BuffDef MakeBuff(string name, Color color, bool stacks, bool cooldown) { //IL_000e: 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) BuffDef val = ScriptableObject.CreateInstance<BuffDef>(); ((Object)val).name = name; val.buffColor = color; val.canStack = stacks; val.isDebuff = false; val.isHidden = false; try { AccessTools.Field(typeof(BuffDef), "isCooldown")?.SetValue(val, cooldown); } catch { } return val; } private static void RecalcPostfix(CharacterBody __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)__instance)) { return; } if (Object.op_Implicit((Object)(object)EmpowerBuff) && (int)EmpowerBuff.buffIndex != -1 && __instance.HasBuff(EmpowerBuff)) { if (!empowerStart.TryGetValue(__instance, out var value)) { value = Time.fixedTime; empowerStart[__instance] = value; } float num = Mathf.Clamp01((Time.fixedTime - value) / Mathf.Max(0.1f, ManualDuration.Value)); __instance.damage *= Mathf.Max(0f, Mathf.Lerp(ManualDamageMult.Value, ManualDamageMultEnd.Value, num)); } else { empowerStart.Remove(__instance); } if (!DisableVanilla.Value || (!__instance.isPlayerControlled && PlayersOnly.Value)) { return; } try { if (setOspFraction != null) { setOspFraction(__instance, 0f); } if (setHasOsp != null) { setHasOsp(__instance, arg2: false); } } catch { } } private static void OnBodyStart(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body)) { return; } if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<OSPVisuals>())) { ((Component)body).gameObject.AddComponent<OSPVisuals>(); } if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master) && (!PlayersOnly.Value || Object.op_Implicit((Object)(object)body.master.playerCharacterMasterController))) { OSPState oSPState = ((Component)body.master).GetComponent<OSPState>(); if (!Object.op_Implicit((Object)(object)oSPState)) { oSPState = ((Component)body.master).gameObject.AddComponent<OSPState>(); } oSPState.OnNewBody(body); } } internal static OSPState StateFor(HealthComponent hc) { if (!Object.op_Implicit((Object)(object)hc) || !Object.op_Implicit((Object)(object)hc.body) || !Object.op_Implicit((Object)(object)hc.body.master)) { return null; } return ((Component)hc.body.master).GetComponent<OSPState>(); } private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo, out HitState __state) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) __state = default(HitState); try { if (!NetworkServer.active || damageInfo == null || damageInfo.rejected) { return; } OSPState oSPState = StateFor(__instance); if (!Object.op_Implicit((Object)(object)oSPState) || !__instance.alive || (Object.op_Implicit((Object)(object)damageInfo.attacker) && (Object)(object)damageInfo.attacker == (Object)(object)((Component)__instance).gameObject && !CountSelfDamage.Value)) { return; } __state.state = oSPState; bool flag = InstantRecharge(); if (oSPState.phase == OSPState.Phase.Active) { if (flag) { damageInfo.rejected = true; } } else if (oSPState.phase == OSPState.Phase.Empowered) { oSPState.RegisterHit(); } else if (oSPState.phase == OSPState.Phase.Ready) { if (flag) { MakeInstantKillLethal(__instance, damageInfo); } if ((damageInfo.damageType.damageType & 1) == 0) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType | 1u); __state.addedNonLethal = true; } } else { oSPState.RegisterHit(); } } catch (Exception ex) { Log.LogError((object)ex); } } private static void MakeInstantKillLethal(HealthComponent hc, DamageInfo damageInfo) { //IL_000d: 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_0037: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0023: 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_002f: Invalid comparison between Unknown and I4 //IL_0071: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected I4, but got Unknown CharacterBody body = hc.body; bool flag = (damageInfo.damageType.damageType & 0x10000) != 0 && Object.op_Implicit((Object)(object)body) && (body.bodyFlags & 0x800) == 0; DamageTypeExtended val = (DamageTypeExtended)18; bool flag2 = (damageInfo.damageType.damageTypeExtended & val) > 0; if (flag || flag2) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType & 0xFFFEFFFFu); ref DamageTypeExtended damageTypeExtended = ref damageInfo.damageType.damageTypeExtended; damageTypeExtended &= ~val; if (flag) { damageInfo.damage = Mathf.Max(damageInfo.damage, hc.fullCombinedHealth * 10f + 1000000f); } } } private static void TakeDamagePostfix(HealthComponent __instance, DamageInfo damageInfo, HitState __state) { try { if (Object.op_Implicit((Object)(object)__state.state) && __state.addedNonLethal) { ref DamageType damageType = ref damageInfo.damageType.damageType; damageType = (DamageType)((uint)damageType & 0xFFFFFFFEu); if (__instance.alive && __instance.health <= 1.001f && !damageInfo.rejected) { __state.state.Trigger(); } } } catch (Exception ex) { Log.LogError((object)ex); } } } internal static class LGCompat { private static readonly Dictionary<string, string> tokens = new Dictionary<string, string>(); private static bool hooked; internal static Func<Dictionary<string, string>> Builder; internal static Dictionary<BuffDef, Func<string>> IconText = new Dictionary<BuffDef, Func<string>>(); private static FieldInfo fStack; internal static void Init(Harmony h) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown if (!hooked) { hooked = true; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Apply)); try { Language.onCurrentLanguageChanged += Apply; } catch { } h.Patch((MethodBase)AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(typeof(LGCompat), "TokenPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(BuffIcon), "UpdateIcon", (Type[])null, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(LGCompat), "IconPostfix", (Type[])null); h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } internal static string KeyName(KeyboardShortcut k) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) string text = KeyLabel(((KeyboardShortcut)(ref k)).MainKey); foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { text = KeyLabel(modifier) + "+" + text; } return text; } private unsafe static string KeyLabel(KeyCode c) { string text = ((object)(*(KeyCode*)(&c))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { text = text.Substring(5); } if (text.StartsWith("Left")) { text = "L" + text.Substring(4); } if (text.StartsWith("Right")) { text = "R" + text.Substring(5); } return text; } internal static void Apply() { try { tokens.Clear(); if (Builder != null) { foreach (KeyValuePair<string, string> item in Builder()) { tokens[item.Key] = item.Value; } } Language currentLanguage = Language.currentLanguage; if (currentLanguage == null || currentLanguage.stringsByToken == null) { return; } foreach (KeyValuePair<string, string> token in tokens) { currentLanguage.stringsByToken[token.Key] = token.Value; } } catch { } } internal static void Add(Dictionary<string, string> d, BuffDef b, string name, string desc) { if (Object.op_Implicit((Object)(object)b)) { d["LG_TOKEN_NAME_" + ((Object)b).name] = name; d["LG_TOKEN_DESCRIPTION_" + ((Object)b).name] = desc; } } private static bool TokenPrefix(string token, ref string __result) { if (token != null && tokens.TryGetValue(token, out var value)) { __result = value; return false; } return true; } private static void IconPostfix(BuffIcon __instance) { try { if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.buffDef) || !IconText.TryGetValue(__instance.buffDef, out var value)) { return; } if (fStack == null) { fStack = AccessTools.Field(typeof(BuffIcon), "stackCount"); } Component val = (Component)((!(fStack != null)) ? null : /*isinst with value type is only supported in some contexts*/); if (Object.op_Implicit((Object)(object)val)) { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (Object.op_Implicit((Object)(object)val2)) { val2.enabled = true; } val.gameObject.SetActive(true); PropertyInfo property = ((object)val).GetType().GetProperty("text"); if (property != null) { property.SetValue(val, value(), null); } } } catch { } } } public class OSPState : MonoBehaviour { public enum Phase { Ready, Active, Cooldown, Empowered } public Phase phase; public float lastHitTime; public float activeUntil; public float charge; private CharacterMaster master; private void Awake() { master = ((Component)this).GetComponent<CharacterMaster>(); } public void OnNewBody(CharacterBody body) { phase = Phase.Ready; ApplyBuffs(body); } public void RegisterHit() { lastHitTime = Time.fixedTime; charge = 0f; } public void Empower() { CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody()); if (Object.op_Implicit((Object)(object)val) && phase == Phase.Ready && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { phase = Phase.Empowered; activeUntil = Time.fixedTime + Mathf.Max(0.1f, OneShotReworkPlugin.ManualDuration.Value); ApplyBuffs(val); OneShotReworkPlugin.Log.LogInfo((object)("One-shot protection spent on empower by " + val.GetDisplayName())); } } public void Trigger() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody()); if (!Object.op_Implicit((Object)(object)val)) { return; } phase = Phase.Active; float num = Mathf.Max(0.1f, OneShotReworkPlugin.InvincibleTime.Value); activeUntil = Time.fixedTime + num; val.AddTimedBuff(Buffs.HiddenInvincibility, num); if (OneShotReworkPlugin.RemoveCurse.Value && Object.op_Implicit((Object)(object)Buffs.PermanentCurse)) { try { HealthComponent healthComponent = val.healthComponent; float num2 = ((!Object.op_Implicit((Object)(object)healthComponent)) ? 0f : healthComponent.health); if (val.GetBuffCount(Buffs.PermanentCurse) > 0) { val.SetBuffCount(Buffs.PermanentCurse.buffIndex, 0); val.RecalculateStats(); if (Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive && healthComponent.health > num2) { healthComponent.Networkhealth = num2; } } } catch { } } ApplyBuffs(val); OneShotReworkPlugin.Log.LogInfo((object)("One-shot protection triggered for " + val.GetDisplayName())); } private void FixedUpdate() { if (!NetworkServer.active) { return; } CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody()); float fixedTime = Time.fixedTime; bool flag = OneShotReworkPlugin.InstantRecharge(); if ((phase == Phase.Active || phase == Phase.Empowered) && fixedTime >= activeUntil) { phase = ((!flag) ? Phase.Cooldown : Phase.Ready); lastHitTime = fixedTime; charge = 0f; } if (phase == Phase.Cooldown) { HealthComponent val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.healthComponent); if (Object.op_Implicit((Object)(object)val2) && val2.alive && (val2.health >= val2.fullHealth - 0.01f || NoFullHp(val) || OneShotReworkPlugin.InVoidScene())) { charge += Time.fixedDeltaTime; } if (flag || charge >= OneShotReworkPlugin.EffectiveCooldown()) { phase = Phase.Ready; } } if (Object.op_Implicit((Object)(object)val)) { ApplyBuffs(val); } } private static bool NoFullHp(CharacterBody b) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) string value = OneShotReworkPlugin.NoFullHpBodies.Value; if (!Object.op_Implicit((Object)(object)b) || string.IsNullOrEmpty(value)) { return false; } string text = BodyCatalog.GetBodyName(b.bodyIndex) ?? string.Empty; string text2 = b.GetDisplayName() ?? string.Empty; string[] array = value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text3 = array[i].Trim(); if (text3.Length > 0 && (text.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } } return false; } private int CooldownStacks() { if (phase != Phase.Cooldown) { return 0; } float num = OneShotReworkPlugin.EffectiveCooldown() - charge; return Mathf.Max(1, Mathf.CeilToInt(num)); } private void ApplyBuffs(CharacterBody body) { if (Object.op_Implicit((Object)(object)body) && NetworkServer.active) { SetCount(body, OneShotReworkPlugin.ReadyBuff, (phase == Phase.Ready) ? 1 : 0); SetCount(body, OneShotReworkPlugin.ActiveBuff, (phase == Phase.Active) ? 1 : 0); SetCount(body, OneShotReworkPlugin.EmpowerBuff, (phase == Phase.Empowered) ? 1 : 0); SetCount(body, OneShotReworkPlugin.CooldownBuff, CooldownStacks()); } } private static void SetCount(CharacterBody body, BuffDef buff, int count) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)buff) && (int)buff.buffIndex != -1) { int i; for (i = body.GetBuffCount(buff); i < count; i++) { body.AddBuff(buff); } while (i > count) { body.RemoveBuff(buff); i--; } } } } public class OSPVisuals : MonoBehaviour { private CharacterBody body; private bool wasActive; private bool wasEmpower; private uint beamEnterId; private string beamStop; private static Texture2D tintTex; private GameObject emitter; private GameObject Emitter() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)emitter)) { emitter = new GameObject("OSPEmpowerSound"); emitter.transform.SetParent(((Component)this).transform, false); } return emitter; } private void SetEmitterVolume() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) try { float num = (OneShotReworkPlugin.InstantRecharge() ? Mathf.Clamp(OneShotReworkPlugin.InstantEmpowerVolume.Value, 0f, 4f) : 1f); ulong akGameObjectID = AkSoundEngine.GetAkGameObjectID(Emitter()); AkSoundEngine.SetGameObjectOutputBusVolume(akGameObjectID, ulong.MaxValue, num); AkAudioListener[] array = Object.FindObjectsOfType<AkAudioListener>(); foreach (AkAudioListener val in array) { if (Object.op_Implicit((Object)(object)val)) { AkSoundEngine.SetGameObjectOutputBusVolume(akGameObjectID, AkSoundEngine.GetAkGameObjectID(((Component)val).gameObject), num); } } } catch (Exception ex) { OneShotReworkPlugin.Log.LogWarning((object)("Empower volume: " + ex.Message)); } } private void StartBeam() { string value = OneShotReworkPlugin.ManualSound.Value; GameObject val = Emitter(); if (value != "@voidling_spinbeam") { try { Util.PlaySound(value, val); SetEmitterVolume(); return; } catch { return; } } try { string enterSoundString = SpinBeamAttack.enterSoundString; if (!string.IsNullOrEmpty(enterSoundString)) { beamEnterId = Util.PlaySound(enterSoundString, val); } LoopSoundDef loopSound = SpinBeamAttack.loopSound; if (Object.op_Implicit((Object)(object)loopSound)) { if (!string.IsNullOrEmpty(loopSound.startSoundName)) { Util.PlaySound(loopSound.startSoundName, val); } beamStop = loopSound.stopSoundName; } SetEmitterVolume(); } catch (Exception ex) { OneShotReworkPlugin.Log.LogWarning((object)("Beam sound: " + ex.Message)); } } private void StopBeam() { try { if (beamEnterId != 0) { AkStop.Stop(beamEnterId); } } catch { } beamEnterId = 0u; try { if (!string.IsNullOrEmpty(beamStop)) { Util.PlaySound(beamStop, Object.op_Implicit((Object)(object)emitter) ? emitter : ((Component)this).gameObject); } } catch { } beamStop = null; } private void OnDestroy() { if (wasEmpower) { StopBeam(); } } private void Awake() { body = ((Component)this).GetComponent<CharacterBody>(); } private bool Active() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 BuffDef activeBuff = OneShotReworkPlugin.ActiveBuff; if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)activeBuff) && (int)activeBuff.buffIndex != -1) { return body.HasBuff(activeBuff); } return false; } private static bool Has(CharacterBody b, BuffDef d) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1) { return b.HasBuff(d); } return false; } private void Update() { //IL_0023: 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) try { if (OneShotReworkPlugin.ManualEnabled.Value && Has(body, OneShotReworkPlugin.ReadyBuff) && OneShotReworkPlugin.Pressed(OneShotReworkPlugin.ManualKey.Value) && IsLocalPlayer() && !ChatOpen()) { OneShotReworkPlugin.RequestEmpower(body); } else if (OneShotReworkPlugin.ShieldKeyEnabled.Value && Has(body, OneShotReworkPlugin.ReadyBuff) && OneShotReworkPlugin.Pressed(OneShotReworkPlugin.ShieldKey.Value) && IsLocalPlayer() && !ChatOpen()) { OneShotReworkPlugin.RequestShield(body); } } catch { } bool flag = Has(body, OneShotReworkPlugin.EmpowerBuff); if (flag != wasEmpower) { wasEmpower = flag; if (flag) { StartBeam(); } else { StopBeam(); } } bool flag2 = Active(); if (flag2 == wasActive) { return; } wasActive = flag2; if (!flag2) { return; } try { string text = OneShotReworkPlugin.SoundOverride.Value; if (string.IsNullOrEmpty(text)) { text = OneShotReworkPlugin.ImplosionSound; } if (string.IsNullOrEmpty(text)) { text = "Play_nullifier_death_vortex_explode"; } Util.PlaySound(text, ((Component)this).gameObject); } catch (Exception ex) { OneShotReworkPlugin.Log.LogWarning((object)ex.Message); } } private bool IsLocalPlayer() { try { foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (readOnlyLocalUsers != null && (Object)(object)readOnlyLocalUsers.cachedBody == (Object)(object)body) { return true; } } } catch { } return false; } private static bool ChatOpen() { try { ChatBox[] array = Object.FindObjectsOfType<ChatBox>(); foreach (ChatBox val in array) { if (Object.op_Implicit((Object)(object)val) && val.showInput) { return true; } } } catch { } return false; } private void OnGUI() { //IL_0060: 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_0045: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references) if ((wasActive || wasEmpower) && OneShotReworkPlugin.ScreenTint.Value && IsLocalPlayer()) { if (!Object.op_Implicit((Object)(object)tintTex)) { tintTex = new Texture2D(1, 1); tintTex.SetPixel(0, 0, Color.white); tintTex.Apply(); } Color color = GUI.color; float num = Mathf.Clamp01(OneShotReworkPlugin.TintStrength.Value); GUI.color = ((!wasEmpower) ? new Color(0.2f, 0f, 0.32f, num) : new Color(1f, 0.35f, 0.75f, num * 0.6f)); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)tintTex); GUI.color = color; } } } internal static class RiskOfOptionsCompat { [MethodImpl(MethodImplOptions.NoInlining)] internal static void Init() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown ModSettingsManager.SetModDescription("Reworked one-shot protection: recharge at full health, empower and manual shield keys."); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OneShotReworkPlugin.ManualKey)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OneShotReworkPlugin.ShieldKey)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ManualEnabled)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ShieldKeyEnabled)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ScreenTint)); } } }
Parry.dll
Decompiled 2 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using AK.Wwise; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates.BrotherMonster; using EntityStates.FalseSon; using EntityStates.Halcyonite; using HarmonyLib; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2.UI; using RoR2.WwiseUtils; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace Parry { internal static class AkStop { private static MethodInfo stop; private static MethodInfo stopAny; private static bool searched; internal static void Stop(uint id) { if (id == 0) { return; } try { if (!searched) { searched = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = null; try { type = assembly.GetType("AkSoundEngine", throwOnError: false); } catch { } if (!(type == null)) { stop = type.GetMethod("StopPlayingID", new Type[1] { typeof(uint) }); if (stop != null) { break; } } } } if (stop != null) { stop.Invoke(null, new object[1] { id }); return; } if (stopAny == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { Type type2 = null; try { type2 = assembly2.GetType("AkSoundEngine", throwOnError: false); } catch { } if (type2 == null) { continue; } MethodInfo[] methods = type2.GetMethods(); foreach (MethodInfo methodInfo in methods) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (methodInfo.Name == "StopPlayingID" && parameters.Length != 0 && parameters[0].ParameterType == typeof(uint)) { stopAny = methodInfo; break; } } if (stopAny != null) { break; } } } if (stopAny != null) { ParameterInfo[] parameters2 = stopAny.GetParameters(); object[] array = new object[parameters2.Length]; array[0] = id; for (int k = 1; k < parameters2.Length; k++) { array[k] = ((!(parameters2[k].ParameterType == typeof(int))) ? ((!parameters2[k].ParameterType.IsValueType) ? null : Activator.CreateInstance(parameters2[k].ParameterType)) : ((object)0)); } stopAny.Invoke(null, array); } } catch { } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("custom.Parry", "Parry", "1.6.3")] public class ParryPlugin : BaseUnityPlugin { private class Provider : IContentPackProvider { private readonly ContentPack pack = new ContentPack(); public string identifier => "custom.Parry"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { try { AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.Parry", null); } catch { } pack.buffDefs.Add((BuffDef[])(object)new BuffDef[5] { ReadyBuff, WindowBuff, InvulnBuff, BoostBuff, CooldownBuff }); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(pack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static CollectContentPackProvidersDelegate <>9__32_0; public static Func<Dictionary<string, string>> <>9__32_1; public static Func<string> <>9__32_2; public static EventHandler<SettingChangedEventArgs> <>9__32_3; public static Action<AsyncOperationHandle<BuffDef>> <>9__33_0; public static Action<AsyncOperationHandle<BuffDef>> <>9__33_1; internal void <Awake>b__32_0(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); } internal Dictionary<string, string> <Awake>b__32_1() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text = LGCompat.KeyName(Key.Value); string text2 = DamageMult.Value + "x"; LGCompat.Add(dictionary, ReadyBuff, "Parry Ready", "Press <style=cIsDamage>[" + text + "]</style> to parry. A successful parry gives <style=cIsUtility>invincibility</style> and a <style=cIsDamage>damage boost</style>."); LGCompat.Add(dictionary, WindowBuff, "Parrying", "The next hit is <style=cIsUtility>parried</style>."); LGCompat.Add(dictionary, InvulnBuff, "Parried!", "<style=cIsUtility>Invincible</style> and damage multiplied by <style=cIsDamage>" + text2 + "</style>."); LGCompat.Add(dictionary, BoostBuff, "Parry Boost", "Damage multiplied by <style=cIsDamage>" + text2 + "</style>."); LGCompat.Add(dictionary, CooldownBuff, "Parry Recharging", "On cooldown."); return dictionary; } internal string <Awake>b__32_2() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return LGCompat.KeyName(Key.Value); } internal void <Awake>b__32_3(object <p0>, SettingChangedEventArgs <p1>) { LGCompat.Apply(); } internal void <CreateBuffs>b__33_0(AsyncOperationHandle<BuffDef> r) { if (Object.op_Implicit((Object)(object)r.Result)) { ReadyBuff.iconSprite = (WindowBuff.iconSprite = (InvulnBuff.iconSprite = (BoostBuff.iconSprite = r.Result.iconSprite))); } } internal void <CreateBuffs>b__33_1(AsyncOperationHandle<BuffDef> r) { if (Object.op_Implicit((Object)(object)r.Result)) { CooldownBuff.iconSprite = r.Result.iconSprite; } } } public const string GUID = "custom.Parry"; internal const string Cmd = "parry_activate"; internal static ManualLogSource Log; internal static ConfigEntry<KeyboardShortcut> Key; internal static ConfigEntry<bool> PlayersOnly; internal static ConfigEntry<bool> ScreenTint; internal static ConfigEntry<float> WindowTime; internal static ConfigEntry<float> InvulnTime; internal static ConfigEntry<float> BoostTime; internal static ConfigEntry<float> DamageMult; internal static ConfigEntry<float> CooldownTime; internal static ConfigEntry<float> WindowTint; internal static ConfigEntry<float> BoostTint; internal static ConfigEntry<float> InvulnTint; internal static ConfigEntry<string> ParrySound; internal static ConfigEntry<string> ActivateSound; internal static ConfigEntry<int> ParryRepeat; internal static ConfigEntry<float> LaserSeconds; internal static ConfigEntry<bool> CutActivate; internal static BuffDef ReadyBuff; internal static BuffDef WindowBuff; internal static BuffDef InvulnBuff; internal static BuffDef BoostBuff; internal static BuffDef CooldownBuff; internal static readonly Color Lvl1 = new Color(0.25f, 0.62f, 0.25f); internal static readonly Color Lvl2 = new Color(0.4f, 0.92f, 0.4f); internal static readonly Color Lvl3 = new Color(0.78f, 1f, 0.78f); internal static readonly Color Pale = new Color(0.78f, 0.9f, 0.78f); private static string impactSound; private static bool impactLoaded; private static readonly Dictionary<string, List<string>> scanned = new Dictionary<string, List<string>>(); private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown //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) //IL_0267: Expected O, but got Unknown //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "ParryKey", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), "Key that opens the parry window."); PlayersOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayersOnly", true, "Only player-controlled survivors can parry."); WindowTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "ParryWindow", 1f, "Seconds the parry window stays open after pressing the key."); InvulnTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "InvincibilityTime", 1f, "Seconds of invincibility after a successful parry."); BoostTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "DamageBoostTime", 5f, "Seconds of boosted damage after a successful parry (includes the invincibility)."); DamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "DamageMultiplier", 2.5f, "Damage multiplier after a successful parry."); CooldownTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "Cooldown", 15f, "Cooldown after the window closes without a parry, or after the damage boost ends."); ScreenTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ScreenTint", true, "Green screen tint during the window and the boost."); WindowTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "WindowTintStrength", 0.08f, "Tint opacity during the parry window."); InvulnTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "InvincibleTintStrength", 0.38f, "Tint opacity during the invincibility right after a parry (strongest)."); BoostTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "BoostTintStrength", 0.16f, "Tint opacity during the rest of the damage boost."); ParrySound = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "ParrySoundV6", "@mithrix_impact,@falseson_laser", "Sound events (comma-separated) played on a successful parry. Special values: @mithrix_impact, @falseson_laser (False Son's Laser of the Father, stopped after FalseSonLaserSeconds), @deus_parry, @halcyonite_laser, @gilded_gong, @mithrix_swing, @mithrix_pizza."); LaserSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "FalseSonLaserSeconds", 5f, "How long the False Son laser sound plays on a successful parry."); ParryRepeat = ((BaseUnityPlugin)this).Config.Bind<int>("Visuals", "ParrySoundRepeat", 3, "How many times the parry sound is layered (louder)."); ActivateSound = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "ActivateSoundV7", "@halcyonite_laser", "Sound events (comma-separated) played when the parry window opens. Default: the Halcyonite laser. Special values: @halcyonite_laser, @deus_parry, @gilded_gong, @mithrix_impact, @mithrix_swing, @mithrix_pizza."); CutActivate = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "CutActivateSoundOnWindowEnd", false, "Stop the window-open sound when the window closes or the parry lands."); CreateBuffs(); object obj = <>c.<>9__32_0; if (obj == null) { CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); }; <>c.<>9__32_0 = val; obj = (object)val; } ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj; Harmony val2 = new Harmony("custom.Parry"); MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null); HarmonyMethod val3 = new HarmonyMethod(typeof(ParryPlugin), "RecalcPostfix", (Type[])null); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null); val2.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(ParryPlugin), "TakeDamagePrefix", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CharacterBody.onBodyStartGlobal += OnBodyStart; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LoadSoundBanks)); LGCompat.Init(val2); LGCompat.Builder = delegate { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text = LGCompat.KeyName(Key.Value); string text2 = DamageMult.Value + "x"; LGCompat.Add(dictionary, ReadyBuff, "Parry Ready", "Press <style=cIsDamage>[" + text + "]</style> to parry. A successful parry gives <style=cIsUtility>invincibility</style> and a <style=cIsDamage>damage boost</style>."); LGCompat.Add(dictionary, WindowBuff, "Parrying", "The next hit is <style=cIsUtility>parried</style>."); LGCompat.Add(dictionary, InvulnBuff, "Parried!", "<style=cIsUtility>Invincible</style> and damage multiplied by <style=cIsDamage>" + text2 + "</style>."); LGCompat.Add(dictionary, BoostBuff, "Parry Boost", "Damage multiplied by <style=cIsDamage>" + text2 + "</style>."); LGCompat.Add(dictionary, CooldownBuff, "Parry Recharging", "On cooldown."); return dictionary; }; LGCompat.IconText[ReadyBuff] = () => LGCompat.KeyName(Key.Value); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { LGCompat.Apply(); }; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { try { RiskOfOptionsCompat.Init(); } catch (Exception ex) { Log.LogWarning((object)("Risk of Options: " + ex.Message)); } } } private void CreateBuffs() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) ReadyBuff = MakeBuff("bdParryReady", Lvl1, cooldown: false); WindowBuff = MakeBuff("bdParryWindow", Lvl2, cooldown: false); InvulnBuff = MakeBuff("bdParryInvincible", Lvl3, cooldown: false); BoostBuff = MakeBuff("bdParryBoost", Lvl2, cooldown: false); CooldownBuff = MakeBuff("bdParryCooldown", Pale, cooldown: true); AsyncOperationHandle<BuffDef> val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdImmune.asset"); val.Completed += delegate(AsyncOperationHandle<BuffDef> r) { if (Object.op_Implicit((Object)(object)r.Result)) { ReadyBuff.iconSprite = (WindowBuff.iconSprite = (InvulnBuff.iconSprite = (BoostBuff.iconSprite = r.Result.iconSprite))); } }; AsyncOperationHandle<BuffDef> val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/EclipseRun/bdPermanentCurse.asset"); val2.Completed += delegate(AsyncOperationHandle<BuffDef> r) { if (Object.op_Implicit((Object)(object)r.Result)) { CooldownBuff.iconSprite = r.Result.iconSprite; } }; } private static BuffDef MakeBuff(string name, Color c, bool cooldown) { //IL_000e: 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) BuffDef val = ScriptableObject.CreateInstance<BuffDef>(); ((Object)val).name = name; val.buffColor = c; val.canStack = cooldown; val.isDebuff = false; val.isHidden = false; try { AccessTools.Field(typeof(BuffDef), "isCooldown")?.SetValue(val, cooldown); } catch { } return val; } internal static bool Pressed(KeyboardShortcut k) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref k)).MainKey == 0) { return false; } IInputSystem current = UnityInput.Current; if (!current.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { if (!current.GetKey(modifier)) { return false; } } return true; } private static void LoadSoundBanks() { try { string text = (ParrySound.Value ?? string.Empty) + "," + (ActivateSound.Value ?? string.Empty); List<string> list = new List<string>(); if (text.Contains("@mithrix")) { list.Add("BrotherBody"); } if (text.Contains("@falseson")) { list.Add("FalseSonBossBody"); } if (text.Contains("@falseson_laser")) { list.Add("FalseSonBody"); } if (text.Contains("@halcyonite")) { list.Add("HalcyoniteBody"); } if (text.Contains("@gilded_gong")) { list.Add("TitanGoldBody"); } HashSet<string> hashSet = new HashSet<string>(); if (text.Contains("@falseson_laser")) { hashSet.Add("char_falseson"); } foreach (string item in list) { GameObject val = BodyCatalog.FindBodyPrefab(item); if (!Object.op_Implicit((Object)(object)val)) { continue; } AkBank[] componentsInChildren = val.GetComponentsInChildren<AkBank>(true); foreach (AkBank val2 in componentsInChildren) { string text2 = (((Object)(object)val2 == (Object)null || val2.data == null) ? null : ((BaseType)val2.data).Name); if (!string.IsNullOrEmpty(text2)) { hashSet.Add(text2); } } SoundbankLoader[] componentsInChildren2 = val.GetComponentsInChildren<SoundbankLoader>(true); foreach (SoundbankLoader val3 in componentsInChildren2) { if ((Object)(object)val3 == (Object)null || val3.soundbankStrings == null) { continue; } string[] soundbankStrings = val3.soundbankStrings; foreach (string text3 in soundbankStrings) { if (!string.IsNullOrEmpty(text3)) { hashSet.Add(text3); } } } } List<string> list2 = new List<string>(); foreach (string item2 in hashSet) { try { AkBankManager.LoadBank(item2, false, false); list2.Add(item2); } catch (Exception ex) { Log.LogWarning((object)("Sound bank " + item2 + ": " + ex.Message)); } } if (list2.Count > 0) { Log.LogInfo((object)("Parry sounds: loaded sound banks " + string.Join(", ", list2.ToArray()) + ".")); } else { Log.LogWarning((object)("Parry sounds: no sound banks found for " + string.Join(", ", list.ToArray()) + ". If the parry is silent, install SoundFixer.")); } } catch (Exception ex2) { Log.LogWarning((object)("Parry sound banks: " + ex2.Message)); } } private static List<string> SoundsIn(string path) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (scanned.TryGetValue(path, out var value)) { return value; } value = new List<string>(); try { GameObject val = Addressables.LoadAssetAsync<GameObject>((object)path).WaitForCompletion(); if (Object.op_Implicit((Object)(object)val)) { Component[] componentsInChildren = val.GetComponentsInChildren<Component>(true); foreach (Component val2 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val2)) { continue; } FieldInfo[] fields = ((object)val2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(string))) { string text = fieldInfo.GetValue(val2) as string; if (!string.IsNullOrEmpty(text) && text.StartsWith("Play_", StringComparison.OrdinalIgnoreCase) && !value.Contains(text)) { value.Add(text); } } } } } } catch (Exception ex) { Log.LogWarning((object)("Sound scan " + path + ": " + ex.Message)); } Log.LogInfo((object)("Sounds in " + path + ": " + ((value.Count <= 0) ? "none" : string.Join(", ", value.ToArray())))); scanned[path] = value; return value; } private static string FirstSound(params string[] paths) { for (int i = 0; i < paths.Length; i++) { List<string> list = SoundsIn(paths[i]); if (list.Count > 0) { return list[0]; } } return null; } private static IEnumerable<string> Resolve(string token) { switch (token) { case "@deus_parry": { string text6 = FirstSound("RoR2/DLC3/Parry/ParryEffect.prefab", "RoR2/DLC3/Parry/ParryOrbEffect.prefab", "RoR2/DLC3/Parry/ParryHalo.prefab"); if (!string.IsNullOrEmpty(text6)) { yield return text6; } break; } case "@gilded_gong": { string text5 = FirstSound("RoR2/DLC2/Elites/EliteAurelionite/AffixAurelionitePreStrikeProjectile.prefab", "RoR2/DLC2/Elites/EliteAurelionite/AffixAurelionitePreFistGhost.prefab", "RoR2/DLC2/Elites/EliteAurelionite/EliteAurelioniteSummonPillarVFX.prefab", "RoR2/DLC2/Elites/EliteAurelionite/AffixAurelioniteStrikeEffect.prefab"); if (!string.IsNullOrEmpty(text5)) { yield return text5; } break; } case "@halcyonite_laser": { string text3 = null; try { text3 = TriLaser.attackSoundString; } catch { } if (string.IsNullOrEmpty(text3)) { text3 = FirstSound("RoR2/DLC2/Halcyonite/LaserTriLaser.prefab", "RoR2/DLC2/Halcyonite/MuzzleflashTriLaser.prefab", "RoR2/DLC2/Halcyonite/ExplosionTriLaser.prefab"); } if (!string.IsNullOrEmpty(text3)) { yield return text3; } break; } case "@mithrix_swing": { string text4 = null; try { text4 = WeaponSlam.attackSoundString; } catch { } if (!string.IsNullOrEmpty(text4)) { yield return text4; } break; } case "@mithrix_impact": case "@mithrix_slam": if (!impactLoaded) { impactLoaded = true; try { GameObject val = WeaponSlam.slamImpactEffect; if (!Object.op_Implicit((Object)(object)val)) { val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherSlamImpact.prefab").WaitForCompletion(); } EffectComponent val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<EffectComponent>()); impactSound = ((!Object.op_Implicit((Object)(object)val2)) ? null : val2.soundName); } catch { } } if (token == "@mithrix_slam") { string text2 = null; try { text2 = WeaponSlam.attackSoundString; } catch { } if (!string.IsNullOrEmpty(text2)) { yield return text2; } } if (!string.IsNullOrEmpty(impactSound)) { yield return impactSound; } break; case "@mithrix_pizza": { string text = null; string b = null; try { text = UltEnterState.soundString; } catch { } try { b = UltChannelState.enterSoundString; } catch { } if (!string.IsNullOrEmpty(text)) { yield return text; } if (!string.IsNullOrEmpty(b)) { yield return b; } break; } default: yield return token; break; case "@falseson_laser": break; } } internal static List<uint> PlayAll(string list, GameObject go, int repeat = 1) { List<uint> list2 = new List<uint>(); if (string.IsNullOrEmpty(list)) { return list2; } string[] array = list.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0) { continue; } foreach (string item in Resolve(text)) { for (int j = 0; j < Mathf.Max(1, repeat); j++) { list2.Add(Util.PlaySound(item, go)); } } } return list2; } internal static bool Has(CharacterBody b, BuffDef d) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1) { return b.HasBuff(d); } return false; } private static void RecalcPostfix(CharacterBody __instance) { if (Object.op_Implicit((Object)(object)__instance) && (Has(__instance, InvulnBuff) || Has(__instance, BoostBuff))) { __instance.damage *= Mathf.Max(0f, DamageMult.Value); } } private static void OnBodyStart(CharacterBody body) { if (Object.op_Implicit((Object)(object)body)) { if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<ParryVisuals>())) { ((Component)body).gameObject.AddComponent<ParryVisuals>(); } if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master) && (!PlayersOnly.Value || Object.op_Implicit((Object)(object)body.master.playerCharacterMasterController))) { (((Component)body.master).GetComponent<ParryState>() ?? ((Component)body.master).gameObject.AddComponent<ParryState>()).OnNewBody(body); } } } private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active && damageInfo != null && !damageInfo.rejected && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.body) && Object.op_Implicit((Object)(object)__instance.body.master)) { ParryState component = ((Component)__instance.body.master).GetComponent<ParryState>(); if (Object.op_Implicit((Object)(object)component) && component.phase == ParryState.Phase.Window && (!(damageInfo.damage <= 0f) || (damageInfo.damageType.damageType & 0x50000) != 0)) { damageInfo.rejected = true; component.Parried(); } } } catch (Exception ex) { Log.LogError((object)ex); } } private void Update() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown try { Console instance = Console.instance; if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("parry_activate")) { instance.concommandCatalog["parry_activate"] = new ConCommand { flags = (ConVarFlags)1, helpText = "Open the parry window.", action = new ConCommandDelegate(ParryCommand) }; } } catch { } } private static void ParryCommand(ConCommandArgs args) { //IL_0007: 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) try { if (NetworkServer.active) { CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master); ParryState parryState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<ParryState>()); if (Object.op_Implicit((Object)(object)parryState)) { parryState.Open(); } } } catch (Exception ex) { Log.LogError((object)ex); } } internal static void Request(CharacterBody body) { try { foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (readOnlyLocalUsers != null && !((Object)(object)readOnlyLocalUsers.cachedBody != (Object)(object)body) && Object.op_Implicit((Object)(object)readOnlyLocalUsers.currentNetworkUser)) { Console.instance.SubmitCmd(readOnlyLocalUsers.currentNetworkUser, "parry_activate", false); break; } } } catch (Exception ex) { Log.LogError((object)ex); } } } internal static class LGCompat { private static readonly Dictionary<string, string> tokens = new Dictionary<string, string>(); private static bool hooked; internal static Func<Dictionary<string, string>> Builder; internal static Dictionary<BuffDef, Func<string>> IconText = new Dictionary<BuffDef, Func<string>>(); private static FieldInfo fStack; internal static void Init(Harmony h) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown if (!hooked) { hooked = true; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Apply)); try { Language.onCurrentLanguageChanged += Apply; } catch { } h.Patch((MethodBase)AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(typeof(LGCompat), "TokenPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(BuffIcon), "UpdateIcon", (Type[])null, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(LGCompat), "IconPostfix", (Type[])null); h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } internal static string KeyName(KeyboardShortcut k) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) string text = KeyLabel(((KeyboardShortcut)(ref k)).MainKey); foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { text = KeyLabel(modifier) + "+" + text; } return text; } private unsafe static string KeyLabel(KeyCode c) { string text = ((object)(*(KeyCode*)(&c))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { text = text.Substring(5); } if (text.StartsWith("Left")) { text = "L" + text.Substring(4); } if (text.StartsWith("Right")) { text = "R" + text.Substring(5); } return text; } internal static void Apply() { try { tokens.Clear(); if (Builder != null) { foreach (KeyValuePair<string, string> item in Builder()) { tokens[item.Key] = item.Value; } } Language currentLanguage = Language.currentLanguage; if (currentLanguage == null || currentLanguage.stringsByToken == null) { return; } foreach (KeyValuePair<string, string> token in tokens) { currentLanguage.stringsByToken[token.Key] = token.Value; } } catch { } } internal static void Add(Dictionary<string, string> d, BuffDef b, string name, string desc) { if (Object.op_Implicit((Object)(object)b)) { d["LG_TOKEN_NAME_" + ((Object)b).name] = name; d["LG_TOKEN_DESCRIPTION_" + ((Object)b).name] = desc; } } private static bool TokenPrefix(string token, ref string __result) { if (token != null && tokens.TryGetValue(token, out var value)) { __result = value; return false; } return true; } private static void IconPostfix(BuffIcon __instance) { try { if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.buffDef) || !IconText.TryGetValue(__instance.buffDef, out var value)) { return; } if (fStack == null) { fStack = AccessTools.Field(typeof(BuffIcon), "stackCount"); } Component val = (Component)((!(fStack != null)) ? null : /*isinst with value type is only supported in some contexts*/); if (Object.op_Implicit((Object)(object)val)) { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (Object.op_Implicit((Object)(object)val2)) { val2.enabled = true; } val.gameObject.SetActive(true); PropertyInfo property = ((object)val).GetType().GetProperty("text"); if (property != null) { property.SetValue(val, value(), null); } } } catch { } } } public class ParryState : MonoBehaviour { public enum Phase { Ready, Window, Invuln, Boost, Cooldown } public Phase phase; private float phaseEnd; private float boostEnd; private CharacterMaster master; private void Awake() { master = ((Component)this).GetComponent<CharacterMaster>(); } public void OnNewBody(CharacterBody body) { phase = Phase.Ready; Apply(body); } private CharacterBody Body() { if (Object.op_Implicit((Object)(object)master)) { return master.GetBody(); } return null; } public void Open() { CharacterBody val = Body(); if (Object.op_Implicit((Object)(object)val) && phase == Phase.Ready && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { phase = Phase.Window; phaseEnd = Time.fixedTime + Mathf.Max(0.05f, ParryPlugin.WindowTime.Value); Apply(val); } } public void Parried() { CharacterBody val = Body(); if (Object.op_Implicit((Object)(object)val)) { float num = Mathf.Max(0f, ParryPlugin.InvulnTime.Value); phase = Phase.Invuln; phaseEnd = Time.fixedTime + num; boostEnd = Time.fixedTime + Mathf.Max(num, ParryPlugin.BoostTime.Value); if (num > 0f) { val.AddTimedBuff(Buffs.HiddenInvincibility, num); } Apply(val); } } private void FixedUpdate() { if (!NetworkServer.active) { return; } float fixedTime = Time.fixedTime; switch (phase) { case Phase.Window: if (fixedTime >= phaseEnd) { StartCooldown(fixedTime); } break; case Phase.Invuln: if (fixedTime >= phaseEnd) { phase = ((!(fixedTime >= boostEnd)) ? Phase.Boost : Phase.Cooldown); } if (phase == Phase.Cooldown) { StartCooldown(fixedTime); } break; case Phase.Boost: if (fixedTime >= boostEnd) { StartCooldown(fixedTime); } break; case Phase.Cooldown: if (fixedTime >= phaseEnd) { phase = Phase.Ready; } break; } CharacterBody val = Body(); if (Object.op_Implicit((Object)(object)val)) { Apply(val); } } private void StartCooldown(float now) { phase = Phase.Cooldown; phaseEnd = now + Mathf.Max(0f, ParryPlugin.CooldownTime.Value); } private void Apply(CharacterBody b) { if (Object.op_Implicit((Object)(object)b) && NetworkServer.active) { Set(b, ParryPlugin.ReadyBuff, (phase == Phase.Ready) ? 1 : 0); Set(b, ParryPlugin.WindowBuff, (phase == Phase.Window) ? 1 : 0); Set(b, ParryPlugin.InvulnBuff, (phase == Phase.Invuln) ? 1 : 0); Set(b, ParryPlugin.BoostBuff, (phase == Phase.Boost) ? 1 : 0); Set(b, ParryPlugin.CooldownBuff, (phase == Phase.Cooldown) ? Mathf.Max(1, Mathf.CeilToInt(phaseEnd - Time.fixedTime)) : 0); } } private static void Set(CharacterBody b, BuffDef d, int n) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1) { int i; for (i = b.GetBuffCount(d); i < n; i++) { b.AddBuff(d); } while (i > n) { b.RemoveBuff(d); i--; } } } } public class ParryVisuals : MonoBehaviour { private CharacterBody body; private bool wasWindow; private bool wasParried; private bool invuln; private List<uint> swingIds; private List<uint> laserIds; private string laserStop; private static Texture2D tex; private void StopSwing() { if (swingIds == null) { return; } foreach (uint swingId in swingIds) { try { if (swingId != 0) { AkStop.Stop(swingId); } } catch { } } swingIds = null; } private void OnDestroy() { StopSwing(); StopLaser(); } private IEnumerator FalseSonLaser() { StopLaser(); laserIds = new List<uint>(); try { string playAttackSoundString = LaserFatherCharged.playAttackSoundString; string playLoopSoundString = LaserFatherCharged.playLoopSoundString; laserStop = LaserFatherCharged.stopLoopSoundString; if (!string.IsNullOrEmpty(playAttackSoundString)) { laserIds.Add(Util.PlaySound(playAttackSoundString, ((Component)this).gameObject)); } if (!string.IsNullOrEmpty(playLoopSoundString)) { laserIds.Add(Util.PlaySound(playLoopSoundString, ((Component)this).gameObject)); } } catch (Exception ex) { ParryPlugin.Log.LogWarning((object)("False Son laser sound: " + ex.Message)); } yield return (object)new WaitForSeconds(Mathf.Max(0.1f, ParryPlugin.LaserSeconds.Value)); StopLaser(); } private void StopLaser() { if (laserIds == null) { return; } try { if (!string.IsNullOrEmpty(laserStop)) { Util.PlaySound(laserStop, ((Component)this).gameObject); } } catch { } foreach (uint laserId in laserIds) { AkStop.Stop(laserId); } laserIds = null; } private void Awake() { body = ((Component)this).GetComponent<CharacterBody>(); } private bool IsLocal() { try { foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (readOnlyLocalUsers != null && (Object)(object)readOnlyLocalUsers.cachedBody == (Object)(object)body) { return true; } } } catch { } return false; } private static bool ChatOpen() { try { ChatBox[] array = Object.FindObjectsOfType<ChatBox>(); foreach (ChatBox val in array) { if (Object.op_Implicit((Object)(object)val) && val.showInput) { return true; } } } catch { } return false; } private void Update() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) try { if (ParryPlugin.Has(body, ParryPlugin.ReadyBuff) && ParryPlugin.Pressed(ParryPlugin.Key.Value) && IsLocal() && !ChatOpen()) { ParryPlugin.Request(body); } } catch { } bool flag = ParryPlugin.Has(body, ParryPlugin.WindowBuff); bool flag2 = ParryPlugin.Has(body, ParryPlugin.InvulnBuff) || ParryPlugin.Has(body, ParryPlugin.BoostBuff); if (flag && !wasWindow) { swingIds = ParryPlugin.PlayAll(ParryPlugin.ActivateSound.Value, ((Component)this).gameObject); } if (!flag && wasWindow && ParryPlugin.CutActivate.Value) { StopSwing(); } if (flag2 && !wasParried) { if (ParryPlugin.CutActivate.Value) { StopSwing(); } ParryPlugin.PlayAll(ParryPlugin.ParrySound.Value, ((Component)this).gameObject, ParryPlugin.ParryRepeat.Value); if ((ParryPlugin.ParrySound.Value ?? string.Empty).Contains("@falseson_laser")) { ((MonoBehaviour)this).StartCoroutine(FalseSonLaser()); } } wasWindow = flag; wasParried = flag2; invuln = ParryPlugin.Has(body, ParryPlugin.InvulnBuff); } private void OnGUI() { //IL_0060: 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_0045: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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) if ((wasWindow || wasParried) && ParryPlugin.ScreenTint.Value && IsLocal()) { if (!Object.op_Implicit((Object)(object)tex)) { tex = new Texture2D(1, 1); tex.SetPixel(0, 0, Color.white); tex.Apply(); } Color color = GUI.color; float num = Mathf.Clamp01(invuln ? ParryPlugin.InvulnTint.Value : ((!wasParried) ? ParryPlugin.WindowTint.Value : ParryPlugin.BoostTint.Value)); GUI.color = new Color(0.25f, 1f, 0.3f, num); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)tex); GUI.color = color; } } } internal static class RiskOfOptionsCompat { [MethodImpl(MethodImplOptions.NoInlining)] internal static void Init() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown ModSettingsManager.SetModDescription("Press a key to open a short parry window; parrying an enemy hit grants brief invincibility and a damage boost."); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(ParryPlugin.Key)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ParryPlugin.ScreenTint)); } } }
SaveSlots.dll
Decompiled 2 hours 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.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.Missions.AccessCodes.Node; using EntityStates.Missions.BrotherEncounter; using EntityStates.ShrineHalcyonite; using EntityStates.VoidCamp; using HG.Reflection; using HarmonyLib; using ProperSave; using ProperSave.Data; using ProperSave.SaveData; using ProperSave.Utils; using RoR2; using RoR2.CharacterAI; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("ProperSave")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: OptIn] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace SaveSlots { [BepInPlugin("custom.SaveSlots", "SaveSlots", "1.4.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SaveSlotsPlugin : BaseUnityPlugin { public const string GUID = "custom.SaveSlots"; public const string Version = "1.4.1"; public const int SlotCount = 6; internal static SaveSlotsPlugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<string> FolderConfig; internal static ConfigEntry<bool> SaveStageStart; internal static ConfigEntry<bool> CpShrine; internal static ConfigEntry<bool> CpTeleporter; internal static ConfigEntry<bool> CpMithrix; internal static ConfigEntry<bool> CpFalseSon; internal static ConfigEntry<bool> CpVoidling; internal static ConfigEntry<bool> RemoveUsed; internal static ConfigEntry<bool> DeathButton; internal static ConfigEntry<bool> ImportProperSave; internal static ConfigEntry<bool> ChatMessages; internal static int activeSlot = -1; internal static int nextNewRunSlot = -1; internal static Checkpoint pendingCheckpoint; internal static List<PlayerBackup> pendingBackups; internal static bool justLoaded; internal static bool newRunFirstStage; internal static RunRngData firstStageRng; internal static Restore restore; internal static bool overridePostRunToLobby; private static string announcement; private static float nextScan; internal static string Folder { get { string text = ((FolderConfig == null) ? string.Empty : FolderConfig.Value); if (string.IsNullOrWhiteSpace(text)) { text = Path.Combine(Paths.BepInExRootPath, "SaveSlots"); } return text; } } private static string ImportedListPath => Path.Combine(Folder, "propersave_imported.txt"); private void Awake() { //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; FolderConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Slots", "Folder", string.Empty, "Folder for the save slot files. Empty = BepInEx/SaveSlots in this mod profile."); SaveStageStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "SaveAtStageStart", true, "Save into the run's slot at the start of every stage (like ProperSave)."); ChatMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "ChatMessages", true, "Say in chat when the run is saved and which slot it uses."); CpShrine = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "HalcyonShrine", true, "Save when a Halcyon Shrine is activated. Loading it puts you beside the shrine and activates it again."); CpTeleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Teleporter", true, "Save when the teleporter is activated. Loading it puts you beside the teleporter and activates it again (Mountain Shrine stacks and portal orbs are kept)."); CpMithrix = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Mithrix", true, "Save when the Mithrix fight starts. Loading it puts you in the arena and starts the fight (no pillars or climb)."); CpFalseSon = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "FalseSon", true, "Save when the False Son fight starts. Loading it starts the fight (no climb)."); CpVoidling = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Voidling", true, "Save at the end of VoidlingRework's phases 1, 5, 8 and 11. Loading one starts the next phase (2, 6, 9 or 12)."); RemoveUsed = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "KeepUsedInteractablesUsed", true, "Things used before a checkpoint stay used when it's loaded: chests, barrels, terminals, drones and cleared void seeds are gone, and shrines (Mountain, Halcyon, Descent and the rest) stay where they were but can't be used again. Their effects carry over: Mountain Shrine bosses, Access Nodes, portal orbs and extra portals."); ImportProperSave = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "ImportProperSaveSave", true, "When the host opens the Save Slots window, the save ProperSave itself would continue for this lobby (one made without SaveSlots, e.g. before switching to it) is copied into the first empty slot, once per save. The ProperSave file is left as it is."); DeathButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Death screen", "LoadButton", true, "Add a button to the game over screen that loads the run's slot again (not added when RespawnButton is installed; its button loads the slot instead)."); InstallHooks(new Harmony("custom.SaveSlots")); Stage.onServerStageBegin += OnServerStageBegin; SceneDirector.onPostPopulateSceneServer += delegate { if (Object.op_Implicit((Object)(object)Instance)) { ((MonoBehaviour)Instance).StartCoroutine(ScanSoon()); } }; Run.onRunDestroyGlobal += delegate { restore = null; Interactables.Reset(); }; SceneManager.activeSceneChanged += delegate { SlotMenu.Close(); }; Log.LogInfo((object)("SaveSlots ready: " + 6 + " slots in " + Folder)); } private void Update() { if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance) && Time.unscaledTime >= nextScan) { nextScan = Time.unscaledTime + 8f; try { Interactables.Scan(); } catch (Exception ex) { Log.LogDebug((object)("Scan: " + ex.Message)); } } } private static IEnumerator ScanSoon() { yield return (object)new WaitForSeconds(1f); try { Interactables.Scan(); } catch (Exception ex) { Log.LogDebug((object)("Scan: " + ex.Message)); } } private static void InstallHooks(Harmony h) { Type type = typeof(SaveFile).Assembly.GetType("ProperSave.Saving"); Type type2 = typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI"); Patch(h, AccessTools.Method(type, "SaveGame", (Type[])null, (Type[])null), "SkipPrefix", null); Patch(h, AccessTools.Method(type, "RunOnServerGameOver", (Type[])null, (Type[])null), "SkipPrefix", null); Patch(h, AccessTools.Method(typeof(Loading), "LoadLobby", (Type[])null, (Type[])null), "LoadLobbyPrefix", null); Patch(h, AccessTools.Method(type2, "LoadOnInputEvent", (Type[])null, (Type[])null), "LobbyButtonPrefix", null); Patch(h, AccessTools.Method(type2, "UpdateLobbyControls", (Type[])null, (Type[])null), null, "LobbyControlsPostfix"); Patch(h, AccessTools.Method(typeof(Run), "Start", (Type[])null, (Type[])null), "RunStartPrefix", null); Patch(h, AccessTools.Method(typeof(Run), "GenerateStageRNG", (Type[])null, (Type[])null), "GenerateStageRngPrefix", null); Patch(h, AccessTools.Method(typeof(Run), "AdvanceStage", (Type[])null, (Type[])null), "AdvanceStagePrefix", null); Patch(h, AccessTools.Method(typeof(Stage), "RespawnCharacter", (Type[])null, (Type[])null), "RespawnCharacterPrefix", null); Patch(h, AccessTools.Method(typeof(HalcyoniteShrineInteractable), "TrackInteractions", (Type[])null, (Type[])null), "ShrinePrefix", null); Patch(h, AccessTools.Method(typeof(IdleState), "OnInteractionBegin", (Type[])null, (Type[])null), "TeleporterPrefix", null); Patch(h, AccessTools.Method(typeof(PreEncounter), "OnEnter", (Type[])null, (Type[])null), null, "MithrixPostfix"); Patch(h, AccessTools.Method(typeof(MeridianEventTriggerInteraction), "HandleInitializeMeridianEvent", (Type[])null, (Type[])null), "FalseSonPrefix", null); Patch(h, AccessTools.Method(typeof(VoidRaidGauntletController), "TryOpenGauntlet", (Type[])null, (Type[])null), null, "GauntletPostfix"); Patch(h, AccessTools.Method(typeof(ScriptedCombatEncounter), "BeginEncounter", (Type[])null, (Type[])null), "BeginEncounterPrefix", null, 800); Patch(h, AccessTools.Method(typeof(GameEndReportPanelController), "SetDisplayData", (Type[])null, (Type[])null), null, "GameEndPostfix"); Patch(h, AccessTools.Method(typeof(MinionData), "LoadMinion", (Type[])null, (Type[])null), "LoadMinionPrefix", null); PatchFinalizer(h, AccessTools.Method(typeof(PlayerData), "LoadPlayer", (Type[])null, (Type[])null), "LoadPlayerFinalizer"); PatchFinalizer(h, AccessTools.Method(typeof(SaveFile), "LoadPlayers", (Type[])null, (Type[])null), "LoadPlayersFinalizer"); Patch(h, AccessTools.Method(typeof(EntityStateMachine), "SetState", new Type[1] { typeof(EntityState) }, (Type[])null), null, "SetStatePostfix"); Type type3 = AccessTools.TypeByName("VoidlingRework.VLController"); if (type3 != null) { Patch(h, AccessTools.Method(type3, "EnterP4", (Type[])null, (Type[])null), null, "VoidlingP4Postfix"); MethodInfo methodInfo = AccessTools.Method(type3, "EndP11", (Type[])null, (Type[])null); if (methodInfo != null) { Patch(h, methodInfo, null, "VoidlingP12Postfix"); } } foreach (MethodInfo item in PostRunMethods()) { Patch(h, item, "PostRunPrefix", null); } } private static void PatchFinalizer(Harmony h, MethodBase target, string finalizer) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (target == null) { Log.LogWarning((object)("Hook target missing for " + finalizer)); return; } try { h.Patch(target, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(SaveSlotsPlugin), finalizer, (Type[])null), (HarmonyMethod)null); } catch (Exception ex) { Log.LogError((object)("Hooking " + finalizer + ": " + ex)); } } private static void Patch(Harmony h, MethodBase target, string prefix, string postfix, int prefixPriority = -1) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (target == null) { Log.LogWarning((object)("Hook target missing for " + (prefix ?? postfix))); return; } try { HarmonyMethod val = null; if (prefix != null) { val = new HarmonyMethod(typeof(SaveSlotsPlugin), prefix, (Type[])null); if (prefixPriority >= 0) { val.priority = prefixPriority; } } h.Patch(target, val, (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SaveSlotsPlugin), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Log.LogError((object)("Could not hook " + target.DeclaringType?.Name + "." + target.Name + ": " + ex)); } } private static IEnumerable<MethodInfo> PostRunMethods() { List<MethodInfo> list = new List<MethodInfo>(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } catch { continue; } if (types == null) { continue; } Type[] array = types; foreach (Type type in array) { if (!(type == null) && (!(type != typeof(Run)) || type.IsSubclassOf(typeof(Run)))) { MethodInfo method = type.GetMethod("HandlePostRunDestination", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && !method.IsAbstract) { list.Add(method); } } } } return list; } private static bool SkipPrefix() { return false; } private static bool LoadLobbyPrefix(ref IEnumerator __result) { __result = LoadSlotRoutine((activeSlot >= 0) ? activeSlot : SlotStore.MostRecent()); return false; } private static bool LobbyButtonPrefix() { SlotMenu.Open(); return false; } private static void LobbyControlsPostfix() { try { object? obj = AccessTools.Field(typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI"), "lobbyButton")?.GetValue(null); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { bool flag = IsLobbyHost(); HGButton component = val.GetComponent<HGButton>(); if (Object.op_Implicit((Object)(object)component)) { ((Selectable)component).interactable = flag; component.hoverToken = "Load a save slot, or pick the slot the next new run saves into."; } LanguageTextMeshController component2 = val.GetComponent<LanguageTextMeshController>(); if (Object.op_Implicit((Object)(object)component2) && component2.token != "Save Slots") { component2.token = "Save Slots"; } SetLobbyTooltip(val, flag); } } catch (Exception ex) { Log.LogDebug((object)("Lobby button: " + ex.Message)); } } internal static void RefreshLobbyTooltip() { try { object? obj = AccessTools.Field(typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI"), "lobbyButton")?.GetValue(null); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { SetLobbyTooltip(val, IsLobbyHost()); } } catch (Exception ex) { Log.LogDebug((object)("Lobby tooltip: " + ex.Message)); } } private static void SetLobbyTooltip(GameObject button, bool host) { //IL_0012: 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: Unknown result type (might be due to invalid IL or missing references) TooltipProvider component = button.GetComponent<TooltipProvider>(); if (Object.op_Implicit((Object)(object)component)) { component.SetContent(new TooltipContent { titleToken = "Save Slots", overrideBodyText = (host ? ("Next new run saves into: " + NewRunSlotText() + ".") : "Only the host can load or choose save slots."), titleColor = Color.black, disableBodyRichText = false }); } } internal static bool IsLobbyHost() { try { if (!NetworkServer.active && NetworkClient.active) { return false; } return PlatformSystems.lobbyManager == null || PlatformSystems.lobbyManager.isInLobby == PlatformSystems.lobbyManager.ownsLobby; } catch { return NetworkServer.active; } } private static void RunStartPrefix() { if (NetworkServer.active) { restore = null; Interactables.Reset(); firstStageRng = null; if (Loading.IsLoading) { newRunFirstStage = false; return; } newRunFirstStage = true; justLoaded = false; pendingCheckpoint = null; activeSlot = ((nextNewRunSlot >= 0) ? nextNewRunSlot : SlotStore.FirstEmpty()); nextNewRunSlot = -1; announcement = ((activeSlot >= 0) ? ("This run saves into slot " + (activeSlot + 1) + ".") : "All save slots are full, so this run isn't being saved. Delete a slot or choose one in the Save Slots menu."); } } private static void GenerateStageRngPrefix(Run __instance) { if (NetworkServer.active && newRunFirstStage && firstStageRng == null) { firstStageRng = MakeRng(__instance); } } private static void AdvanceStagePrefix() { newRunFirstStage = false; } internal static RunRngData MakeRng(Run run) { //IL_000c: 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_0022: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown RngData val = RngData.Create(run.runRNG); return new RunRngData { runRng = RngData.Create(run.runRNG), nextStageRng = ((run.nextStageRng != null) ? RngData.Create(run.nextStageRng) : val), stageRngGenerator = ((run.stageRngGenerator != null) ? RngData.Create(run.stageRngGenerator) : val), loopRngGenerator = ((run.loopRngGenerator != null) ? RngData.Create(run.loopRngGenerator) : val), rerollStageRng = ((run.rerollStageRng != null) ? RngData.Create(run.rerollStageRng) : val) }; } internal static string NewRunSlotText() { if (nextNewRunSlot >= 0) { return "slot " + (nextNewRunSlot + 1) + (SlotStore.Exists(nextNewRunSlot) ? " (replacing the run saved there)" : " (chosen)"); } int num = SlotStore.FirstEmpty(); if (num < 0) { return "nothing, all slots are full"; } return "slot " + (num + 1) + " (first empty)"; } private static void OnServerStageBegin(Stage stage) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Invalid comparison between Unknown and I4 if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance)) { return; } try { restore = null; Interactables.Reset(); SceneDef val = ((!Object.op_Implicit((Object)(object)stage)) ? null : stage.sceneDef); string text; if (Object.op_Implicit((Object)(object)val)) { text = val.cachedName; } else { Scene activeScene = SceneManager.GetActiveScene(); text = ((Scene)(ref activeScene)).name; } string text2 = text; if (announcement != null) { Say(announcement); announcement = null; } if (justLoaded) { justLoaded = false; try { PlayerBackup.Verify(pendingBackups, "stage start"); } catch (Exception ex) { Log.LogWarning((object)("Inventory check: " + ex.Message)); } pendingBackups = null; Checkpoint checkpoint = pendingCheckpoint; pendingCheckpoint = null; if (checkpoint != null && checkpoint.kind != CpKind.None) { if (checkpoint.scene == text2) { StartRestore(stage, checkpoint); return; } Log.LogWarning((object)("Checkpoint was saved in " + checkpoint.scene + " but the run loaded into " + text2 + "; it starts from the stage start.")); } } else if (Object.op_Implicit((Object)(object)val) && (int)val.sceneType != 0 && (int)val.sceneType != 3 && SaveStageStart.Value) { SaveNow(null); } } catch (Exception ex2) { Log.LogError((object)("Stage start: " + ex2)); } } private static bool LoadMinionPrefix(MinionData __instance, CharacterMaster playerMaster) { //IL_0006: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; try { if (__instance == null || __instance.masterIndex == MasterIndex.none || !Object.op_Implicit((Object)(object)playerMaster)) { return false; } GameObject masterPrefab = MasterCatalog.GetMasterPrefab(__instance.masterIndex); if (!Object.op_Implicit((Object)(object)masterPrefab)) { Log.LogWarning((object)("An ally of " + ((Object)playerMaster).name + " couldn't be restored (its master no longer exists).")); return false; } val = Object.Instantiate<GameObject>(masterPrefab); CharacterMaster component = val.GetComponent<CharacterMaster>(); if (!Object.op_Implicit((Object)(object)component)) { throw new Exception(((Object)masterPrefab).name + " has no CharacterMaster"); } component.teamIndex = (TeamIndex)1; if (__instance.master != null) { __instance.master.LoadMaster(component, true); } CharacterMaster val2 = playerMaster; if (Object.op_Implicit((Object)(object)val2.minionOwnership) && Object.op_Implicit((Object)(object)val2.minionOwnership.ownerMaster)) { val2 = val2.minionOwnership.ownerMaster; } if (Object.op_Implicit((Object)(object)component.minionOwnership)) { component.minionOwnership.SetOwner(val2); } AIOwnership component2 = val.GetComponent<AIOwnership>(); if (Object.op_Implicit((Object)(object)component2)) { component2.ownerMaster = playerMaster; } BaseAI component3 = val.GetComponent<BaseAI>(); if (Object.op_Implicit((Object)(object)component3) && component3.leader != null) { component3.leader.gameObject = ((Component)playerMaster).gameObject; } if (__instance.devotedLemurianData != null) { try { DevotedLemurianController component4 = ((Component)component).GetComponent<DevotedLemurianController>(); if (Object.op_Implicit((Object)(object)component4)) { __instance.devotedLemurianData.LoadData(component4); component4._lemurianMaster = component; component4._devotionInventoryController = CharacterMasterData.GetDevotionInventoryController(playerMaster); } } catch (Exception ex) { Log.LogWarning((object)("Devoted lemurian: " + ex.Message)); } } if (__instance.droneRepairData != null) { try { DroneRepairMaster component5 = ((Component)component).GetComponent<DroneRepairMaster>(); if (Object.op_Implicit((Object)(object)component5)) { __instance.droneRepairData.LoadData(component5); } } catch (Exception ex2) { Log.LogWarning((object)("Drone repair data: " + ex2.Message)); } } NetworkServer.Spawn(val); } catch (Exception ex3) { Log.LogWarning((object)("An ally of " + (Object.op_Implicit((Object)(object)playerMaster) ? ((Object)playerMaster).name : "a player") + " couldn't be restored and was skipped: " + ex3.Message)); if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } return false; } private static Exception LoadPlayerFinalizer(Exception __exception, NetworkUser player) { if (__exception != null) { Log.LogError((object)("ProperSave couldn't fully load " + (Object.op_Implicit((Object)(object)player) ? player.userName : "a player") + " (SaveSlots will restore their items from its own copy): " + __exception)); } return null; } private static Exception LoadPlayersFinalizer(Exception __exception) { if (__exception != null) { Log.LogError((object)("Loading the players: " + __exception)); } try { PlayerBackup.Verify(pendingBackups, "run start"); } catch (Exception ex) { Log.LogWarning((object)("Inventory check: " + ex)); } return null; } private static void SetStatePostfix(EntityStateMachine __instance, EntityState newState) { if (NetworkServer.active && newState is Deactivate && Object.op_Implicit((Object)(object)__instance)) { Interactables.MarkVoidSeedCleared(((Component)__instance).gameObject); } } internal static void SaveCheckpoint(Checkpoint cp) { //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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || activeSlot < 0 || (restore != null && !restore.done) || Loading.IsLoading) { return; } try { Scene activeScene = SceneManager.GetActiveScene(); cp.scene = ((Scene)(ref activeScene)).name; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody()); string text = UserKey(instance); if (Object.op_Implicit((Object)(object)val) && text != null && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { cp.players.Add(new KeyValuePair<string, Vector3>(text, val.footPosition)); } } if (cp.spot == Vector3.zero) { cp.spot = (Vector3)(((??)NearestPlayer(cp.anchor)) ?? cp.anchor); } CaptureStageEffects(cp); if (RemoveUsed.Value) { cp.used = Interactables.Used(cp.exclude); } } catch (Exception ex) { Log.LogWarning((object)("Checkpoint data: " + ex.Message)); } SaveNow(cp); } internal static void SaveNow(Checkpoint cp) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || activeSlot < 0 || Loading.IsLoading) { return; } int num = activeSlot; try { PrepareStageRng(); SaveFileHeader val = new SaveFileHeader(); val.FillFromCurrentRun(); SaveFile val2 = new SaveFile(); val2.FillFromCurrentRun(); bool flag = ProperSavePlugin.Resilient == null || ProperSavePlugin.Resilient.Value; byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { using BinaryWriter binaryWriter = new BinaryWriter(memoryStream); val.Write(binaryWriter, flag); val2.Write(binaryWriter, flag); binaryWriter.Flush(); array = memoryStream.ToArray(); } SlotInfo slotInfo = SlotInfo.FromCurrentRun(num, val, cp); List<PlayerBackup> backups = null; try { backups = PlayerBackup.CaptureAll(); } catch (Exception ex) { Log.LogWarning((object)("Inventory backup: " + ex.Message)); } SlotStore.Write(num, slotInfo, cp, array, backups); ProperSavePlugin.CurrentSave = new SaveFileMetadata { Header = val, Body = val2, ForceLoad = false }; Say("Saved to slot " + (num + 1) + ": " + slotInfo.kindLabel + "."); Log.LogInfo((object)("Saved slot " + (num + 1) + " (" + slotInfo.kindLabel + ", " + slotInfo.scene + ", " + array.Length + " bytes).")); } catch (Exception ex2) { Log.LogError((object)("Save failed: " + ex2)); Say("Saving to slot " + (num + 1) + " failed (see the log)."); } finally { try { ObjectBuffer.Clear(); } catch { } } } private static void PrepareStageRng() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Scene activeScene; if (newRunFirstStage) { if (firstStageRng == null) { Log.LogWarning((object)"The first stage's RNG wasn't recorded; this save won't regenerate the stage exactly."); firstStageRng = MakeRng(Run.instance); } Saving.PreStageRng = firstStageRng; activeScene = SceneManager.GetActiveScene(); Saving.PreStageSceneName = ((Scene)(ref activeScene)).name; } else if (Saving.PreStageRng == null) { Log.LogWarning((object)"No stage RNG recorded; this save won't regenerate the stage exactly."); Saving.PreStageRng = MakeRng(Run.instance); activeScene = SceneManager.GetActiveScene(); Saving.PreStageSceneName = ((Scene)(ref activeScene)).name; } if (string.IsNullOrEmpty(Saving.PreStageSceneName)) { activeScene = SceneManager.GetActiveScene(); Saving.PreStageSceneName = ((Scene)(ref activeScene)).name; } } internal static string ImportProperSaveFile() { //IL_011f: 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_0094: Unknown result type (might be due to invalid IL or missing references) if (ImportProperSave == null || !ImportProperSave.Value || !Object.op_Implicit((Object)(object)PreGameController.instance)) { return null; } SaveFileMetadata val = null; try { val = SaveFileMetadata.GetCurrentLobbySaveMetadata((NetworkUser)null) ?? SoloProperSave(); if (val == null || val.Header == null || !val.FilePath.HasValue || ProperSavePlugin.SavesFileSystem == null || !ProperSavePlugin.SavesFileSystem.FileExists(val.FilePath.Value)) { return null; } DateTime dateTime = val.Header.SaveDate; try { DateTime lastWriteTime = ProperSavePlugin.SavesFileSystem.GetLastWriteTime(val.FilePath.Value); if (dateTime.Year < 2000 || lastWriteTime > dateTime) { dateTime = lastWriteTime; } } catch { } string item = val.FileName + "|" + dateTime.Ticks; HashSet<string> hashSet = ReadImported(); if (hashSet.Contains(item)) { return null; } int num = SlotStore.FirstEmpty(); if (num < 0) { return "Your ProperSave save can't be imported: every slot is full. Delete one and open this window again."; } byte[] array; using (Stream stream = ProperSavePlugin.SavesFileSystem.OpenFile(val.FilePath.Value, FileMode.Open, FileAccess.Read, FileShare.None)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } using (MemoryStream input = new MemoryStream(array)) { using BinaryReader binaryReader = new BinaryReader(input); SaveFileHeader.Read(binaryReader); } SlotInfo slotInfo = SlotInfo.FromHeader(num, val.Header, (dateTime.Kind == DateTimeKind.Utc) ? dateTime : dateTime.ToUniversalTime()); SlotStore.Write(num, slotInfo, null, array); hashSet.Add(item); Directory.CreateDirectory(Folder); File.WriteAllLines(ImportedListPath, hashSet.ToArray()); Log.LogInfo((object)("Imported ProperSave's save \"" + val.FileName + "\" into slot " + (num + 1) + " (" + slotInfo.OneLine() + ").")); return "Imported your ProperSave save into slot " + (num + 1) + "."; } catch (Exception ex) { Log.LogError((object)("ProperSave import" + ((val == null) ? "" : (" (\"" + val.FileName + "\")")) + ": " + ex)); return "Your ProperSave save couldn't be imported (see the log)."; } finally { try { ObjectBuffer.Clear(); } catch { } } } private static SaveFileMetadata SoloProperSave() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkUser.readOnlyInstancesList.Count != 1 || LocalUserManager.readOnlyLocalUsersList.Count == 0 || !Object.op_Implicit((Object)(object)PreGameController.instance)) { return null; } string profile = Path.GetFileNameWithoutExtension(LocalUserManager.readOnlyLocalUsersList[0].userProfile.fileName ?? string.Empty); GameModeIndex mode = PreGameController.instance.gameModeIndex; return ((IEnumerable<SaveFileMetadata>)SaveFileMetadata.SavesMetadata).FirstOrDefault((Func<SaveFileMetadata, bool>)((SaveFileMetadata m) => m != null && m.Header != null && m.Header.Users != null && m.Header.Users.Length == 1 && m.Header.GameMode == mode && Path.GetFileNameWithoutExtension(m.Header.UserProfileId ?? string.Empty) == profile)); } catch { return null; } } private static HashSet<string> ReadImported() { HashSet<string> hashSet = new HashSet<string>(); try { if (File.Exists(ImportedListPath)) { string[] array = File.ReadAllLines(ImportedListPath); foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text)) { hashSet.Add(text.Trim()); } } } } catch (Exception ex) { Log.LogWarning((object)("Imported list: " + ex.Message)); } return hashSet; } internal static IEnumerator LoadSlotRoutine(int slot) { yield return null; LoadSlot(slot); } internal static bool LoadSlot(int slot) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown string text = CanLoad(slot); if (text != null) { SlotMenu.ShowStatus(text); Log.LogInfo((object)("Can't load slot " + (slot + 1) + ": " + text)); return false; } SlotInfo slotInfo = SlotStore.Read(slot, withBlob: true); if (slotInfo == null || !slotInfo.exists || slotInfo.blob == null) { SlotMenu.ShowStatus("Slot " + (slot + 1) + " couldn't be read" + ((slotInfo == null || slotInfo.error == null) ? "." : (": " + slotInfo.error))); return false; } SaveFileHeader val; SaveFile val2; try { using MemoryStream input = new MemoryStream(slotInfo.blob); using BinaryReader binaryReader = new BinaryReader(input); val = SaveFileHeader.Read(binaryReader); val2 = SaveFile.Read(binaryReader); } catch (Exception ex) { Log.LogError((object)("Reading slot " + (slot + 1) + ": " + ex)); SlotMenu.ShowStatus("Slot " + (slot + 1) + " couldn't be read (see the log)."); return false; } finally { try { ObjectBuffer.Clear(); } catch { } } if (PreGameController.instance.gameModeIndex != val.GameMode) { SlotMenu.ShowStatus("Slot " + (slot + 1) + " is a " + ModeName(val.GameMode) + " run; switch the lobby to that mode first."); return false; } if (val.ContentHash != ProperSavePlugin.ContentHash) { Log.LogWarning((object)("Slot " + (slot + 1) + " was saved with a different mod list; loading anyway.")); } activeSlot = slot; nextNewRunSlot = -1; pendingCheckpoint = slotInfo.checkpoint; pendingBackups = slotInfo.backups; justLoaded = true; newRunFirstStage = false; firstStageRng = null; Saving.PreStageRng = val2.RunData.runRng; Saving.PreStageSceneName = val2.RunData.previousSceneName; ProperSavePlugin.CurrentSave = new SaveFileMetadata { Header = val, Body = val2, ForceLoad = false }; announcement = "Loaded slot " + (slot + 1) + ": " + slotInfo.kindLabel + "."; Log.LogInfo((object)("Loading slot " + (slot + 1) + " (" + slotInfo.kindLabel + ", " + slotInfo.scene + ").")); SlotMenu.Close(); Loading.IsLoading = true; PreGameController.instance.StartRun(); return true; } internal static string CanLoad(int slot) { if (slot < 0 || slot >= 6) { return "There's no save to load."; } if (Object.op_Implicit((Object)(object)Run.instance)) { return "A run is already in progress."; } if (Loading.IsLoading) { return "Already loading."; } if (!Object.op_Implicit((Object)(object)PreGameController.instance)) { return "Load from the character select screen."; } if (!IsLobbyHost()) { return "Only the host can load."; } if (!SlotStore.Exists(slot)) { return "Slot " + (slot + 1) + " is empty."; } return null; } internal static string ModeName(GameModeIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { string gameModeName = GameModeCatalog.GetGameModeName(index); return string.IsNullOrEmpty(gameModeName) ? "different" : gameModeName.Replace("Run", string.Empty); } catch { return "different"; } } private static void StartRestore(Stage stage, Checkpoint cp) { restore = new Restore { cp = cp, stage = stage }; Log.LogInfo((object)("Restoring checkpoint: " + cp.Label())); if (cp.kind == CpKind.Voidling) { TryOpenVoidGauntlets(); } ((MonoBehaviour)Instance).StartCoroutine(RestoreRoutine(restore)); } private static IEnumerator RestoreRoutine(Restore r) { Checkpoint cp = r.cp; float t0 = Time.time; if (cp.kind == CpKind.Voidling) { while (!r.voidOpened && Time.time - t0 < 20f) { if (restore != r) { yield break; } TryOpenVoidGauntlets(); yield return (object)new WaitForSeconds(0.25f); } } t0 = Time.time; while (Time.time - t0 < 20f && !AllPlayersSpawned()) { if (restore != r) { yield break; } yield return (object)new WaitForSeconds(0.25f); } yield return (object)new WaitForSeconds(1f); if (restore != r) { yield break; } try { if (RemoveUsed.Value && cp.used.Count > 0) { Interactables.Apply(cp.used); } } catch (Exception ex) { Log.LogWarning((object)("Used interactables: " + ex.Message)); } try { RestoreStageEffects(cp); } catch (Exception ex2) { Log.LogWarning((object)("Stage effects: " + ex2.Message)); } IEnumerator routine = null; switch (cp.kind) { case CpKind.Teleporter: routine = RestoreTeleporter(r); break; case CpKind.Shrine: routine = RestoreShrine(r); break; case CpKind.Mithrix: routine = RestoreMithrix(r); break; case CpKind.FalseSon: routine = RestoreFalseSon(r); break; case CpKind.Voidling: routine = RestoreVoidling(r); break; } if (routine != null) { while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex3) { Log.LogError((object)("Restoring " + cp.Label() + ": " + ex3)); break; } if (!flag) { break; } yield return routine.Current; if (restore != r) { yield break; } } } if (restore == r) { r.done = true; Log.LogInfo((object)("Checkpoint restored: " + cp.Label())); } } private static bool AllPlayersSpawned() { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.networkUser) && Object.op_Implicit((Object)(object)instance.master) && !Object.op_Implicit((Object)(object)instance.master.GetBody())) { return false; } } return true; } private static Interactor FirstInteractor() { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody()); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { Interactor component = ((Component)val).GetComponent<Interactor>(); if (Object.op_Implicit((Object)(object)component)) { return component; } } } return null; } private static IEnumerator RestoreTeleporter(Restore r) { float t0 = Time.time; while (!Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && Time.time - t0 < 10f) { yield return (object)new WaitForSeconds(0.25f); } TeleporterInteraction instance = TeleporterInteraction.instance; if (!Object.op_Implicit((Object)(object)instance)) { Log.LogWarning((object)"No teleporter found to activate."); yield break; } try { Type type = AccessTools.TypeByName("GuaranteedHalcyonShrine.GuaranteedHalcyonShrinePlugin"); ((type == null) ? null : AccessTools.Field(type, "shrineDefeated"))?.SetValue(null, true); } catch (Exception ex) { Log.LogDebug((object)("Halcyon lock: " + ex.Message)); } Interactor val = FirstInteractor(); if (!Object.op_Implicit((Object)(object)val)) { Log.LogWarning((object)"No player to activate the teleporter."); } else if (instance.isIdle) { instance.OnInteractionBegin(val); } } private static IEnumerator RestoreShrine(Restore r) { Checkpoint cp = r.cp; HalcyoniteShrineInteractable shrine = null; float t0 = Time.time; while (Time.time - t0 < 10f) { shrine = NearestShrine(cp.anchor); if (Object.op_Implicit((Object)(object)shrine)) { break; } yield return (object)new WaitForSeconds(0.25f); } if (!Object.op_Implicit((Object)(object)shrine)) { Log.LogWarning((object)"No Halcyon Shrine found to activate."); } else if (shrine.interactions <= 0) { Interactor val = FirstInteractor(); PurchaseInteraction component = ((Component)shrine).GetComponent<PurchaseInteraction>(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)component) && component.available) { component.OnInteractionBegin(val); } yield return (object)new WaitForSeconds(0.5f); if (Object.op_Implicit((Object)(object)shrine) && shrine.interactions == 0) { shrine.TrackInteractions(); } } } private static HalcyoniteShrineInteractable NearestShrine(Vector3 pos) { //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_0029: Unknown result type (might be due to invalid IL or missing references) HalcyoniteShrineInteractable result = null; float num = float.MaxValue; HalcyoniteShrineInteractable[] array = Object.FindObjectsOfType<HalcyoniteShrineInteractable>(); foreach (HalcyoniteShrineInteractable val in array) { Vector3 val2 = ((Component)val).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } return result; } private static IEnumerator RestoreMithrix(Restore r) { Checkpoint cp = r.cp; EntityStateMachine esm = null; float t0 = Time.time; while (Time.time - t0 < 10f) { esm = FindBrotherEncounter(cp.objectPath); if (Object.op_Implicit((Object)(object)esm)) { break; } yield return (object)new WaitForSeconds(0.25f); } if (!Object.op_Implicit((Object)(object)esm)) { Log.LogWarning((object)"Mithrix's arena wasn't found."); yield break; } if (!((Component)esm).gameObject.activeInHierarchy) { Transform val = ((Component)esm).transform; while (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(true); val = val.parent; } } yield return (object)new WaitForSeconds(0.5f); if (Object.op_Implicit((Object)(object)esm) && !(esm.state is PreEncounter) && !(esm.state is BrotherEncounterBaseState)) { esm.SetNextState((EntityState)new PreEncounter()); } } private static EntityStateMachine FindBrotherEncounter(string path) { //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_002a: 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) Scene activeScene = SceneManager.GetActiveScene(); EntityStateMachine val = null; EntityStateMachine[] array = Resources.FindObjectsOfTypeAll<EntityStateMachine>(); foreach (EntityStateMachine val2 in array) { if (!Object.op_Implicit((Object)(object)val2) || ((Component)val2).gameObject.scene != activeScene) { continue; } ChildLocator component = ((Component)val2).GetComponent<ChildLocator>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.FindChild("PreEncounter")) && Object.op_Implicit((Object)(object)component.FindChild("ArenaWalls"))) { if (!string.IsNullOrEmpty(path) && PathOf(((Component)val2).transform) == path) { return val2; } if (!Object.op_Implicit((Object)(object)val)) { val = val2; } } } return val; } internal static string PathOf(Transform t) { StringBuilder stringBuilder = new StringBuilder(); while (Object.op_Implicit((Object)(object)t)) { stringBuilder.Insert(0, "/" + ((Object)t).name); t = t.parent; } return stringBuilder.ToString(); } private static IEnumerator RestoreFalseSon(Restore r) { MeridianEventTriggerInteraction trigger = null; float t0 = Time.time; while (Time.time - t0 < 10f) { trigger = MeridianEventTriggerInteraction.instance; if (!Object.op_Implicit((Object)(object)trigger)) { trigger = ((IEnumerable<MeridianEventTriggerInteraction>)Resources.FindObjectsOfTypeAll<MeridianEventTriggerInteraction>()).FirstOrDefault((Func<MeridianEventTriggerInteraction, bool>)((MeridianEventTriggerInteraction m) => Object.op_Implicit((Object)(object)m) && ((Component)m).gameObject.scene == SceneManager.GetActiveScene())); } if (Object.op_Implicit((Object)(object)trigger)) { break; } yield return (object)new WaitForSeconds(0.25f); } if (!Object.op_Implicit((Object)(object)trigger)) { Log.LogWarning((object)"False Son's event trigger wasn't found."); yield break; } if (!((Component)trigger).gameObject.activeInHierarchy) { ((Component)trigger).gameObject.SetActive(true); yield return null; } if (!trigger.isTriggered) { trigger.HandleInitializeMeridianEvent(); BoxCollider component = ((Component)trigger).GetComponent<BoxCollider>(); if (Object.op_Implicit((Object)(object)component)) { ((Collider)component).enabled = false; } } } internal static void TryOpenVoidGauntlets() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Restore restore = SaveSlotsPlugin.restore; if (restore == null || restore.cp.kind != CpKind.Voidling || restore.voidOpened) { return; } VoidRaidGauntletController instance = VoidRaidGauntletController.instance; if (!Object.op_Implicit((Object)(object)instance) || !instance.hasShuffled || instance.followingDonuts == null || instance.followingDonuts.Length == 0) { return; } int num = Mathf.Clamp(restore.cp.phase, 2, 5); int num2 = (restore.voidEncounterIndex = (restore.voidGauntletTarget = Mathf.Min(num - 1, 2))); int num3 = 0; while (instance.gauntletIndex < num2 && num3++ < 4) { DonutInfo val = instance.currentDonut ?? instance.initialDonut; Vector3 val2 = ((val == null || !Object.op_Implicit((Object)(object)val.crabPosition)) ? Vector3.zero : val.crabPosition.position); if (!instance.TryOpenGauntlet(val2, NetworkInstanceId.Invalid)) { break; } } DonutInfo val3 = instance.followingDonuts[Mathf.Clamp(num2 - 1, 0, instance.followingDonuts.Length - 1)]; if (val3 != null) { if (Object.op_Implicit((Object)(object)val3.root) && !val3.root.activeSelf) { val3.root.SetActive(true); } restore.voidSpawn = (Object.op_Implicit((Object)(object)val3.returnPoint) ? val3.returnPoint.position : ((!Object.op_Implicit((Object)(object)val3.crabPosition)) ? Vector3.zero : val3.crabPosition.position)); restore.voidFace = ((!Object.op_Implicit((Object)(object)val3.crabPosition)) ? restore.voidSpawn : val3.crabPosition.position); restore.voidOpened = true; Log.LogInfo((object)("Voidling checkpoint: opened the way to phase " + Checkpoint.VoidlingPhaseNumber(num) + "'s arena.")); } } private static IEnumerator RestoreVoidling(Restore r) { VoidRaidGauntletController g = VoidRaidGauntletController.instance; if (!Object.op_Implicit((Object)(object)g) || !r.voidOpened) { Log.LogWarning((object)"Voidling's arenas weren't found."); yield break; } int num = 0; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster val = ((!Object.op_Implicit((Object)(object)instance)) ? null : instance.master); CharacterBody val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetBody()); if (Object.op_Implicit((Object)(object)val2) && Flat(val2.footPosition - r.voidSpawn) > 60f) { Vector3 val3 = Ring(r.voidSpawn, num++); RespawnArgs val4 = new RespawnArgs { spawnBodyArgs = new SpawnBodyArgs { spawnPointPosition = val3, spawnPointRotation = Face(val3, r.voidFace), spawnPointIsFootPos = true }, ignoreMetamorphosis = true }; val.Respawn(ref val4); } } yield return (object)new WaitForSeconds(1.5f); ScriptedCombatEncounter[] phaseEncounters = g.phaseEncounters; if (phaseEncounters == null || r.voidEncounterIndex >= phaseEncounters.Length) { yield break; } ScriptedCombatEncounter val5 = phaseEncounters[r.voidEncounterIndex]; bool flag = false; if (r.cp.phase >= 4) { try { Type type = AccessTools.TypeByName("VoidlingRework.VoidlingReworkPlugin"); PropertyInfo propertyInfo = ((type == null) ? null : AccessTools.Property(type, (r.cp.phase >= 5) ? "CheckpointStartPhase12" : "CheckpointStartPhase9")); if (propertyInfo != null) { propertyInfo.SetValue(null, true, null); flag = true; } else if (r.cp.phase >= 5) { Log.LogWarning((object)"This VoidlingRework can't start at phase 12; the last arena's fight starts from phase 6."); } } catch (Exception ex) { Log.LogWarning((object)("Phase " + ((r.cp.phase >= 5) ? "12" : "9") + " start: " + ex.Message)); } } if (Object.op_Implicit((Object)(object)val5) && !val5.hasSpawnedServer) { val5.BeginEncounter(); } if (r.cp.phase != 4 || flag) { yield break; } Type vl = AccessTools.TypeByName("VoidlingRework.VLController"); if (vl == null) { yield break; } FieldInfo phaseField = AccessTools.Field(vl, "phase"); FieldInfo stageField = AccessTools.Field(vl, "stage"); MethodInfo enterP4 = AccessTools.Method(vl, "EnterP4", (Type[])null, (Type[])null); if (phaseField == null || stageField == null || enterP4 == null) { yield break; } float t0 = Time.time; float seen = -1f; while (Time.time - t0 < 90f) { Object val6 = ((IEnumerable<Object>)Object.FindObjectsOfType(vl)).FirstOrDefault((Func<Object, bool>)((Object o) => Object.op_Implicit(o) && (int)phaseField.GetValue(o) == 3)); if (val6 != (Object)null) { int num2 = (int)stageField.GetValue(val6); if (num2 >= 40) { yield break; } if (num2 >= 30) { if (seen < 0f) { seen = Time.time; } if (Time.time - seen >= 3f) { enterP4.Invoke(val6, null); Log.LogInfo((object)"Voidling checkpoint: phase 9 started."); yield break; } } } yield return (object)new WaitForSeconds(0.25f); } Log.LogWarning((object)"The last arena's voidling never appeared, so phase 9 couldn't start."); } private static bool BeginEncounterPrefix(ScriptedCombatEncounter __instance) { try { Restore restore = SaveSlotsPlugin.restore; if (!NetworkServer.active || restore == null || restore.cp.kind != CpKind.Voidling) { return true; } VoidRaidGauntletController instance = VoidRaidGauntletController.instance; if (!Object.op_Implicit((Object)(object)instance) || instance.phaseEncounters == null) { return true; } int num = Array.IndexOf(instance.phaseEncounters, __instance); int num2 = Mathf.Min(Mathf.Clamp(restore.cp.phase, 2, 5) - 1, 2); if (num >= 0 && num < num2) { Log.LogInfo((object)("Voidling checkpoint: phase " + (num + 1) + " skipped.")); return false; } } catch (Exception ex) { Log.LogWarning((object)("BeginEncounterPrefix: " + ex.Message)); } return true; } private static bool RespawnCharacterPrefix(Stage __instance, CharacterMaster characterMaster) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) try { Restore restore = SaveSlotsPlugin.restore; if (!NetworkServer.active || restore == null || restore.done || !Object.op_Implicit((Object)(object)characterMaster) || !Object.op_Implicit((Object)(object)characterMaster.playerCharacterMasterController) || restore.spawned.Contains(characterMaster)) { return true; } Checkpoint cp = restore.cp; Vector3 val; Vector3 to; switch (cp.kind) { case CpKind.Shrine: case CpKind.Teleporter: case CpKind.Mithrix: { string key = UserKey(characterMaster.playerCharacterMasterController); KeyValuePair<string, Vector3> keyValuePair = cp.players.FirstOrDefault((KeyValuePair<string, Vector3> p) => p.Key == key); val = ((keyValuePair.Key != null && Flat(keyValuePair.Value - cp.spot) <= 60f) ? keyValuePair.Value : Ring(cp.spot, restore.spawnCount)); to = cp.anchor; break; } case CpKind.Voidling: TryOpenVoidGauntlets(); if (!restore.voidOpened) { return true; } val = Ring(restore.voidSpawn, restore.spawnCount); to = restore.voidFace; break; default: return true; } restore.spawned.Add(characterMaster); restore.spawnCount++; RespawnArgs val2 = new RespawnArgs { spawnBodyArgs = new SpawnBodyArgs { spawnPointPosition = val, spawnPointRotation = Face(val, to), spawnPointIsFootPos = true }, ignoreMetamorphosis = true }; characterMaster.Respawn(ref val2); __instance.spawnedAnyPlayer = true; return false; } catch (Exception ex) { Log.LogWarning((object)("Checkpoint spawn: " + ex.Message)); return true; } } internal static float Flat(Vector3 v) { v.y = 0f; return ((Vector3)(ref v)).magnitude; } internal static Vector3 Ring(Vector3 center, int index) { //IL_0028: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (index <= 0) { return center; } float num = (float)index * 72f * ((float)Math.PI / 180f); float num2 = 2.5f + 1.5f * (float)((index - 1) / 5); return center + new Vector3(Mathf.Cos(num) * num2, 0.5f, Mathf.Sin(num) * num2); } internal static Quaternion Face(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0029: 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) Vector3 val = to - from; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { return Quaternion.identity; } return Quaternion.LookRotation(val); } internal static Vector3? NearestPlayer(Vector3 pos) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) Vector3? result = null; float num = float.MaxValue; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody()); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive) { Vector3 val2 = val.footPosition - pos; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val.footPosition; } } } return result; } internal static string UserKey(PlayerCharacterMasterController pc) { //IL_0044: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)pc)) { return null; } NetworkUser networkUser = pc.networkUser; if (!Object.op_Implicit((Object)(object)networkUser)) { return "master:" + (Object.op_Implicit((Object)(object)pc.master) ? ((Object)pc.master).name : "?"); } NetworkUserId id = networkUser.id; return id.value + "|" + id.strValue + "|" + id.subId; } private static void CaptureStageEffects(Checkpoint cp) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) try { TeleporterInteraction instance = TeleporterInteraction.instance; if (Object.op_Implicit((Object)(object)instance)) { cp.shrineStacks = instance.shrineBonusStacks; cp.shopPortal = instance.shouldAttemptToSpawnShopPortal; cp.goldPortal = instance.shouldAttemptToSpawnGoldshoresPortal; cp.msPortal = instance.shouldAttemptToSpawnMSPortal; cp.hiddenPortal = instance.shouldAttemptToSpawnHiddenRealmsPortal; cp.accessDone = instance.showAccessCodesIndicator; } if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Run.instance.nextStageScene)) { cp.nextScene = Run.instance.nextStageScene.cachedName ?? string.Empty; } PortalSpawner[] array = Object.FindObjectsOfType<PortalSpawner>(); foreach (PortalSpawner val in array) { if (Object.op_Implicit((Object)(object)val) && val.hasRegisteredToTeleporter) { cp.portals.Add(new KeyValuePair<string, Vector3>(Interactables.Clean(((Object)((Component)val).gameObject).name), ((Component)val).transform.position)); } } AccessCodesMissionController instance2 = AccessCodesMissionController.instance; if (!Object.op_Implicit((Object)(object)instance2) || instance2.nodes == null) { return; } AccessCodesNodeData[] nodes = instance2.nodes; foreach (AccessCodesNodeData val2 in nodes) { EntityStateMachine val3 = ((!Object.op_Implicit((Object)(object)val2.node)) ? null : val2.node.GetComponent<EntityStateMachine>()); if (Object.op_Implicit((Object)(object)val3) && (val3.state is NodeActive || val3.state is NodeAccessed || val3.state is Complete)) { cp.accessNodes.Add(val2.id); } } if (cp.accessNodes.Count > 0 && cp.accessNodes.Count >= instance2.nodes.Length) { cp.accessDone = true; } } catch (Exception ex) { Log.LogWarning((object)("Stage effects: " + ex.Message)); } } private static void RestoreStageEffects(Checkpoint cp) { //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown TeleporterInteraction instance = TeleporterInteraction.instance; bool flag = Object.op_Implicit((Object)(object)instance) && instance.isIdle; if (flag) { int num = 0; while (instance.shrineBonusStacks < cp.shrineStacks && num++ < 100) { instance.AddShrineStack(); } if (num > 0) { Log.LogInfo((object)("Mountain Shrine stacks restored: " + instance.shrineBonusStacks + ".")); } if (cp.shopPortal) { instance.shouldAttemptToSpawnShopPortal = true; } if (cp.goldPortal) { instance.shouldAttemptToSpawnGoldshoresPortal = true; } if (cp.msPortal) { instance.shouldAttemptToSpawnMSPortal = true; } if (cp.hiddenPortal) { instance.shouldAttemptToSpawnHiddenRealmsPortal = true; } } if (!string.IsNullOrEmpty(cp.nextScene) && Object.op_Implicit((Object)(object)Run.instance)) { SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(cp.nextScene); if (Object.op_Implicit((Object)(object)sceneDefFromSceneName) && (Object)(object)Run.instance.nextStageScene != (Object)(object)sceneDefFromSceneName) { Run.instance.nextStageScene = sceneDefFromSceneName; Log.LogInfo((object)("Next stage restored: " + cp.nextScene + ".")); } } if (cp.portals.Count > 0) { PortalSpawner[] array = Object.FindObjectsOfType<PortalSpawner>(); foreach (KeyValuePair<string, Vector3> portal in cp.portals) { PortalSpawner val = null; float num2 = 2.25f; PortalSpawner[] array2 = array; foreach (PortalSpawner val2 in array2) { if (Object.op_Implicit((Object)(object)val2) && Interactables.Clean(((Object)((Component)val2).gameObject).name) == portal.Key) { Vector3 val3 = ((Component)val2).transform.position - portal.Value; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; val = val2; } } } if (Object.op_Implicit((Object)(object)val) && !val.hasRegisteredToTeleporter) { if (!val.willSpawn) { val.NetworkwillSpawn = true; } if (val.registerSelfToPortalRemotelyOnActivation) { val.TryToRemotelyRegisterToPortal(); } else if (Object.op_Implicit((Object)(object)instance)) { instance.TryAddingPortal(val); val.hasRegisteredToTeleporter = true; } Log.LogInfo((object)("Portal restored: " + portal.Key + ".")); } } } AccessCodesMissionController instance2 = AccessCodesMissionController.instance; if (!flag || !Object.op_Implicit((Object)(object)instance2) || instance2.nodes == null) { return; } if (cp.accessDone) { if (!instance.showAccessCodesIndicator) { instance2.ActivateCode(); Log.LogInfo((object)"Access Nodes restored: complete."); } } else { if (cp.accessNodes.Count <= 0) { return; } int num3 = 0; AccessCodesNodeData[] nodes = instance2.nodes; foreach (AccessCodesNodeData val4 in nodes) { if (cp.accessNodes.Contains(val4.id) && Object.op_Implicit((Object)(object)val4.node)) { EntityStateMachine component = val4.node.GetComponent<EntityStateMachine>(); if (Object.op_Implicit((Object)(object)component)) { component.SetNextState((EntityState)new NodeActive { Id = val4.id }); num3++; } } } instance2.Network_currentCode = num3; Log.LogInfo((object)("Access Nodes restored: " + num3 + " accessed.")); } } private static bool Saving_Allowed(ConfigEntry<bool> entry) { if (NetworkServer.active && entry.Value && activeSlot >= 0 && (restore == null || restore.done) && Object.op_Implicit((Object)(object)Run.instance)) { return !Run.instance.isGameOverServer; } return false; } private static void ShrinePrefix(HalcyoniteShrineInteractable __instance) { //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) try { if (Object.op_Implicit((Object)(object)__instance) && __instance.interactions == 0 && Saving_Allowed(CpShrine)) { SaveCheckpoint(new Checkpoint { kind = CpKind.Shrine, anchor = ((Component)__instance).transform.position, exclude = ((Component)__instance).gameObject }); } } catch (Exception ex) { Log.LogError((object)("Shrine checkpoint: " + ex)); } } private static void TeleporterPrefix(Interactor activator) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) //IL_005b: 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) try { TeleporterInteraction instance = TeleporterInteraction.instance; if (Object.op_Implicit((Object)(object)instance) && instance.isIdle && Saving_Allowed(CpTeleporter)) { CharacterBody val = ((!Object.op_Implicit((Object)(object)activator)) ? null : ((Component)activator).GetComponent<CharacterBody>()); SaveCheckpoint(new Checkpoint { kind = CpKind.Teleporter, anchor = ((Component)instance).transform.position, spot = ((!Object.op_Implicit((Object)(object)val)) ? Vector3.zero : val.footPosition), exclude = ((Component)instance).gameObject }); } } catch (Exception ex) { Log.LogError((object)("Teleporter checkpoint: " + ex)); } } private static void MithrixPostfix(PreEncounter __instance) { //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) try { if (__instance != null && Object.op_Implicit((Object)(object)((EntityState)__instance).outer) && Saving_Allowed(CpMithrix)) { Transform transform = ((Component)((EntityState)__instance).outer).transform; SaveCheckpoint(new Checkpoint { kind = CpKind.Mithrix, anchor = transform.position, objectPath = PathOf(transform) }); } } catch (Exception ex) { Log.LogError((object)("Mithrix checkpoint: " + ex)); } } private static void FalseSonPrefix(MeridianEventTriggerInteraction __instance) { //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) try { if (Object.op_Implicit((Object)(object)__instance) && !__instance.isTriggered && Saving_Allowed(CpFalseSon)) { SaveCheckpoint(new Checkpoint { kind = CpKind.FalseSon, anchor = ((Component)__instance).transform.position }); } } catch (Exception ex) { Log.LogError((object)("False Son checkpoint: " + ex)); } } private static void GauntletPostfix(VoidRaidGauntletController __instance, bool __result) { //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) try { if (__result && Object.op_Implicit((Object)(object)__instance) && Saving_Allowed(CpVoidling)) { int gauntletIndex = __instance.gauntletIndex; if (gauntletIndex == 1 || gauntletIndex == 2) { SaveCheckpoint(new Checkpoint { kind = CpKind.Voidling, phase = gauntletIndex + 1, anchor = Vector3.zero }); } } } catch (Exception ex) { Log.LogError((object)("Voidling checkpoint: " + ex)); } } private static void VoidlingP4Postfix() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) try { if (Saving_Allowed(CpVoidling)) { SaveCheckpoint(new Checkpoint { kind = CpKind.Voidling, phase = 4, anchor = Vector3.zero }); } } catch (Exception ex) { Log.LogError((object)("Voidling phase 4 checkpoint: " + ex)); } } private static void VoidlingP12Postfix() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) try { if (Saving_Allowed(CpVoidling)) { SaveCheckpoint(new Checkpoint { kind = CpKind.Voidling, phase = 5, anchor = Vector3.zero }); } } catch (Exception ex) { Log.LogError((object)("Voidling phase 12 checkpoint: " + ex)); } } private static void GameEndPostfix(GameEndReportPanelController __instance, DisplayData newDisplayData) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown try { if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.continueButton)) { return; } Transform parent = ((Component)__instance.continueButton).transform.parent; Transform val = parent.Find("SaveSlotsLoadButton"); RunReport runReport = newDisplayData.runReport; if (!DeathButton.Value || Chainloader.PluginInfos.ContainsKey("Gorakh.RespawnButton") || !NetworkServer.active || runReport == null || !Object.op_Implicit((Object)(object)runReport.gameEnding) || runReport.gameEnding.isWin || activeSlot < 0 || !SlotStore.Exists(activeSlot) || !Object.op_Implicit((Object)(object)Run.instance) || !(((object)Run.instance).GetType() == typeof(Run))) { if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(false); } return; } int slot = activeSlot; if (!Object.op_Implicit((Object)(object)val)) { GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.continueButton).gameObject, parent); ((Object)obj).name = "SaveSlotsLoadButton"; obj.transform.SetAsLastSibling(); Transform val2 = obj.transform.Find("GenericGlyph"); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.SetActive(false); } val = obj.transform; } ((Component)val).gameObject.SetActive(true); HGButton component = ((Component)val).GetComponent<HGButton>(); if (Object.op_Implicit((Object)(object)component)) { ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { LoadAfterRunEnd(slot); }); ((Selectable)component).interactable = true; } LanguageTextMeshController componentInChildren = ((Component)val).GetComponentInChildren<LanguageTextMeshController>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.token = "Load slot " + (slot + 1); } } catch (Exception ex) { Log.LogWarning((object)("Game over button: " + ex.Message)); } } internal static void LoadAfterRunEnd(int slot) { if (Object.op_Implicit((Object)(object)Run.instance) && NetworkServer.active && Object.op_Implicit((Object)(object)NetworkSession.instance)) { overridePostRunToLobby = true; NetworkSession.instance.EndRun(); ((MonoBehaviour)Instance).StartCoroutine(WaitForLobbyThenLoad(slot)); } } private static IEnumerator WaitForLobbyThenLoad(int slot) { float t0 = Time.unscaledTime; while (Time.unscaledTime - t0 < 30f && (!Object.op_Implicit((Object)(object)PreGameController.instance) || Object.op_Implicit((Object)(object)Run.instance))) { yield return null; } overridePostRunToLobby = false; if (!Object.op_Implicit((Object)(object)PreGameController.instance)) { Log.LogWarning((object)("The lobby didn't open, so slot " + (slot + 1) + " wasn't loaded.")); yield break; } t0 = Time.unscaledTime; while (Time.unscaledTime - t0 < 15f && !NetworkUser.AllParticipatingNetworkUsersReady()) { yield return null; } yield return (object)new WaitForSeconds(0.5f); LoadSlot(slot); } private static bool PostRunPrefix() { if (!overridePostRunToLobby) { return true; } if (NetworkServer.active) { NetworkManager.singleton.ServerChangeScene("lobby"); } return false; } internal static void Say(string text) { //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_006e: Expected O, but got Unknown if (string.IsNullOrEmpty(text) || !NetworkServer.active) { return; } if (ChatMessages != null && !ChatMessages.Value) { Log.LogInfo((object)text); return; } try { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "<color=#9fd8ff>" + text.Replace("{", "(").Replace("}", ")") + "</color>" }); } catch (Exception ex) { Log.LogDebug((object)("Chat: " + ex.Message)); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCList(ConCommandArgs args) { for (int i = 0; i < 6; i++) { SlotInfo slotInfo = SlotStore.Read(i, withBlob: false); Debug.Log((object)("Slot " + (i + 1) + ": " + ((slotInfo == null || !slotInfo.exists) ? "empty" : slotInfo.OneLine()))); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCLoad(ConCommandArgs args) { if (!LoadSlot(((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1)) { Debug.Log((object)(SlotMenu.status ?? "Couldn't load.")); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCNewRun(ConCommandArgs args) { int num = ((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1; if (num >= 0 && num < 6) { nextNewRunSlot = num; RefreshLobbyTooltip(); Debug.Log((object)("The next new run saves into slot " + (num + 1) + ".")); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCDelete(ConCommandArgs args) { int num = ((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1; if (num >= 0 && num < 6) { SlotStore.Delete(num); Debug.Log((object)("Slot " + (num + 1) + " deleted.")); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCMenu(ConCommandArgs args) { SlotMenu.Open(); } } internal enum CpKind { None, Shrine, Teleporter, Mithrix, FalseSon, Voidling } internal class Checkpoint { public CpKind kind; public string scene = string.Empty; public int phase; public Vector3 anchor; public Vector3 spot; public int shrineStacks; public bool shopPortal; public bool goldPortal; public bool msPortal; public bool hiddenPortal; public string objectPath = string.Empty; public List<KeyValuePair<string, Vector3>> players = new List<KeyValuePair<string, Vector3>>(); public List<KeyValuePair<string, Vector3>> used = new List<KeyValuePair<string, Vector3>>(); public string nextScene = string.Empty; public List<KeyValuePair<string, Vector3>> portals = new List<KeyValuePair<string, Vector3>>(); public List<int> accessNodes = new List<int>(); public bool accessDone; public GameObject exclude; public static int VoidlingPhaseNumber(int arena) { if (arena <= 2) { return 2; } return arena switch { 4 => 9, 3 => 6, _ => 12, }; } public string Label() { return kind switch { CpKind.Shrine => "Halcyon Shrine", CpKind.Teleporter => "Teleporter", CpKind.Mithrix => "Mithrix", CpKind.FalseSon => "False Son", CpKind.Voidling => "Voidling phase " + VoidlingPhaseNumber(phase), _ => "Stage start", }; } public void Write(BinaryWriter w) { //IL_002f: 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) w.Write((int)kind); w.Write(scene ?? string.Empty); w.Write(phase); WriteV(w, anchor); WriteV(w, spot); w.Write(shrineStacks); w.Write((byte)((shopPortal ? 1u : 0u) | (uint)(goldPortal ? 2 : 0) | (uint)(msPortal ? 4 : 0) | (uint)(hiddenPortal ? 8 : 0))); w.Write(objectPath ?? string.Empty); WriteList(w, players); WriteList(w, used); w.Write(nextScene ?? string.Empty); WriteList(w, portals); w.Write(accessNodes.Count); foreach (int accessNode in accessNodes) { w.Write(accessNode); } w.Write(accessDone); } public static Checkpoint Read(BinaryReader r, int version) { //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_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) Checkpoint checkpoint = new Checkpoint(); checkpoint.kind = (CpKind)r.ReadInt32(); checkpoint.scene = r.ReadString(); checkpoint.phase = r.ReadInt32(); checkpoint.anchor = ReadV(r); checkpoint.spot = ReadV(r); checkpoint.shrineStacks = r.ReadInt32(); byte b = r.ReadByte(); checkpoint.shopPortal = (b & 1) != 0; checkpoint.goldPortal = (b & 2) != 0; checkpoint.msPortal = (b & 4) != 0; checkpoint.hiddenPortal = (b & 8) != 0; checkpoint.objectPath = r.ReadString(); checkpoint.players = ReadList(r); checkpoint.used = ReadList(r); if (version >= 2) { checkpoint.nextScene = r.ReadString(); checkpoint.portals = ReadList(r); int num = r.ReadInt32(); for (int i = 0; i < num; i++) { checkpoint.accessNodes.Add(r.ReadInt32()); } checkpoint.accessDone = r.ReadBoolean(); } return checkpoint; } private static void WriteV(BinaryWriter w, Vector3 v) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) w.Write(v.x); w.Write(v.y); w.Write(v.z); } private static Vector3 ReadV(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private static void WriteList(BinaryWriter w, List<KeyValuePair<string, Vector3>> list) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) w.Write(list.Count); foreach (KeyValuePair<string, Vector3> item in list) { w.Write(item.Key ?? string.Empty); WriteV(w, item.Value); } } private static List<KeyValuePair<string, Vector3>> ReadList(BinaryReader r) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) int num = r.ReadInt32(); List<KeyValuePair<string, Vector3>> list = new List<KeyValuePair<string, Vector3>>(Mathf.Clamp(num, 0, 4096)); for (int i = 0; i < num; i++) { string key = r.ReadString(); list.Add(new KeyValuePair<string, Vector3>(key, ReadV(r))); } return list; } } internal class Restore { public Checkpoint cp; public Stage stage; public bool done; public readonly HashSet<CharacterMaster> spawned = new HashSet<CharacterMaster>(); public int spawnCount; public bool voidOpened; public int voidGauntletTarget; public int voidEncounterIndex; public Vector3 voidSpawn; public Vector3 voidFace; } internal class SlotInfo { public int slot; public bool exists; public string error; public DateTime savedUtc; public string scene = string.Empty; public string sceneLabel = string.Empty; public int stage; public int time; public string difficulty = string.Empty; public string mode = string.Empty; public string kindLabel = string.Empty; public string contentHash = string.Empty; public List<string> players = new List<string>(); public string hostBody = string.Empty; public string hostSurvivor = string.Empty; public Checkpoint checkpoint; public byte[] blob; public List<PlayerBackup> backups; public static SlotInfo FromCurrentRun(int slot, SaveFileHeader header, Checkpoint cp) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) SlotInfo slotInfo = new SlotInfo { slot = slot, exists = true, savedUtc = DateTime.UtcNow, scene = (header.SceneName ?? string.Empty), stage = header.StageClearCount + 1, time = header.Time, contentHash = (header.ContentHash ?? string.Empty), checkpoint = cp, kindLabel = ((cp == null) ? "Stage start" : cp.Label()), mode = SaveSlotsPlugin.ModeName(header.GameMode) }; try { SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(slotInfo.scene); slotInfo.sceneLabel = ((!Object.op_Implicit((Object)(object)sceneDefFromSceneName)) ? slotInfo.scene : Language.GetString(sceneDefFromSceneName.nameToken)); DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(header.Difficulty); slotInfo.difficulty = ((difficultyDef == null) ? string.Empty : Language.GetString(difficultyDef.nameToken)); } catch { } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master)) { string text = (Object.op_Implicit((Object)(object)instance.networkUser) ? instance.networkUser.userName : "Player"); string text2 = string.Empty; try { SurvivorDef val = SurvivorCatalog.FindSurvivorDefFromBody(instance.master.bodyPrefab); text2 = (((Object)(object)val == (Object)null) ? string.Empty : Language.GetString(val.displayNameToken)); } catch { } slotInfo.players.Add(string.IsNullOrEmpty(text2) ? text : (text + " (" + text2 + ")")); bool flag = Object.op_Implicit((Object)(object)instance.networkUser) && ((NetworkBehaviour)instance.networkUser).isLocalPlayer; if ((flag || string.IsNullOrEmpty(slotInfo.hostBody)) && (flag || slotInfo.players.Count == 1)) { slotInfo.hostBody = (Object.op_Implicit((Object)(object)instance.master.bodyPrefab) ? ((Object)instance.master.bodyPrefab).name : string.Empty); slotInfo.hostSurvivor = text2; } } } return slotInfo; } public static SlotInfo FromHeader(int slot, SaveFileHeader header, DateTime savedUtc) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Invalid comparison between Unknown and I4 //IL_0118: 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) //IL_0134: Unknown result type (might be due to invalid IL or missing references) SlotInfo slotInfo = new SlotInfo { slot = slot, exists = true, savedUtc = savedUtc, scene = (header.SceneName ?? string.Empty), stage = header.StageClearCount + 1, time = header.Time, contentHash = (header.ContentHash ?? string.Empty), checkpoint = null, kindLabel = "ProperSave save", mode = SaveSlotsPlugin.ModeName(header.GameMode) }; try { SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(slotInfo.scene); slotInfo.sceneLabel = ((!Object.op_Implicit((Object)(object)sceneDefFromSceneName)) ? slotInfo.scene : Language.GetString(sceneDefFromSceneName.nameToken)); DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(header.Difficulty); slotInfo.difficulty = ((difficultyDef == null) ? string.Empty : Language.GetString(difficultyDef.nameToken)); } catch { } HeaderUserData[] array = (HeaderUserData[])(((object)header.Users) ?? ((object)new HeaderUserData[0])); for (int i = 0; i < array.Length; i++) { HeaderUserData val = array[i]; string text = string.Empty; string text2 = string.Empty; try { if (val != null && (int)val.Body != -1) { text2 = BodyCatalog.GetBodyName(val.Body) ?? string.Empty; SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(val.Body)); text = (((Object)(object)survivorDef == (Object)null) ? string.Empty : Language.GetString(survivorDef.displayNameToken)); } } catch { } string text3 = "Player " + (i + 1); slotInfo.players.Add(string.IsNullOrEmpty(text) ? text3 : (text3 + " (" + text + ")")); if (i == 0) { slotInfo.hostBody = text2; slotInfo.hostSurvivor = text; } } return slotInfo; } public static string Clock(int seconds) { seconds = Mathf.Max(0, seconds); if (seconds >= 3600) { return seconds / 3600 + ":" + (seconds / 60 % 60).ToString("00") + ":" + (seconds % 60).ToString("00"); } return (seconds / 60).ToString("00") + ":" + (seconds % 60).ToString("00"); } public string OneLine() { return sceneLabel + ", stage " + stage + ", " + Clock(time) + ", " + difficulty + ", " + kindLabel + ", " + string.Join(", ", players.ToArray()) + ", saved " + savedUtc.ToLocalTime().ToString("g"); } } internal class PlayerBackup { internal struct EquipEntry { public uint slot; public uint set; public string name; public byte charges; } public string key = string.Empty; public string name = string.Empty; public uint money; public uint voidCoins; public uint infusion; public List<KeyValuePair<string, int>> items = new List<KeyValuePair<string, int>>(); public List<EquipEntry> equipment = new List<EquipEntry>(); public static List<PlayerBackup> CaptureAll() { List<PlayerBackup> list = new List<PlayerBackup>(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master) && Object.op_Implicit((Object)(object)instance.master.inventory)) { list.Add(Capture(instance)); } } return list; } private static PlayerBackup Capture(PlayerCharacterMasterController pc) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Invalid comparison between Unknown and I4 //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) CharacterMaster master = pc.master; Inventory inventory = master.inventory; PlayerBackup playerBackup = new PlayerBackup { key = (SaveSlotsPlugin.UserKey(pc) ?? string.Empty), name = ((Object.op_Implicit((Object)(object)pc.networkUser) ? pc.networkUser.userName : ((Object)master).name) ?? string.Empty), money = master.money, voidCoins = master.voidCoins, infusion = inventory.infusionBonus }; foreach (ItemIndex item in inventory.itemAcquisitionOrder) { int itemCountPermanent = inventory.GetItemCountPermanent(item); ItemDef itemDef = ItemCatalog.GetItemDef(item); if (itemCountPermanent > 0 && Object.op_Implicit((Object)(object)itemDef)) { playerBackup.items.Add(new KeyValuePair<string, int>(((Object)itemDef).name, itemCountPermanent)); } } int equipmentSlotCount = inventory.GetEquipmentSlotCount(); int equipmentSetCount = inventory.GetEquipmentSetCount(); for (uint num = 0u; num < equipmentSlotCount; num++) { for (uint num2 = 0u; num2 < equipmentSetCount; num2++) { EquipmentState val = inventory.GetEquipment(num, num2); EquipmentDef val2 = (((int)val.equipmentIndex == -1) ? null : EquipmentCatalog.GetEquipmentDef(val.equipmentIndex)); if (Object.op_Implicit((Object)(object)val2)) { playerBackup.equipment.Add(new EquipEntry { slot = num, set = num2, name = ((Object)val2).name, charges = val.charges }); } } } return playerBackup; } public static void Verify(List<PlayerBackup> backups, string when) { if (backups == null || backups.Count == 0 || !NetworkServer.active) { return; } List<PlayerCharacterMasterController> list = PlayerCharacterMasterController.instances.Where((PlayerCharacterMasterController p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.master) && Object.op_Implicit((Object)(object)p.master.inventory)).ToList(); List<PlayerBackup> list2 = new List<PlayerBackup>(backups); List<KeyValuePair<PlayerCharacterMasterController, PlayerBackup>> list3 = new List<KeyValuePair<PlayerCharacterMasterController, PlayerBackup>>(); Func<PlayerCharacterMasterController, PlayerBackup>[] array = new Func<PlayerCharacterMasterController, PlayerBackup>[2] { (PlayerCharacterMasterController p) => list2.FirstOrDefault((PlayerBackup b) => b.key.Length > 0 && b.key == SaveSlotsPlugin.UserKey(p)), (PlayerCharacterMasterController p) => list2.FirstOrDefault((PlayerBackup b) => Object.op_Implicit((Object)(object)p.networkUser) && b.name.Length > 0 && b.name == p.networkUser.userName) }; foreach (Func<PlayerCharacterMasterController, PlayerBackup> func in array) { PlayerCharacterMasterController[] array2 = Enumerable.ToArray(list); foreach (PlayerCharacterMasterController val in array2) { PlayerBackup playerBackup = func(val); if (playerBackup != null) { list3.Add(new KeyValuePair<PlayerCharacterMasterController, PlayerBackup>(val, playerBackup)); list2.Remove(playerBackup); list.Remove(val); } } } for (int num3 = 0; num3 < list.Count && num3 < list2.Count; num3++) { list3.Add(new KeyValuePair<PlayerCharacterMasterController, PlayerBackup>(list[num3], list2[num3])); } foreach (KeyValuePair<PlayerCharacterMasterController, PlayerBackup> item in list3) { try { string text = Differences(item.Key.master, item.Value); if (text != null) { Apply(item.Key.master, item.Value); string text2 = (Object.op_Implicit((Object)(object)item.Key.networkUser) ? item.Key.networkUser.userName : item.Value.name); SaveSlotsPlugin.Log.LogWarning((object)("Restored " + text2 + "'s items, equipment and money from SaveSlots' own copy (" + when + "; " + text + ").")); } } catch (Exception ex) { SaveSlotsPlugin.Log.LogError((object)("Restoring a player's items: " + ex)); } } } private static Dictionary<ItemIndex, int> Wanted(PlayerBackup b, out int unknown) { //IL_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) Dictionary<ItemIndex, int> dictionary = new Dictionary<ItemIndex, int>(); unknown = 0; foreach (KeyValuePair<string, int> item in b.items) { ItemIndex val = ItemCatalog.FindItemIndex(item.Key); if ((int)val == -1) { unknown++; } else { dictionary[val] = item.Value; } } return dictionary; } private static string Differences(CharacterMaster master, PlayerBackup b) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Invalid comparison between Unknown and I4 //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = master.inventory; int unknown; Dictionary<ItemIndex, int> dictionary = Wanted(b, out unknown); int num = 0; foreach (KeyValuePair<ItemIndex, int> item in dictionary) { if (inventory.GetItemCountPermanent(item.Key) != item.Value) { num++; } } foreach (ItemIndex item2 in inventory.itemAcquisitionOrder) { if (!dictionary.ContainsKey(item2) && inventory.GetItemCountPermanent(item2) > 0) { num++; } } int num2 = 0; foreach (Eq
TeleporterExpansionPlus.dll
Decompiled 2 hours agousing System; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace TeleporterExpansionPlus { [BepInPlugin("custom.TeleporterExpansionPlus", "TeleporterExpansionPlus", "1.0.0")] public class TeleporterExpansionPlusPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> AllowEclipse; internal static ConfigEntry<bool> BlockWithFocus; internal static ConfigEntry<float> SecondsTo8x; internal static ConfigEntry<float> MinCharge; internal static ConfigEntry<float> MaxMultiplier; internal static ConfigEntry<string> DisabledStages; private void Awake() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "After the teleporter boss is killed, the charging teleporter zone keeps expanding."); SecondsTo8x = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SecondsTo8x", 42.857143f, "Seconds for the zone to grow to 8x its size (original mod: 30; 30% slower: 42.86). Growth continues past that."); MaxMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxMultiplier", 0f, "Maximum size multiplier. 0 = no limit."); MinCharge = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumCharge", 0.05f, "Charge fraction required before expansion can start (original: 0.05)."); DisabledStages = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DisabledStages", "2", "Comma-separated stage numbers (1-5, loop-independent) where the teleporter never expands."); AllowEclipse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowInEclipse", false, "Allow expansion on Eclipse difficulties (original default: off)."); BlockWithFocus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableWithFocusedConvergence", true, "No expansion while the team has Focused Convergence (original behaviour)."); Harmony val = new Harmony("custom.TeleporterExpansionPlus"); MethodInfo methodInfo = AccessTools.Method(typeof(HoldoutZoneController), "OnEnable", (Type[])null, (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(TeleporterExpansionPlusPlugin), "OnEnablePostfix", (Type[])null); val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void OnEnablePostfix(HoldoutZoneController __instance) { if (Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ZoneExpander>()) && Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<TeleporterInteraction>())) { ((Component)__instance).gameObject.AddComponent<ZoneExpander>(); } } internal static bool StageAllowed() { if (!Object.op_Implicit((Object)(object)Run.instance)) { return false; } int num = Run.instance.stageClearCount % 5 + 1; string[] array = (DisabledStages.Value ?? string.Empty).Split(new char[1] { ',' }); foreach (string text in array) { if (int.TryParse(text.Trim(), out var result) && result == num) { return false; } } return true; } } public class ZoneExpander : MonoBehaviour { private HoldoutZoneController zone; private TeleporterInteraction tp; private bool started; private float startTime; private float startRadius; private static FieldInfo fCleared; private bool subscribed; private void Awake() { zone = ((Component)this).GetComponent<HoldoutZoneController>(); tp = ((Component)this).GetComponent<TeleporterInteraction>(); if (fCleared == null) { fCleared = AccessTools.Field(typeof(TeleporterInteraction), "monstersCleared"); } } private void OnEnable() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)zone) && !subscribed) { zone.calcRadius += new CalcRadiusDelegate(CalcRadius); subscribed = true; } } private void OnDisable() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)zone) && subscribed) { zone.calcRadius -= new CalcRadiusDelegate(CalcRadius); subscribed = false; } } private bool BossCleared() { if (NetworkServer.active && fCleared != null) { try { return (bool)fCleared.GetValue(tp); } catch { } } try { return Object.op_Implicit((Object)(object)tp.bossGroup) && Object.op_Implicit((Object)(object)tp.bossGroup.combatSquad) && tp.bossGroup.combatSquad.memberCount == 0; } catch { return false; } } private void Update() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (!started && TeleporterExpansionPlusPlugin.Enabled.Value && Object.op_Implicit((Object)(object)tp) && Object.op_Implicit((Object)(object)zone) && Object.op_Implicit((Object)(object)Run.instance) && tp.isCharging && !(tp.chargeFraction <= TeleporterExpansionPlusPlugin.MinCharge.Value) && TeleporterExpansionPlusPlugin.StageAllowed() && (TeleporterExpansionPlusPlugin.AllowEclipse.Value || (int)Run.instance.selectedDifficulty < 3) && (!TeleporterExpansionPlusPlugin.BlockWithFocus.Value || Util.GetItemCountForTeam(zone.chargingTeam, Items.FocusConvergence.itemIndex, true, true) <= 0) && BossCleared()) { started = true; startTime = Time.time; startRadius = Mathf.Max(0.01f, zone.currentRadius); } } private void CalcRadius(ref float radius) { if (started) { float num = Time.time - startTime; float num2 = Mathf.Max(0.1f, TeleporterExpansionPlusPlugin.SecondsTo8x.Value); float num3 = Mathf.Exp(Mathf.Log(8f) * num / num2); float value = TeleporterExpansionPlusPlugin.MaxMultiplier.Value; if (value > 0f) { num3 = Mathf.Min(num3, value); } num3 = Mathf.Min(num3, 100000f); radius = Mathf.Max(radius, startRadius * num3); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } }
UnifiedStagePool.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace UnifiedStagePool { [BepInPlugin("custom.UnifiedStagePool", "UnifiedStagePool", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class UnifiedStagePoolPlugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<bool> addReformedAltar; private ConfigEntry<bool> addTreebornColony; private ConfigEntry<bool> addConduitCanyon; private ConfigEntry<bool> mergeLoopVariants; private ConfigEntry<bool> routeNormalExit; private ConfigEntry<float> addedWeight; private ConfigEntry<string> extraStages; private static readonly FieldInfo entriesField = typeof(SceneCollection).GetField("_sceneEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; addReformedAltar = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "ReformedAltar", true, "Add Reformed Altar (lemuriantemple) to the stage 2 pool, before and after looping."); addTreebornColony = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "TreebornColony", true, "Add Treeborn Colony (habitat) and its loop variant (habitatfall) to the stage 3 pool, before and after looping."); addConduitCanyon = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "ConduitCanyon", true, "Add Conduit Canyon (conduitcanyon) to the stage 4 pool, before and after looping."); extraStages = ((BaseUnityPlugin)this).Config.Bind<string>("Stages", "ExtraStages", string.Empty, "Extra scenes as name:stage pairs, comma separated (e.g. mymap:3)."); mergeLoopVariants = ((BaseUnityPlugin)this).Config.Bind<bool>("Loops", "MergeLoopVariants", true, "Every stage pool contains both the normal and the loop-variant stages, before and after looping (villagenight, lakesnight, etc.)."); addedWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Stages", "AddedStageWeight", 1f, "Selection weight for added stages (vanilla stages are 1)."); routeNormalExit = ((BaseUnityPlugin)this).Config.Bind<bool>("Routes", "RouteStagesUseNormalExit", true, "Added route stages lead into the normal pool of the next stage instead of continuing their route."); try { Apply(); } catch (Exception ex) { Log.LogError((object)ex); } } private static SceneEntry[] Raw(SceneCollection c) { if ((Object)(object)c == (Object)null || entriesField == null) { return (SceneEntry[])(object)new SceneEntry[0]; } return (SceneEntry[])(((object)(SceneEntry[])entriesField.GetValue(c)) ?? ((object)new SceneEntry[0])); } private static T Load<T>(string path) where T : Object { //IL_0001: 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) try { return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion(); } catch (Exception ex) { Log.LogWarning((object)("Could not load " + path + ": " + ex.Message)); return (T)(object)null; } } private static SceneDef Scene(string name) { //IL_00ff: 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) Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("lemuriantemple", "RoR2/DLC2/lemuriantemple/lemuriantemple.asset"); dictionary.Add("habitat", "RoR2/DLC2/habitat/habitat.asset"); dictionary.Add("habitatfall", "RoR2/DLC2/habitatfall/habitatfall.asset"); dictionary.Add("conduitcanyon", "RoR2/DLC3/conduitcanyon/conduitcanyon.asset"); Dictionary<string, string> dictionary2 = dictionary; if (dictionary2.TryGetValue(name, out var value)) { SceneDef val = Load<SceneDef>(value); if (Object.op_Implicit((Object)(object)val)) { return val; } } SceneDef val2 = SceneCatalog.FindSceneDef(name); if (Object.op_Implicit((Object)(object)val2)) { return val2; } string[] array = new string[5] { "Base", "DLC1", "DLC2", "DLC3", "DLC4" }; string[] array2 = array; foreach (string text in array2) { SceneDef val3 = null; try { val3 = Addressables.LoadAssetAsync<SceneDef>((object)("RoR2/" + text + "/" + name + "/" + name + ".asset")).WaitForCompletion(); } catch { } if (Object.op_Implicit((Object)(object)val3)) { return val3; } } Log.LogWarning((object)("Scene not found: " + name)); return null; } private void Apply() { SceneCollection[] array = (SceneCollection[])(object)new SceneCollection[6]; SceneCollection[] array2 = (SceneCollection[])(object)new SceneCollection[6]; for (int i = 1; i <= 5; i++) { array[i] = Load<SceneCollection>("RoR2/Base/SceneGroups/sgStage" + i + ".asset"); array2[i] = Load<SceneCollection>("RoR2/Base/SceneGroups/loopSgStage" + i + ".asset"); } if (mergeLoopVariants.Value) { for (int j = 1; j <= 5; j++) { if (!Object.op_Implicit((Object)(object)array[j]) || !Object.op_Implicit((Object)(object)array2[j])) { continue; } List<SceneDef> list = (from e in Raw(array[j]) select e.sceneDef into d where (Object)(object)d != (Object)null select d).ToList(); List<SceneDef> list2 = (from e in Raw(array2[j]) select e.sceneDef into d where (Object)(object)d != (Object)null select d).ToList(); foreach (SceneDef item in list2) { Add(item, array[j]); } foreach (SceneDef item2 in list) { Add(item2, array2[j]); } } } List<KeyValuePair<SceneDef, int>> list3 = new List<KeyValuePair<SceneDef, int>>(); if (addReformedAltar.Value) { list3.Add(new KeyValuePair<SceneDef, int>(Scene("lemuriantemple"), 2)); } if (addTreebornColony.Value) { list3.Add(new KeyValuePair<SceneDef, int>(Scene("habitat"), 3)); list3.Add(new KeyValuePair<SceneDef, int>(Scene("habitatfall"), 3)); } if (addConduitCanyon.Value) { list3.Add(new KeyValuePair<SceneDef, int>(Scene("conduitcanyon"), 4)); } string[] array3 = extraStages.Value.Split(new char[1] { ',' }); foreach (string text in array3) { string[] array4 = text.Trim().Split(new char[1] { ':' }); if (array4.Length == 2 && int.TryParse(array4[1], out var result) && result >= 1 && result <= 5) { list3.Add(new KeyValuePair<SceneDef, int>(Scene(array4[0].Trim()), result)); } } foreach (KeyValuePair<SceneDef, int> item3 in list3) { if ((Object)(object)item3.Key == (Object)null || !Object.op_Implicit((Object)(object)item3.Key)) { Log.LogWarning((object)"Skipping a stage that failed to load."); continue; } Add(item3.Key, array[item3.Value]); Add(item3.Key, array2[item3.Value]); if (!routeNormalExit.Value || item3.Value >= 5) { continue; } if (Object.op_Implicit((Object)(object)array[item3.Value + 1])) { item3.Key.destinationsGroup = array[item3.Value + 1]; } if (Object.op_Implicit((Object)(object)array2[item3.Value + 1])) { FieldInfo field = typeof(SceneDef).GetField("loopedDestinationsGroup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(item3.Key, array2[item3.Value + 1]); } } } for (int num2 = 1; num2 <= 5; num2++) { if (Object.op_Implicit((Object)(object)array[num2])) { Log.LogInfo((object)("sgStage" + num2 + ": " + string.Join(", ", from e in Raw(array[num2]) select (!((Object)(object)e.sceneDef != (Object)null)) ? "NULL" : ((Object)e.sceneDef).name))); } if (Object.op_Implicit((Object)(object)array2[num2])) { Log.LogInfo((object)("loopSgStage" + num2 + ": " + string.Join(", ", from e in Raw(array2[num2]) select (!((Object)(object)e.sceneDef != (Object)null)) ? "NULL" : ((Object)e.sceneDef).name))); } } } private void Add(SceneDef scene, SceneCollection collection) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scene == (Object)null || (Object)(object)collection == (Object)null || entriesField == null) { return; } SceneEntry[] array = (SceneEntry[])(((object)(SceneEntry[])entriesField.GetValue(collection)) ?? ((object)new SceneEntry[0])); SceneEntry[] array2 = array; for (int i = 0; i < array2.Length; i++) { SceneEntry val = array2[i]; if (object.ReferenceEquals(val.sceneDef, scene)) { return; } } SceneEntry item = new SceneEntry { sceneDef = scene }; ((SceneEntry)(ref item)).weight = addedWeight.Value; List<SceneEntry> list = array.Where((SceneEntry e) => (Object)(object)e.sceneDef != (Object)null).ToList(); list.Add(item); entriesField.SetValue(collection, list.ToArray()); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } }