Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of BossAntiSoftlock v1.0.6
BossAntiSoftlock.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HG.Reflection; using On.RoR2; using On.RoR2.UI; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BossAntiSoftlock")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2ec8214889eebe76c979278446bedc0ec9296a0c")] [assembly: AssemblyProduct("BossAntiSoftlock")] [assembly: AssemblyTitle("BossAntiSoftlock")] [assembly: AssemblyVersion("1.0.0.0")] namespace BossAntiSoftlock; [BepInPlugin("com.justinderby.bossantisoftlock", "Boss Anti-Softlock", "1.0.6")] public class BossAntiSoftlock : BaseUnityPlugin { public const string GUID = "com.justinderby.bossantisoftlock"; public const string ModName = "Boss Anti-Softlock"; public const string Version = "1.0.6"; public static Dictionary<CharacterBody, Vector3> SpawnPositions = new Dictionary<CharacterBody, Vector3>(); public static ConfigEntry<bool> ModHint; public static ConfigEntry<bool> ResetVoid; public static BossAntiSoftlock Instance; public void Awake() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown Instance = SingletonHelper.Assign<BossAntiSoftlock>(Instance, this); ModHint = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Hints", true, "Whether to send a reminder every time the teleporter event has started."); ResetVoid = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Reset Voidtouched Monsters", true, "Whether to also reset voidtouched monsters."); Stage.onStageStartGlobal += delegate { SpawnPositions.Clear(); }; Run.OnServerCharacterBodySpawned += new hook_OnServerCharacterBodySpawned(TrackNewMonster); GlobalEventManager.onCharacterDeathGlobal += RemoveMonster; TeleporterInteraction.onTeleporterBeginChargingGlobal += SendModHint; PauseScreenController.Awake += new hook_Awake(AddResetBossesButton); Console.RunCmd += new hook_RunCmd(HandleCommand); } public void Destroy() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown Instance = null; Stage.onStageStartGlobal -= delegate { SpawnPositions.Clear(); }; Run.OnServerCharacterBodySpawned -= new hook_OnServerCharacterBodySpawned(TrackNewMonster); GlobalEventManager.onCharacterDeathGlobal -= RemoveMonster; TeleporterInteraction.onTeleporterBeginChargingGlobal -= SendModHint; PauseScreenController.Awake -= new hook_Awake(AddResetBossesButton); Console.RunCmd -= new hook_RunCmd(HandleCommand); SpawnPositions.Clear(); } private void AddResetBossesButton(orig_Awake orig, PauseScreenController self) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown orig.Invoke(self); if (!((Object)(object)Run.instance == (Object)null) && !((Object)(object)PreGameController.instance != (Object)null) && NetworkServer.active) { Transform child = ((Transform)self.mainPanel).GetChild(0).GetChild(1); Transform val = Object.Instantiate<Transform>(child, ((Transform)self.mainPanel).GetChild(0)); ((Object)val).name = "GenericMenuButton (Reset Bosses)"; val.SetSiblingIndex(child.GetSiblingIndex() + 1); TextMeshProUGUI componentInChildren = (TextMeshProUGUI)(object)((Component)val).GetComponentInChildren<HGTextMeshProUGUI>(); ((TMP_Text)componentInChildren).SetText(Language.GetStringFormatted("BAS_MENU_RESET_BOSSES", Array.Empty<object>()), true); HGButton component = ((Component)val).GetComponent<HGButton>(); ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(ResetAllBosses)); } } private void SendModChat(string message) { //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_001c: Expected O, but got Unknown Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "<color=#93c47d>Boss Anti-Softlock:</color> " + message }); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void ForceResetPositions(ConCommandArgs _) { if (!((Object)(object)Instance == (Object)null)) { Debug.Log((object)"Resetting all monster positions..."); Instance.ResetCharactersPositions(GetBosses()); } } private void HandleCommand(orig_RunCmd orig, Console self, CmdSender sender, string concommandName, List<string> userArgs) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, sender, concommandName, userArgs); if (concommandName.Equals("say", StringComparison.InvariantCultureIgnoreCase) && userArgs.Count != 0) { string text = userArgs[0]; switch (text.ToLower()) { case "/bossreset": case "/boss_reset": case "/resetboss": case "/resetbosses": case "/reset_boss": case "/reset_bosses": case "/br": case "/rb": ResetAllBosses(); break; } } } private void ResetAllBosses() { List<CharacterBody> bosses = GetBosses(); SendModChat(string.Format("Resetting monster positions... ({0} monster{1})", bosses.Count, (bosses.Count == 1) ? "" : "s")); try { ResetCharactersPositions(bosses); } catch (Exception ex) { Debug.LogException(ex); SendModChat("Error resetting boss positions; check console for more info!"); } } private void SendModHint(TeleporterInteraction obj) { if (ModHint.Value) { SendModChat("Type '/bossreset' to reset monster positions."); } } private void TrackNewMonster(orig_OnServerCharacterBodySpawned orig, Run self, CharacterBody body) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, body); if (!((Object)(object)((Component)body).gameObject == (Object)null) && ((Behaviour)body).isActiveAndEnabled && !body.isPlayerControlled) { SpawnPositions.Add(body, body.footPosition); } } private static List<CharacterBody> GetBosses() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 List<CharacterBody> list = new List<CharacterBody>(); foreach (CharacterBody key in SpawnPositions.Keys) { if (!((Object)(object)((key != null) ? ((Component)key).gameObject : null) == (Object)null) && ((Behaviour)key).isActiveAndEnabled && (key.isBoss || Run.instance is InfiniteTowerRun || (ResetVoid.Value && (int)key.teamComponent.teamIndex == 4))) { list.Add(key); } } return list; } private void RemoveMonster(DamageReport report) { if ((Object)(object)report?.victimBody != (Object)null) { SpawnPositions.Remove(report.victimBody); } } private void ResetCharactersPositions(List<CharacterBody> bodies) { //IL_00d5: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if (ResetVoid.Value) { foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)4)) { if ((Object)(object)teamMember.body != (Object)null && !bodies.Contains(teamMember.body)) { bodies.Add(teamMember.body); } } } foreach (CharacterBody body in bodies) { if ((Object)(object)body == (Object)null || (Object)(object)((Component)body).gameObject == (Object)null || !((Behaviour)body).isActiveAndEnabled) { SpawnPositions.Remove(body); continue; } Debug.Log((object)string.Format("{0} - Teleporting {1} to {2}", "com.justinderby.bossantisoftlock", body, SpawnPositions[body])); TeleportHelper.TeleportBody(body, SpawnPositions[body], false); GameObject gameObject = ((Component)body).gameObject; if (Object.op_Implicit((Object)(object)gameObject)) { EntityStateMachine[] components = gameObject.GetComponents<EntityStateMachine>(); foreach (EntityStateMachine val in components) { val.initialStateType = val.mainStateType; } GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(gameObject.gameObject); if (Object.op_Implicit((Object)(object)teleportEffectPrefab)) { EffectManager.SimpleEffect(teleportEffectPrefab, SpawnPositions[body], Quaternion.identity, true); } } } } }