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.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HG; using Microsoft.CodeAnalysis; using On.RoR2; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Navigation; using RoR2.Orbs; using SimpleJSON; using UnityEngine; using UnityEngine.Networking; [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("Refightilization")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5021e41ceafbf44e10a8175c0df09d2dfb2c1393")] [assembly: AssemblyProduct("Refightilization")] [assembly: AssemblyTitle("Refightilization")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 Wonda { [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Wonda.Refightilization", "Refightilization", "1.2.3")] public class Refightilization : BaseUnityPlugin { public class PlayerStorage { public NetworkUser user = null; public CharacterMaster master = null; public GameObject origPrefab = null; public bool isDead = false; public int[] blacklistedInventory = new int[ItemCatalog.itemCount]; public float[] blacklistedInventoryDecay = new float[ItemCatalog.itemCount]; public bool giftedAffix = false; public EquipmentIndex previousEquipment = (EquipmentIndex)(-1); public NetworkUser lastDamagedBy = null; public float lastDamagedTime = 0f; public bool isLoggedOut = false; public int lastStage = 0; } private const string guid = "com.Wonda.Refightilization"; private const string modName = "Refightilization"; private const string version = "1.2.3"; private RefightilizationConfig _config; private RefightilizationLanguage _language; public List playerStorage = new List(); private List voidWhitelist = new List(); private List finalBossWhitelist = new List(); private List respawnMethodCheck = new List { "RefightRespawn" }; public float respawnTime; private int respawnLoops; public List currEnemyWhitelist = new List(); public List currSpecialEnemyWhitelist = new List(); public List currEliteWhitelist = new List(); public List currItemBlacklist = new List(); public bool moonDisabled; public void Awake() { _config = new RefightilizationConfig(((BaseUnityPlugin)this).Config); SetupHooks(); respawnMethodCheck.AddRange(_config.PreventPrefabResetMethods); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Refightilization!"); } public void Start() { if (Chainloader.PluginInfos.TryGetValue("com.rune580.riskofoptions", out var _)) { _config.BuildRiskOfOptionsMenu(); } } private void SetupHooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown Run.Start += new hook_Start(Run_Start); GlobalEventManager.OnPlayerCharacterDeath += new hook_OnPlayerCharacterDeath(GlobalEventManager_OnPlayerCharacterDeath); GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt; Run.OnServerSceneChanged += new hook_OnServerSceneChanged(Run_OnServerSceneChanged); Run.OnUserAdded += new hook_OnUserAdded(Run_OnUserAdded); Run.OnUserRemoved += new hook_OnUserRemoved(Run_OnUserRemoved); TeleporterInteraction.OnInteractionBegin += new hook_OnInteractionBegin(TeleporterInteraction_OnInteractionBegin); GenericPickupController.AttemptGrant += new hook_AttemptGrant(GenericPickupController_AttemptGrant); Inventory.GiveItemPermanent_ItemIndex_int += new hook_GiveItemPermanent_ItemIndex_int(Inventory_GiveItemPermanent_ItemIndex_int); Inventory.GiveItemTemp += new hook_GiveItemTemp(Inventory_GiveItemTemp); CharacterMaster.Respawn_Vector3_Quaternion_bool += new hook_Respawn_Vector3_Quaternion_bool(CharacterMaster_Respawn); CharacterMaster.PickRandomSurvivorBodyPrefab += new hook_PickRandomSurvivorBodyPrefab(CharacterMaster_PickRandomSurvivorBodyPrefab); CharacterMaster.IsDeadAndOutOfLivesServer += new hook_IsDeadAndOutOfLivesServer(CharacterMaster_IsDeadAndOutOfLivesServer); Run.BeginGameOver += new hook_BeginGameOver(Run_BeginGameOver); InfiniteTowerRun.OnWaveAllEnemiesDefeatedServer += new hook_OnWaveAllEnemiesDefeatedServer(InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer); } private void Run_Start(orig_Start orig, Run self) { orig.Invoke(self); if (_config.EnableRefightilization) { respawnTime = _config.RespawnDelay; SetupPlayers(); SetupLang(); moonDisabled = false; } } private void GlobalEventManager_OnPlayerCharacterDeath(orig_OnPlayerCharacterDeath orig, GlobalEventManager self, DamageReport damageReport, NetworkUser victimNetworkUser) { //IL_0207: 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_00e0: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0129: 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_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) orig.Invoke(self, damageReport, victimNetworkUser); if (!_config.EnableRefightilization) { return; } if (_config.MurderRevive) { PlayerStorage playerStorage = FindPlayerStorage(victimNetworkUser.master); PlayerStorage playerStorage2 = null; if (playerStorage != null && (Object)(object)playerStorage.lastDamagedBy != (Object)null && FindPlayerStorage(playerStorage.lastDamagedBy.master) != null) { playerStorage2 = FindPlayerStorage(playerStorage.lastDamagedBy.master); } if (playerStorage != null && !playerStorage.isDead && playerStorage2 != null && playerStorage2.isDead && Time.time <= playerStorage.lastDamagedTime + _config.MurderWindow) { CleanPlayer(playerStorage2); Vector3 val = (playerStorage2.master.hasBody ? playerStorage2.master.GetBody().footPosition : playerStorage2.master.deathFootPosition); if (Object.op_Implicit((Object)(object)DirectorCore.instance) && playerStorage2.master.hasBody) { val = Run.instance.FindSafeTeleportPositionSimplified(playerStorage2.master.GetBody().hullClassification, val, float.NegativeInfinity, float.NegativeInfinity); } playerStorage2.master.Respawn(val, playerStorage2.master.GetBody().transform.rotation, false); string text = _language.RevengeMessages[Random.Range(0, _language.RevengeMessages.Count - 1)]; text = text.Replace("{0}", playerStorage2.master.playerCharacterMasterController.networkUser.userName); text = text.Replace("{1}", playerStorage.master.playerCharacterMasterController.networkUser.userName); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = " " + text + " " }); } } ((MonoBehaviour)this).StartCoroutine(RespawnCheck(((Component)victimNetworkUser.master).transform.position, respawnTime)); respawnTime += _config.AdditionalRespawnTime; } private void GlobalEventManager_onServerDamageDealt(DamageReport report) { if ((_config.EnableRefightilization || _config.MurderRevive) && FindPlayerStorage(report.attackerMaster) != null && FindPlayerStorage(report.victimMaster) != null) { PlayerStorage playerStorage = FindPlayerStorage(report.victimMaster); playerStorage.lastDamagedBy = FindPlayerStorage(report.attackerMaster).user; playerStorage.lastDamagedTime = Time.time; } } private void Run_OnServerSceneChanged(orig_OnServerSceneChanged orig, Run self, string sceneName) { //IL_0014: 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) if (_config.EnableRefightilization) { ((MonoBehaviour)this).StopCoroutine(RespawnCheck()); } orig.Invoke(self, sceneName); if (_config.EnableRefightilization) { if (sceneName.Equals("moon") || sceneName.Equals("moon2")) { moonDisabled = true; } if (self.stageClearCount > 0) { ResetPrefabs(); } ((MonoBehaviour)this).Invoke("UpdateStageWhitelist", 1f); ((MonoBehaviour)this).Invoke("UpdateEliteWhitelist", 1f); ((MonoBehaviour)this).Invoke("UpdateBlacklistedItems", 1f); respawnTime = _config.RespawnDelay; } } private void Run_OnUserAdded(orig_OnUserAdded orig, Run self, NetworkUser user) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, user); if (!(Run.instance.time > 1f) || !_config.EnableRefightilization) { return; } bool flag = false; foreach (PlayerStorage item in playerStorage) { if (item.user.userName == user.userName) { item.user = user; item.master = user.master; item.isLoggedOut = false; flag = true; ((BaseUnityPlugin)this).Logger.LogDebug((object)(user.userName + " returned. Marking them as logged in.")); if (item.lastStage < Run.instance.stageClearCount && Object.op_Implicit((Object)(object)user.master) && Object.op_Implicit((Object)(object)Stage.instance)) { ((MonoBehaviour)this).Invoke("NaturalRespawnCharacter", 3f); } else { item.isDead = true; ((MonoBehaviour)this).StartCoroutine(RespawnCheck(((Component)item.master).transform.position, 3f)); } item.blacklistedInventory = new int[ItemCatalog.itemCount]; item.blacklistedInventoryDecay = new float[ItemCatalog.itemCount]; break; } } if (!flag) { SetupPlayers(StageUpdate: false); } } private void NaturalRespawnCharacter() { foreach (PlayerStorage item in playerStorage) { if (!item.isDead && !item.isLoggedOut && !Object.op_Implicit((Object)(object)item.master.GetBody())) { Stage.instance.RespawnCharacter(item.master); } } } private void Run_OnUserRemoved(orig_OnUserRemoved orig, Run self, NetworkUser user) { if (Run.instance.time > 1f && _config.EnableRefightilization) { foreach (PlayerStorage item in playerStorage) { if (item.user.userName == user.userName) { CleanPlayer(item); break; } } } orig.Invoke(self, user); if (!(Run.instance.time > 1f) || !_config.EnableRefightilization) { return; } foreach (PlayerStorage item2 in playerStorage) { if (item2.user.userName == user.userName) { item2.isLoggedOut = true; item2.lastStage = Run.instance.stageClearCount; ((BaseUnityPlugin)this).Logger.LogDebug((object)(user.userName + " left. Marking them as logged out.")); break; } } } private void TeleporterInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator) { //IL_003d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 if (_config.EnableRefightilization) { foreach (PlayerStorage item in playerStorage) { if (self.isCharged) { ((MonoBehaviour)this).StopCoroutine(RespawnCheck()); } if ((Object)(object)item.master != (Object)null && (Object)(object)item.master.GetBody() != (Object)null && (Object)(object)((Component)item.master.GetBody()).gameObject == (Object)(object)((Component)activator).gameObject && item.isDead && (int)item.master.teamIndex != 1 && playerStorage.Count > 1) { return; } } } orig.Invoke(self, activator); } private void GenericPickupController_AttemptGrant(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (_config.EnableRefightilization) { PlayerStorage playerStorage = null; if (Object.op_Implicit((Object)(object)body.master)) { playerStorage = FindPlayerStorage(body.master); } if (playerStorage != null && playerStorage.isDead && _config.ItemPickupToggle) { playerStorage.master.GetBody().teamComponent.teamIndex = (TeamIndex)1; } orig.Invoke(self, body); if (playerStorage != null && playerStorage.isDead && _config.ItemPickupToggle) { playerStorage.master.GetBody().teamComponent.teamIndex = _config.RespawnTeam; } } else { orig.Invoke(self, body); } } private void WhyDoActionsDoSillySillyThings(ItemTransferOrb orb) { } private void Inventory_GiveItemPermanent_ItemIndex_int(orig_GiveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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) //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown if (_config.EnableRefightilization && currItemBlacklist.Contains(itemIndex) && count > 0) { CharacterMaster component = ((Component)self).GetComponent(); PlayerStorage playerStorage = null; if ((Object)(object)component != (Object)null) { playerStorage = FindPlayerStorage(component); } if (playerStorage != null && playerStorage.isDead) { playerStorage.blacklistedInventory[itemIndex] += count; ItemTransferOrb.DispatchItemTransferOrb(component.GetBody().footPosition, component.inventory, itemIndex, 0, 0f, (Action)WhyDoActionsDoSillySillyThings, default(Either)); string itemBlacklistWarning = _language.ItemBlacklistWarning; itemBlacklistWarning = itemBlacklistWarning.Replace("{0}", playerStorage.user.userName); itemBlacklistWarning = itemBlacklistWarning.Replace("{1}", ItemCatalog.itemNames[itemIndex]); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "" + itemBlacklistWarning }); return; } } orig.Invoke(self, itemIndex, count); } private void Inventory_GiveItemTemp(orig_GiveItemTemp orig, Inventory self, ItemIndex itemIndex, float count) { //IL_0014: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00ff: Expected O, but got Unknown if (_config.EnableRefightilization && currItemBlacklist.Contains(itemIndex) && count > 0f) { CharacterMaster component = ((Component)self).GetComponent(); PlayerStorage playerStorage = null; if ((Object)(object)component != (Object)null) { playerStorage = FindPlayerStorage(component); } if (playerStorage != null && playerStorage.isDead) { playerStorage.blacklistedInventoryDecay[itemIndex] += count; ItemTransferOrb.DispatchItemTransferOrb(component.GetBody().footPosition, component.inventory, itemIndex, 0, 0f, (Action)WhyDoActionsDoSillySillyThings, default(Either)); string itemBlacklistWarning = _language.ItemBlacklistWarning; itemBlacklistWarning = itemBlacklistWarning.Replace("{0}", playerStorage.user.userName); itemBlacklistWarning = itemBlacklistWarning.Replace("{1}", ItemCatalog.itemNames[itemIndex]); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "" + itemBlacklistWarning }); return; } } orig.Invoke(self, itemIndex, count); } private CharacterBody CharacterMaster_Respawn(orig_Respawn_Vector3_Quaternion_bool orig, CharacterMaster self, Vector3 footPosition, Quaternion rotation, bool wasRevivedMidStage = false) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (_config.EnableRefightilization) { string currMethod = new StackFrame(2).GetMethod().Name; if (!respawnMethodCheck.Exists((string x) => x.Equals(currMethod)) && FindPlayerStorage(self) != null) { CleanPlayer(FindPlayerStorage(self)); } } return orig.Invoke(self, footPosition, rotation, wasRevivedMidStage); } private GameObject CharacterMaster_PickRandomSurvivorBodyPrefab(orig_PickRandomSurvivorBodyPrefab orig, Xoroshiro128Plus rng, NetworkUser networkUser, bool allowHidden) { if (_config.EnableRefightilization && _config.OverrideMetamorphosis) { string name = new StackFrame(6).GetMethod().Name; if (name == "RefightRespawn") { return currEnemyWhitelist[Random.Range(0, currEnemyWhitelist.Count - 1)]; } } return orig.Invoke(rng, networkUser, allowHidden); } private bool CharacterMaster_IsDeadAndOutOfLivesServer(orig_IsDeadAndOutOfLivesServer orig, CharacterMaster self) { if (_config.EnableRefightilization) { PlayerStorage playerStorage = FindPlayerStorage(self); if (playerStorage != null && playerStorage.isDead) { return true; } } return orig.Invoke(self); } private void Run_BeginGameOver(orig_BeginGameOver orig, Run self, GameEndingDef gameEndingDef) { //IL_0025: 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) if (!_config.EnableRefightilization || _config.EndGameWhenEverybodyDead) { ((MonoBehaviour)this).StopCoroutine(RespawnCheck()); ResetPrefabs(); orig.Invoke(self, gameEndingDef); } } private void InfiniteTowerRun_OnWaveAllEnemiesDefeatedServer(orig_OnWaveAllEnemiesDefeatedServer orig, InfiniteTowerRun self, InfiniteTowerWaveController wc) { foreach (PlayerStorage item in playerStorage) { if (item == null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Player is null! Continuing."); } else if (item.isDead) { item.master.TrueKill(); } } orig.Invoke(self, wc); } private void SetupLang() { _language = new RefightilizationLanguage(); } private void SetupPlayers(bool StageUpdate = true) { //IL_01ff: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Setting up players..."); if (StageUpdate) { this.playerStorage.Clear(); } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (this.playerStorage != null && (Object)(object)instance.networkUser == (Object)null) { continue; } if (!StageUpdate && this.playerStorage != null) { bool flag = false; foreach (PlayerStorage item in this.playerStorage) { if ((Object)(object)item.master == (Object)(object)instance.master) { flag = true; break; } } if (flag) { continue; } } PlayerStorage playerStorage = new PlayerStorage(); if (Object.op_Implicit((Object)(object)instance.networkUser)) { playerStorage.user = instance.networkUser; } if (Object.op_Implicit((Object)(object)instance.master)) { playerStorage.master = instance.master; } if (Object.op_Implicit((Object)(object)instance.master.bodyPrefab)) { playerStorage.origPrefab = instance.master.bodyPrefab; } if (Object.op_Implicit((Object)(object)instance.master.inventory)) { playerStorage.blacklistedInventory = new int[ItemCatalog.itemCount]; } if (Object.op_Implicit((Object)(object)instance.master.inventory)) { playerStorage.blacklistedInventoryDecay = new float[ItemCatalog.itemCount]; } this.playerStorage.Add(playerStorage); ((BaseUnityPlugin)this).Logger.LogDebug((object)(playerStorage.user.userName + " added to PlayerStorage!")); } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Setting up players finished."); if (!StageUpdate) { ((MonoBehaviour)this).StartCoroutine(RespawnCheck(new Vector3(0f, 0f, 0f), respawnTime)); } } private IEnumerator RespawnCheck(Vector3 deathPos = default(Vector3), float waitTime = 1f) { //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) ((BaseUnityPlugin)this).Logger.LogDebug((object)("Respawn called! Waiting " + waitTime + " seconds!")); yield return (object)new WaitForSeconds(waitTime); if (!Object.op_Implicit((Object)(object)Run.instance) || !((Behaviour)Run.instance).isActiveAndEnabled) { yield break; } if (!_config.EnableRefightilization) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Nevermind. Mod is disabled via config."); yield break; } if (_config.NoRespawnsAfterTeleporter && Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && TeleporterInteraction.instance.isCharged) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Respawning after teleporter is disabled!"); yield break; } if (_config.DisableMoon && moonDisabled) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Respawn prevented due to current stage."); yield break; } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Checking players..."); bool isEverybodyDead = true; if (playerStorage == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"PlayerStorage is null!"); yield break; } foreach (PlayerStorage player in playerStorage) { if (player == null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Player doesn't exist! Skipping..."); playerStorage.Remove(player); RespawnCheck(deathPos, waitTime); yield break; } if (player.master.IsDeadAndOutOfLivesServer() && !player.isLoggedOut && (!Object.op_Implicit((Object)(object)player.master.GetBody()) || (Object.op_Implicit((Object)(object)player.master.GetBody()) && !player.master.GetBody().healthComponent.alive))) { ((BaseUnityPlugin)this).Logger.LogDebug((object)(player.user.userName + " passed spawn check!")); if (!player.isDead) { player.isDead = true; } player.master.teamIndex = _config.RespawnTeam; respawnLoops = 0; RefightRespawn(player.master, deathPos); } else { ((BaseUnityPlugin)this).Logger.LogDebug((object)(player.user.userName + " failed spawn check.")); if (!player.isDead) { isEverybodyDead = false; } } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Checking players complete."); if (isEverybodyDead && (!((Object)(object)TeleporterInteraction.instance != (Object)null) || !TeleporterInteraction.instance.isInFinalSequence) && _config.EndGameWhenEverybodyDead) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Everybody is dead. Forcibly ending the game."); ResetPrefabs(); Run.instance.BeginGameOver(GameEndings.StandardLoss); } } private void RefightRespawn(CharacterMaster player, Vector3 deathPos) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Invalid comparison between Unknown and I4 //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Expected O, but got Unknown //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Attempting player respawn!"); respawnLoops++; if (respawnLoops > 99) { ((BaseUnityPlugin)this).Logger.LogError((object)"INFINITE LOOP CAUGHT! Please file a bug report for Refightilization! This is not intended behavior."); return; } if ((Object)(object)player == (Object)null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Player is null!? Aborting Respawn."); return; } if ((Object)(object)player.playerCharacterMasterController.networkUser == (Object)null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Player doesn't have a networkUser!? Aborting Respawn."); return; } if (FindPlayerStorage(player).giftedAffix) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Yoinking that Affix."); player.inventory.SetEquipmentIndex(FindPlayerStorage(player).previousEquipment, true); FindPlayerStorage(player).giftedAffix = false; } List list = currEnemyWhitelist; if (Util.CheckRoll(5f, player.playerCharacterMasterController.master) && currSpecialEnemyWhitelist.Count >= 1) { list = new List(currSpecialEnemyWhitelist); } if (Util.CheckRoll(0.1f, player.playerCharacterMasterController.master) && finalBossWhitelist.Count >= 1) { list = new List(finalBossWhitelist); } if (_config.NoRepeatRespawns && list.Count > 1) { list.Remove(list.Where((GameObject entity) => ((Object)entity).name == ((Object)player.bodyPrefab).name).FirstOrDefault()); } GameObject val = list[Random.Range(0, list.Count - 1)]; ((BaseUnityPlugin)this).Logger.LogDebug((object)("Found body " + ((Object)val).name + ".")); if (Object.op_Implicit((Object)(object)player.bodyPrefab) && Object.op_Implicit((Object)(object)val)) { player.bodyPrefab = val; ((BaseUnityPlugin)this).Logger.LogDebug((object)(player.playerCharacterMasterController.networkUser.userName + " was assigned to " + ((Object)player.bodyPrefab).name + ".")); Vector3 val2 = deathPos; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor((float)Random.Range(-5, 5), (float)Random.Range(-5, 5), (float)Random.Range(-2, 2)); Random r = new Random(); foreach (PlayerCharacterMasterController item in PlayerCharacterMasterController.instances.OrderBy((PlayerCharacterMasterController x) => r.Next())) { if (!item.master.IsDeadAndOutOfLivesServer() && (Object)(object)item.master != (Object)null) { val2 = ((Component)item.master).transform.position + val3; break; } } if (val2 == deathPos && Object.op_Implicit((Object)(object)TeleporterInteraction.instance)) { val2 = ((Component)TeleporterInteraction.instance).transform.position + val3; } player.Respawn(GrabNearestNodePosition(val2), Quaternion.identity, false); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Respawned " + player.playerCharacterMasterController.networkUser.userName + "!")); CharacterBody body = player.GetBody(); body.baseMaxHealth *= _config.RespawnHealthMultiplier; CharacterBody body2 = player.GetBody(); body2.baseDamage *= _config.RespawnDamageMultiplier; if (Object.op_Implicit((Object)(object)((Component)player.GetBody()).GetComponent())) { DeathRewards component = ((Component)player.GetBody()).GetComponent(); component.goldReward *= (uint)_config.RespawnMoneyMultiplier; } player.GetBody().baseRegen = 1f; player.GetBody().levelRegen = 0.2f; ((BaseUnityPlugin)this).Logger.LogDebug((object)"Applied stats."); TakeBlacklistedItems(player); if (!Object.op_Implicit((Object)(object)((Component)player.GetBody()).GetComponent())) { ((Component)player.GetBody()).gameObject.AddComponent(); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Granting an interaction driver."); } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Has interaction driver."); if (Object.op_Implicit((Object)(object)((Component)player.GetBody()).GetComponent()) && Object.op_Implicit((Object)(object)((Component)player.GetBody().modelLocator.modelTransform).GetComponent()) && Object.op_Implicit((Object)(object)((Component)player.GetBody().modelLocator.modelTransform).GetComponent().mainSkinnedMeshRenderer)) { Interactor component2 = ((Component)player.GetBody()).GetComponent(); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Getting the model bounds."); Bounds bounds = ((Renderer)((Component)player.GetBody().modelLocator.modelTransform).GetComponent().mainSkinnedMeshRenderer).bounds; Vector3 val4 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)player.GetBody().modelLocator).transform.localScale); float maxInteractionDistance = Mathf.Max(Mathf.Max(val4.x, val4.y), val4.z); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Setting interact radius."); component2.maxInteractionDistance = maxInteractionDistance; if (player.GetBody().isFlying) { component2.maxInteractionDistance *= 1.5f; } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Modifying interaction distance."); } ChangeMinionsTeam(player); player.GetBody().AddTimedBuff(Buffs.ArmorBoost, 15f); player.GetBody().AddTimedBuff(Buffs.CloakSpeed, 30f); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Applied buffs."); if (_config.RespawnAffixEnabled && (Util.CheckRoll(_config.RespawnAffixChance, player.playerCharacterMasterController.master) || RunArtifactManager.instance.IsArtifactEnabled(Artifacts.eliteOnlyArtifactDef))) { if ((int)player.inventory.GetEquipmentIndex() != -1 && !_config.ForceGrantAffix) { return; } if (_config.ForceGrantAffix) { FindPlayerStorage(player).previousEquipment = player.inventory.GetEquipmentIndex(); } int index = Random.Range(0, currEliteWhitelist.Count - 1); player.inventory.SetEquipmentIndex(currEliteWhitelist[index], false); FindPlayerStorage(player).giftedAffix = _config.TakeAffix; ((BaseUnityPlugin)this).Logger.LogDebug((object)"Gifted affix."); } player.preventGameOver = false; respawnLoops = 0; if (_config.AnnounceRespawns) { string text = _language.ReviveMessages[Random.Range(0, _language.ReviveMessages.Count - 1)]; text = text.Replace("{0}", player.playerCharacterMasterController.networkUser.userName); text = text.Replace("{1}", player.GetBody().GetDisplayName()); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = " " + text + " " }); } } else { ((BaseUnityPlugin)this).Logger.LogDebug((object)(player.playerCharacterMasterController.networkUser.userName + " has no bodyPrefab!? Retrying...")); RefightRespawn(player, deathPos); } } private void ResetPrefabs() { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Resetting player prefabs..."); if (playerStorage == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"PlayerStorage is null!"); return; } foreach (PlayerStorage item in playerStorage) { if (item == null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Player is null! Continuing."); continue; } if (item.isDead) { CleanPlayer(item); } ((BaseUnityPlugin)this).Logger.LogDebug((object)(item.user.userName + "'s prefab reset.")); } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Reset player prefabs!"); } private void CleanPlayer(PlayerStorage player) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) player.master.bodyPrefab = player.origPrefab; player.master.teamIndex = (TeamIndex)1; ChangeMinionsTeam(player.master); if (player.giftedAffix) { player.master.inventory.SetEquipmentIndex(player.previousEquipment, true); player.giftedAffix = false; } player.isDead = false; ((MonoBehaviour)this).StartCoroutine(ReturnBlacklistedItemsWait(player.master, 1f)); } private void ChangeMinionsTeam(CharacterMaster player) { //IL_0032: 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_00b3: 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) if (!_config.ChangeMinionsTeam) { return; } MinionGroup val = null; for (int i = 0; i < MinionGroup.instancesList.Count; i++) { MinionGroup val2 = MinionGroup.instancesList[i]; if (MinionGroup.instancesList[i].ownerId == ((NetworkBehaviour)player).netId) { val = val2; break; } } if (val == null) { return; } MinionOwnership[] members = val.members; foreach (MinionOwnership val3 in members) { if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)((Component)val3).GetComponent())) { ((Component)val3).GetComponent().teamIndex = player.teamIndex; if (Object.op_Implicit((Object)(object)((Component)val3).GetComponent().GetBody())) { ((Component)val3).GetComponent().GetBody().teamComponent.teamIndex = player.teamIndex; } ((BaseUnityPlugin)this).Logger.LogDebug((object)("Changed " + ((Object)((Component)val3).GetComponent()).name + "'s team.")); } } } private void UpdateStageWhitelist() { //IL_0190: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Updating the stage whitelist."); currEnemyWhitelist.Clear(); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Whitelist cleared."); if (_config.EnableFixedPool) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Fixed pool is enabled."); string[] fixedPool = _config.FixedPool; foreach (string text in fixedPool) { currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab(text)); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Adding " + text + " to the currWhitelist.")); } } else if ((Object)(object)ClassicStageInfo.instance == (Object)null || ClassicStageInfo.instance.monsterSelection == null || ClassicStageInfo.instance.monsterSelection.choices == null) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"There is no available monster selection!"); if (Object.op_Implicit((Object)(object)VoidRaidGauntletController.instance)) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Void raid detected! Forcing monster selection..."); currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab("NullifierBody")); currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab("VoidJailerBody")); currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab("VoidMegaCrabBody")); } } else { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Selection isn't null."); List> list = ClassicStageInfo.instance.monsterSelection.choices.ToList(); foreach (ChoiceInfo item in list) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Testing choice."); if (item.value == null) { continue; } SpawnCard spawnCard = item.value.spawnCard; if ((Object)(object)spawnCard == (Object)null) { continue; } GameObject val = BodyCatalog.FindBodyPrefab(((Object)spawnCard.prefab).name.Replace("Master", "Body")); if ((Object)(object)val == (Object)null) { continue; } ((BaseUnityPlugin)this).Logger.LogDebug((object)("We have found " + ((Object)val).name + ".")); if ((!_config.AllowBosses || Run.instance.loopClearCount < _config.BossRequiredLoopCount) && val.GetComponent().isChampion) { if (_config.AllowBosses) { currSpecialEnemyWhitelist.Add(val); } } else if (((_config.AllowScavengers && Run.instance.loopClearCount >= _config.ScavangerRequiredLoopCount) || !(((Object)val).name == "ScavengerBody")) && !CheckBlacklist(((Object)val).name)) { currEnemyWhitelist.Add(val); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Adding " + ((Object)val).name + " to the currWhitelist.")); } } } finalBossWhitelist.Add(BodyCatalog.FindBodyPrefab("BrotherBody")); finalBossWhitelist.Add(BodyCatalog.FindBodyPrefab("MiniVoidRaidCrabBodyBase")); finalBossWhitelist.Add(BodyCatalog.FindBodyPrefab("FalseSonBossBody")); finalBossWhitelist.Add(BodyCatalog.FindBodyPrefab("SolusWingBody")); if (currEnemyWhitelist.Count <= 0) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"No enemies were found, pulling out the backup enemies."); string[] fixedPool2 = _config.FixedPool; foreach (string text2 in fixedPool2) { currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab(text2)); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Adding " + text2 + " to the currWhitelist.")); } if (currEnemyWhitelist.Count <= 0) { currEnemyWhitelist.Add(BodyCatalog.FindBodyPrefab("LemurianBody")); } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Done updating Whitelist."); } private void UpdateEliteWhitelist() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Updating the Elite whitelist."); if (CombatDirector.instancesList == null && (Object)(object)CombatDirector.instancesList[0] == (Object)null) { return; } currEliteWhitelist.Clear(); EliteTierDef[] eliteTiers = CombatDirector.eliteTiers; if (eliteTiers == null || eliteTiers.Length == 0) { return; } for (int i = 0; i < eliteTiers.Length; i++) { if (!eliteTiers[i].isAvailable((EliteRules)0) && !eliteTiers[i].isAvailable((EliteRules)2)) { continue; } for (int j = 0; j < eliteTiers[i].eliteTypes.Length; j++) { if (!((Object)(object)eliteTiers[i].eliteTypes[j] == (Object)null) && !((Object)(object)eliteTiers[i].eliteTypes[j].eliteEquipmentDef == (Object)null) && !((Object)(object)eliteTiers[i].eliteTypes[j].eliteEquipmentDef.pickupIconSprite == (Object)null)) { currEliteWhitelist.Add(eliteTiers[i].eliteTypes[j].eliteEquipmentDef.equipmentIndex); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Added " + eliteTiers[i].eliteTypes[j].eliteEquipmentDef.nameToken + " to the pool.")); } } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Done updating Whitelist."); } private Vector3 GrabNearestNodePosition(Vector3 startPos) { //IL_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00b5: 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) NodeGraph groundNodes = SceneInfo.instance.groundNodes; NodeIndex val = groundNodes.FindClosestNode(startPos, (HullClassification)2, float.PositiveInfinity); NodeGraphSpider val2 = new NodeGraphSpider(groundNodes, (HullMask)4); val2.AddNodeForNextStep(val); List list = new List(); int num = 0; List collectedSteps = val2.collectedSteps; while (val2.PerformStep() && num < 8) { num++; for (int i = 0; i < collectedSteps.Count; i++) { list.Add(collectedSteps[i]); } collectedSteps.Clear(); } Vector3 result = default(Vector3); groundNodes.GetNodePosition(list[Random.Range(0, list.Count - 1)].node, ref result); return result; } private bool CheckBlacklist(string name) { bool result = false; string[] blacklistedEnemies = _config.BlacklistedEnemies; foreach (string text in blacklistedEnemies) { if (name == text) { result = true; break; } } return result; } private PlayerStorage FindPlayerStorage(CharacterMaster cMaster) { foreach (PlayerStorage item in playerStorage) { if ((Object)(object)item.master == (Object)(object)cMaster) { return item; } } return null; } private void UpdateBlacklistedItems() { //IL_0037: 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_003f: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Updating the Item blacklist."); currItemBlacklist = new List(); string[] blacklistedItems = _config.BlacklistedItems; foreach (string text in blacklistedItems) { ItemIndex val = ItemCatalog.FindItemIndex(text); if ((int)val != -1) { currItemBlacklist.Add(val); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Added " + ((object)(ItemIndex)(ref val)).ToString() + "|" + text + " to the pool.")); } else { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Couldn't find " + text + ".")); } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Done updating Blacklist."); } private void TakeBlacklistedItems(CharacterMaster player) { //IL_002e: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0067: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ad: 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) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Taking blacklisted items."); PlayerStorage playerStorage = FindPlayerStorage(player); foreach (ItemIndex item in currItemBlacklist) { ItemIndex current = item; if (player.inventory.GetItemCountEffective(current) != 0) { playerStorage.blacklistedInventory[current] = player.inventory.GetItemCountPermanent(current); playerStorage.blacklistedInventoryDecay[current] = player.inventory.GetTempItemRawValue(current); player.inventory.RemoveItemPermanent(current, player.inventory.GetItemCountPermanent(current)); player.inventory.RemoveItemTemp(current, player.inventory.GetTempItemRawValue(current)); ItemTransferOrb.DispatchItemTransferOrb(player.GetBody().footPosition, player.inventory, current, 0, 0f, (Action)WhyDoActionsDoSillySillyThings, default(Either)); ((BaseUnityPlugin)this).Logger.LogDebug((object)("Took away an item at " + ((object)(ItemIndex)(ref current)).ToString())); } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Done checking for blacklisted items."); } private IEnumerator ReturnBlacklistedItemsWait(CharacterMaster player, float time) { yield return (object)new WaitForSeconds(time); ReturnBlacklistedItems(player); } private void ReturnBlacklistedItems(CharacterMaster player) { //IL_002e: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) ((BaseUnityPlugin)this).Logger.LogDebug((object)"Giving blacklisted items."); PlayerStorage playerStorage = FindPlayerStorage(player); foreach (ItemIndex item in currItemBlacklist) { ItemIndex current = item; if (playerStorage.blacklistedInventory[current] != 0 || playerStorage.blacklistedInventoryDecay[current] != 0f) { ItemTransferOrb.DispatchItemTransferOrb(player.GetBody().footPosition, player.inventory, current, playerStorage.blacklistedInventory[current], playerStorage.blacklistedInventoryDecay[current], (Action)null, default(Either)); playerStorage.blacklistedInventory[current] = 0; playerStorage.blacklistedInventoryDecay[current] = 0f; ((BaseUnityPlugin)this).Logger.LogDebug((object)("Gave an item at " + ((object)(ItemIndex)(ref current)).ToString())); } } ((BaseUnityPlugin)this).Logger.LogDebug((object)"Done checking for blacklisted items."); } } internal class RefightilizationConfig { private readonly ConfigEntry _enableRefightilization; private readonly ConfigEntry _allowBosses; private readonly ConfigEntry _allowScavengers; private readonly ConfigEntry _blacklistedEnemies; private readonly ConfigEntry _bossRequiredLoopCount; private readonly ConfigEntry _scavangerRequiredLoopCount; private readonly ConfigEntry _enableFixedPool; private readonly ConfigEntry _fixedPool; private readonly ConfigEntry _respawnDelay; private readonly ConfigEntry _respawnTeam; private readonly ConfigEntry _respawnHealthMultiplier; private readonly ConfigEntry _respawnDamageMultiplier; private readonly ConfigEntry _respawnMoneyMultiplier; private readonly ConfigEntry _respawnAffixEnabled; private readonly ConfigEntry _respawnAffixChance; private readonly ConfigEntry _additionalRespawnTime; private readonly ConfigEntry _noRespawnsAfterTeleporter; private readonly ConfigEntry _noRepeatRespawns; private readonly ConfigEntry _itemPickupToggle; private readonly ConfigEntry _takeAffix; private readonly ConfigEntry _forceGrantAffix; private readonly ConfigEntry _blacklistedItems; private readonly ConfigEntry _murderRevive; private readonly ConfigEntry _murderWindow; private readonly ConfigEntry _announceRespawns; private readonly ConfigEntry _disableMoon; private readonly ConfigEntry _overrideMetamorphosis; private readonly ConfigEntry _changeMinionsTeam; private readonly ConfigEntry _endGameWhenEverybodyDead; private readonly ConfigEntry _maxRespawnTries; private readonly ConfigEntry _preventPrefabResetMethods; public bool EnableRefightilization => _enableRefightilization.Value; public bool AllowBosses => _allowBosses.Value; public bool AllowScavengers => _allowScavengers.Value; public string[] BlacklistedEnemies => _blacklistedEnemies.Value.Replace(" ", "").Split(','); public int BossRequiredLoopCount => _bossRequiredLoopCount.Value; public int ScavangerRequiredLoopCount => _scavangerRequiredLoopCount.Value; public bool EnableFixedPool => _enableFixedPool.Value; public string[] FixedPool => _fixedPool.Value.Replace(" ", "").Split(','); public float RespawnDelay => _respawnDelay.Value; public TeamIndex RespawnTeam => _respawnTeam.Value; public float RespawnHealthMultiplier => _respawnHealthMultiplier.Value; public float RespawnDamageMultiplier => _respawnDamageMultiplier.Value; public float RespawnMoneyMultiplier => _respawnMoneyMultiplier.Value; public bool RespawnAffixEnabled => _respawnAffixEnabled.Value; public float RespawnAffixChance => _respawnAffixChance.Value; public float AdditionalRespawnTime => _additionalRespawnTime.Value; public bool NoRespawnsAfterTeleporter => _noRespawnsAfterTeleporter.Value; public bool NoRepeatRespawns => _noRepeatRespawns.Value; public bool ItemPickupToggle => _itemPickupToggle.Value; public bool TakeAffix => _takeAffix.Value; public bool ForceGrantAffix => _forceGrantAffix.Value; public string[] BlacklistedItems => _blacklistedItems.Value.Replace(" ", "").Split(','); public bool MurderRevive => _murderRevive.Value; public float MurderWindow => _murderWindow.Value; public bool AnnounceRespawns => _announceRespawns.Value; public bool DisableMoon => _disableMoon.Value; public bool OverrideMetamorphosis => _overrideMetamorphosis.Value; public bool ChangeMinionsTeam => _changeMinionsTeam.Value; public bool EndGameWhenEverybodyDead => _endGameWhenEverybodyDead.Value; public int MaxRespawnTries => _maxRespawnTries.Value; public string[] PreventPrefabResetMethods => _preventPrefabResetMethods.Value.Replace(" ", "").Split(','); public RefightilizationConfig(ConfigFile config) { _enableRefightilization = config.Bind("Master", "EnableRefightilization", true, "Enables/Disables the entire mod."); _allowBosses = config.Bind("Monster Categories", "AllowBosses", true, "Allows players to spawn as bosses."); _allowScavengers = config.Bind("Monster Categories", "AllowScavengers", false, "Allows players to spawn as Scavengers."); _blacklistedEnemies = config.Bind("Monster Categories", "BlacklistedEnemies", "BeetleBody, JellyfishBody, WispBody, MinorConstructBody, VoidBarnacleBody, ClayBossBody, ScorchlingBody, IronHaulerBody, MinePodBody, SolusAmalgamatorBody", "Sets monsters to prevent players from spawning as. A list of bodies can be grabbed by using body_list in the console."); _bossRequiredLoopCount = config.Bind("Monster Categories", "BossRequiredLoopCount", 2, "The required amount of loops before a player can spawn as a boss."); _scavangerRequiredLoopCount = config.Bind("Monster Categories", "ScavangerRequiredLoopCount", 5, "The required amount of loops before a player can spawn as a scavanger."); _enableFixedPool = config.Bind("Monster Categories", "EnableFixedPool", false, "Forces players to respawn from a pre-defined list of monsters, instead of the current stage's monsters."); _fixedPool = config.Bind("Monster Categories", "FixedPool", "LemurianBody", "Provides a fixed list of monsters that the player could spawn as with EnableFixedPool enabled. This list will also be used if there are no available monsters to spawn as."); _respawnDelay = config.Bind("Respawn Settings", "RespawnDelay", 5f, "Sets the delay until the player can respawn."); _respawnTeam = config.Bind("Respawn Settings", "RespawnTeam", (TeamIndex)0, "Sets the team of the respawned players."); _respawnHealthMultiplier = config.Bind("Respawn Settings", "RespawnHealthMultiplier", 1.1f, "Multiplies the health a player spawns with."); _respawnDamageMultiplier = config.Bind("Respawn Settings", "RespawnDamageMultiplier", 5f, "Multiplies the damage a player spawns with."); _respawnMoneyMultiplier = config.Bind("Respawn Settings", "RespawnMoneyMultiplier", 1.1f, "Multiplies the money rewarded for killing a player."); _respawnAffixEnabled = config.Bind("Respawn Settings", "RespawnAffixEnabled", true, "Allows players to spawn with affixes if they have an empty equipment slot."); _respawnAffixChance = config.Bind("Respawn Settings", "RespawnAffixChance", 60f, "Sets the chance that a respawned player will have an affix."); _additionalRespawnTime = config.Bind("Respawn Settings", "AdditionalRespawnTime", 0.2f, "Sets how much respawn time will increase per player death. This will effect everyone."); _noRespawnsAfterTeleporter = config.Bind("Respawn Settings", "NoRespawnsAfterTeleporter", true, "Disables respawning after the Teleporter event concludes."); _noRepeatRespawns = config.Bind("Respawn Settings", "NoRepeatRespawns", true, "Will attempt to prevent the player from respawning as the same monster twice in a row."); _itemPickupToggle = config.Bind("Item Settings", "ItemPickupToggle", true, "Allows monster players to pick up items off the ground. (Disabling won't work if RespawnTeam is set to Player.)"); _takeAffix = config.Bind("Item Settings", "TakeAffix", true, "Will take away granted affixes upon respawning."); _forceGrantAffix = config.Bind("Item Settings", "ForceGrantAffix", false, "Will forcibly give the player an aspect, even if they have an equipment item."); _blacklistedItems = config.Bind("Item Settings", "BlacklistedItems", "HealingPotion, FragileDamageBonus, LunarPrimaryReplacement, LunarSecondaryReplacement, LunarSpecialReplacement, LunarUtilityReplacement, Thorns, ExtraLife, ExtraLifeVoid, AncientScepterItem", "Will take away these items from monster players, returning them after they respawn."); _murderRevive = config.Bind("Behavior Settings", "MurderRevive", true, "Will respawn a dead player as a survivor if they kill another player."); _murderWindow = config.Bind("Behavior Settings", "MurderWindow", 15f, "The amount of time that a player has after damaging a player to respawn as them."); _announceRespawns = config.Bind("Behavior Settings", "AnnounceRespawns", true, "Will announce a player respawning in the chat."); _disableMoon = config.Bind("Behavior Settings", "DisableMoon", true, "Prevents players from respawning in Commencement."); _overrideMetamorphosis = config.Bind("Behavior Settings", "OverrideMetamorphosis", true, "Allows Refightilization to override Artifact of Metamorphosis's behavior."); _changeMinionsTeam = config.Bind("Behavior Settings", "ChangeMinionsTeam", true, "Minions will have their team changed to match the player."); _endGameWhenEverybodyDead = config.Bind("Debug", "EndGameWhenEverybodyDead", true, "Ends the round when everybody is dead. (Keep this on.)"); _maxRespawnTries = config.Bind("Debug", "MaxRespawnTries", 5, "The maximum attempts the game will make to retry spawning a player."); _preventPrefabResetMethods = config.Bind("Debug", "PreventPrefabResetMethods", "SwapCharacters, RevertCharacter, CCSpawnAs", "Manually set methods to not be affected by Refight's BodyPrefab-Resetting behavior. (Don't touch this unless you know what you're doing.)"); } public void BuildRiskOfOptionsMenu() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_010b: 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) //IL_011b: 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_0136: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0153: 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_0163: 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_017e: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_0245: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Expected O, but got Unknown //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Expected O, but got Unknown //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Expected O, but got Unknown //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Expected O, but got Unknown byte[] array = File.ReadAllBytes(Assembly.GetExecutingAssembly().Location.Replace("Refightilization.dll", "") + "icon.png"); Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, array); Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); ModSettingsManager.SetModIcon(modIcon); ModSettingsManager.SetModDescriptionToken("REFIGHT_MOD_DESCRIPTION"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_enableRefightilization)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_allowBosses)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_allowScavengers)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(_blacklistedEnemies)); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(_bossRequiredLoopCount)); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(_scavangerRequiredLoopCount)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_enableFixedPool)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(_fixedPool)); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_respawnDelay, new StepSliderConfig { min = 0f, max = 60f, increment = 1f })); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)_respawnTeam)); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_respawnHealthMultiplier, new StepSliderConfig { min = 0f, max = 2f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_respawnDamageMultiplier, new StepSliderConfig { min = 0f, max = 10f, increment = 0.2f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_respawnMoneyMultiplier, new StepSliderConfig { min = 0f, max = 2f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_respawnAffixEnabled)); ModSettingsManager.AddOption((BaseOption)new SliderOption(_respawnAffixChance)); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_additionalRespawnTime, new StepSliderConfig { min = 0f, max = 2f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_noRespawnsAfterTeleporter)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_noRepeatRespawns)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_itemPickupToggle)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_takeAffix)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_forceGrantAffix)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(_blacklistedItems)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_murderRevive)); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(_murderWindow, new StepSliderConfig { min = 1f, max = 60f, increment = 1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_announceRespawns)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_disableMoon)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_overrideMetamorphosis)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_changeMinionsTeam)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_endGameWhenEverybodyDead)); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(_maxRespawnTries)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(_preventPrefabResetMethods, new InputFieldConfig { restartRequired = true })); } } internal class RefightilizationLanguage { public List ReviveMessages { get; set; } public List RevengeMessages { get; set; } public string ItemBlacklistWarning { get; set; } public string RiskOfOptionsDescription { get; set; } public RefightilizationLanguage() { ReviveMessages = new List(); RevengeMessages = new List(); ItemBlacklistWarning = "{0}'s {1} will be returned, later."; string text = Language.currentLanguageName; FileStream stream = File.Open(Assembly.GetExecutingAssembly().Location.Replace("Refightilization.dll", "") + "LanguageResource.json", FileMode.Open, FileAccess.Read); StreamReader streamReader = new StreamReader(stream, Encoding.Unicode); string text2 = streamReader.ReadToEnd(); JSONNode val = JSON.Parse(text2); if (val[text] == (object)null) { text = "en"; } ConvertArrayToStringList(val[text]["reviveMessages"].AsArray, ReviveMessages); ConvertArrayToStringList(val[text]["revengeMessages"].AsArray, RevengeMessages); ItemBlacklistWarning = JSONNode.op_Implicit(val[text]["itemBlacklistWarning"]); streamReader.Close(); } private void ConvertArrayToStringList(JSONArray input, List output) { for (int i = 0; i < ((JSONNode)input).Count; i++) { output.Add(((JSONNode)input)[i].Value); } } } }