Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of PlayerBotsFork v0.9.9
PlayerBots.dll
Decompiled a week 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EnforcerPlugin; using EntityStates; using EntityStates.AI.Walker; using EntityStates.Railgunner.Reload; using IL.RoR2; using IL.RoR2.UI; using Modules.Characters; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.CharacterAI; using On.RoR2.ExpansionManagement; using PlayerBots.AI; using PlayerBots.AI.SkillHelpers; using PlayerBots.Custom; using RoR2; using RoR2.CharacterAI; using RoR2.ExpansionManagement; using RoR2.Navigation; 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("PlayerBots")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9ee091ed88f178008fb4132143303b794af08521")] [assembly: AssemblyProduct("PlayerBots")] [assembly: AssemblyTitle("PlayerBots")] [assembly: AssemblyVersion("2.0.0.0")] public class CommandHelper { public static void RegisterCommands(Console self) { //IL_008c: 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_00cf: Expected O, but got Unknown Type[] types = typeof(CommandHelper).Assembly.GetTypes(); IDictionary fieldValue = self.GetFieldValue<IDictionary>("concommandCatalog"); foreach (MethodInfo item in types.SelectMany((Type x) => x.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))) { foreach (ConCommandAttribute item2 in item.GetCustomAttributes(inherit: false).OfType<ConCommandAttribute>()) { object obj = Reflection.GetNestedType<Console>("ConCommand").Instantiate(); obj.SetFieldValue("flags", item2.flags); obj.SetFieldValue("helpText", item2.helpText); obj.SetFieldValue("action", (object)(ConCommandDelegate)Delegate.CreateDelegate(typeof(ConCommandDelegate), item)); fieldValue[item2.commandName.ToLower()] = obj; } } } } public static class Reflection { private static readonly BindingFlags _defaultFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; public static TReturn GetFieldValue<TReturn>(this object instance, string fieldName) { return (TReturn)instance.GetType().GetField(fieldName, _defaultFlags | BindingFlags.Instance).GetValue(instance); } public static TReturn GetFieldValue<TClass, TReturn>(string fieldName) { return typeof(TClass).GetFieldValue<TReturn>(fieldName); } public static TReturn GetFieldValue<TReturn>(this Type type, string fieldName) { return (TReturn)type.GetField(fieldName, _defaultFlags | BindingFlags.Static).GetValue(null); } public static void SetFieldValue(this object instance, string fieldName, object value) { instance.GetType().GetField(fieldName, _defaultFlags | BindingFlags.Instance).SetValue(instance, value); } public static void SetFieldValue<TClass>(string fieldName, object value) { typeof(TClass).SetFieldValue(fieldName, value); } public static void SetFieldValue(this Type type, string fieldName, object value) { type.GetField(fieldName, _defaultFlags | BindingFlags.Static).SetValue(null, value); } public static TReturn GetPropertyValue<TReturn>(this object instance, string propName) { return (TReturn)instance.GetType().GetProperty(propName, _defaultFlags | BindingFlags.Instance).GetValue(instance); } public static TReturn GetPropertyValue<TClass, TReturn>(string propName) { return typeof(TClass).GetPropertyValue<TReturn>(propName); } public static TReturn GetPropertyValue<TReturn>(this Type type, string propName) { return (TReturn)type.GetProperty(propName, _defaultFlags | BindingFlags.Static).GetValue(null); } public static void SetPropertyValue(this object instance, string propName, object value) { instance.GetType().GetProperty(propName, _defaultFlags | BindingFlags.Instance).SetValue(instance, value); } public static void SetPropertyValue<TClass>(string propName, object value) { typeof(TClass).SetPropertyValue(propName, value); } public static void SetPropertyValue(this Type type, string propName, object value) { type.GetProperty(propName, _defaultFlags | BindingFlags.Static).SetValue(null, value); } public static TReturn InvokeMethod<TReturn>(this object instance, string methodName, params object[] methodParams) { return (TReturn)instance.GetType().GetMethod(methodName, _defaultFlags | BindingFlags.Instance).Invoke(instance, methodParams); } public static TReturn InvokeMethod<TClass, TReturn>(string methodName, params object[] methodParams) { return typeof(TClass).InvokeMethod<TReturn>(methodName, methodParams); } public static TReturn InvokeMethod<TReturn>(this Type type, string methodName, params object[] methodParams) { return (TReturn)type.GetMethod(methodName, _defaultFlags | BindingFlags.Static).Invoke(null, methodParams); } public static void InvokeMethod(this object instance, string methodName, params object[] methodParams) { instance.InvokeMethod<object>(methodName, methodParams); } public static void InvokeMethod<TClass>(string methodName, params object[] methodParams) { InvokeMethod<TClass, object>(methodName, methodParams); } public static void InvokeMethod(this Type type, string methodName, params object[] methodParams) { InvokeMethod<object>(methodName, methodParams); } public static Type GetNestedType<TParent>(string name) { return GetNestedType(typeof(TParent), name); } public static Type GetNestedType(this Type parentType, string name) { return parentType.GetNestedType(name, BindingFlags.Public | BindingFlags.NonPublic); } public static object Instantiate(this Type type) { return Activator.CreateInstance(type, nonPublic: true); } public static object InstantiateGeneric<TClass>(Type typeArgument) { return typeof(TClass).InstantiateGeneric(typeArgument); } public static object InstantiateGeneric(this Type genericType, Type typeArgument) { return genericType.MakeGenericType(typeArgument).Instantiate(); } public static object InstantiateGeneric<TClass>(Type[] typeArguments) { return typeof(TClass).InstantiateGeneric(typeArguments); } public static object InstantiateGeneric(this Type genericType, Type[] typeArguments) { return genericType.MakeGenericType(typeArguments).Instantiate(); } public static IList InstantiateList(this Type type) { return (IList)typeof(List<>).MakeGenericType(type).Instantiate(); } } namespace PlayerBots { internal class ItemManager : MonoBehaviour { private enum ChestTier { WHITE, GREEN, RED } public CharacterMaster master; private WeightedSelection<ChestTier> chestPicker; private ChestTier nextChestTier; private int nextChestPrice = 25; private int purchases; private int maxPurchases = 8; private FixedTimeStamp lastBuyCheck; private float buyingDelay; private ItemIndex saleStarItemIndex = (ItemIndex)(-1); private ItemIndex saleStarConsumedItemIndex = (ItemIndex)(-1); public void Awake() { master = ((Component)this).gameObject.GetComponent<CharacterMaster>(); maxPurchases = PlayerBotManager.MaxBotPurchasesPerStage.Value; chestPicker = new WeightedSelection<ChestTier>(8); chestPicker.AddChoice(ChestTier.WHITE, PlayerBotManager.Tier1ChestBotWeight.Value); chestPicker.AddChoice(ChestTier.GREEN, PlayerBotManager.Tier2ChestBotWeight.Value); chestPicker.AddChoice(ChestTier.RED, PlayerBotManager.Tier3ChestBotWeight.Value); InitializeSaleStarItems(); ResetPurchases(); ResetBuyingDelay(); } private void InitializeSaleStarItems() { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) saleStarItemIndex = ItemCatalog.FindItemIndex("LowerPricedChests"); if ((int)saleStarItemIndex == -1) { saleStarItemIndex = ItemCatalog.FindItemIndex("SaleStar"); } saleStarConsumedItemIndex = ItemCatalog.FindItemIndex("LowerPricedChestsConsumed"); if ((int)saleStarConsumedItemIndex == -1) { saleStarConsumedItemIndex = ItemCatalog.FindItemIndex("SaleStarConsumed"); } } public void FixedUpdate() { if (((FixedTimeStamp)(ref lastBuyCheck)).timeSince >= buyingDelay) { CheckBuy(); ResetBuyingDelay(); } } public void ResetPurchases() { ResetChest(); maxPurchases = GetMaxPurchases(); } private void ResetBuyingDelay() { //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) lastBuyCheck = FixedTimeStamp.now; buyingDelay = Random.Range(PlayerBotManager.MinBuyingDelay.Value, PlayerBotManager.MaxBuyingDelay.Value); } public void ResetChest() { nextChestTier = chestPicker.Evaluate(Random.value); switch (nextChestTier) { case ChestTier.WHITE: nextChestPrice = Run.instance.GetDifficultyScaledCost(PlayerBotManager.Tier1ChestBotCost.Value); break; case ChestTier.GREEN: nextChestPrice = Run.instance.GetDifficultyScaledCost(PlayerBotManager.Tier2ChestBotCost.Value); break; case ChestTier.RED: nextChestPrice = Run.instance.GetDifficultyScaledCost(PlayerBotManager.Tier3ChestBotCost.Value); break; } } private int GetMaxPurchases() { return PlayerBotManager.MaxBotPurchasesPerStage.Value * (Run.instance.stageClearCount + 1); } private void CheckBuy() { //IL_002b: 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) if (master.IsDeadAndOutOfLivesServer()) { return; } bool flag = Object.op_Implicit((Object)(object)master.GetBody()) && master.GetBody().bodyIndex == BodyCatalog.FindBodyIndex("RobomandoBody"); if (flag || purchases < maxPurchases) { uint num = (uint)nextChestPrice; if (flag) { num = (uint)Mathf.CeilToInt((float)nextChestPrice * 0.6f); } if (master.money >= num) { Buy(nextChestTier); CharacterMaster obj = master; obj.money -= num; purchases++; ResetChest(); } } } private void Buy(ChestTier chestTier) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0109: 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) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Invalid comparison between Unknown and I4 //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_0156: Invalid comparison between Unknown and I4 //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Invalid comparison between Unknown and I4 //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown bool flag = HasActiveSaleStar(); if (flag) { TryConsumeSaleStar(); } List<PickupIndex> list = null; switch (chestTier) { case ChestTier.WHITE: list = (((int)master.inventory.currentEquipmentIndex != -1 || PlayerBotManager.EquipmentBuyChance.Value <= Random.Range(0, 100)) ? Run.instance.smallChestDropTierSelector.Evaluate(Random.value) : Run.instance.availableEquipmentDropList); break; case ChestTier.GREEN: list = Run.instance.mediumChestDropTierSelector.Evaluate(Random.value); break; case ChestTier.RED: list = Run.instance.largeChestDropTierSelector.Evaluate(Random.value); break; } if (list == null || list.Count <= 0) { return; } List<PickupIndex> list2 = list.Where(delegate(PickupIndex pickupIndex) { //IL_0000: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (IsScrapPickup(pickupIndex)) { return false; } PickupDef pickupDef3 = PickupCatalog.GetPickupDef(pickupIndex); return pickupDef3 == null || (int)pickupDef3.itemIndex == -1 || PlayerBotManager.IsItemAllowed(pickupDef3.itemIndex); }).ToList(); if (list2.Count == 0) { return; } int num = ((!flag) ? 1 : 2); int num2 = 0; PickupIndex val = PickupIndex.none; ItemIndex val2 = (ItemIndex)(-1); while (num2 < num && list2.Count > 0) { PickupIndex val3 = Run.instance.treasureRng.NextElementUniform<PickupIndex>(list2); PickupDef pickupDef = PickupCatalog.GetPickupDef(val3); if ((int)pickupDef.itemIndex != -1) { master.inventory.GiveItem(pickupDef.itemIndex, 1); if (num2 == 0) { val = val3; val2 = pickupDef.itemIndex; } } else { if ((int)pickupDef.equipmentIndex == -1) { continue; } if (num2 == 0) { master.inventory.SetEquipmentIndex(pickupDef.equipmentIndex); val = val3; val2 = (ItemIndex)(-1); } } num2++; } if (PlayerBotManager.ShowBuyMessages.Value && num2 > 0 && val != PickupIndex.none) { PickupDef pickupDef2 = PickupCatalog.GetPickupDef(val); Chat.SendBroadcastChat((ChatMessageBase)new PlayerPickupChatMessage { subjectAsCharacterBody = master.GetBody(), baseToken = "PLAYER_PICKUP", pickupToken = (pickupDef2?.nameToken ?? PickupCatalog.invalidPickupToken), pickupColor = Color32.op_Implicit(pickupDef2?.baseColor ?? Color.black), pickupQuantity = (((int)val2 == -1) ? 1u : ((uint)master.inventory.GetItemCount(val2))) }); } } private static bool IsScrapPickup(PickupIndex pickupIndex) { //IL_0000: 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_0015: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef == null) { return false; } ItemIndex itemIndex = pickupDef.itemIndex; if ((int)itemIndex == -1) { return false; } ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); if ((Object)(object)itemDef == (Object)null) { return false; } if (!itemDef.ContainsTag((ItemTag)10)) { return itemDef.ContainsTag((ItemTag)14); } return true; } private bool HasActiveSaleStar() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((int)saleStarItemIndex != -1) { return master.inventory.GetItemCount(saleStarItemIndex) > 0; } return false; } private bool TryConsumeSaleStar() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0020: 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_0050: Unknown result type (might be due to invalid IL or missing references) if ((int)saleStarItemIndex == -1 || (int)saleStarConsumedItemIndex == -1) { return false; } if (master.inventory.GetItemCount(saleStarItemIndex) > 0) { master.inventory.RemoveItem(saleStarItemIndex, 1); master.inventory.GiveItem(saleStarConsumedItemIndex, 1); return true; } return false; } } internal class PlayerBotHooks { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnBodyLost <>9__1_0; public static hook_OnServerMasterSummonGlobal <>9__1_1; public static Func<Instruction, bool> <>9__1_15; public static Manipulator <>9__1_2; public static hook_GiveTeamMoney_TeamIndex_uint <>9__1_3; public static hook_BeginStage <>9__1_4; public static hook_Start <>9__1_5; public static hook_DropRewards <>9__1_6; public static hook_OnInteraction <>9__1_7; public static hook_DropRewards <>9__1_8; public static Func<PlayerCharacterMasterController, bool> <>9__1_18; public static Func<PlayerCharacterMasterController, bool> <>9__1_19; public static hook_PlaceTeleporter <>9__1_9; public static hook_PlayerCanUseBody <>9__1_10; public static hook_Update <>9__1_11; public static Func<Instruction, bool> <>9__1_21; public static Func<bool, bool> <>9__1_22; public static Manipulator <>9__1_20; public static hook_CanUserSpectateBody <>9__1_12; public static Func<Instruction, bool> <>9__1_23; public static Func<bool, bool> <>9__1_24; public static Manipulator <>9__1_13; public static hook_UnlockGateEffects <>9__1_14; public static Func<Instruction, bool> <>9__2_0; internal void <AddHooks>b__1_0(orig_OnBodyLost orig, BaseAI self, CharacterBody body) { if (((Object)self).name.Equals("PlayerBot")) { self.stateMachine.SetNextState(EntityStateCatalog.InstantiateState(ref self.scanState)); } else { orig.Invoke(self, body); } } internal void <AddHooks>b__1_1(orig_OnServerMasterSummonGlobal orig, CaptainDefenseMatrixController self, MasterSummonReport summonReport) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)self.GetFieldValue<CharacterBody>("characterBody") == (Object)null)) { orig.Invoke(self, summonReport); } } internal void <AddHooks>b__1_2(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown <>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0(); ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isPlayerControlled") }); CS$<>8__locals0.isPlayerBot = false; val.EmitDelegate<Func<CharacterBody, CharacterBody>>((Func<CharacterBody, CharacterBody>)delegate(CharacterBody x) { CS$<>8__locals0.isPlayerBot = ((Object)x.master).name.Equals("PlayerBot"); return x; }); val.Index += 1; val.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => CS$<>8__locals0.isPlayerBot || x)); } internal bool <AddHooks>b__1_15(Instruction x) { return ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isPlayerControlled"); } internal void <AddHooks>b__1_3(orig_GiveTeamMoney_TeamIndex_uint orig, TeamManager self, TeamIndex teamIndex, uint money) { //IL_0002: 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_007f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, teamIndex, money); if (PlayerBotManager.playerbots.Count <= 0) { return; } int num = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.livingPlayerCount : 0); if (num != 0) { money = (uint)Mathf.CeilToInt((float)money / (float)num); } foreach (GameObject playerbot in PlayerBotManager.playerbots) { if (Object.op_Implicit((Object)(object)playerbot)) { CharacterMaster component = playerbot.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component) && !component.IsDeadAndOutOfLivesServer() && component.teamIndex == teamIndex) { component.GiveMoney(money); } } } } internal void <AddHooks>b__1_4(orig_BeginStage orig, Run self) { GameObject[] array = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val in array) { if (!Object.op_Implicit((Object)(object)val)) { PlayerBotManager.playerbots.Remove(val); continue; } ItemManager component = val.GetComponent<ItemManager>(); if (Object.op_Implicit((Object)(object)component)) { component.ResetPurchases(); component.master.money = 0u; } } orig.Invoke(self); } internal IEnumerator <AddHooks>b__1_5(orig_Start orig, Stage self) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) IEnumerator result = orig.Invoke(self); if (NetworkServer.active) { if (PlayerBotManager.PlayerMode.Value) { GameObject[] array = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val in array) { if (!Object.op_Implicit((Object)(object)val)) { PlayerBotManager.playerbots.Remove(val); continue; } CharacterMaster component = val.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component)) { Stage.instance.RespawnCharacter(component); } } } if (Run.instance.stageClearCount == 0) { if (PlayerBotManager.InitialRandomBots.Value > 0) { PlayerBotManager.SpawnRandomPlayerbots(NetworkUser.readOnlyInstancesList[0].master, PlayerBotManager.InitialRandomBots.Value); } for (int j = 0; j < PlayerBotManager.InitialBots.Length; j++) { if (PlayerBotManager.InitialBots[j].Value > 0) { PlayerBotManager.SpawnPlayerbots(NetworkUser.readOnlyInstancesList[0].master, PlayerBotManager.RandomSurvivorsList[j], PlayerBotManager.InitialBots[j].Value); } } } } return result; } internal void <AddHooks>b__1_6(orig_DropRewards orig, BossGroup self) { if (ShouldFilterBotsForBossGroup(self)) { DropRewardsExcludingBots(self); } else { orig.Invoke(self); } } internal void <AddHooks>b__1_7(orig_OnInteraction orig, ShrineColossusAccessBehavior self, Interactor interactor) { orig.Invoke(self, interactor); ApplyShrineOfShapingToBots(self); } internal void <AddHooks>b__1_8(orig_DropRewards orig, HalcyoniteShrineInteractable self) { if (ShouldFilterBotsForHalcyonShrine(self)) { DropHalcyonRewardsExcludingBots(self); } else { orig.Invoke(self); } } internal void <AddHooks>b__1_9(orig_PlaceTeleporter orig, SceneDirector self) { //IL_0073: 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_007a: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) if (PlayerBotManager.DontScaleInteractables.Value) { int num = PlayerCharacterMasterController.instances.Count((PlayerCharacterMasterController v) => Object.op_Implicit((Object)(object)v.networkUser)); float num2 = 0.5f + (float)num * 0.5f; ClassicStageInfo component = ((Component)SceneInfo.instance).GetComponent<ClassicStageInfo>(); int num3 = (int)((float)component.sceneDirectorInteractibleCredits * num2); if (component.bonusInteractibleCreditObjects != null) { for (int i = 0; i < component.bonusInteractibleCreditObjects.Length; i++) { BonusInteractibleCreditObject val = component.bonusInteractibleCreditObjects[i]; if (val.objectThatGrantsPointsIfEnabled.activeSelf) { num3 += val.points; } } } self.interactableCredit = num3; } else if (Run.instance.stageClearCount == 0 && PlayerBotManager.GetInitialBotCount() > 0) { int num4 = PlayerCharacterMasterController.instances.Count((PlayerCharacterMasterController v) => Object.op_Implicit((Object)(object)v.networkUser)); num4 += PlayerBotManager.GetInitialBotCount(); float num5 = 0.5f + (float)num4 * 0.5f; ClassicStageInfo component2 = ((Component)SceneInfo.instance).GetComponent<ClassicStageInfo>(); int num6 = (int)((float)component2.sceneDirectorInteractibleCredits * num5); if (component2.bonusInteractibleCreditObjects != null) { for (int j = 0; j < component2.bonusInteractibleCreditObjects.Length; j++) { BonusInteractibleCreditObject val2 = component2.bonusInteractibleCreditObjects[j]; if (val2.objectThatGrantsPointsIfEnabled.activeSelf) { num6 += val2.points; } } } self.interactableCredit = num6; } orig.Invoke(self); } internal bool <AddHooks>b__1_18(PlayerCharacterMasterController v) { return Object.op_Implicit((Object)(object)v.networkUser); } internal bool <AddHooks>b__1_19(PlayerCharacterMasterController v) { return Object.op_Implicit((Object)(object)v.networkUser); } internal bool <AddHooks>b__1_10(orig_PlayerCanUseBody orig, ExpansionRequirementComponent self, PlayerCharacterMasterController master) { if (((Object)master).name.Equals("PlayerBot")) { return true; } return orig.Invoke(self, master); } internal void <AddHooks>b__1_11(orig_Update orig, PlayerCharacterMasterController self) { if (!((Object)self).name.Equals("PlayerBot")) { orig.Invoke(self); } } internal void <AddHooks>b__1_20(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterMaster>(x, "get_playerCharacterMasterController") }); val.Index += 2; val.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => false)); } internal bool <AddHooks>b__1_21(Instruction x) { return ILPatternMatchingExt.MatchCallvirt<CharacterMaster>(x, "get_playerCharacterMasterController"); } internal bool <AddHooks>b__1_22(bool x) { return false; } internal bool <AddHooks>b__1_12(orig_CanUserSpectateBody orig, NetworkUser viewer, CharacterBody body) { if (!body.isPlayerControlled) { return orig.Invoke(viewer, body); } return true; } internal void <AddHooks>b__1_13(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<PlayerCharacterMasterController>(x, "get_isConnected") }); val.Index += 1; val.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => PlayerBotManager.IsContinueAfterDeathAllowedForCurrentStage() || x)); } internal bool <AddHooks>b__1_23(Instruction x) { return ILPatternMatchingExt.MatchCallvirt<PlayerCharacterMasterController>(x, "get_isConnected"); } internal bool <AddHooks>b__1_24(bool x) { if (PlayerBotManager.IsContinueAfterDeathAllowedForCurrentStage()) { return true; } return x; } internal void <AddHooks>b__1_14(orig_UnlockGateEffects orig, SeekerController self, byte chakraGate) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0116: 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_00e0: 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_0112: 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) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown orig.Invoke(self, chakraGate); if (!NetworkServer.active) { return; } CharacterBody component = ((Component)self).GetComponent<CharacterBody>(); if ((Object)(object)component == (Object)null || (Object)(object)component.master == (Object)null || chakraGate < 7) { return; } int num = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.stageClearCount : (-1)); NetworkIdentity component2 = ((Component)self).GetComponent<NetworkIdentity>(); NetworkInstanceId key = ((component2 != null) ? component2.netId : NetworkInstanceId.Invalid); if (seekerReviveStages.TryGetValue(key, out var value) && value == num) { return; } seekerReviveStages[key] = num; GameObject[] array = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } CharacterMaster component3 = val.GetComponent<CharacterMaster>(); if ((Object)(object)component3 == (Object)null || !component3.IsDeadAndOutOfLivesServer()) { continue; } Vector3 val2 = component3.deathFootPosition; if (Object.op_Implicit((Object)(object)component)) { val2 = component.footPosition + new Vector3(Random.Range(-2f, 2f), 0.5f, Random.Range(-2f, 2f)); } component3.Respawn(val2, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), true); CharacterBody body = component3.GetBody(); if (Object.op_Implicit((Object)(object)body)) { body.AddTimedBuff(Buffs.Immune, 3f); EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>(); foreach (EntityStateMachine obj in components) { obj.initialStateType = obj.mainStateType; } GameObject val3 = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/TeleporterHealNovaPulse"); if (Object.op_Implicit((Object)(object)val3)) { EffectManager.SpawnEffect(val3, new EffectData { origin = val2, rotation = ((Component)body).transform.rotation }, true); } } } } internal bool <InjectBotsIntoScoreboard>b__2_0(Instruction x) { return ILPatternMatchingExt.MatchStloc(x, 0); } } [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public bool isPlayerBot; internal CharacterBody <AddHooks>b__16(CharacterBody x) { isPlayerBot = ((Object)x.master).name.Equals("PlayerBot"); return x; } internal bool <AddHooks>b__17(bool x) { if (isPlayerBot) { return true; } return x; } } private static Dictionary<NetworkInstanceId, int> seekerReviveStages = new Dictionary<NetworkInstanceId, int>(); public static void AddHooks() { //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_001f: Expected O, but got Unknown //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_0043: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //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_007f: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00b0: 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: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown object obj = <>c.<>9__1_0; if (obj == null) { hook_OnBodyLost val = delegate(orig_OnBodyLost orig, BaseAI self, CharacterBody body) { if (((Object)self).name.Equals("PlayerBot")) { self.stateMachine.SetNextState(EntityStateCatalog.InstantiateState(ref self.scanState)); } else { orig.Invoke(self, body); } }; <>c.<>9__1_0 = val; obj = (object)val; } BaseAI.OnBodyLost += (hook_OnBodyLost)obj; object obj2 = <>c.<>9__1_1; if (obj2 == null) { hook_OnServerMasterSummonGlobal val2 = delegate(orig_OnServerMasterSummonGlobal orig, CaptainDefenseMatrixController self, MasterSummonReport summonReport) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)self.GetFieldValue<CharacterBody>("characterBody") == (Object)null)) { orig.Invoke(self, summonReport); } }; <>c.<>9__1_1 = val2; obj2 = (object)val2; } CaptainDefenseMatrixController.OnServerMasterSummonGlobal += (hook_OnServerMasterSummonGlobal)obj2; if (PlayerBotManager.ShowNameplates.Value && !PlayerBotManager.PlayerMode.Value) { object obj3 = <>c.<>9__1_2; if (obj3 == null) { Manipulator val3 = delegate(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val27 = new ILCursor(il); val27.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isPlayerControlled") }); bool isPlayerBot = false; val27.EmitDelegate<Func<CharacterBody, CharacterBody>>((Func<CharacterBody, CharacterBody>)delegate(CharacterBody x) { isPlayerBot = ((Object)x.master).name.Equals("PlayerBot"); return x; }); val27.Index += 1; val27.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => isPlayerBot || x)); }; <>c.<>9__1_2 = val3; obj3 = (object)val3; } TeamComponent.SetupIndicator += (Manipulator)obj3; } if (!PlayerBotManager.PlayerMode.Value && PlayerBotManager.AutoPurchaseItems.Value) { object obj4 = <>c.<>9__1_3; if (obj4 == null) { hook_GiveTeamMoney_TeamIndex_uint val4 = delegate(orig_GiveTeamMoney_TeamIndex_uint orig, TeamManager self, TeamIndex teamIndex, uint money) { //IL_0002: 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_007f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, teamIndex, money); if (PlayerBotManager.playerbots.Count > 0) { int num9 = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.livingPlayerCount : 0); if (num9 != 0) { money = (uint)Mathf.CeilToInt((float)money / (float)num9); } foreach (GameObject playerbot in PlayerBotManager.playerbots) { if (Object.op_Implicit((Object)(object)playerbot)) { CharacterMaster component8 = playerbot.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component8) && !component8.IsDeadAndOutOfLivesServer() && component8.teamIndex == teamIndex) { component8.GiveMoney(money); } } } } }; <>c.<>9__1_3 = val4; obj4 = (object)val4; } TeamManager.GiveTeamMoney_TeamIndex_uint += (hook_GiveTeamMoney_TeamIndex_uint)obj4; } if (PlayerBotManager.AutoPurchaseItems.Value) { object obj5 = <>c.<>9__1_4; if (obj5 == null) { hook_BeginStage val5 = delegate(orig_BeginStage orig, Run self) { GameObject[] array3 = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val26 in array3) { if (!Object.op_Implicit((Object)(object)val26)) { PlayerBotManager.playerbots.Remove(val26); } else { ItemManager component7 = val26.GetComponent<ItemManager>(); if (Object.op_Implicit((Object)(object)component7)) { component7.ResetPurchases(); component7.master.money = 0u; } } } orig.Invoke(self); }; <>c.<>9__1_4 = val5; obj5 = (object)val5; } Run.BeginStage += (hook_BeginStage)obj5; } object obj6 = <>c.<>9__1_5; if (obj6 == null) { hook_Start val6 = delegate(orig_Start orig, Stage self) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) IEnumerator result = orig.Invoke(self); if (NetworkServer.active) { if (PlayerBotManager.PlayerMode.Value) { GameObject[] array2 = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val25 in array2) { if (!Object.op_Implicit((Object)(object)val25)) { PlayerBotManager.playerbots.Remove(val25); } else { CharacterMaster component6 = val25.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component6)) { Stage.instance.RespawnCharacter(component6); } } } } if (Run.instance.stageClearCount == 0) { if (PlayerBotManager.InitialRandomBots.Value > 0) { PlayerBotManager.SpawnRandomPlayerbots(NetworkUser.readOnlyInstancesList[0].master, PlayerBotManager.InitialRandomBots.Value); } for (int n = 0; n < PlayerBotManager.InitialBots.Length; n++) { if (PlayerBotManager.InitialBots[n].Value > 0) { PlayerBotManager.SpawnPlayerbots(NetworkUser.readOnlyInstancesList[0].master, PlayerBotManager.RandomSurvivorsList[n], PlayerBotManager.InitialBots[n].Value); } } } } return result; }; <>c.<>9__1_5 = val6; obj6 = (object)val6; } Stage.Start += (hook_Start)obj6; Target.GetBullseyePosition += new hook_GetBullseyePosition(Hook_GetBullseyePosition); object obj7 = <>c.<>9__1_6; if (obj7 == null) { hook_DropRewards val7 = delegate(orig_DropRewards orig, BossGroup self) { if (ShouldFilterBotsForBossGroup(self)) { DropRewardsExcludingBots(self); } else { orig.Invoke(self); } }; <>c.<>9__1_6 = val7; obj7 = (object)val7; } BossGroup.DropRewards += (hook_DropRewards)obj7; object obj8 = <>c.<>9__1_7; if (obj8 == null) { hook_OnInteraction val8 = delegate(orig_OnInteraction orig, ShrineColossusAccessBehavior self, Interactor interactor) { orig.Invoke(self, interactor); ApplyShrineOfShapingToBots(self); }; <>c.<>9__1_7 = val8; obj8 = (object)val8; } ShrineColossusAccessBehavior.OnInteraction += (hook_OnInteraction)obj8; object obj9 = <>c.<>9__1_8; if (obj9 == null) { hook_DropRewards val9 = delegate(orig_DropRewards orig, HalcyoniteShrineInteractable self) { if (ShouldFilterBotsForHalcyonShrine(self)) { DropHalcyonRewardsExcludingBots(self); } else { orig.Invoke(self); } }; <>c.<>9__1_8 = val9; obj9 = (object)val9; } HalcyoniteShrineInteractable.DropRewards += (hook_DropRewards)obj9; if (PlayerBotManager.PlayerMode.Value) { object obj10 = <>c.<>9__1_9; if (obj10 == null) { hook_PlaceTeleporter val10 = delegate(orig_PlaceTeleporter orig, SceneDirector self) { //IL_0073: 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_007a: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) if (PlayerBotManager.DontScaleInteractables.Value) { int num2 = PlayerCharacterMasterController.instances.Count((PlayerCharacterMasterController v) => Object.op_Implicit((Object)(object)v.networkUser)); float num3 = 0.5f + (float)num2 * 0.5f; ClassicStageInfo component4 = ((Component)SceneInfo.instance).GetComponent<ClassicStageInfo>(); int num4 = (int)((float)component4.sceneDirectorInteractibleCredits * num3); if (component4.bonusInteractibleCreditObjects != null) { for (int k = 0; k < component4.bonusInteractibleCreditObjects.Length; k++) { BonusInteractibleCreditObject val23 = component4.bonusInteractibleCreditObjects[k]; if (val23.objectThatGrantsPointsIfEnabled.activeSelf) { num4 += val23.points; } } } self.interactableCredit = num4; } else if (Run.instance.stageClearCount == 0 && PlayerBotManager.GetInitialBotCount() > 0) { int num5 = PlayerCharacterMasterController.instances.Count((PlayerCharacterMasterController v) => Object.op_Implicit((Object)(object)v.networkUser)); num5 += PlayerBotManager.GetInitialBotCount(); float num6 = 0.5f + (float)num5 * 0.5f; ClassicStageInfo component5 = ((Component)SceneInfo.instance).GetComponent<ClassicStageInfo>(); int num7 = (int)((float)component5.sceneDirectorInteractibleCredits * num6); if (component5.bonusInteractibleCreditObjects != null) { for (int l = 0; l < component5.bonusInteractibleCreditObjects.Length; l++) { BonusInteractibleCreditObject val24 = component5.bonusInteractibleCreditObjects[l]; if (val24.objectThatGrantsPointsIfEnabled.activeSelf) { num7 += val24.points; } } } self.interactableCredit = num7; } orig.Invoke(self); }; <>c.<>9__1_9 = val10; obj10 = (object)val10; } SceneDirector.PlaceTeleporter += (hook_PlaceTeleporter)obj10; object obj11 = <>c.<>9__1_10; if (obj11 == null) { hook_PlayerCanUseBody val11 = (orig_PlayerCanUseBody orig, ExpansionRequirementComponent self, PlayerCharacterMasterController master) => ((Object)master).name.Equals("PlayerBot") || orig.Invoke(self, master); <>c.<>9__1_10 = val11; obj11 = (object)val11; } ExpansionRequirementComponent.PlayerCanUseBody += (hook_PlayerCanUseBody)obj11; object obj12 = <>c.<>9__1_11; if (obj12 == null) { hook_Update val12 = delegate(orig_Update orig, PlayerCharacterMasterController self) { if (!((Object)self).name.Equals("PlayerBot")) { orig.Invoke(self); } }; <>c.<>9__1_11 = val12; obj12 = (object)val12; } PlayerCharacterMasterController.Update += (hook_Update)obj12; try { EventInfo @event = typeof(AllyCardManager).GetEvent("PopulateCharacterDataSet", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (@event != null) { object obj13 = <>c.<>9__1_20; if (obj13 == null) { Manipulator val13 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val22 = new ILCursor(il); val22.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterMaster>(x, "get_playerCharacterMasterController") }); val22.Index += 2; val22.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => false)); }; <>c.<>9__1_20 = val13; obj13 = (object)val13; } Manipulator val14 = (Manipulator)obj13; @event.GetAddMethod(nonPublic: true).Invoke(null, new object[1] { val14 }); } } catch (Exception ex) { PlayerBotManager.BotLogger.LogError((object)("Failed to apply AllyCardManager hook: " + ex)); } object obj14 = <>c.<>9__1_12; if (obj14 == null) { hook_CanUserSpectateBody val15 = (orig_CanUserSpectateBody orig, NetworkUser viewer, CharacterBody body) => body.isPlayerControlled || orig.Invoke(viewer, body); <>c.<>9__1_12 = val15; obj14 = (object)val15; } CameraRigControllerSpectateControls.CanUserSpectateBody += (hook_CanUserSpectateBody)obj14; if (PlayerBotManager.ContinueAfterDeath.Value) { object obj15 = <>c.<>9__1_13; if (obj15 == null) { Manipulator val16 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val21 = new ILCursor(il); val21.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<PlayerCharacterMasterController>(x, "get_isConnected") }); val21.Index += 1; val21.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool x) => PlayerBotManager.IsContinueAfterDeathAllowedForCurrentStage() || x)); }; <>c.<>9__1_13 = val16; obj15 = (object)val16; } Stage.Update += (Manipulator)obj15; } ScoreboardController.Rebuild += new Manipulator(InjectBotsIntoScoreboard); } object obj16 = <>c.<>9__1_14; if (obj16 == null) { hook_UnlockGateEffects val17 = delegate(orig_UnlockGateEffects orig, SeekerController self, byte chakraGate) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0116: 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_00e0: 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_0112: 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) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown orig.Invoke(self, chakraGate); if (NetworkServer.active) { CharacterBody component = ((Component)self).GetComponent<CharacterBody>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.master == (Object)null) && chakraGate >= 7) { int num = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.stageClearCount : (-1)); NetworkIdentity component2 = ((Component)self).GetComponent<NetworkIdentity>(); NetworkInstanceId key = ((component2 != null) ? component2.netId : NetworkInstanceId.Invalid); if (!seekerReviveStages.TryGetValue(key, out var value) || value != num) { seekerReviveStages[key] = num; GameObject[] array = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val18 in array) { if (Object.op_Implicit((Object)(object)val18)) { CharacterMaster component3 = val18.GetComponent<CharacterMaster>(); if (!((Object)(object)component3 == (Object)null) && component3.IsDeadAndOutOfLivesServer()) { Vector3 val19 = component3.deathFootPosition; if (Object.op_Implicit((Object)(object)component)) { val19 = component.footPosition + new Vector3(Random.Range(-2f, 2f), 0.5f, Random.Range(-2f, 2f)); } component3.Respawn(val19, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), true); CharacterBody body2 = component3.GetBody(); if (Object.op_Implicit((Object)(object)body2)) { body2.AddTimedBuff(Buffs.Immune, 3f); EntityStateMachine[] components = ((Component)body2).GetComponents<EntityStateMachine>(); foreach (EntityStateMachine obj17 in components) { obj17.initialStateType = obj17.mainStateType; } GameObject val20 = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/TeleporterHealNovaPulse"); if (Object.op_Implicit((Object)(object)val20)) { EffectManager.SpawnEffect(val20, new EffectData { origin = val19, rotation = ((Component)body2).transform.rotation }, true); } } } } } } } } }; <>c.<>9__1_14 = val17; obj16 = (object)val17; } SeekerController.UnlockGateEffects += (hook_UnlockGateEffects)obj16; } private static void InjectBotsIntoScoreboard(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 0) })) { val.Emit(OpCodes.Ldloc_0); val.EmitDelegate<Func<List<PlayerCharacterMasterController>, List<PlayerCharacterMasterController>>>((Func<List<PlayerCharacterMasterController>, List<PlayerCharacterMasterController>>)IncludeBotsInScoreboardList); val.Emit(OpCodes.Stloc_0); return; } ManualLogSource botLogger = PlayerBotManager.BotLogger; if (botLogger != null) { botLogger.LogWarning((object)"Failed to patch ScoreboardController.Rebuild for bot inclusion."); } } private static List<PlayerCharacterMasterController> IncludeBotsInScoreboardList(List<PlayerCharacterMasterController> list) { if (list == null) { return list; } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && !list.Contains(instance) && Object.op_Implicit((Object)(object)((Component)instance).gameObject) && ((Component)instance).gameObject.activeInHierarchy) { CharacterMaster master = instance.master; if (Object.op_Implicit((Object)(object)master) && !((Object)(object)master.GetBody() == (Object)null) && Util.GetBestMasterName(master) != null && IsPlayerBotController(instance)) { list.Add(instance); } } } return list; } public static bool Hook_GetBullseyePosition(orig_GetBullseyePosition orig, Target self, out Vector3 position) { orig.Invoke(self, ref position); return true; } private static bool ShouldFilterBotsForBossGroup(BossGroup bossGroup) { if (!NetworkServer.active || (Object)(object)bossGroup == (Object)null) { return false; } if (PlayerBotManager.playerbots.Count == 0) { return false; } TeleporterInteraction instance = TeleporterInteraction.instance; if (Object.op_Implicit((Object)(object)instance)) { return (Object)(object)instance.bossGroup == (Object)(object)bossGroup; } return false; } private static void DropRewardsExcludingBots(BossGroup bossGroup) { //IL_0056: 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_0070: 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_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_00ed: 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_00fc: 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) //IL_0110: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)bossGroup)) { return; } Run instance = Run.instance; if (!Object.op_Implicit((Object)(object)instance)) { Debug.LogError((object)"No valid run instance!"); return; } Xoroshiro128Plus fieldValue = bossGroup.GetFieldValue<Xoroshiro128Plus>("rng"); if (fieldValue == null) { Debug.LogError((object)"RNG is null!"); return; } int nonBotParticipatingPlayerCount = GetNonBotParticipatingPlayerCount(); if (nonBotParticipatingPlayerCount == 0) { return; } if (Object.op_Implicit((Object)(object)bossGroup.dropPosition)) { UniquePickup val = UniquePickup.none; if (Object.op_Implicit((Object)(object)bossGroup.dropTable)) { val = bossGroup.dropTable.GeneratePickup(fieldValue); } else { List<PickupIndex> list = (bossGroup.forceTier3Reward ? instance.availableTier3DropList : instance.availableTier2DropList); if (list != null && list.Count > 0) { ((UniquePickup)(ref val))..ctor(fieldValue.NextElementUniform<PickupIndex>(list)); } } int num = 1 + bossGroup.bonusRewardCount; if (bossGroup.scaleRewardsByPlayerCount) { num *= nonBotParticipatingPlayerCount; } if (num <= 0) { return; } float num2 = 360f / (float)num; Vector3 val2 = Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f); Quaternion val3 = Quaternion.AngleAxis(num2, Vector3.up); List<UniquePickup> fieldValue2 = bossGroup.GetFieldValue<List<UniquePickup>>("bossDrops"); List<PickupDropTable> fieldValue3 = bossGroup.GetFieldValue<List<PickupDropTable>>("bossDropTables"); bool flag = fieldValue2 != null && fieldValue2.Count > 0; bool flag2 = fieldValue3 != null && fieldValue3.Count > 0; for (int i = 0; i < num; i++) { UniquePickup val4 = val; if (fieldValue2 != null && (flag || flag2) && fieldValue.nextNormalizedFloat <= bossGroup.bossDropChance) { if (flag2) { PickupDropTable val5 = fieldValue.NextElementUniform<PickupDropTable>(fieldValue3); if ((Object)(object)val5 != (Object)null) { val4 = val5.GeneratePickup(fieldValue); } } else { val4 = fieldValue.NextElementUniform<UniquePickup>(fieldValue2); } } PickupDropletController.CreatePickupDroplet(val4, bossGroup.dropPosition.position, val2); val2 = val3 * val2; } } else { Debug.LogWarning((object)"dropPosition not set for BossGroup! No item will be spawned."); } } private static bool ShouldFilterBotsForHalcyonShrine(HalcyoniteShrineInteractable shrine) { if (!NetworkServer.active || (Object)(object)shrine == (Object)null) { return false; } return PlayerBotManager.playerbots.Count > 0; } private static void DropHalcyonRewardsExcludingBots(HalcyoniteShrineInteractable shrine) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //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_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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_0109: Expected O, but got Unknown //IL_0202: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01e6: 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) if (!NetworkServer.active || (Object)(object)shrine == (Object)null) { return; } EntityStateMachine stateMachine = shrine.stateMachine; SerializableEntityStateType finishedState = shrine.finishedState; if ((Object)(object)stateMachine != (Object)null) { stateMachine.SetNextState(EntityStateCatalog.InstantiateState(ref finishedState)); } BasicPickupDropTable fieldValue = shrine.GetFieldValue<BasicPickupDropTable>("rewardDropTable"); if (!Object.op_Implicit((Object)(object)((Component)shrine).gameObject) || !Object.op_Implicit((Object)(object)fieldValue)) { return; } int nonBotParticipatingPlayerCount = GetNonBotParticipatingPlayerCount(); if (nonBotParticipatingPlayerCount <= 0) { return; } int num = Math.Max(1, shrine.GetFieldValue<int>("quantityIncreaseFromBuyIn")); int num2 = nonBotParticipatingPlayerCount * num; if (num2 <= 0) { return; } Vector3 fieldValue2 = shrine.GetFieldValue<Vector3>("rewardOffset"); int fieldValue3 = shrine.GetFieldValue<int>("rewardOptionCount"); GameObject fieldValue4 = shrine.GetFieldValue<GameObject>("rewardPickupPrefab"); ItemTier fieldValue5 = shrine.GetFieldValue<ItemTier>("rewardDisplayTier"); BasicPickupDropTable fieldValue6 = shrine.GetFieldValue<BasicPickupDropTable>("halcyoniteDropTableTier3"); BasicPickupDropTable fieldValue7 = shrine.GetFieldValue<BasicPickupDropTable>("halcyoniteDropTableTier2"); Xoroshiro128Plus val = shrine.GetFieldValue<Xoroshiro128Plus>("rng"); if (val == null && Run.instance?.treasureRng != null) { val = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong); shrine.SetFieldValue("rng", val); } if (val == null) { Debug.LogWarning((object)"Halcyonite shrine RNG is null; aborting reward drop."); return; } float num3 = 360f / (float)num2; Vector3 val2 = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f); Quaternion val3 = Quaternion.AngleAxis(num3, Vector3.up); Vector3 val4 = ((Component)shrine).gameObject.transform.position + fieldValue2; for (int i = 0; i < num2; i++) { CreatePickupInfo val5; if (HalcyoniteShrineInteractable.isCommandEnabled) { int num4 = Mathf.Max(0, fieldValue3 - 2); for (int j = 0; j < num4; j++) { UniquePickup pickup = ((PickupDropTable)fieldValue).GeneratePickup(val); val5 = default(CreatePickupInfo); ((CreatePickupInfo)(ref val5)).pickup = pickup; val5.rotation = Quaternion.identity; val5.position = val4; CreatePickupInfo val6 = val5; PickupDropletController.CreatePickupDroplet(val6, val6.position, val2); } } else { val5 = default(CreatePickupInfo); ((CreatePickupInfo)(ref val5)).pickup = new UniquePickup(PickupCatalog.FindPickupIndex(fieldValue5)); val5.pickerOptions = PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm(fieldValue3, (PickupDropTable)(object)fieldValue6, (PickupDropTable)(object)fieldValue7, val); val5.rotation = Quaternion.identity; val5.position = val4; val5.prefabOverride = fieldValue4; PickupDropletController.CreatePickupDroplet(val5, val4, val2); } val2 = val3 * val2; } } private static int GetNonBotParticipatingPlayerCount() { int num = 0; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && !IsPlayerBotController(instance)) { num++; } } return num; } private static bool IsPlayerBotController(PlayerCharacterMasterController controller) { if (!Object.op_Implicit((Object)(object)controller)) { return false; } if (((Object)controller).name.Equals("PlayerBot", StringComparison.Ordinal)) { return true; } CharacterMaster master = controller.master; if (Object.op_Implicit((Object)(object)master)) { return ((Object)master).name.Equals("PlayerBot", StringComparison.Ordinal); } return false; } private static void ApplyShrineOfShapingToBots(ShrineColossusAccessBehavior shrine) { //IL_004a: 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_00d0: 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_0112: 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_0118: 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_00e7: 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_015b: 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) if (!NetworkServer.active || (Object)(object)shrine == (Object)null || PlayerBotManager.playerbots.Count == 0) { return; } NodeGraph val = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? SceneInfo.instance.GetNodeGraph((GraphType)0) : null); List<NodeIndex> list = ((val != null) ? val.FindNodesInRange(((Component)shrine).gameObject.transform.position, 10f, 30f, (HullMask)1) : null); bool flag = list != null && list.Count > 0; GameObject[] array = PlayerBotManager.playerbots.ToArray(); foreach (GameObject val2 in array) { if (!Object.op_Implicit((Object)(object)val2)) { PlayerBotManager.playerbots.Remove(val2); continue; } CharacterMaster component = val2.GetComponent<CharacterMaster>(); if (!Object.op_Implicit((Object)(object)component)) { continue; } if (component.IsDeadAndOutOfLivesServer()) { Vector3 position = ((Component)shrine).transform.position; if (flag) { NodeIndex val3 = list[Random.Range(0, list.Count)]; val.GetNodePosition(val3, ref position); } Quaternion val4 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); component.Respawn(position, val4, true); CharacterBody body = component.GetBody(); if (Object.op_Implicit((Object)(object)body)) { body.AddTimedBuff(Buffs.Immune, 3f); EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>(); foreach (EntityStateMachine obj in components) { obj.initialStateType = obj.mainStateType; } } } else { CharacterBody body2 = component.GetBody(); if (Object.op_Implicit((Object)(object)body2) && !((Object)(object)body2.healthComponent == (Object)null) && body2.healthComponent.alive) { body2.AddTimedBuff(Buffs.Immune, 3f); body2.AddBuff(Buffs.ExtraLifeBuff); } } } } } [BepInPlugin("com.meledy.PlayerBots", "PlayerBots", "1.7.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PlayerBotManager : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Awake <>9__114_0; public static Func<PlayerCharacterMasterController, bool> <>9__128_0; internal void <Awake>b__114_0(orig_Awake orig, Console self) { CommandHelper.RegisterCommands(self); orig.Invoke(self); } internal bool <FixedUpdate>b__128_0(PlayerCharacterMasterController p) { if (p.preventGameOver) { return p.isConnected; } return false; } } public static Random random = new Random(); public static List<GameObject> playerbots = new List<GameObject>(); public static List<SurvivorIndex> RandomSurvivorsList = new List<SurvivorIndex>(); public static Dictionary<string, SurvivorIndex> SurvivorDict = new Dictionary<string, SurvivorIndex>(); public static ConfigEntry<int>[] InitialBots; public static bool allRealPlayersDead; public static ManualLogSource BotLogger { get; private set; } public static ConfigEntry<int> InitialRandomBots { get; set; } public static ConfigEntry<int> MaxBotPurchasesPerStage { get; set; } public static ConfigEntry<bool> AutoPurchaseItems { get; set; } public static ConfigEntry<float> Tier1ChestBotWeight { get; set; } public static ConfigEntry<int> Tier1ChestBotCost { get; set; } public static ConfigEntry<float> Tier2ChestBotWeight { get; set; } public static ConfigEntry<int> Tier2ChestBotCost { get; set; } public static ConfigEntry<float> Tier3ChestBotWeight { get; set; } public static ConfigEntry<int> Tier3ChestBotCost { get; set; } public static ConfigEntry<int> EquipmentBuyChance { get; set; } public static ConfigEntry<float> MinBuyingDelay { get; set; } public static ConfigEntry<float> MaxBuyingDelay { get; set; } public static ConfigEntry<bool> ShowBuyMessages { get; set; } public static ConfigEntry<bool> HostOnlySpawnBots { get; set; } public static ConfigEntry<bool> ShowNameplates { get; set; } public static ConfigEntry<bool> PlayerMode { get; set; } public static ConfigEntry<bool> DontScaleInteractables { get; set; } public static ConfigEntry<bool> BotsUseInteractables { get; set; } public static ConfigEntry<bool> ContinueAfterDeath { get; set; } public static ConfigEntry<string> ContinueAfterDeathBlacklist { get; set; } public static ConfigEntry<bool> RespawnAfterWave { get; set; } public static ConfigEntry<float> BotTeleportDistance { get; set; } public static ConfigEntry<bool> EnableDroneSupport { get; set; } public static ConfigEntry<bool> EnableDroneSupportAllBots { get; set; } public static ConfigEntry<string> SurvivorBlacklist { get; set; } public static ConfigEntry<string> ItemBlacklist { get; set; } public void Awake() { //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_03b9: Expected O, but got Unknown BotLogger = ((BaseUnityPlugin)this).Logger; InitialRandomBots = ((BaseUnityPlugin)this).Config.Bind<int>("Starting Bots", "StartingBots.Random", 0, "Starting amount of bots to spawn at the start of a run. (Random)"); AutoPurchaseItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Bot Inventory", "AutoPurchaseItems", true, "Maximum amount of purchases a playerbot can do per stage. Items are purchased directly instead of from chests."); MaxBotPurchasesPerStage = ((BaseUnityPlugin)this).Config.Bind<int>("Bot Inventory", "MaxBotPurchasesPerStage", 10, "Maximum amount of putchases a playerbot can do per stage."); Tier1ChestBotWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Bot Inventory", "Tier1ChestBotWeight", 0.8f, "Weight of a bot picking an item from a small chest's loot table."); Tier2ChestBotWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Bot Inventory", "Tier2ChestBotWeight", 0.2f, "Weight of a bot picking an item from a large chest's loot table."); Tier3ChestBotWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Bot Inventory", "Tier3ChestBotWeight", 0f, "Weight of a bot picking an item from a legendary chest's loot table."); Tier1ChestBotCost = ((BaseUnityPlugin)this).Config.Bind<int>("Bot Inventory", "Tier1ChestBotCost", 25, "Base price of a small chest for the bot."); Tier2ChestBotCost = ((BaseUnityPlugin)this).Config.Bind<int>("Bot Inventory", "Tier2ChestBotCost", 50, "Base price of a large chest for the bot."); Tier3ChestBotCost = ((BaseUnityPlugin)this).Config.Bind<int>("Bot Inventory", "Tier3ChestBotCost", 400, "Base price of a legendary chest for the bot."); EquipmentBuyChance = ((BaseUnityPlugin)this).Config.Bind<int>("Bot Inventory", "EquipmentBuyChance", 15, "Chance between 0 and 100 for a bot to buy from an equipment barrel instead of a tier 1 chest. Only active while the bot does not have a equipment item. (Default: 15)"); MinBuyingDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Bot Inventory", "MinBuyingDelay", 0f, "Minimum delay in seconds between the time it takes for a bot checks to buy an item."); MaxBuyingDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Bot Inventory", "MaxBuyingDelay", 5f, "Maximum delay in seconds between the time it takes for a bot checks to buy an item."); ShowBuyMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("Bot Inventory", "ShowBuyMessages", true, "Displays whenever a bot buys an item in chat."); HostOnlySpawnBots = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "HostOnlySpawnBots", true, "Set true so that only the host may spawn bots"); ShowNameplates = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "ShowNameplates", true, "Show player nameplates on playerbots if PlayerMode is false. (Host only)"); PlayerMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "PlayerMode", false, "Makes the game treat playerbots like how regular players are treated. The bots now show up on the scoreboard, can pick up items, influence the map scaling, etc."); DontScaleInteractables = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "DontScaleInteractables", true, "Prevents interactables spawn count from scaling with bots. Only active is PlayerMode is true."); BotsUseInteractables = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "BotsUseInteractables", false, "[Experimental] Allow bots to use interactables, such as buying from a chest and picking up items on the ground. Only active is PlayerMode is true. [TEMPORARILY DISABLED - BROKEN]"); ContinueAfterDeath = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "ContinueAfterDeath", false, "Bots will activate and use teleporters when all real players die. Only active is PlayerMode is true."); ContinueAfterDeathBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Player Mode", "ContinueAfterDeathBlacklist", "arena,artifactworld,artifactworld01,artifactworld02,artifactworld03,bazaar,computationalexchange,conduitcanyon,goldshores,meridian,moon,moon2,mysteryspace,solusweb,solutionalhaunt,voidraid,voidstage", "List of stage names where ContinueAfterDeath should be disabled. Only active if PlayerMode and ContinueAfterDeath are true."); RespawnAfterWave = ((BaseUnityPlugin)this).Config.Bind<bool>("Simulacrum", "RespawnAfterWave", false, "Respawns bots after each wave in simulacrum"); BotTeleportDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "BotTeleportDistance", 100f, "Maximum distance in meters a bot can be from their master player before teleporting to them. Set to 0 to disable teleportation."); EnableDroneSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "EnableDroneSupport", true, "Allow Operator bots to purchase support drones."); EnableDroneSupportAllBots = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Mode", "EnableDroneSupportAllBots", false, "Allow all bots to purchase support drones. EnableDroneSupport must be enabled."); SurvivorBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Starting Bots", "SurvivorBlacklist", "", "Comma-separated list of survivor names to exclude from random bot spawning. Supports both in-game display names (e.g., 'Chef', 'Mercenary') and technical asset names (e.g., 'GnomeChefBody', 'MercenaryBody'). Leave empty to disable filtering. Use pb_listsurvivors to see available survivor names."); ItemBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Bot Inventory", "ItemBlacklist", "", "Comma-separated list of item names that bots will never buy. Leave empty to disable filtering."); MaxBuyingDelay.Value = Math.Max(MaxBuyingDelay.Value, MinBuyingDelay.Value); object obj = <>c.<>9__114_0; if (obj == null) { hook_Awake val = delegate(orig_Awake orig, Console self) { CommandHelper.RegisterCommands(self); orig.Invoke(self); }; <>c.<>9__114_0 = val; obj = (object)val; } Console.Awake += (hook_Awake)obj; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnContentLoad)); PlayerBotHooks.AddHooks(); } public void OnContentLoad() { //IL_000f: 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_0041: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00be: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) SurvivorDict.Add("mult", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("mul-t", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("toolbot", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("hunt", SurvivorCatalog.FindSurvivorIndex("Huntress")); SurvivorDict.Add("huntress", SurvivorCatalog.FindSurvivorIndex("Huntress")); SurvivorDict.Add("engi", SurvivorCatalog.FindSurvivorIndex("Engi")); SurvivorDict.Add("engineer", SurvivorCatalog.FindSurvivorIndex("Engi")); SurvivorDict.Add("mage", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("arti", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("artificer", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("merc", SurvivorCatalog.FindSurvivorIndex("Merc")); SurvivorDict.Add("mercenary", SurvivorCatalog.FindSurvivorIndex("Merc")); SurvivorDict.Add("rex", SurvivorCatalog.FindSurvivorIndex("Treebot")); SurvivorDict.Add("treebot", SurvivorCatalog.FindSurvivorIndex("Treebot")); SurvivorDict.Add("croco", SurvivorCatalog.FindSurvivorIndex("Croco")); SurvivorDict.Add("capt", SurvivorCatalog.FindSurvivorIndex("Captain")); SurvivorDict.Add("captain", SurvivorCatalog.FindSurvivorIndex("Captain")); SurvivorDict.Add("railgunner", SurvivorCatalog.FindSurvivorIndex("Railgunner")); SurvivorDict.Add("rail", SurvivorCatalog.FindSurvivorIndex("Railgunner")); SurvivorDict.Add("void", SurvivorCatalog.FindSurvivorIndex("VoidSurvivor")); SurvivorDict.Add("voidfiend", SurvivorCatalog.FindSurvivorIndex("VoidSurvivor")); SurvivorDict.Add("voidsurvivor", SurvivorCatalog.FindSurvivorIndex("VoidSurvivor")); SurvivorDict.Add("seeker", SurvivorCatalog.FindSurvivorIndex("Seeker")); SurvivorDict.Add("chef", SurvivorCatalog.FindSurvivorIndex("Chef")); SurvivorDict.Add("son", SurvivorCatalog.FindSurvivorIndex("FalseSon")); SurvivorDict.Add("falseson", SurvivorCatalog.FindSurvivorIndex("FalseSon")); AiSkillHelperCatalog.Populate(); InitialBots = new ConfigEntry<int>[RandomSurvivorsList.Count]; for (int i = 0; i < RandomSurvivorsList.Count; i++) { string text = BodyCatalog.GetBodyName(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(RandomSurvivorsList[i])).Replace("'", ""); InitialBots[i] = ((BaseUnityPlugin)this).Config.Bind<int>("Starting Bots", "StartingBots." + text, 0, "Starting amount of bots to spawn at the start of a run. (" + text + ")"); } } public static int GetInitialBotCount() { int num = InitialRandomBots.Value; for (int i = 0; i < InitialBots.Length; i++) { num += InitialBots[i].Value; } return num; } public static void SpawnPlayerbot(CharacterMaster owner, SurvivorIndex survivorIndex) { //IL_0015: 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) if (PlayerMode.Value) { SpawnPlayerbotAsPlayer(owner, survivorIndex); } else { SpawnPlayerbotAsSummon(owner, survivorIndex); } } private static void SpawnPlayerbotAsPlayer(CharacterMaster owner, SurvivorIndex survivorIndex) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_007d: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) //IL_00ca: 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_00e6: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex); if ((Object)(object)survivorDef == (Object)null) { return; } if (!survivorDef.CheckRequiredExpansionEnabled((NetworkUser)null)) { Debug.Log((object)"You do not have the proper expansion enabled."); return; } GameObject bodyPrefab = survivorDef.bodyPrefab; if ((Object)(object)bodyPrefab == (Object)null) { return; } PlayerBotSpawnCard playerBotSpawnCard = ScriptableObject.CreateInstance<PlayerBotSpawnCard>(); ((SpawnCard)playerBotSpawnCard).hullSize = (HullClassification)0; ((SpawnCard)playerBotSpawnCard).nodeGraphType = (GraphType)0; ((SpawnCard)playerBotSpawnCard).occupyPosition = false; ((SpawnCard)playerBotSpawnCard).sendOverNetwork = true; ((SpawnCard)playerBotSpawnCard).forbiddenFlags = (NodeFlags)4; ((SpawnCard)playerBotSpawnCard).prefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMaster"); Transform randomSpawnPosition = GetRandomSpawnPosition(owner); if ((Object)(object)randomSpawnPosition == (Object)null) { Debug.LogError((object)"No spawn positions found for playerbot"); return; } DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)playerBotSpawnCard, new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = 3f, maxDistance = 40f, spawnOnTarget = randomSpawnPosition }, RoR2Application.rng); val.ignoreTeamMemberLimit = true; val.teamIndexOverride = (TeamIndex)1; val.onSpawnedServer = delegate(SpawnResult result) { //IL_0000: 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_0065: 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) GameObject spawnedInstance = result.spawnedInstance; if (!((Object)(object)spawnedInstance == (Object)null)) { spawnedInstance.AddComponent<PlayerBotStateMachine>(); BaseAI ai = (BaseAI)(object)spawnedInstance.AddComponent<PlayerBotBaseAI>(); spawnedInstance.AddComponent<AIOwnership>().ownerMaster = owner; CharacterMaster component = spawnedInstance.GetComponent<CharacterMaster>(); ((Object)spawnedInstance.GetComponent<PlayerCharacterMasterController>()).name = "PlayerBot"; component.bodyPrefab = bodyPrefab; component.Respawn(((Component)component).transform.position, ((Component)component).transform.rotation, false); SetRandomSkin(component, bodyPrefab); component.SetFieldValue("aiComponents", spawnedInstance.GetComponents<BaseAI>()); component.destroyOnBodyDeath = false; GiveStartingItems(owner, component); InjectSkillDrivers(spawnedInstance, ai, survivorIndex); if (AutoPurchaseItems.Value) { spawnedInstance.AddComponent<ItemManager>(); } MaybeAttachOperatorDroneSupport(spawnedInstance, bodyPrefab); playerbots.Add(spawnedInstance); } }; try { DirectorCore.instance.TrySpawnObject(val); } catch (Exception ex) { Debug.LogError((object)ex); } Object.Destroy((Object)(object)playerBotSpawnCard); } private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_007d: 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) //IL_00c4: 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_00cb: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex); if ((Object)(object)survivorDef == (Object)null) { return; } if (!survivorDef.CheckRequiredExpansionEnabled((NetworkUser)null)) { Debug.Log((object)"You do not have the proper expansion enabled."); return; } GameObject bodyPrefab = survivorDef.bodyPrefab; if ((Object)(object)bodyPrefab == (Object)null) { return; } PlayerBotSpawnCard playerBotSpawnCard = ScriptableObject.CreateInstance<PlayerBotSpawnCard>(); ((SpawnCard)playerBotSpawnCard).hullSize = (HullClassification)0; ((SpawnCard)playerBotSpawnCard).nodeGraphType = (GraphType)0; ((SpawnCard)playerBotSpawnCard).occupyPosition = false; ((SpawnCard)playerBotSpawnCard).sendOverNetwork = true; ((SpawnCard)playerBotSpawnCard).forbiddenFlags = (NodeFlags)4; ((SpawnCard)playerBotSpawnCard).prefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"); playerBotSpawnCard.bodyPrefab = bodyPrefab; Transform randomSpawnPosition = GetRandomSpawnPosition(owner); if ((Object)(object)randomSpawnPosition == (Object)null) { Debug.LogError((object)"No spawn positions found for playerbot"); return; } DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)playerBotSpawnCard, new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = 3f, maxDistance = 40f, spawnOnTarget = randomSpawnPosition }, RoR2Application.rng); val.ignoreTeamMemberLimit = true; val.teamIndexOverride = (TeamIndex)1; val.onSpawnedServer = delegate(SpawnResult result) { //IL_0000: 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) GameObject spawnedInstance = result.spawnedInstance; if (!((Object)(object)spawnedInstance == (Object)null)) { CharacterMaster component = spawnedInstance.GetComponent<CharacterMaster>(); BaseAI component2 = spawnedInstance.GetComponent<BaseAI>(); spawnedInstance.AddComponent<AIOwnership>().ownerMaster = owner; if (Object.op_Implicit((Object)(object)component)) { ((Object)component).name = "PlayerBot"; component.teamIndex = (TeamIndex)1; SetRandomSkin(component, bodyPrefab); GiveStartingItems(owner, component); component.destroyOnBodyDeath = false; ((Component)component).gameObject.AddComponent<SetDontDestroyOnLoad>(); } InjectSkillDrivers(spawnedInstance, component2, survivorIndex); if (AutoPurchaseItems.Value) { spawnedInstance.AddComponent<ItemManager>(); } MaybeAttachOperatorDroneSupport(spawnedInstance, bodyPrefab); playerbots.Add(spawnedInstance); } }; try { DirectorCore.instance.TrySpawnObject(val); } catch (Exception ex) { Debug.LogError((object)ex); } Object.Destroy((Object)(object)playerBotSpawnCard); } private static void MaybeAttachOperatorDroneSupport(GameObject masterObject, GameObject bodyPrefab) { if (Object.op_Implicit((Object)(object)masterObject) && Object.op_Implicit((Object)(object)bodyPrefab) && EnableDroneSupport != null && EnableDroneSupport.Value) { CharacterBody droneTechBody = BodyPrefabs.DroneTechBody; if ((Object.op_Implicit((Object)(object)droneTechBody) && (Object)(object)bodyPrefab == (Object)(object)((Component)droneTechBody).gameObject && !Object.op_Implicit((Object)(object)masterObject.GetComponent<OperatorDroneSupport>())) || EnableDroneSupportAllBots.Value) { masterObject.AddComponent<OperatorDroneSupport>(); } } } private static Transform GetRandomSpawnPosition(CharacterMaster owner) { if ((Object)(