Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FakeFriend v1.2.0
FakeFriend.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.AI.Walker; using EntityStates.Railgunner.Reload; using FakeFriend.AI; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using RoR2; using RoR2.CharacterAI; using RoR2.Navigation; using RoR2.Skills; using RoR2.UI; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [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("FakeFriend")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("FakeFriend")] [assembly: AssemblyTitle("FakeFriend")] [assembly: AssemblyVersion("1.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FakeFriend { internal static class BotBrain { private static readonly FieldInfo PrimaryField = OverrideField("newPrimarySkill"); private static readonly FieldInfo SecondaryField = OverrideField("newSecondarySkill"); private static readonly FieldInfo UtilityField = OverrideField("newUtilitySkill"); private static readonly FieldInfo SpecialField = OverrideField("newSpecialSkill"); public static void Setup(CharacterMaster master, string bodyName, bool keepOwnAi) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00db: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Invalid comparison between Unknown and I4 master.destroyOnBodyDeath = false; BaseAI component = ((Component)master).GetComponent<BaseAI>(); if (!Object.op_Implicit((Object)(object)component)) { return; } AiSkillHelper aiSkillHelper = AiSkillHelperCatalog.Create(bodyName); if (aiSkillHelper != null) { keepOwnAi = false; } else { master.onBodyStart += ApplyAiSkillOverrides; aiSkillHelper = new DefaultSkillHelper(); } component.fullVision = true; component.neverRetaliateFriendlies = true; component.copyLeaderTarget = true; component.aimVectorDampTime = 0.01f; component.aimVectorMaxSpeed = 180f; component.enemyAttentionDuration = 5f; component.scanState = new SerializableEntityStateType(typeof(Wander)); List<AISkillDriver> list = new List<AISkillDriver>(); AISkillDriver val = ((Component)master).gameObject.AddComponent<AISkillDriver>(); val.customName = "FakeFriend.FarLeash"; val.skillSlot = (SkillSlot)(-1); val.moveTargetType = (TargetType)2; val.minDistance = BotSettings.LeashDistance.Value * 2f; val.movementType = (MovementType)1; val.aimType = (AimType)4; val.buttonPressType = (ButtonPressType)1; val.shouldSprint = true; val.resetCurrentEnemyOnNextDriverSelection = true; val.driverUpdateTimerOverride = 3f; list.Add(val); AISkillDriver[] skillDrivers; if (keepOwnAi) { skillDrivers = component.skillDrivers; foreach (AISkillDriver val2 in skillDrivers) { if (Object.op_Implicit((Object)(object)val2) && (int)val2.moveTargetType != 2) { list.Add(val2); } } } else { skillDrivers = ((Component)master).GetComponents<AISkillDriver>(); foreach (AISkillDriver val3 in skillDrivers) { if ((Object)(object)val3 != (Object)(object)val) { Object.DestroyImmediate((Object)(object)val3); } } } HashSet<AISkillDriver> hashSet = new HashSet<AISkillDriver>(((Component)master).GetComponents<AISkillDriver>()); aiSkillHelper.InjectSkills(((Component)master).gameObject, component); skillDrivers = ((Component)master).GetComponents<AISkillDriver>(); foreach (AISkillDriver item in skillDrivers) { if (!hashSet.Contains(item)) { list.Add(item); } } component.ReplaceSkillDrivers(list.ToArray()); ((Component)master).gameObject.AddComponent<BotController>().Init(aiSkillHelper); } public static void ApplyAiSkillOverrides(CharacterBody body) { DoppelgangerSkillOverride val = (Object.op_Implicit((Object)(object)body) ? ((Component)body).GetComponent<DoppelgangerSkillOverride>() : null); SkillLocator val2 = (Object.op_Implicit((Object)(object)body) ? body.skillLocator : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { Override(val2.primary, val, PrimaryField, body); Override(val2.secondary, val, SecondaryField, body); Override(val2.utility, val, UtilityField, body); Override(val2.special, val, SpecialField, body); } } private static FieldInfo OverrideField(string name) { return typeof(DoppelgangerSkillOverride).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } private static void Override(GenericSkill slot, DoppelgangerSkillOverride overrides, FieldInfo field, CharacterBody body) { if (Object.op_Implicit((Object)(object)slot) && field != null) { object? value = field.GetValue(overrides); SkillDef val = (SkillDef)((value is SkillDef) ? value : null); if (val != null && Object.op_Implicit((Object)(object)val)) { slot.SetSkillOverride((object)((Component)body).gameObject, val, (SkillOverridePriority)3); } } } public static void SetLeader(CharacterMaster master, CharacterBody leader) { GameObject gameObject = (Object.op_Implicit((Object)(object)leader) ? ((Component)leader).gameObject : null); BaseAI[] aiComponents = master.AiComponents; foreach (BaseAI val in aiComponents) { if (Object.op_Implicit((Object)(object)val) && val.leader != null) { val.leader.gameObject = gameObject; } } } } internal sealed class BotItems { private const float SyncInterval = 0.5f; private const float ForgetLossAfter = 5f; private static readonly ItemTier[] RandomTiers; private readonly BotSlot slot; private float timer; private ItemMode lastMode; private readonly Dictionary<ItemTier, int> matched = new Dictionary<ItemTier, int>(); private readonly Dictionary<ItemTier, float> lowerSince = new Dictionary<ItemTier, float>(); private readonly Dictionary<ItemTier, int> hostCounts = new Dictionary<ItemTier, int>(); private readonly List<ItemIndex> pool = new List<ItemIndex>(); public BotItems(BotSlot slot) { this.slot = slot; } public void Reset() { timer = 0f; matched.Clear(); lowerSince.Clear(); lastMode = slot.Items.Value; } public void FixedUpdate(CharacterMaster bot, CharacterMaster host, float deltaTime) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) timer -= deltaTime; if (timer > 0f || !Object.op_Implicit((Object)(object)bot) || !Object.op_Implicit((Object)(object)bot.inventory) || !Object.op_Implicit((Object)(object)host) || !Object.op_Implicit((Object)(object)host.inventory)) { return; } timer = 0.5f; ItemMode value = slot.Items.Value; if (value != lastMode) { matched.Clear(); lowerSince.Clear(); if (value == ItemMode.RandomSameTier && lastMode == ItemMode.CopyHost) { CountTiers(host.inventory); foreach (KeyValuePair<ItemTier, int> hostCount in hostCounts) { matched[hostCount.Key] = hostCount.Value; } } lastMode = value; } switch (value) { case ItemMode.CopyHost: CopyFrom(host.inventory, bot.inventory); break; case ItemMode.RandomSameTier: MatchTiers(host.inventory, bot.inventory); break; default: Clear(bot.inventory); break; } } public static bool IsAllowed(ItemIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 ItemDef itemDef = ItemCatalog.GetItemDef(index); if (!Object.op_Implicit((Object)(object)itemDef) || itemDef.hidden || (int)itemDef.tier == 5) { return false; } if (itemDef.ContainsTag((ItemTag)13) || itemDef.ContainsTag((ItemTag)9) || itemDef.ContainsTag((ItemTag)10) || itemDef.ContainsTag((ItemTag)18) || itemDef.ContainsTag((ItemTag)17) || itemDef.ContainsTag((ItemTag)32)) { return false; } if ((Object)(object)itemDef != (Object)(object)Items.ExtraLife && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeConsumed && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoid) { return (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoidConsumed; } return false; } private static void CopyFrom(Inventory source, Inventory target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) for (ItemIndex val = (ItemIndex)0; (int)val < ItemCatalog.itemCount; val = (ItemIndex)(val + 1)) { if (IsAllowed(val)) { int num = source.GetItemCountPermanent(val) - target.GetItemCountPermanent(val); if (num > 0) { target.GiveItemPermanent(val, num); } else if (num < 0) { target.RemoveItemPermanent(val, -num); } } } } private static void Clear(Inventory target) { //IL_0001: 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_002a: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) for (ItemIndex val = (ItemIndex)0; (int)val < ItemCatalog.itemCount; val = (ItemIndex)(val + 1)) { if (IsAllowed(val)) { int itemCountPermanent = target.GetItemCountPermanent(val); if (itemCountPermanent > 0) { target.RemoveItemPermanent(val, itemCountPermanent); } } } } private void CountTiers(Inventory host) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_000f: 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) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) hostCounts.Clear(); for (ItemIndex val = (ItemIndex)0; (int)val < ItemCatalog.itemCount; val = (ItemIndex)(val + 1)) { if (IsAllowed(val)) { int itemCountPermanent = host.GetItemCountPermanent(val); if (itemCountPermanent > 0) { ItemTier tier = ItemCatalog.GetItemDef(val).tier; hostCounts.TryGetValue(tier, out var value); hostCounts[tier] = value + itemCountPermanent; } } } } private void MatchTiers(Inventory host, Inventory bot) { //IL_0017: 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_002d: 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_004d: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) CountTiers(host); ItemTier[] randomTiers = RandomTiers; foreach (ItemTier val in randomTiers) { hostCounts.TryGetValue(val, out var value); matched.TryGetValue(val, out var value2); if (value > value2) { GiveRandom(bot, val, value - value2); matched[val] = value; lowerSince.Remove(val); } else if (value < value2) { if (!lowerSince.TryGetValue(val, out var value3)) { lowerSince[val] = Time.time; } else if (Time.time - value3 > 5f) { matched[val] = value; lowerSince.Remove(val); } } else { lowerSince.Remove(val); } } } private void GiveRandom(Inventory bot, ItemTier tier, int count) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) pool.Clear(); List<PickupIndex> list = DropList(tier); if (list != null) { foreach (PickupIndex item in list) { PickupDef pickupDef = PickupCatalog.GetPickupDef(item); if (pickupDef != null && (int)pickupDef.itemIndex != -1 && IsAllowed(pickupDef.itemIndex)) { pool.Add(pickupDef.itemIndex); } } } if (pool.Count != 0) { for (int i = 0; i < count; i++) { bot.GiveItemPermanent(pool[Random.Range(0, pool.Count)], 1); } } } private static List<PickupIndex> DropList(ItemTier tier) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown Run instance = Run.instance; return (int)tier switch { 0 => instance.availableTier1DropList, 1 => instance.availableTier2DropList, 2 => instance.availableTier3DropList, 4 => instance.availableBossDropList, 3 => instance.availableLunarItemDropList, 6 => instance.availableVoidTier1DropList, 7 => instance.availableVoidTier2DropList, 8 => instance.availableVoidTier3DropList, 9 => instance.availableVoidBossDropList, _ => null, }; } static BotItems() { ItemTier[] array = new ItemTier[9]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); RandomTiers = (ItemTier[])(object)array; } } internal sealed class BotManager { public readonly FakeBot[] Bots; public BotManager() { Bots = new FakeBot[4]; for (int i = 0; i < Bots.Length; i++) { Bots[i] = new FakeBot(BotSettings.Slots[i]); } } public void Hook() { Run.onRunStartGlobal += OnRunStart; Run.onRunDestroyGlobal += OnRunDestroy; Stage.onServerStageBegin += OnStageBegin; } public void Unhook() { Run.onRunStartGlobal -= OnRunStart; Run.onRunDestroyGlobal -= OnRunDestroy; Stage.onServerStageBegin -= OnStageBegin; if (NetworkServer.active) { DespawnAll(); } } private void OnRunStart(Run run) { FakeBot[] bots = Bots; for (int i = 0; i < bots.Length; i++) { bots[i].OnRunStart(); } } private void OnRunDestroy(Run run) { FakeBot[] bots = Bots; for (int i = 0; i < bots.Length; i++) { bots[i].OnRunDestroy(); } } private void OnStageBegin(Stage stage) { FakeBot[] bots = Bots; for (int i = 0; i < bots.Length; i++) { bots[i].OnStageBegin(); } } public void FixedUpdate() { if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || Run.instance.isGameOverServer) { return; } if (!BotSettings.Enabled.Value) { DespawnAll(); } else if (Object.op_Implicit((Object)(object)Stage.instance) && StageAllowsBots()) { CharacterMaster host = FindHostMaster(); FakeBot[] bots = Bots; for (int i = 0; i < bots.Length; i++) { bots[i].FixedUpdate(host, Time.fixedDeltaTime); } } } public void DespawnAll() { FakeBot[] bots = Bots; foreach (FakeBot fakeBot in bots) { if (Object.op_Implicit((Object)(object)fakeBot.Master)) { fakeBot.Despawn(); } } } public void BringAllToMe() { FakeBot[] bots = Bots; for (int i = 0; i < bots.Length; i++) { bots[i].BringToMe(); } } private static bool StageAllowsBots() { SceneInfo instance = SceneInfo.instance; if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.sceneDef)) { return !instance.sceneDef.suppressPlayerEntry; } return false; } public static CharacterMaster FindHostMaster() { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser != null && Object.op_Implicit((Object)(object)firstLocalUser.cachedMaster)) { return firstLocalUser.cachedMaster; } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master)) { return instance.master; } } return null; } public static CharacterBody FindLeader(CharacterBody bot) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) CharacterMaster val = FindHostMaster(); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBody() : null); if (IsAlive(val2)) { return val2; } CharacterBody result = null; float num = float.PositiveInfinity; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val3 = ((Object.op_Implicit((Object)(object)instance) && instance.isConnected && Object.op_Implicit((Object)(object)instance.master)) ? instance.master.GetBody() : null); if (IsAlive(val3)) { float num2; if (!Object.op_Implicit((Object)(object)bot)) { num2 = 0f; } else { Vector3 val4 = val3.corePosition - bot.corePosition; num2 = ((Vector3)(ref val4)).sqrMagnitude; } float num3 = num2; if (num3 < num) { result = val3; num = num3; } } } return result; } public static bool IsAlive(CharacterBody body) { if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent)) { return body.healthComponent.alive; } return false; } public static Vector3 FindSpotNear(Vector3 center, CharacterBody body) { //IL_0039: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) SceneInfo instance = SceneInfo.instance; bool flag = Object.op_Implicit((Object)(object)body) && body.isFlying; NodeGraph val = (Object.op_Implicit((Object)(object)instance) ? instance.GetNodeGraph((GraphType)(flag ? 1 : 0)) : null); if (!Object.op_Implicit((Object)(object)val)) { return center; } HullMask val2 = (HullMask)(1 << (Object.op_Implicit((Object)(object)body) ? ((int)body.hullClassification) : 0)); List<NodeIndex> list = val.FindNodesInRangeWithFlagConditions(center, 3f, 15f, val2, (NodeFlags)0, (NodeFlags)4, false); if (list.Count == 0) { list = val.FindNodesInRange(center, 0f, 40f, val2); } Vector3 result = default(Vector3); if (list.Count > 0 && val.GetNodePosition(list[Random.Range(0, list.Count)], ref result)) { return result; } return center; } public static Vector3 Flat(Vector3 direction) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) direction.y = 0f; if (!(((Vector3)(ref direction)).sqrMagnitude > 0.01f)) { return Vector3.forward; } return direction; } public static void PlayTeleportEffect(CharacterBody body, Vector3 position) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)Run.instance)) { GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(((Component)body).gameObject); if (Object.op_Implicit((Object)(object)teleportEffectPrefab)) { EffectManager.SimpleEffect(teleportEffectPrefab, position, Quaternion.identity, true); } } } } internal sealed class BotPanel { private enum AiKind { Tuned, Mod, Generic } private class Icon { public string Name; public string Subtitle; public string Description; public Texture Texture; public Rect Uv = new Rect(0f, 0f, 1f, 1f); public Color Color = Styles.TextDim; public bool Locked; } private sealed class SurvivorIcon : Icon { public SurvivorDef Def; public AiKind Ai; } private sealed class SkillRow { public string Title; public int Slot; public readonly List<Icon> Variants = new List<Icon>(); } private sealed class SlotView { public string Survivor; public SurvivorIcon Icon; public readonly List<Icon> Skins = new List<Icon>(); public readonly List<SkillRow> Skills = new List<SkillRow>(); } private const int WindowId = 17990; private const float WindowWidth = 548f; private const float ContentWidth = 520f; private const float SheetWidth = 496f; private const float ScrollbarWidth = 12f; private const float ButtonWidth = 172f; private const float ButtonHeight = 38f; private const float Margin = 16f; private static readonly string[] ItemModeNames = new string[3] { "Copy mine", "Random, same rarity", "None" }; private static readonly string[] ItemModeHelp = new string[3] { "Has the same items as you, kept in sync.", "Whenever you get an item, it gets a random one of the same rarity.", "Gets no items." }; private readonly BotManager manager; private readonly UiBlocker blocker = new UiBlocker(); private readonly List<Action> queued = new List<Action>(); private readonly List<MPEventSystem> cursorHolders = new List<MPEventSystem>(); private readonly List<Image> cursorImages = new List<Image>(); private readonly Vector3[] cursorCorners = (Vector3[])(object)new Vector3[4]; private List<SurvivorIcon> survivors; private readonly Dictionary<SurvivorDef, SurvivorIcon> survivorByDef = new Dictionary<SurvivorDef, SurvivorIcon>(); private readonly SlotView[] views = new SlotView[4]; private bool open; private bool openedInRun; private bool inLobby; private float lobbyCheckTimer; private int selected; private Rect windowRect; private Rect drawnWindowRect; private bool positioned; private float lastHeight; private float guiScale = 1f; private Vector2 survivorScroll; private Vector2 skinScroll; private Icon hovered; private Texture2D logo; public static bool CapturesInput { get; private set; } private static bool IsHost { get { if (!NetworkServer.active) { return !NetworkClient.active; } return true; } } private bool ButtonVisible { get { if (IsHost) { if (!inLobby) { if (Object.op_Implicit((Object)(object)Run.instance)) { if (!open) { return PauseScreenController.instancesList.Count > 0; } return true; } return false; } return true; } return false; } } public BotPanel(BotManager manager) { this.manager = manager; for (int i = 0; i < views.Length; i++) { views[i] = new SlotView(); } } public void OnKey() { if (inLobby || Object.op_Implicit((Object)(object)Run.instance)) { Toggle(); } } private void Toggle() { if (open) { Close(); } else { Open(); } } private void Open() { if (open) { return; } open = true; openedInRun = Object.op_Implicit((Object)(object)Run.instance); positioned = false; if (!openedInRun) { return; } CapturesInput = true; foreach (MPEventSystem readOnlyInstances in MPEventSystem.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances)) { int cursorOpenerCount = readOnlyInstances.cursorOpenerCount; readOnlyInstances.cursorOpenerCount = cursorOpenerCount + 1; cursorHolders.Add(readOnlyInstances); } } } private void Close() { if (!open) { return; } open = false; CapturesInput = false; foreach (MPEventSystem cursorHolder in cursorHolders) { if (Object.op_Implicit((Object)(object)cursorHolder)) { int cursorOpenerCount = cursorHolder.cursorOpenerCount; cursorHolder.cursorOpenerCount = cursorOpenerCount - 1; } } cursorHolders.Clear(); } public void Destroy() { Close(); blocker.Destroy(); } public void Update() { lobbyCheckTimer -= Time.unscaledDeltaTime; if (lobbyCheckTimer <= 0f) { lobbyCheckTimer = 0.5f; inLobby = !Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Object.FindObjectOfType<CharacterSelectController>()); } if (open && (openedInRun != Object.op_Implicit((Object)(object)Run.instance) || (!Object.op_Implicit((Object)(object)Run.instance) && !inLobby))) { Close(); } if (queued.Count > 0) { Action[] array = queued.ToArray(); queued.Clear(); Action[] array2 = array; foreach (Action action in array2) { try { action(); } catch (Exception ex) { FakeFriendPlugin.Log.LogError((object)ex); } } } if (open) { EnsureCatalog(); if (!BotSettings.Slots[selected].Active.Value) { selected = FirstActiveSlot(); } } if (!open && !ButtonVisible) { blocker.Begin(); blocker.End(); } } private void Queue(Action action) { queued.Add(action); } private static int FirstActiveSlot() { for (int i = 0; i < 4; i++) { if (BotSettings.Slots[i].Active.Value) { return i; } } return 0; } private void AddBot() { BotSlot[] slots = BotSettings.Slots; foreach (BotSlot botSlot in slots) { if (botSlot.Active.Value) { continue; } HashSet<string> hashSet = new HashSet<string>(); BotSlot[] slots2 = BotSettings.Slots; foreach (BotSlot botSlot2 in slots2) { if (botSlot2.Active.Value) { hashSet.Add(botSlot2.Survivor.Value); } } foreach (SurvivorIcon survivor in survivors) { if (!survivor.Locked && !hashSet.Contains(survivor.Def.cachedName)) { botSlot.SelectSurvivor(survivor.Def); break; } } botSlot.Active.Value = true; selected = botSlot.Index; break; } } private void RemoveBot(BotSlot slot) { slot.Active.Value = false; selected = FirstActiveSlot(); } private void EnsureCatalog() { if (survivors == null) { survivors = new List<SurvivorIcon>(); foreach (SurvivorDef orderedSurvivorDef in SurvivorCatalog.orderedSurvivorDefs) { if (Object.op_Implicit((Object)(object)orderedSurvivorDef) && !orderedSurvivorDef.hidden && BotSettings.IsUsable(orderedSurvivorDef)) { SurvivorIcon survivorIcon = MakeSurvivorIcon(orderedSurvivorDef); survivors.Add(survivorIcon); survivorByDef[orderedSurvivorDef] = survivorIcon; } } } BotSlot[] slots = BotSettings.Slots; foreach (BotSlot botSlot in slots) { SlotView slotView = views[botSlot.Index]; if (slotView.Survivor != botSlot.Survivor.Value) { BuildView(botSlot, slotView); } } } private static SurvivorIcon MakeSurvivorIcon(SurvivorDef def) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = def.bodyPrefab.GetComponent<CharacterBody>(); bool flag = def.CheckLocalUserHasRequiredEntitlement(); AiKind ai = ((!AiSkillHelperCatalog.Has(BodyCatalog.GetBodyName(component.bodyIndex))) ? ((MasterCatalog.FindAiMasterIndexForBody(component.bodyIndex) != MasterIndex.none) ? AiKind.Mod : AiKind.Generic) : AiKind.Tuned); return new SurvivorIcon { Def = def, Ai = ai, Name = Helpers.Lang(def.displayNameToken, def.cachedName), Subtitle = Helpers.Lang(component.subtitleNameToken, ""), Description = ((!flag) ? "You don't own the DLC for this survivor." : AiDescription(ai)), Texture = component.portraitIcon, Color = ((def.primaryColor.a > 0f) ? def.primaryColor : Styles.Accent), Locked = !flag }; } private static string AiDescription(AiKind ai) { return ai switch { AiKind.Tuned => "Hand-tuned AI for this survivor (from PlayerBots): knows when to use every skill.", AiKind.Mod => "Uses the AI that came with this survivor's mod.", _ => "No AI was made for this survivor, so the bot uses a generic one and plays simpler.", }; } private void BuildView(BotSlot slot, SlotView view) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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) view.Survivor = slot.Survivor.Value; view.Skins.Clear(); view.Skills.Clear(); SurvivorDef val = slot.ResolveSurvivor(); if (!Object.op_Implicit((Object)(object)val)) { view.Icon = null; return; } view.Icon = (survivorByDef.TryGetValue(val, out var value) ? value : MakeSurvivorIcon(val)); CharacterBody component = val.bodyPrefab.GetComponent<CharacterBody>(); BodyIndex bodyIndex = component.bodyIndex; SkinDef[] bodySkinDefs = SkinCatalog.GetBodySkinDefs(bodyIndex); foreach (SkinDef val2 in bodySkinDefs) { Icon icon = new Icon { Name = Helpers.Lang(Object.op_Implicit((Object)(object)val2) ? val2.nameToken : null, Object.op_Implicit((Object)(object)val2) ? ((Object)val2).name : "?"), Subtitle = "Skin", Color = view.Icon.Color }; SetSprite(icon, Object.op_Implicit((Object)(object)val2) ? val2.icon : null); view.Skins.Add(icon); } GenericSkill[] array = BodyCatalog.GetBodyPrefabSkillSlots(bodyIndex) ?? Array.Empty<GenericSkill>(); SkillLocator component2 = ((Component)component).GetComponent<SkillLocator>(); for (int j = 0; j < array.Length; j++) { GenericSkill val3 = array[j]; if (!Object.op_Implicit((Object)(object)val3) || val3.hideInLoadoutSelect || !Object.op_Implicit((Object)(object)val3.skillFamily) || val3.skillFamily.variants.Length <= 1) { continue; } SkillRow skillRow = new SkillRow { Slot = j, Title = SlotTitle(val3, component2) }; Variant[] variants = val3.skillFamily.variants; foreach (Variant val4 in variants) { Icon icon2 = new Icon { Subtitle = skillRow.Title, Color = view.Icon.Color }; if (Object.op_Implicit((Object)(object)val4.skillDef)) { icon2.Name = Helpers.Lang(val4.skillDef.skillNameToken, val4.skillDef.skillName); icon2.Description = Helpers.StripTags(Helpers.Lang(val4.skillDef.skillDescriptionToken, "")); SetSprite(icon2, val4.skillDef.icon); } else { icon2.Name = "?"; } skillRow.Variants.Add(icon2); } view.Skills.Add(skillRow); } } private static string SlotTitle(GenericSkill slot, SkillLocator locator) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown if (!string.IsNullOrWhiteSpace(slot.loadoutTitleToken)) { return Helpers.Lang(slot.loadoutTitleToken, "Skill"); } SkillSlot val = (SkillSlot)((!Object.op_Implicit((Object)(object)locator)) ? (-1) : ((int)locator.FindSkillSlot(slot))); return (int)val switch { 0 => Helpers.Lang("LOADOUT_SKILL_PRIMARY", "Primary"), 1 => Helpers.Lang("LOADOUT_SKILL_SECONDARY", "Secondary"), 2 => Helpers.Lang("LOADOUT_SKILL_UTILITY", "Utility"), 3 => Helpers.Lang("LOADOUT_SKILL_SPECIAL", "Special"), _ => Helpers.Lang("LOADOUT_SKILL_MISC", "Misc"), }; } private static void SetSprite(Icon icon, Sprite sprite) { //IL_0023: 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) if (Object.op_Implicit((Object)(object)sprite) && Object.op_Implicit((Object)(object)sprite.texture)) { icon.Texture = (Texture)(object)sprite.texture; icon.Uv = Helpers.SpriteUv(sprite); } } public void OnGUI() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between Unknown and I4 //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01ca: Expected O, but got Unknown //IL_01c5: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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) bool buttonVisible = ButtonVisible; if (!buttonVisible && !open) { return; } Styles.Init(); if (!Object.op_Implicit((Object)(object)logo)) { logo = LoadLogo(); } float num = (float)Screen.height / 1080f * BotSettings.UiScale.Value; num = Mathf.Min(num, (float)Screen.width / 580f); if (lastHeight > 0f) { num = Mathf.Min(num, (float)Screen.height / (lastHeight + 38f + 48f)); } num = (guiScale = Mathf.Max(num, 0.3f)); Matrix4x4 matrix = GUI.matrix; GUISkin skin = GUI.skin; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); GUI.skin = Styles.Skin; float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; bool flag = (int)Event.current.type == 7; if (flag) { blocker.Begin(); } if (buttonVisible) { Rect rect = DrawTopButton(num2); if (flag) { blocker.Add(Scaled(rect, num)); } } if (open && survivors != null) { if (!positioned) { windowRect = new Rect(num2 - 548f - 16f, 62f, 548f, 0f); positioned = true; } drawnWindowRect = windowRect; windowRect = GUILayout.Window(17990, new Rect(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, 548f, 0f), new WindowFunction(DrawWindow), GUIContent.none, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(548f) }); ((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, num2 - ((Rect)(ref windowRect)).width)); ((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, num3 - ((Rect)(ref windowRect)).height)); lastHeight = ((Rect)(ref windowRect)).height; if (flag) { blocker.Add(Scaled(windowRect, num)); } } if (buttonVisible) { DrawGameCursor(Vector2.zero); } if (flag) { blocker.End(); } GUI.matrix = matrix; GUI.skin = skin; } private static Rect Scaled(Rect rect, float scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref rect)).x * scale, ((Rect)(ref rect)).y * scale, ((Rect)(ref rect)).width * scale, ((Rect)(ref rect)).height * scale); } private Rect DrawTopButton(float viewWidth) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00af: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00fd: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(viewWidth - 172f - 16f, 16f, 172f, 38f); Event current = Event.current; bool flag = ((Rect)(ref val)).Contains(current.mousePosition); if (flag && (int)current.type == 0 && current.button == 0) { current.Use(); Queue(Toggle); } if ((int)current.type == 7) { Color val2 = (open ? Styles.Accent : (flag ? Styles.CellHover : Styles.WindowBg)); Styles.Fill(val, 10, open ? Styles.Accent : Color32.op_Implicit(new Color32((byte)44, (byte)52, (byte)68, byte.MaxValue))); Styles.Fill(Helpers.Inset(val, 1f), 10, val2); if (Object.op_Implicit((Object)(object)logo)) { Rect val3 = new Rect(((Rect)(ref val)).x + 4f, ((Rect)(ref val)).y + 4f, 30f, 30f); GUI.DrawTexture(val3, (Texture)(object)logo); Styles.Mask(val3, 7, val2); } Color val4 = (open ? Styles.TextDark : Color.white); GUI.Label(new Rect(((Rect)(ref val)).x + 41f, ((Rect)(ref val)).y, 100f, ((Rect)(ref val)).height), "<b><color=#" + ColorUtility.ToHtmlStringRGB(val4) + ">FakeFriend</color></b>", Styles.Label); int num = (BotSettings.Enabled.Value ? BotSettings.ActiveCount : 0); Rect val5 = new Rect(((Rect)(ref val)).xMax - 31f, ((Rect)(ref val)).y + 8f, 22f, 22f); Styles.Circle(val5, open ? Styles.TextDark : ((num > 0) ? Styles.Accent : Styles.CellHover)); GUI.Label(val5, $"<b><color=#{ColorUtility.ToHtmlStringRGB(open ? Styles.Accent : Styles.TextDark)}>{num}</color></b>", Styles.Center); } return val; } private void DrawWindow(int id) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) hovered = null; DrawHeader(); if (!IsHost) { GUILayout.Label("You are a client in someone else's lobby: only the host's FakeFriends join, so these settings do nothing here.", Styles.Banner, Array.Empty<GUILayoutOption>()); } DrawTabs(); BotSlot botSlot = BotSettings.Slots[selected]; if (!botSlot.Active.Value) { DrawEmptyState(); } else { GUILayout.BeginVertical(Styles.Card, Array.Empty<GUILayoutOption>()); DrawHero(botSlot); DrawSurvivors(botSlot); DrawSkins(botSlot); DrawSkills(botSlot); DrawItems(botSlot); GUILayout.EndVertical(); } DrawFooter(); DrawGameCursor(((Rect)(ref drawnWindowRect)).position); GUI.DragWindow(new Rect(0f, 0f, 428f, 52f)); } private void DrawHeader() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }); Rect rect = GUILayoutUtility.GetRect(38f, 38f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(38f), GUILayout.Height(38f) }); if (Object.op_Implicit((Object)(object)logo) && (int)Event.current.type == 7) { GUI.DrawTexture(rect, (Texture)(object)logo); Styles.Mask(rect, 9, Styles.WindowBg); } GUILayout.Space(8f); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label("FakeFriend", Styles.Title, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) }); int activeCount = BotSettings.ActiveCount; GUILayout.Label((activeCount == 0) ? "No AI teammates yet" : ($"{activeCount} of {4} AI teammates" + (BotSettings.Enabled.Value ? "" : " · switched off")), Styles.Subtitle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(BotSettings.Enabled.Value ? "<b>ON</b>" : "<b>OFF</b>", Styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }); if (Switch(BotSettings.Enabled.Value)) { Queue(delegate { BotSettings.Enabled.Value = !BotSettings.Enabled.Value; }); } GUILayout.Space(10f); if (GUILayout.Button("×", Styles.Close, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) })) { Queue(Close); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(6f); } private bool Switch(bool on) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_00d6: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(50f, 26f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(50f), GUILayout.Height(26f) }); Event current = Event.current; bool flag = ((Rect)(ref rect)).Contains(current.mousePosition); if ((int)current.type == 7) { Color val = (on ? Styles.Green : Color32.op_Implicit(new Color32((byte)58, (byte)64, (byte)80, byte.MaxValue))); if (flag) { val = Color.Lerp(val, Color.white, 0.15f); } Styles.Fill(rect, 10, val); Styles.Circle(new Rect(on ? (((Rect)(ref rect)).xMax - 23f) : (((Rect)(ref rect)).x + 3f), ((Rect)(ref rect)).y + 3f, 20f, 20f), Color.white); } if (flag && (int)current.type == 0 && current.button == 0) { current.Use(); return true; } return false; } private void DrawTabs() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0128: Invalid comparison between Unknown and I4 //IL_00c4: 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_012e: Unknown result type (might be due to invalid IL or missing references) float num = 125.5f; Rect rect = GUILayoutUtility.GetRect(520f, 54f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(520f), GUILayout.Height(54f) }); Event current = Event.current; int num2 = 0; bool flag = false; BotSlot[] slots = BotSettings.Slots; Rect rect2 = default(Rect); foreach (BotSlot botSlot in slots) { bool flag2 = !botSlot.Active.Value; if (flag2 && (flag || !IsHost)) { continue; } flag = flag || flag2; ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + (float)num2 * (num + 6f), ((Rect)(ref rect)).y, num, ((Rect)(ref rect)).height); num2++; bool flag3 = ((Rect)(ref rect2)).Contains(current.mousePosition); if (flag3 && (int)current.type == 0 && current.button == 0) { current.Use(); int index = botSlot.Index; if (flag2) { Queue(AddBot); } else { Queue(delegate { selected = index; }); } } if ((int)current.type == 7) { if (flag2) { DrawAddTab(rect2, flag3); } else { DrawBotTab(rect2, botSlot, flag3); } } } GUILayout.Space(4f); } private void DrawBotTab(Rect rect, BotSlot slot, bool hover) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) bool num = slot.Index == selected; Color val = (num ? Styles.CardBg : (hover ? Styles.CellHover : Styles.CellBg)); Styles.Fill(rect, 10, val); if (num) { Styles.Ring(rect, 10, Styles.Accent); } SurvivorIcon icon = views[slot.Index].Icon; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f, 38f, 38f); if (icon != null && Object.op_Implicit((Object)(object)icon.Texture)) { GUI.DrawTextureWithTexCoords(val2, icon.Texture, icon.Uv, true); } Styles.Mask(val2, 8, val); float num2 = ((Rect)(ref val2)).xMax + 8f; float num3 = ((Rect)(ref rect)).xMax - num2 - 6f; GUI.Label(new Rect(num2, ((Rect)(ref rect)).y + 9f, num3, 18f), slot.Name, Styles.TabName); GUI.Label(new Rect(num2, ((Rect)(ref rect)).y + 27f, num3, 16f), (icon != null) ? icon.Name : "?", Styles.TabSub); FakeBot fakeBot = manager.Bots[slot.Index]; if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)fakeBot.Master)) { Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(num2, ((Rect)(ref rect)).yMax - 9f, num3, 3f); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.5f); GUI.DrawTexture(val3, (Texture)(object)Texture2D.whiteTexture); float num4 = (fakeBot.IsAlive ? fakeBot.Body.healthComponent.combinedHealthFraction : 0f); GUI.color = ((num4 > 0.5f) ? Styles.Green : ((num4 > 0.25f) ? Styles.Gold : Styles.Red)); GUI.DrawTexture(new Rect(((Rect)(ref val3)).x, ((Rect)(ref val3)).y, ((Rect)(ref val3)).width * num4, ((Rect)(ref val3)).height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } } private static void DrawAddTab(Rect rect, bool hover) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) Styles.Fill(rect, 10, hover ? Styles.CellHover : Color32.op_Implicit(new Color32((byte)18, (byte)22, (byte)30, byte.MaxValue))); Styles.Ring(rect, 10, hover ? Styles.Accent : Color32.op_Implicit(new Color32((byte)44, (byte)52, (byte)68, byte.MaxValue))); GUI.Label(rect, hover ? "<b><color=#6ec8f5>+ Add FakeFriend</color></b>" : "<b><color=#8a94a6>+ Add FakeFriend</color></b>", Styles.Center); } private void DrawEmptyState() { GUILayout.BeginVertical(Styles.Card, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) }); GUILayout.FlexibleSpace(); GUILayout.Label("<b>No FakeFriends in your team.</b>", Styles.Center, Array.Empty<GUILayoutOption>()); GUILayout.Label("Add up to four AI teammates and pick who each of them plays.", Styles.DimCenter, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUI.enabled = IsHost; if (GUILayout.Button("+ Add FakeFriend", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(190f), GUILayout.Height(34f) })) { Queue(AddBot); } GUI.enabled = true; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } private void DrawHero(BotSlot slot) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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) SurvivorIcon icon = views[slot.Index].Icon; FakeBot fakeBot = manager.Bots[slot.Index]; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(88f) }); Rect rect = GUILayoutUtility.GetRect(84f, 84f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(84f), GUILayout.Height(84f) }); if ((int)Event.current.type == 7) { Styles.Fill(rect, 12, Styles.CellBg); if (icon != null && Object.op_Implicit((Object)(object)icon.Texture)) { GUI.DrawTextureWithTexCoords(rect, icon.Texture, icon.Uv, true); } Styles.Mask(rect, 12, Styles.CardBg); Styles.Ring(rect, 12, icon?.Color ?? Styles.Accent); } GUILayout.Space(12f); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label(slot.Name.ToUpperInvariant(), Styles.Section, Array.Empty<GUILayoutOption>()); GUILayout.Label((icon != null) ? icon.Name : "?", Styles.HeroName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (icon != null) { DrawAiChip(icon.Ai); if (!string.IsNullOrEmpty(icon.Subtitle)) { GUILayout.Label(icon.Subtitle, Styles.Dim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) }); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (Object.op_Implicit((Object)(object)Run.instance)) { GUILayout.Label(fakeBot.Status(), Styles.Dim, Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); if (IsHost) { if (Object.op_Implicit((Object)(object)Run.instance)) { GUI.enabled = fakeBot.IsOutdated; if (GUILayout.Button(fakeBot.IsOutdated ? "Apply changes" : "Up to date", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { Queue(fakeBot.Apply); } GUI.enabled = fakeBot.IsAlive; if (GUILayout.Button("Bring to me", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { Queue(fakeBot.BringToMe); } GUI.enabled = true; } else { GUILayout.Space(30f); } if (GUILayout.Button("Remove", Styles.DangerButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { Queue(delegate { RemoveBot(slot); }); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } private static void DrawAiChip(AiKind ai) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) string text; Color backgroundColor; switch (ai) { case AiKind.Tuned: text = "TUNED AI"; backgroundColor = Styles.Green; break; case AiKind.Mod: text = "MOD AI"; backgroundColor = Styles.Gold; break; default: text = "GENERIC AI"; backgroundColor = Color32.op_Implicit(new Color32((byte)150, (byte)158, (byte)174, byte.MaxValue)); break; } Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = backgroundColor; GUILayout.Label(text, Styles.Chip, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) }); GUI.backgroundColor = backgroundColor2; } private void DrawSurvivors(BotSlot slot) { GUILayout.Label("CHARACTER", Styles.Section, Array.Empty<GUILayoutOption>()); SurvivorDef current = slot.ResolveSurvivor(); int num = DrawGrid(survivors.Count, (int i) => survivors[i], (int i) => (Object)(object)survivors[i].Def == (Object)(object)current, 64f, 64f, 2.5f, ref survivorScroll, 496f); if (num >= 0 && !survivors[num].Locked) { SurvivorDef def = survivors[num].Def; Queue(delegate { slot.SelectSurvivor(def); }); } } private void DrawSkins(BotSlot slot) { List<Icon> skins = views[slot.Index].Skins; if (skins.Count <= 1) { return; } int selectedSkin = ((slot.Skin.Value >= 0 && slot.Skin.Value < skins.Count) ? slot.Skin.Value : 0); GUILayout.Label("SKIN <color=#eaeef4>" + skins[selectedSkin].Name + "</color>", Styles.Section, Array.Empty<GUILayoutOption>()); int index = DrawGrid(skins.Count, (int i) => skins[i], (int i) => i == selectedSkin, 48f, 48f, 2f, ref skinScroll, 496f); if (index >= 0) { Queue(delegate { slot.Skin.Value = index; }); } } private void DrawSkills(BotSlot slot) { //IL_0113: 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) List<SkillRow> skills = views[slot.Index].Skills; if (skills.Count == 0) { return; } GUILayout.Label("SKILLS", Styles.Section, Array.Empty<GUILayoutOption>()); foreach (SkillRow row in skills) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(row.Title, Styles.Dim, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(92f), GUILayout.Height(44f) }); uint chosen = slot.GetSkill(row.Slot); if (chosen >= row.Variants.Count) { chosen = 0u; } Vector2 scroll = Vector2.zero; int index = DrawGrid(row.Variants.Count, (int i) => row.Variants[i], (int i) => i == chosen, 44f, 44f, 0f, ref scroll, 400f); GUILayout.EndHorizontal(); if (index >= 0) { int skillSlot = row.Slot; Queue(delegate { slot.SetSkill(skillSlot, (uint)index); }); } } } private void DrawItems(BotSlot slot) { GUILayout.Label("ITEMS", Styles.Section, Array.Empty<GUILayoutOption>()); int value = (int)slot.Items.Value; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int newMode = GUILayout.Toolbar(value, ItemModeNames, Styles.Segment, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); if (newMode != value) { Queue(delegate { slot.Items.Value = (ItemMode)newMode; }); } GUILayout.Label(ItemModeHelp[Mathf.Clamp(value, 0, ItemModeHelp.Length - 1)], Styles.Dim, Array.Empty<GUILayoutOption>()); } private void DrawFooter() { //IL_00e6: 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_0055: Unknown result type (might be due to invalid IL or missing references) string text2; string text3; if (hovered != null) { string text = (string.IsNullOrEmpty(hovered.Subtitle) ? "" : (" <size=12><color=#8a94a6>" + hovered.Subtitle + "</color></size>")); text2 = "<b><color=#" + ColorUtility.ToHtmlStringRGB(hovered.Color) + ">" + hovered.Name + "</color></b>" + text; text3 = (string.IsNullOrEmpty(hovered.Description) ? " " : hovered.Description); } else { text2 = "<color=#8a94a6>Hover over something to see what it is.</color>"; text3 = (Object.op_Implicit((Object)(object)Run.instance) ? $"{BotSettings.PanelKey.Value} or the FakeFriend button (in the pause menu) opens this menu. Changes to a bot's character apply with Apply changes." : $"Your FakeFriends join next to you when the run starts. In the run, {BotSettings.PanelKey.Value} opens this menu."); } GUILayout.Space(4f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(58f) }); GUILayout.Label(text2, Styles.Small, Array.Empty<GUILayoutOption>()); GUILayout.Label(text3, Styles.Dim, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); } private int DrawGrid(int count, Func<int, Icon> iconAt, Func<int, bool> isSelected, float cellWidth, float cellHeight, float maxRows, ref Vector2 scroll, float width) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Invalid comparison between Unknown and I4 //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; int result = -1; int num = Mathf.Max(1, Mathf.FloorToInt((width - 12f) / cellWidth)); int num2 = (count + num - 1) / num; float num3 = Mathf.Max((float)num2 * cellHeight, 1f); bool flag = maxRows > 0f && (float)num2 > maxRows; float num4 = (flag ? (maxRows * cellHeight) : num3); if (flag) { scroll = GUILayout.BeginScrollView(scroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(num4), GUILayout.Width(width) }); } Rect rect = GUILayoutUtility.GetRect((float)num * cellWidth, num3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); float num5 = (flag ? scroll.y : float.NegativeInfinity); float num6 = (flag ? (scroll.y + num4) : float.PositiveInfinity); bool flag2 = current.mousePosition.y >= num5 && current.mousePosition.y <= num6; Rect rect2 = default(Rect); for (int i = 0; i < count; i++) { int num7 = i / num; int num8 = i % num; ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + (float)num8 * cellWidth + 3f, ((Rect)(ref rect)).y + (float)num7 * cellHeight + 3f, cellWidth - 6f, cellHeight - 6f); if (((Rect)(ref rect2)).yMax < num5 || ((Rect)(ref rect2)).y > num6) { continue; } Icon icon = iconAt(i); bool flag3 = flag2 && ((Rect)(ref rect2)).Contains(current.mousePosition); if (flag3) { hovered = icon; if ((int)current.type == 0 && current.button == 0) { result = i; current.Use(); } } if ((int)current.type == 7) { DrawCell(rect2, icon, isSelected(i), flag3); } } if (flag) { GUILayout.EndScrollView(); } return result; } private static void DrawCell(Rect rect, Icon icon, bool selected, bool hover) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) Styles.Fill(rect, 8, hover ? Styles.CellHover : Styles.CellBg); Color color = GUI.color; if (Object.op_Implicit((Object)(object)icon.Texture)) { GUI.color = (Color)(icon.Locked ? new Color(1f, 1f, 1f, 0.25f) : Color.white); GUI.DrawTextureWithTexCoords(rect, icon.Texture, icon.Uv, true); GUI.color = color; } else { GUI.Label(rect, "<size=10>" + icon.Name + "</size>", Styles.Center); } Styles.Mask(rect, 8, Styles.CardBg); if (icon.Locked) { GUI.Label(rect, "<size=10><b><color=#8a94a6>DLC</color></b></size>", Styles.Center); } if (selected) { Styles.Ring(rect, 8, Styles.Accent); } else if (hover) { Styles.Ring(rect, 8, new Color(1f, 1f, 1f, 0.4f)); } } private void DrawGameCursor(Vector2 offset) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000e: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type != 7) { return; } Color color = GUI.color; foreach (MPEventSystem readOnlyInstances in MPEventSystem.readOnlyInstancesList) { if (!Object.op_Implicit((Object)(object)readOnlyInstances) || !readOnlyInstances.isCursorVisible) { continue; } CursorIndicatorController componentInChildren = ((Component)readOnlyInstances).GetComponentInChildren<CursorIndicatorController>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { continue; } ((Component)componentInChildren).GetComponentsInChildren<Image>(false, cursorImages); foreach (Image cursorImage in cursorImages) { if (((Behaviour)cursorImage).enabled && Object.op_Implicit((Object)(object)cursorImage.sprite)) { Canvas canvas = ((Graphic)cursorImage).canvas; Camera obj = ((Object.op_Implicit((Object)(object)canvas) && (int)canvas.renderMode != 0) ? canvas.worldCamera : null); ((Graphic)cursorImage).rectTransform.GetWorldCorners(cursorCorners); Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[0]); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[2]); Rect val3 = new Rect(val.x / guiScale - offset.x, ((float)Screen.height - val2.y) / guiScale - offset.y, (val2.x - val.x) / guiScale, (val2.y - val.y) / guiScale); GUI.color = ((Graphic)cursorImage).color; GUI.DrawTextureWithTexCoords(val3, (Texture)(object)cursorImage.sprite.texture, Helpers.SpriteUv(cursorImage.sprite), true); } } } GUI.color = color; } private static Texture2D LoadLogo() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown using Stream stream = typeof(BotPanel).Assembly.GetManifestResourceStream("FakeFriend.logo.png"); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; ImageConversion.LoadImage(val, array); Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height, (TextureFormat)4, true) { hideFlags = (HideFlags)61, filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1 }; val2.SetPixels32(val.GetPixels32()); val2.Apply(true, true); Object.Destroy((Object)(object)val); return val2; } } internal enum ItemMode { CopyHost, RandomSameTier, None } internal static class BotSettings { public const int MaxBots = 4; public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> RespawnDelay; public static ConfigEntry<float> LeashDistance; public static ConfigEntry<float> TeleportDistance; public static ConfigEntry<KeyboardShortcut> PanelKey; public static ConfigEntry<float> UiScale; public static BotSlot[] Slots; public static int ActiveCount { get { int num = 0; BotSlot[] slots = Slots; for (int i = 0; i < slots.Length; i++) { if (slots[i].Active.Value) { num++; } } return num; } } public static void Bind(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, "Main switch for all FakeFriends. Off = no bots join, without losing their setup."); RespawnDelay = config.Bind<float>("General", "Respawn delay", 0f, new ConfigDescription("Seconds until a dead bot comes back. 0 = it waits for the next stage, like a real co-op player.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); PanelKey = config.Bind<KeyboardShortcut>("General", "Panel key", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Opens the FakeFriend menu during a run. The FakeFriend button in the top-right corner (character select, pause menu) does the same."); UiScale = config.Bind<float>("General", "UI scale", 1f, new ConfigDescription("Menu size. 1 = sized for 1080p and scaled with your resolution.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>())); LeashDistance = config.Bind<float>("Behaviour", "Leash distance", 60f, new ConfigDescription("If a bot gets further than this from you (meters) and has nothing to shoot, it runs back. At twice this distance it runs back even mid-fight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 200f), Array.Empty<object>())); TeleportDistance = config.Bind<float>("Behaviour", "Teleport distance", 120f, new ConfigDescription("If a bot stays further than this from you for a few seconds, it teleports next to you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 1000f), Array.Empty<object>())); Slots = new BotSlot[4]; for (int i = 0; i < 4; i++) { Slots[i] = new BotSlot(config, i); } MigrateSingleBotConfig(config); } public static bool IsUsable(SurvivorDef def) { if (Object.op_Implicit((Object)(object)def) && Object.op_Implicit((Object)(object)def.bodyPrefab)) { return Object.op_Implicit((Object)(object)def.bodyPrefab.GetComponent<CharacterBody>()); } return false; } private static void MigrateSingleBotConfig(ConfigFile config) { string text; try { text = (File.Exists(config.ConfigFilePath) ? File.ReadAllText(config.ConfigFilePath) : ""); } catch (IOException) { return; } if (text.Contains("[Bot]")) { bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; BotSlot botSlot = Slots[0]; botSlot.Active.Value = true; Enabled.Value = Take(config, "Enabled", Enabled.Value); botSlot.Survivor.Value = Take(config, "Survivor", botSlot.Survivor.Value); botSlot.Skin.Value = Take(config, "Skin", botSlot.Skin.Value); botSlot.Skills.Value = Take(config, "Skills", botSlot.Skills.Value); botSlot.Items.Value = Take(config, "Items", botSlot.Items.Value); RespawnDelay.Value = Take(config, "Respawn delay", RespawnDelay.Value); config.SaveOnConfigSet = saveOnConfigSet; config.Save(); } } private static T Take<T>(ConfigFile config, string key, T fallback) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition("Bot", key); T value = config.Bind<T>(val, fallback, (ConfigDescription)null).Value; config.Remove(val); return value; } } internal sealed class BotSlot { public readonly int Index; public readonly ConfigEntry<bool> Active; public readonly ConfigEntry<string> Survivor; public readonly ConfigEntry<int> Skin; public readonly ConfigEntry<string> Skills; public readonly ConfigEntry<ItemMode> Items; public string Name => "FakeFriend " + (Index + 1); public string Signature => Survivor.Value + "|" + Skin.Value + "|" + Skills.Value; public BotSlot(ConfigFile config, int index) { Index = index; string text = "Bot " + (index + 1); Active = config.Bind<bool>(text, "Active", index == 0, "Whether this bot is in your team. Add or remove bots in the FakeFriend menu."); Survivor = config.Bind<string>(text, "Survivor", "Commando", "Internal name of the bot's survivor (SurvivorDef name, e.g. Commando, Huntress, Merc)."); Skin = config.Bind<int>(text, "Skin", 0, "Skin index of the bot's survivor (0 = default)."); Skills = config.Bind<string>(text, "Skills", "", "Skill variant per loadout slot, comma separated (e.g. 0,1,0,0). Empty = defaults."); Items = config.Bind<ItemMode>(text, "Items", ItemMode.RandomSameTier, "CopyHost: same items as the host. RandomSameTier: a random item of the same rarity whenever the host gets one. None: no items."); } public SurvivorDef ResolveSurvivor() { SurvivorDef val = SurvivorCatalog.FindSurvivorDef(Survivor.Value); if (BotSettings.IsUsable(val)) { return val; } val = SurvivorCatalog.FindSurvivorDef("Commando"); if (!BotSettings.IsUsable(val)) { return SurvivorCatalog.defaultSurvivor; } return val; } public void SelectSurvivor(SurvivorDef def) { if (BotSettings.IsUsable(def) && !(def.cachedName == Survivor.Value)) { Survivor.Value = def.cachedName; Skin.Value = 0; Skills.Value = ""; } } public uint[] ParseSkills() { List<uint> list = new List<uint>(); string[] array = (Skills.Value ?? "").Split(','); foreach (string text in array) { list.Add(uint.TryParse(text.Trim(), out var result) ? result : 0u); } return list.ToArray(); } public void SetSkill(int slot, uint variant) { uint[] array = ParseSkills(); if (array.Length <= slot) { Array.Resize(ref array, slot + 1); } array[slot] = variant; Skills.Value = string.Join(",", Array.ConvertAll(array, (uint v) => v.ToString())); } public uint GetSkill(int slot) { uint[] array = ParseSkills(); if (slot >= array.Length) { return 0u; } return array[slot]; } public Loadout BuildLoadout(SurvivorDef def) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Loadout val = new Loadout(); BodyIndex val2 = BodyCatalog.FindBodyIndex(def.bodyPrefab); if ((int)val2 == -1) { return val; } int bodySkinCount = SkinCatalog.GetBodySkinCount(val2); if (Skin.Value > 0 && Skin.Value < bodySkinCount) { val.bodyLoadoutManager.SetSkinIndex(val2, (uint)Skin.Value); } GenericSkill[] array = BodyCatalog.GetBodyPrefabSkillSlots(val2) ?? Array.Empty<GenericSkill>(); uint[] array2 = ParseSkills(); for (int i = 0; i < array.Length && i < array2.Length; i++) { SkillFamily val3 = (Object.op_Implicit((Object)(object)array[i]) ? array[i].skillFamily : null); if (Object.op_Implicit((Object)(object)val3) && array2[i] < val3.variants.Length) { val.bodyLoadoutManager.SetSkillVariant(val2, i, array2[i]); } } return val; } } internal sealed class FakeBot { private const float SpawnDelay = 1f; private const float SpawnStagger = 0.35f; private const float FarGracePeriod = 3f; public readonly BotSlot Slot; private CharacterMaster master; private string spawnedSignature; private string spawnedName; private float readyTimer; private float farTimer; private float deadSince = -1f; private int stageId; private int deathStageId; private bool snapPending; private readonly BotItems items; public CharacterMaster Master => master; public CharacterBody Body { get { if (!Object.op_Implicit((Object)(object)master)) { return null; } return master.GetBody(); } } public bool IsAlive => BotManager.IsAlive(Body); public bool IsDead { get { if (Object.op_Implicit((Object)(object)master) && !IsAlive) { return deadSince >= 0f; } return false; } } public bool IsOutdated { get { if (Object.op_Implicit((Object)(object)master)) { return spawnedSignature != Slot.Signature; } return false; } } public FakeBot(BotSlot slot) { Slot = slot; items = new BotItems(slot); } public void OnRunStart() { master = null; spawnedSignature = null; readyTimer = 0f; deadSince = -1f; items.Reset(); } public void OnRunDestroy() { master = null; spawnedSignature = null; } public void OnStageBegin() { stageId++; snapPending = true; farTimer = 0f; readyTimer = 0f; } public void FixedUpdate(CharacterMaster host, float deltaTime) { if (!Slot.Active.Value) { if (Object.op_Implicit((Object)(object)master)) { Despawn(); } return; } CharacterBody body = Body; CharacterBody val = BotManager.FindLeader(body); bool flag = Object.op_Implicit((Object)(object)val) && !Object.op_Implicit((Object)(object)val.currentVehicle); if (!Object.op_Implicit((Object)(object)master)) { readyTimer = (flag ? (readyTimer + deltaTime) : 0f); if (readyTimer >= 1f + (float)Slot.Index * 0.35f) { readyTimer = 0f; items.Reset(); Spawn(host, val, null, null); } return; } items.FixedUpdate(master, host, deltaTime); if (BotManager.IsAlive(body)) { deadSince = -1f; BotBrain.SetLeader(master, val); if (flag) { if (snapPending) { snapPending = false; TeleportNear(body, val); } else { KeepClose(body, val, deltaTime); } } } else { if (master.IsExtraLifePendingServer()) { return; } if (master.lostBodyToDeath) { if (deadSince < 0f) { deadSince = Time.time; deathStageId = stageId; Chat.AddMessage("<style=cIsDamage>" + Slot.Name + "</style> (" + spawnedName + ") died. " + ((BotSettings.RespawnDelay.Value > 0f) ? $"Back in {BotSettings.RespawnDelay.Value:0} s." : "Back next stage.")); } bool num = deathStageId != stageId; bool flag2 = BotSettings.RespawnDelay.Value > 0f && Time.time - deadSince >= BotSettings.RespawnDelay.Value; if (!num && !flag2) { return; } } if (flag) { RespawnNear(val); } } } public void Apply() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && Object.op_Implicit((Object)(object)master)) { CharacterBody val = BotManager.FindLeader(Body); if (Object.op_Implicit((Object)(object)val)) { CharacterMaster val2 = master; CharacterBody body = val2.GetBody(); Vector3? at = (BotManager.IsAlive(body) ? new Vector3?(body.footPosition) : ((Vector3?)null)); master = null; Spawn(BotManager.FindHostMaster(), val, val2.inventory, at); Destroy(val2, effect: false); } } } public void BringToMe() { CharacterBody body = Body; CharacterBody val = BotManager.FindLeader(body); if (BotManager.IsAlive(body) && Object.op_Implicit((Object)(object)val)) { TeleportNear(body, val); } } public void Despawn() { if (Object.op_Implicit((Object)(object)master)) { Destroy(master, effect: true); } master = null; spawnedSignature = null; deadSince = -1f; } private void Spawn(CharacterMaster host, CharacterBody leader, Inventory carryItemsFrom, Vector3? at) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011a: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0142: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) SurvivorDef val = Slot.ResolveSurvivor(); if (!val.CheckRequiredExpansionEnabled((NetworkUser)null)) { Chat.AddMessage(Slot.Name + ": " + Helpers.Lang(val.displayNameToken, val.cachedName) + " needs a DLC that is off in this run, using Commando instead."); val = SurvivorCatalog.FindSurvivorDef("Commando"); } GameObject bodyPrefab = val.bodyPrefab; CharacterBody component = bodyPrefab.GetComponent<CharacterBody>(); string bodyName = BodyCatalog.GetBodyName(component.bodyIndex); GameObject val2 = (AiSkillHelperCatalog.Has(bodyName) ? null : MasterCatalog.GetMasterPrefab(MasterCatalog.FindAiMasterIndexForBody(component.bodyIndex))); bool keepOwnAi = Object.op_Implicit((Object)(object)val2); if (!Object.op_Implicit((Object)(object)val2)) { val2 = MasterCatalog.FindMasterPrefab("CommandoMonsterMaster"); } if (!Object.op_Implicit((Object)(object)val2)) { FakeFriendPlugin.Log.LogError((object)("No AI master found for " + val.cachedName)); return; } Vector3 val3 = (Vector3)(((??)at) ?? BotManager.FindSpotNear(leader.footPosition, component)); Quaternion rotation = Quaternion.LookRotation(BotManager.Flat(leader.footPosition - val3)); MasterSummon val4 = new MasterSummon { masterPrefab = val2, position = val3, rotation = rotation, teamIndexOverride = (TeamIndex)1, ignoreTeamMemberLimit = true, useAmbientLevel = false, loadout = Slot.BuildLoadout(val), preSpawnSetupCallback = delegate(CharacterMaster newMaster) { newMaster.bodyPrefab = bodyPrefab; BotBrain.Setup(newMaster, bodyName, keepOwnAi); if (Object.op_Implicit((Object)(object)host)) { newMaster.minionOwnership.SetOwner(host); } ((Component)newMaster).gameObject.AddComponent<SetDontDestroyOnLoad>(); if (Object.op_Implicit((Object)(object)carryItemsFrom)) { newMaster.inventory.AddItemsFrom(carryItemsFrom, (Func<ItemIndex, bool>)((ItemIndex index) => index != Items.MinionLeash.itemIndex)); } } }; master = val4.Perform(); if (Object.op_Implicit((Object)(object)master)) { ((Object)master).name = Slot.Name; spawnedSignature = Slot.Signature; spawnedName = Helpers.Lang(val.displayNameToken, val.cachedName); snapPending = false; farTimer = 0f; deadSince = -1f; BotManager.PlayTeleportEffect(master.GetBody(), val3); if ((Object)(object)carryItemsFrom == (Object)null) { Chat.AddMessage("<style=cIsUtility>" + Slot.Name + "</style> joined as <style=cIsUtility>" + spawnedName + "</style>."); } } } private void RespawnNear(CharacterBody leader) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) CharacterBody body = (Object.op_Implicit((Object)(object)master.bodyPrefab) ? master.bodyPrefab.GetComponent<CharacterBody>() : null); Vector3 val = BotManager.FindSpotNear(leader.footPosition, body); CharacterBody body2 = master.Respawn(val, Quaternion.LookRotation(BotManager.Flat(leader.footPosition - val)), false); snapPending = false; farTimer = 0f; deadSince = -1f; BotManager.PlayTeleportEffect(body2, val); } private void KeepClose(CharacterBody bot, CharacterBody leader, float deltaTime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (Vector3.Distance(bot.footPosition, leader.footPosition) < BotSettings.TeleportDistance.Value) { farTimer = 0f; return; } farTimer += deltaTime; if (farTimer >= 3f) { TeleportNear(bot, leader); } } private void TeleportNear(CharacterBody bot, CharacterBody leader) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = BotManager.FindSpotNear(leader.footPosition, bot); TeleportHelper.TeleportBody(bot, val, true); BotManager.PlayTeleportEffect(bot, val); farTimer = 0f; } private static void Destroy(CharacterMaster target, bool effect) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) CharacterBody body = target.GetBody(); if (effect && Object.op_Implicit((Object)(object)body)) { BotManager.PlayTeleportEffect(body, body.footPosition); } target.DestroyBody(); Object.Destroy((Object)(object)((Component)target).gameObject); } public string Status() { if (!Object.op_Implicit((Object)(object)Run.instance)) { return "Joins when the run starts."; } if (!NetworkServer.active) { return "Only the host's FakeFriends join."; } if (!BotSettings.Enabled.Value) { return "All FakeFriends are switched off."; } if (!Object.op_Implicit((Object)(object)master)) { return "Joining..."; } CharacterBody body = Body; if (BotManager.IsAlive(body)) { return $"Alive · {body.healthComponent.combinedHealthFraction * 100f:0}% health · level {body.level:0}"; } if (deadSince >= 0f && BotSettings.RespawnDelay.Value > 0f) { float num = BotSettings.RespawnDelay.Value - (Time.time - deadSince); return $"Dead · back in {Mathf.Max(0f, num):0} s"; } if (!(deadSince >= 0f)) { return "Joining..."; } return "Dead · back next s