Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of VoidCellsRequiresAllPlayers v1.2.0
VoidCellsRequiresAllPlayers.dll
Decompiled a year agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using On.RoR2; using R2API.Utils; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VoidCellsRequiresAllPlayers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6c38c110799a868192e9682ef3b07ad203ce40c9")] [assembly: AssemblyProduct("VoidCellsRequiresAllPlayers")] [assembly: AssemblyTitle("VoidCellsRequiresAllPlayers")] [assembly: AssemblyVersion("1.0.0.0")] namespace VoidCellsRequiresAllPlayers; public static class ChatHelper { private const string RedColor = "ff0000"; private const string GreenColor = "32cd32"; public static void VoidStartMessage() { //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_0017: Expected O, but got Unknown string baseToken = "<color=#32cd32>All players will be healed on void cell interaction!</color>"; Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = baseToken }); } public static void AllPlayersAreRequired() { //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_0017: Expected O, but got Unknown string baseToken = "<color=#ff0000>All players are required to be in zone to start!</color>"; Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = baseToken }); } } internal class Timer : NetworkBehaviour { public delegate void TimerEnd(); private float timeRemaining; public bool IsRunning { get; private set; } public event TimerEnd OnTimerEnd; public void StartTimer(float time) { timeRemaining = time; IsRunning = true; } public void Reset() { IsRunning = false; timeRemaining = 0f; } public void Update() { if (IsRunning) { if (timeRemaining > 0f) { timeRemaining -= Time.deltaTime; return; } Reset(); this.OnTimerEnd?.Invoke(); } } } internal class VoidCellsInteractionController : NetworkBehaviour { private Timer startMessageTimer; private bool WasWardInteractedOnceBeforeUnlock; public void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown startMessageTimer = ((Component)this).gameObject.AddComponent<Timer>(); startMessageTimer.OnTimerEnd += StartMessageTimer_OnTimerEnd; Run.OnServerSceneChanged += new hook_OnServerSceneChanged(Run_OnServerSceneChanged); PurchaseInteraction.GetInteractability += new hook_GetInteractability(PurchaseInteraction_GetInteractability); PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin); } private void StartMessageTimer_OnTimerEnd() { ChatHelper.VoidStartMessage(); } private void Run_OnServerSceneChanged(orig_OnServerSceneChanged orig, Run self, string sceneName) { orig.Invoke(self, sceneName); if (sceneName == "arena" && PluginConfig.ShouldHealOnStartingVoidCell.Value) { startMessageTimer.StartTimer(3f); } } private Interactability PurchaseInteraction_GetInteractability(orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!CheckIfIsNullSafeZone(self) && !CheckIfIsDeepVoidBaterry(self)) { return orig.Invoke(self, activator); } if (!WasWardInteractedOnceBeforeUnlock || CheckIfAllAlivePlayersInsideNullSafeZone(self)) { return orig.Invoke(self, activator); } return (Interactability)1; } private void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { bool flag = CheckIfIsNullSafeZone(self); bool flag2 = CheckIfIsDeepVoidBaterry(self); if (!flag && !flag2) { orig.Invoke(self, activator); } else if (CheckIfAllAlivePlayersInsideNullSafeZone(self)) { WasWardInteractedOnceBeforeUnlock = false; if ((PluginConfig.ShouldHealOnStartingVoidCell.Value && flag) || (PluginConfig.ShouldHealOnStartingVoidBattery.Value && flag2)) { HealAllPlayers(); } orig.Invoke(self, activator); } else if (!WasWardInteractedOnceBeforeUnlock) { WasWardInteractedOnceBeforeUnlock = true; ChatHelper.AllPlayersAreRequired(); } } private bool CheckIfAllAlivePlayersInsideNullSafeZone(PurchaseInteraction nullSafeZone) { //IL_0023: 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) SphereZone component = ((Component)nullSafeZone).gameObject.GetComponent<SphereZone>(); if (Object.op_Implicit((Object)(object)component)) { if (Object.op_Implicit((Object)(object)component)) { return CheckIfAllAlivePlayersInsideSphere(((Component)component).transform.position, component.radius); } return false; } HoldoutZoneController component2 = ((Component)nullSafeZone).gameObject.GetComponent<HoldoutZoneController>(); if (Object.op_Implicit((Object)(object)component2)) { if (Object.op_Implicit((Object)(object)component2)) { return CheckIfAllAlivePlayersInsideSphere(((Component)component2).transform.position, component2.baseRadius); } return false; } return false; } private bool CheckIfAllAlivePlayersInsideSphere(Vector3 spherePosition, float sphereRadius) { //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) return GetAllAlivePlayerBodies().All((CharacterBody body) => CheckIfPlayerInsideSphere(body, spherePosition, sphereRadius)); } private bool CheckIfPlayerInsideSphere(CharacterBody body, Vector3 spherePosition, float sphereRadius) { //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) return Vector3.Distance(((Component)body).transform.position, spherePosition) <= sphereRadius; } public static IEnumerable<CharacterBody> GetAllAlivePlayerBodies() { List<CharacterBody> list = new List<CharacterBody>(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody body = instance.master.GetBody(); if (Object.op_Implicit((Object)(object)body) && !instance.master.IsDeadAndOutOfLivesServer()) { list.Add(body); } } return list; } private void HealAllPlayers() { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody body = instance.master.GetBody(); if (Object.op_Implicit((Object)(object)body)) { HealPlayer(body); } } } private void HealPlayer(CharacterBody body) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) HealthComponent component = ((Component)body).GetComponent<HealthComponent>(); if (Object.op_Implicit((Object)(object)component) && component.health < component.fullHealth) { component.Heal(component.fullHealth - component.health, default(ProcChainMask), true); } } private bool CheckIfIsNullSafeZone(PurchaseInteraction purchaseInteraction) { if (PluginConfig.ShouldWorkOnVoidCell.Value) { return purchaseInteraction.displayNameToken.Contains("NULL_WARD"); } return false; } private bool CheckIfIsDeepVoidBaterry(PurchaseInteraction purchaseInteraction) { if (PluginConfig.ShouldWorkOnVoidBattery.Value) { return purchaseInteraction.displayNameToken.Contains("DEEPVOIDBATTERY_NAME"); } return false; } } internal class PluginConfig { public static ConfigEntry<bool> ShouldWorkOnVoidCell; public static ConfigEntry<bool> ShouldHealOnStartingVoidCell; public static ConfigEntry<bool> ShouldWorkOnVoidBattery; public static ConfigEntry<bool> ShouldHealOnStartingVoidBattery; } [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Mordrog.VoidCellsRequiresAllPlayers", "VoidCellsRequiresAllPlayers", "1.1.3")] public class VoidCellsRequiresAllPlayersPlugin : BaseUnityPlugin { public const string ModVer = "1.1.3"; public const string ModName = "VoidCellsRequiresAllPlayers"; public const string ModGuid = "com.Mordrog.VoidCellsRequiresAllPlayers"; public VoidCellsRequiresAllPlayersPlugin() { InitConfig(); } public void Awake() { ((Component)this).gameObject.AddComponent<VoidCellsInteractionController>(); } private void InitConfig() { PluginConfig.ShouldWorkOnVoidCell = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldWorkOnVoidCell", true, "Should mod work on void cells"); PluginConfig.ShouldHealOnStartingVoidCell = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldHealBeforeStartingVoidCell", true, "Should all players be healed on start of cell stabilization"); PluginConfig.ShouldWorkOnVoidBattery = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldWorkOnVoidBattery", true, "Should mod work on void batteries"); PluginConfig.ShouldHealOnStartingVoidBattery = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldHealOnStartingVoidBattery", false, "Should all players be healed on start of deep void signal charge"); } }