Decompiled source of AutoCommandQueuePickup v1.1.0
AutoCommandQueuePickup.dll
Decompiled 10 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using AutoCommandQueuePickup.Configuration; using AutoCommandQueuePickup.Hooks; using AutoCommandQueuePickup.ItemDistributors; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates.Scrapper; using IL.EntityStates.Scrapper; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour.HookGen; using On.RoR2; using On.RoR2.Artifacts; using On.RoR2.UI; using ProperSave; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Artifacts; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyVersion("1.0.3.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class CharacterMasterManager : MonoBehaviour { public static Dictionary<uint, CharacterMaster> playerCharacterMasters = new Dictionary<uint, CharacterMaster>(); } namespace AutoCommandQueuePickup { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("com.kuberoot.commandqueue")] [BepInIncompatibility("com.kuberoot.autoitempickup")] [BepInPlugin("symmys.AutoCommandQueuePickup", "AutoCommandQueuePickup", "1.0.3")] public class AutoCommandQueuePickup : BaseUnityPlugin { public const string PluginAuthor = "symmys"; public const string PluginName = "AutoCommandQueuePickup"; public const string PluginGUID = "symmys.AutoCommandQueuePickup"; public const string PluginVersion = "1.0.3"; private static readonly MethodInfo GenericPickupController_AttemptGrant = typeof(GenericPickupController).GetMethod("AttemptGrant", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo GenericPickupController_consumed = typeof(GenericPickupController).GetField("consumed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private bool distributorNeedsUpdate; public static Action PluginUnloaded; public static bool IsLoaded; public static bool dontDestroy = false; private HookManager hookManager; public readonly string LastCommandQueuePath = Path.Combine(Application.persistentDataPath, "ProperSave", "Saves") + "\\LastCommandQueue.csv"; private static GameObject commandUIPrefab; public static readonly FieldInfo commandCubePrefabField = typeof(CommandArtifactManager).GetField("commandCubePrefab", BindingFlags.Static | BindingFlags.NonPublic); private static readonly FieldInfo PickupPickerController_options = typeof(PickupPickerController).GetField("options", BindingFlags.Instance | BindingFlags.NonPublic); public ItemDistributor Distributor { get; private set; } public static Config config { get; private set; } private void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); config = new Config(this, ((BaseUnityPlugin)this).Logger); } private void SaveFile_OnGatherSaveData(Dictionary<string, object> obj) { SaveAndLoad.Save(LastCommandQueuePath); } private void Loading_OnLoadingEnded(SaveFile _) { if (File.Exists(LastCommandQueuePath)) { SaveAndLoad.Load(LastCommandQueuePath); } else { Log.Warning("CommandQueue save file does not exist!"); } } public void OnEnable() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown hookManager = new HookManager(this); hookManager.RegisterHooks(); object? value = commandCubePrefabField.GetValue(null); object? obj = ((value is GameObject) ? value : null); commandUIPrefab = ((obj != null) ? ((GameObject)obj).GetComponent<PickupPickerController>().panelPrefab : null); PlayerCharacterMasterController.OnBodyDeath += (hook_OnBodyDeath)delegate(orig_OnBodyDeath orig, PlayerCharacterMasterController self) { orig.Invoke(self); UpdateTargets(); }; PlayerCharacterMasterController.OnBodyStart += (hook_OnBodyStart)delegate(orig_OnBodyStart orig, PlayerCharacterMasterController self) { orig.Invoke(self); UpdateTargets(); }; PickupDropletController.OnCollisionEnter += new Manipulator(ModifyDropletCollision); PlayerCharacterMasterController.Awake += new hook_Awake(OnPlayerAwake); PlayerCharacterMasterController.onPlayerAdded += UpdateTargetsWrapper; PlayerCharacterMasterController.onPlayerRemoved += UpdateTargetsWrapper; config.distributionMode.SettingChanged += delegate { Distributor = ItemDistributor.GetItemDistributor(config.distributionMode.Value, this); }; IsLoaded = true; ScoreboardController.Awake += new hook_Awake(ScoreboardController_Awake); PickupPickerController.OnDisplayBegin += new hook_OnDisplayBegin(HandleCommandDisplayBegin); CommandArtifactManager.Init += new hook_Init(CommandArtifactManager_Init); QueueManager.Enable(); HUD[] array = Object.FindObjectsOfType<HUD>(); foreach (HUD val in array) { val.scoreboardPanel.AddComponent<UIManager>(); } SaveFile.OnGatherSaveData += SaveFile_OnGatherSaveData; Loading.OnLoadingEnded += Loading_OnLoadingEnded; } public void OnDisable() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown CharacterMasterManager.playerCharacterMasters.Clear(); hookManager.UnregisterHooks(); HookEndpointManager.RemoveAllOwnedBy(HookEndpointManager.GetOwner((Delegate)new Action(OnDisable))); PlayerCharacterMasterController.onPlayerAdded -= UpdateTargetsWrapper; PlayerCharacterMasterController.onPlayerRemoved -= UpdateTargetsWrapper; IsLoaded = false; PluginUnloaded?.Invoke(); ScoreboardController.Awake -= new hook_Awake(ScoreboardController_Awake); QueueManager.Disable(); } private void CommandArtifactManager_Init(orig_Init orig) { orig.Invoke(); object? value = commandCubePrefabField.GetValue(null); object? obj = ((value is GameObject) ? value : null); commandUIPrefab = ((obj != null) ? ((GameObject)obj).GetComponent<PickupPickerController>().panelPrefab : null); } private void HandleCommandDisplayBegin(orig_OnDisplayBegin orig, PickupPickerController self, NetworkUIPromptController networkUIPromptController, LocalUser localUser, CameraRigController cameraRigController) { //IL_0043: 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_0049: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) if ((Object)(object)self.panelPrefab == (Object)(object)commandUIPrefab) { foreach (var (tier, val) in QueueManager.PeekAll()) { if (!self.IsChoiceAvailable(val)) { continue; } QueueManager.Pop(tier); Option[] array = (Option[])PickupPickerController_options.GetValue(self); int i; for (i = 0; i < array.Length; i++) { if (array[i].pickupIndex == val && array[i].available) { ((MonoBehaviour)self).StartCoroutine(submitChoiceNextFrame()); break; } } return; IEnumerator submitChoiceNextFrame() { yield return 0; self.SubmitChoice(i); } } } orig.Invoke(self, networkUIPromptController, localUser, cameraRigController); } private void ScoreboardController_Awake(orig_Awake orig, ScoreboardController self) { UIManager uIManager = ((Component)self).gameObject.AddComponent<UIManager>(); orig.Invoke(self); } private void UpdateTargetsWrapper(PlayerCharacterMasterController player) { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Dictionary<uint, CharacterMaster> playerCharacterMasters = CharacterMasterManager.playerCharacterMasters; NetworkInstanceId netId = ((NetworkBehaviour)player.master).netId; if (!playerCharacterMasters.ContainsKey(((NetworkInstanceId)(ref netId)).Value)) { Dictionary<uint, CharacterMaster> playerCharacterMasters2 = CharacterMasterManager.playerCharacterMasters; netId = ((NetworkBehaviour)player.master).netId; playerCharacterMasters2.Add(((NetworkInstanceId)(ref netId)).Value, player.master); UpdateTargets(); } } private void OnPlayerAwake(orig_Awake orig, PlayerCharacterMasterController self) { orig.Invoke(self); if (!NetworkServer.active) { return; } CharacterMaster master = self.master; if (Object.op_Implicit((Object)(object)master)) { master.onBodyStart += delegate { UpdateTargets(); }; } } private void ModifyDropletCollision(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //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) ILCursor val = new ILCursor(il); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction i) => ILPatternMatchingExt.MatchCall<GenericPickupController>(i, "CreatePickup") }); val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<GenericPickupController, PickupDropletController>>((Action<GenericPickupController, PickupDropletController>)delegate(GenericPickupController pickupController, PickupDropletController self) { OverrideDistributorBehaviour component = ((Component)self).GetComponent<OverrideDistributorBehaviour>(); if (Object.op_Implicit((Object)(object)component)) { OverrideDistributorBehaviour overrideDistributorBehaviour = ((Component)pickupController).gameObject.AddComponent<OverrideDistributorBehaviour>(); overrideDistributorBehaviour.Distributor = component.Distributor; } }); } [Server] public static void GrantItem(GenericPickupController item, CharacterMaster master) { //IL_002f: 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_0045: 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_0048: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00cf: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (master.hasBody) { GenericPickupController_AttemptGrant.Invoke(item, new object[1] { master.GetBody() }); return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(item.pickupIndex); ItemIndex val = (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex)); if ((int)val != -1) { master.inventory.GiveItem(val, 1); PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController; NetworkUser subjectAsNetworkUser = (((Object)(object)playerCharacterMasterController != (Object)null) ? playerCharacterMasterController.networkUser : null); PickupDef pickupDef2 = PickupCatalog.GetPickupDef(item.pickupIndex); Chat.AddMessage(((ChatMessageBase)new PlayerPickupChatMessage { subjectAsNetworkUser = subjectAsNetworkUser, baseToken = "PLAYER_PICKUP", pickupToken = (pickupDef2?.nameToken ?? PickupCatalog.invalidPickupToken), pickupColor = Color32.op_Implicit(pickupDef2?.baseColor ?? Color.black), pickupQuantity = (uint)master.inventory.GetItemCount(val) }).ConstructChatString()); GenericPickupController_consumed.SetValue(item, true); Object.Destroy((Object)(object)((Component)item).gameObject); } } public static bool GrantCommandItem(PickupIndex pickupIndex, CharacterMaster master) { //IL_0001: 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_0013: 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_0016: Invalid comparison between Unknown and I4 //IL_0029: 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_004d: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); ItemIndex val = (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex)); if ((int)val != -1) { master.inventory.GiveItem(val, 1); PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController; NetworkUser subjectAsNetworkUser = ((playerCharacterMasterController != null) ? playerCharacterMasterController.networkUser : null); PickupDef pickupDef2 = PickupCatalog.GetPickupDef(pickupIndex); Chat.AddMessage(((ChatMessageBase)new PlayerPickupChatMessage { subjectAsNetworkUser = subjectAsNetworkUser, baseToken = "PLAYER_PICKUP", pickupToken = (pickupDef2?.nameToken ?? PickupCatalog.invalidPickupToken), pickupColor = Color32.op_Implicit(pickupDef2?.baseColor ?? Color.black), pickupQuantity = (uint)master.inventory.GetItemCount(val) }).ConstructChatString()); return true; } return false; } private void UpdateTargets() { distributorNeedsUpdate = true; } public void PreDistributeItemInternal(Cause cause) { if (Distributor == null) { Distributor = ItemDistributor.GetItemDistributor(config.distributionMode.Value, this); } if (distributorNeedsUpdate) { distributorNeedsUpdate = false; Distributor?.UpdateTargets(); } } public void DistributeItemInternal(GenericPickupController item, Cause cause) { ItemDistributor distributorInternal = GetDistributorInternal(((Component)item).gameObject); try { distributorInternal.DistributeItem(item); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Caught AutoItemPickup distributor exception:\n{ex}\n{ex.StackTrace}"); } } public void DistributeItem(GenericPickupController item, Cause cause) { PreDistributeItemInternal(cause); DistributeItemInternal(item, cause); } public void DistributeItems(IEnumerable<GenericPickupController> items, Cause cause) { PreDistributeItemInternal(cause); foreach (GenericPickupController item in items) { DistributeItemInternal(item, cause); } } public ItemDistributor GetDistributorInternal(GameObject item) { if ((Object)(object)item != (Object)null) { OverrideDistributorBehaviour component = item.GetComponent<OverrideDistributorBehaviour>(); if ((Object)(object)component != (Object)null) { return component.Distributor; } } return Distributor; } public ItemDistributor GetDistributor(GameObject item, Cause cause) { PreDistributeItemInternal(cause); return GetDistributorInternal(item); } } public class CommandArtifactPickup : MonoBehaviour { public PickupIndex pickupIndex; public PickupDropletController pickupDropletController; public CharacterMaster characterMaster; public bool isCommand; } public enum Cause { Teleport, Drop } public enum Mode { Sequential, Random, Closest, LeastItems } public enum Distribution { OnTeleport, OnDrop } internal class QueueDisplay : MonoBehaviour { public class QueueItemBehavior : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IPointerClickHandler { private GameObject m_DraggingIcon; private QueueDisplay m_Queue; private ItemIcon m_ItemIcon; public void Init(QueueDisplay queue) { m_Queue = queue; m_ItemIcon = ((Component)this).GetComponent<ItemIcon>(); } public void OnBeginDrag(PointerEventData eventData) { //IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0091: 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_00ab: 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_00cf: 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_0106: Unknown result type (might be due to invalid IL or missing references) InputButton button = eventData.button; InputButton val = button; if ((int)val <= 1) { m_DraggingIcon = new GameObject("QueueItemDragIcon"); m_DraggingIcon.transform.SetParent(((Component)m_Queue).transform, false); m_DraggingIcon.transform.SetAsLastSibling(); RawImage val2 = m_DraggingIcon.AddComponent<RawImage>(); val2.texture = m_ItemIcon.image.texture; RectTransform rectTransform = ((Graphic)val2).rectTransform; Rect rect = ((Graphic)m_ItemIcon.image).rectTransform.rect; float height = ((Rect)(ref rect)).height; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(height, height); ((Transform)rectTransform).localScale = ((Transform)m_ItemIcon.rectTransform).localScale; ((Graphic)val2).color = new Color(1f, 1f, 1f, 0.6f); SetDraggedPosition(eventData); ((AbstractEventData)eventData).Use(); } } public void OnDrag(PointerEventData eventData) { if (Object.op_Implicit((Object)(object)m_DraggingIcon)) { SetDraggedPosition(eventData); ((AbstractEventData)eventData).Use(); } } public void OnEndDrag(PointerEventData eventData) { //IL_0030: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)m_DraggingIcon)) { return; } Object.Destroy((Object)(object)m_DraggingIcon); Vector2 val = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Queue.rectTransform, eventData.position, eventData.pressEventCamera, ref val)) { float num = val.x / (m_Queue.iconScale * (m_Queue.itemIconPrefabWidth + 5f)); int newIndex = Mathf.RoundToInt(num); int num2 = m_Queue.icons.FindIndex((ItemIcon icon) => (Object)(object)((Component)icon).gameObject == (Object)(object)((Component)this).gameObject); List<QueueManager.QueueEntry> queue = m_Queue.queue; if (num2 < 0 || num2 > queue.Count) { return; } int num3 = m_Queue.queue[num2].count; if ((int)eventData.button == 1 && num3 > 1) { num3 /= 2; } QueueManager.Move(m_Queue.tier, num2, newIndex, num3); } ((AbstractEventData)eventData).Use(); } private void SetDraggedPosition(PointerEventData data) { //IL_0019: 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) RectTransform component = m_DraggingIcon.GetComponent<RectTransform>(); Vector3 position = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_Queue.rectTransform, data.position, data.pressEventCamera, ref position)) { ((Transform)component).position = position; } } public void OnPointerClick(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0067: 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) if ((int)eventData.button != 1 || !AutoCommandQueuePickup.config.rightClickRemovesStack.Value) { return; } List<ItemIcon> icons = m_Queue.icons; for (int i = 0; i < icons.Count; i++) { if ((Object)(object)((Component)icons[i]).gameObject == (Object)(object)((Component)this).gameObject) { QueueManager.QueueEntry queueEntry = m_Queue.queue[i]; QueueManager.Remove(m_Queue.tier, i, queueEntry.count); break; } } ((AbstractEventData)eventData).Use(); } } public GameObject itemIconPrefab = null; public float itemIconPrefabWidth = 64f; public ItemTier tier; private float iconScale = 1f; private RectTransform rectTransform; private List<ItemIcon> icons = new List<ItemIcon>(); private List<QueueManager.QueueEntry> queue; public void Awake() { ref RectTransform reference = ref rectTransform; Transform transform = ((Component)this).transform; reference = (RectTransform)(object)((transform is RectTransform) ? transform : null); } public void Start() { //IL_0008: 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) Rect rect = rectTransform.rect; iconScale = (((Rect)(ref rect)).height - 10f) / itemIconPrefabWidth; LayoutIcons(); } public void LayoutIcon(int index, RectTransform transform) { //IL_001d: 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) transform.anchoredPosition = new Vector2((float)index * iconScale * (itemIconPrefabWidth + 5f), 5f); ((Transform)transform).localScale = new Vector3(iconScale, iconScale, 1f); } public void LayoutIcons(int first = 0) { for (int i = first; i < icons.Count; i++) { LayoutIcon(i, icons[i].rectTransform); } } public ItemIcon AllocateIcon(int index) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) ItemIcon icon = Object.Instantiate<GameObject>(itemIconPrefab, (Transform)(object)rectTransform, false).GetComponent<ItemIcon>(); RectTransform val = icon.rectTransform; Button val2 = ((Component)icon).gameObject.AddComponent<Button>(); ((UnityEvent)val2.onClick).AddListener((UnityAction)delegate { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < icons.Count; i++) { if ((Object)(object)icons[i] == (Object)(object)icon) { QueueManager.Remove(tier, i); break; } } }); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val2).navigation = navigation; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); LayoutIcon(index, val); QueueItemBehavior queueItemBehavior = ((Component)icon).gameObject.AddComponent<QueueItemBehavior>(); queueItemBehavior.Init(this); icons.Insert(index, icon); return icon; } public void AllocateIcons(int count, Action<int, ItemIcon> action = null) { for (int num = icons.Count - 1; num >= count; num--) { Object.Destroy((Object)(object)((Component)icons[num]).gameObject); icons.RemoveAt(num); } for (int i = icons.Count; i < count; i++) { ItemIcon arg = AllocateIcon(i); action?.Invoke(i, arg); } } public void DestroyUI() { foreach (ItemIcon icon in icons) { Object.Destroy((Object)(object)((Component)icon).gameObject); } icons.Clear(); } public void UpdateUI() { AllocateIcons(queue.Count); UpdateIcons(); } private void UpdateIcon(int i) { //IL_001d: 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) ItemIcon val = icons[i]; QueueManager.QueueEntry queueEntry = queue[i]; val.SetItemIndex(PickupCatalog.GetPickupDef(queueEntry.pickupIndex).itemIndex, queueEntry.count); } private void UpdateIcons() { for (int i = 0; i < icons.Count; i++) { UpdateIcon(i); } } private void HandleQueueChange(QueueManager.QueueChange change, ItemTier tier, int index) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)itemIconPrefab) && tier == this.tier) { switch (change) { case QueueManager.QueueChange.Changed: UpdateIcon(index); break; case QueueManager.QueueChange.Added: AllocateIcon(index); UpdateIcon(index); break; case QueueManager.QueueChange.Removed: Object.Destroy((Object)(object)((Component)icons[index]).gameObject); icons.RemoveAt(index); LayoutIcons(index); break; case QueueManager.QueueChange.Moved: UpdateUI(); break; } } } public void OnEnable() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)itemIconPrefab)) { queue = QueueManager.mainQueues[tier]; UpdateUI(); QueueManager.OnQueueChanged += HandleQueueChange; } } public void OnDisable() { QueueManager.OnQueueChanged -= HandleQueueChange; } } public static class QueueManager { public struct QueueEntry { public PickupIndex pickupIndex; public int count; } public enum QueueChange { Removed, Added, Changed, Moved } public static Dictionary<ItemTier, List<QueueEntry>> mainQueues = new Dictionary<ItemTier, List<QueueEntry>> { { (ItemTier)0, new List<QueueEntry>() }, { (ItemTier)1, new List<QueueEntry>() }, { (ItemTier)2, new List<QueueEntry>() } }; public static Dictionary<ItemTier, bool> queueRepeat = new Dictionary<ItemTier, bool>(); public static event Action<Run> OnRunQueueInit; public static event Action<QueueChange, ItemTier, int> OnQueueChanged; internal static void Enable() { Run.onRunStartGlobal += InitQueues; UpdateQueueAvailability(); } internal static void Disable() { Run.onRunStartGlobal -= InitQueues; } public static void UpdateQueueAvailability() { //IL_0093: 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_009f: 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) mainQueues.Clear(); object[] source = (from a in AutoCommandQueuePickup.config.enabledTabsConfig where a.Value select Enum.Parse(typeof(ItemTier), ((ConfigEntryBase)a).Definition.Key)).ToArray(); foreach (ItemTier item in ((IEnumerable<object>)source).Select((Func<object, ItemTier>)((object v) => (ItemTier)v))) { if (!mainQueues.ContainsKey(item)) { mainQueues.Add(item, new List<QueueEntry>()); } } } private static void InitQueues(Run run) { UpdateQueueAvailability(); QueueManager.OnRunQueueInit?.Invoke(run); } public static bool DoesRepeat(ItemTier tier) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) bool value; return queueRepeat.TryGetValue(tier, out value) && value; } public static void ToggleRepeat(ItemTier tier) { //IL_0006: 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) queueRepeat[tier] = !DoesRepeat(tier); } public static void Enqueue(PickupIndex pickupIndex) { //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_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_007e: Unknown result type (might be due to invalid IL or missing references) ItemTier tier = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(pickupIndex).itemIndex).tier; List<QueueEntry> list = mainQueues[tier]; if (list.Count > 0) { QueueEntry value = list[list.Count - 1]; if (value.pickupIndex == pickupIndex) { value.count++; list[list.Count - 1] = value; QueueManager.OnQueueChanged?.Invoke(QueueChange.Changed, tier, list.Count - 1); return; } } QueueEntry queueEntry = default(QueueEntry); queueEntry.pickupIndex = pickupIndex; queueEntry.count = 1; QueueEntry item = queueEntry; list.Add(item); QueueManager.OnQueueChanged?.Invoke(QueueChange.Added, tier, list.Count - 1); } public static PickupIndex Peek(ItemTier tier) { //IL_0006: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) List<QueueEntry> list = mainQueues[tier]; if (list.Count == 0) { return PickupIndex.none; } return list[0].pickupIndex; } public static PickupIndex Pop(ItemTier tier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) PickupIndex val = Remove(tier, 0); if (DoesRepeat(tier)) { Enqueue(val); } return val; } public static PickupIndex Remove(ItemTier tier, int index, int count = 1) { //IL_0006: 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_0046: 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) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_007d: Unknown result type (might be due to invalid IL or missing references) List<QueueEntry> list = mainQueues[tier]; QueueEntry value = list[index]; value.count -= count; if (value.count <= 0) { list.RemoveAt(index); QueueManager.OnQueueChanged?.Invoke(QueueChange.Removed, tier, index); if (TryMerge(tier, index - 1, index)) { QueueManager.OnQueueChanged?.Invoke(QueueChange.Removed, tier, index); QueueManager.OnQueueChanged?.Invoke(QueueChange.Changed, tier, index - 1); } } else { list[index] = value; QueueManager.OnQueueChanged?.Invoke(QueueChange.Changed, tier, index); } return value.pickupIndex; } private static bool TryMerge(ItemTier tier, int into, int from) { //IL_0006: 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_004d: Unknown result type (might be due to invalid IL or missing references) List<QueueEntry> list = mainQueues[tier]; if (into < 0 || into >= list.Count || from < 0 || from >= list.Count) { return false; } QueueEntry value = list[into]; QueueEntry queueEntry = list[from]; if (value.pickupIndex != queueEntry.pickupIndex) { return false; } value.count += queueEntry.count; list[into] = value; list.RemoveAt(from); return true; } public static void Move(ItemTier tier, int oldIndex, int newIndex, int count = 1) { //IL_0006: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) List<QueueEntry> list = mainQueues[tier]; newIndex = Math.Max(0, Math.Min(list.Count, newIndex)); if (newIndex == oldIndex) { return; } QueueEntry item = list[oldIndex]; if (item.count < count) { return; } if (item.count == count) { list.RemoveAt(oldIndex); if (newIndex > oldIndex) { newIndex--; } } else { QueueEntry value = list[oldIndex]; value.count -= count; list[oldIndex] = value; } item.count = count; if (TryMerge(tier, oldIndex - 1, oldIndex) && newIndex > oldIndex) { newIndex--; } list.Insert(newIndex, item); TryMerge(tier, newIndex - 1, newIndex); TryMerge(tier, newIndex, newIndex + 1); QueueManager.OnQueueChanged?.Invoke(QueueChange.Moved, tier, -1); } public static IEnumerable<(ItemTier, PickupIndex)> PeekAll() { return from entry in mainQueues where entry.Value.Count > 0 select (entry.Key, entry.Value.First().pickupIndex); } public static void ClearAllQueues() { UpdateQueueAvailability(); } public static bool PeekForItemTier(ItemTier tier) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (mainQueues.ContainsKey(tier)) { return mainQueues[tier].Count > 0; } return false; } public static void SetRepeat(ItemTier tier, bool value) { //IL_0006: 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) if (!queueRepeat.ContainsKey(tier)) { queueRepeat.Add(tier, value); } } } public class UIManager : MonoBehaviour { private struct ButtonWrapper { public HGButton hgButton { get; private set; } public TextMeshProUGUI textComponent { get; private set; } public RectTransform rectTransform { get; private set; } public LanguageTextMeshController languageTextMeshController { get; private set; } public ButtonClickedEvent _onClick => ((Button)hgButton).onClick; public string text { get { return languageTextMeshController.token; } set { languageTextMeshController.token = value; } } public string directText { get { TextMeshProUGUI obj = textComponent; return (obj != null) ? ((TMP_Text)obj).text : null; } set { ((TMP_Text)textComponent).text = value; } } public event UnityAction onClick { add { ((UnityEvent)_onClick).AddListener(value); } remove { ((UnityEvent)_onClick).RemoveListener(value); } } public ButtonWrapper(HGButton button) { hgButton = button; textComponent = ((Component)button).GetComponentInChildren<TextMeshProUGUI>(); rectTransform = ((Component)button).GetComponent<RectTransform>(); languageTextMeshController = ((Component)button).GetComponent<LanguageTextMeshController>(); } } private static readonly GameObject commandUIPrefab; private static readonly GameObject commandCancelButton; private static readonly PickupPickerPanel prefabPickupPickerPanel; private static readonly GameObject commandItemButton; private static readonly GameObject commandItemContainer; private static Texture2D repeatIconTexture; private static readonly MethodInfo PickupPickerController_GetOptionsFromPickupIndex; private static readonly Color selectedColorMult; private Sprite missingUnlockIcon; private GameObject itemIconPrefab; private ItemInventoryDisplay itemInventoryDisplayPrefab; private ScoreboardController scoreboard; private HUD hud; private GameObject container; private GameObject origContainer; private ColorBlock origButtonColors; private ColorBlock selectedButtonColors; private ButtonWrapper scoreboardButton; private ButtonWrapper queueButton; private ItemTier lastActiveTab = (ItemTier)0; private GameObject queueContainer; private Dictionary<ItemTier, GameObject> queueDisplays = new Dictionary<ItemTier, GameObject>(); private Dictionary<ItemTier, ButtonWrapper> queueButtons = new Dictionary<ItemTier, ButtonWrapper>(); private bool displayingQueues; private ItemTier selectedQueue = (ItemTier)0; private static Dictionary<ItemTier, ButtonWrapper> repeatButtonListByTier; private List<GameObject> uiElements = new List<GameObject>(); private ItemTier SelectedQueue { get { //IL_0002: 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_000a: Unknown result type (might be due to invalid IL or missing references) return selectedQueue; } set { //IL_0002: 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_0019: 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_0045: 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) //IL_0062: 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) if (selectedQueue != value) { queueDisplays[selectedQueue].SetActive(false); queueDisplays[value].SetActive(true); TransitionEnabledButton(queueButtons[selectedQueue], queueButtons[value]); selectedQueue = value; } } } static UIManager() { //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) PickupPickerController_GetOptionsFromPickupIndex = typeof(PickupPickerController).GetMethod("GetOptionsFromPickupIndex", BindingFlags.Static | BindingFlags.NonPublic); selectedColorMult = new Color(0.3f, 0.3f, 0.3f); repeatButtonListByTier = new Dictionary<ItemTier, ButtonWrapper>(); FieldInfo field = typeof(CommandArtifactManager).GetField("commandCubePrefab", BindingFlags.Static | BindingFlags.NonPublic); object? value = field.GetValue(null); object? obj = ((value is GameObject) ? value : null); commandUIPrefab = ((obj != null) ? ((GameObject)obj).GetComponent<PickupPickerController>().panelPrefab : null); commandCancelButton = ((Component)commandUIPrefab.GetComponentsInChildren<HGButton>().First((HGButton a) => ((Object)a).name == "CancelButton")).gameObject; prefabPickupPickerPanel = commandUIPrefab.GetComponent<PickupPickerPanel>(); commandItemButton = prefabPickupPickerPanel.buttonPrefab; commandItemContainer = ((Component)prefabPickupPickerPanel.buttonContainer).gameObject; } private static void CopyRectTransform(RectTransform dest, RectTransform source) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_002a: 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) dest.anchorMin = source.anchorMin; dest.anchorMax = source.anchorMax; dest.anchoredPosition = source.anchoredPosition; ((Transform)dest).position = ((Transform)source).position; dest.sizeDelta = source.sizeDelta; } private static void ReparentChildren(Transform dest, Transform source, bool keepWorldPos = false, Action<Transform> additionalAction = null) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown List<Transform> list = new List<Transform>(); foreach (Transform item in source) { Transform val = item; if ((Object)(object)val != (Object)(object)dest) { list.Add(val); } } foreach (Transform item2 in list) { item2.SetParent(dest, keepWorldPos); additionalAction?.Invoke(item2); } } private static IEnumerator ExecuteNextFrameInner(Action action) { yield return 0; action(); } private void ExecuteNextFrame(Action action) { ((MonoBehaviour)this).StartCoroutine(ExecuteNextFrameInner(action)); } private ButtonWrapper CreateButton(GameObject parent = null, UnityAction onClick = null, string text = null) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(commandCancelButton, (parent != null) ? parent.transform : null); uiElements.Add(val); HGButton component = val.GetComponent<HGButton>(); ((MPButton)component).onSelect = new UnityEvent(); ((MPButton)component).onDeselect = new UnityEvent(); ((Button)component).onClick = new ButtonClickedEvent(); ButtonWrapper result = new ButtonWrapper(component); if (text != null) { result.text = text; } if (onClick != null) { result.onClick += onClick; } return result; } private void MarkButton(ButtonWrapper button, bool state) { //IL_0014: 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_0035: 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) ((Selectable)button.hgButton).colors = (state ? selectedButtonColors : origButtonColors); ((Graphic)button.hgButton.imageOnHover).color = (state ? selectedColorMult : Color.white); } private void TransitionEnabledButton(ButtonWrapper from, ButtonWrapper to) { MarkButton(from, state: false); MarkButton(to, state: true); } private void UpdateButtonColors() { if (Object.op_Implicit((Object)(object)queueButton.hgButton) && Object.op_Implicit((Object)(object)scoreboardButton.hgButton)) { ButtonWrapper to; ButtonWrapper from; if (displayingQueues) { to = queueButton; from = scoreboardButton; } else { to = scoreboardButton; from = queueButton; } TransitionEnabledButton(from, to); } } private void PrintObject(GameObject obj, bool components = false, int depth = 0) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(' ', depth * 2); stringBuilder.Append(((object)obj).ToString()); Debug.Log((object)stringBuilder.ToString()); if (components) { Component[] components2 = obj.GetComponents<Component>(); foreach (Component val in components2) { stringBuilder.Clear(); stringBuilder.Append(' ', depth * 2); stringBuilder.Append('-'); stringBuilder.Append(((object)val).ToString()); Debug.Log((object)stringBuilder.ToString()); } } foreach (Transform item in obj.transform) { Transform val2 = item; PrintObject(((Component)val2).gameObject, components, depth + 1); } } private PickupIndex GetPickupIndexOfItemTier(ItemTier itemTier) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_0006: 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_0035: Expected I4, but got Unknown //IL_00be: 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_00b4: 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_00c7: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = null; switch ((int)itemTier) { case 0: list = Run.instance.availableTier1DropList; break; case 1: list = Run.instance.availableTier2DropList; break; case 2: list = Run.instance.availableTier3DropList; break; case 4: list = Run.instance.availableBossDropList; break; case 3: list = Run.instance.availableLunarItemDropList; break; case 6: list = Run.instance.availableVoidTier1DropList; break; case 7: list = Run.instance.availableVoidTier2DropList; break; case 8: list = Run.instance.availableVoidTier3DropList; break; case 9: list = Run.instance.availableVoidBossDropList; break; } return list?.FirstOrDefault() ?? PickupIndex.none; } private RectTransform CreateQueueContainer(ItemTier itemTier, RectTransform parent, Action<PickupIndex> callback) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_00a3: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_012f: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"{itemTier}QueueContainer", new Type[1] { typeof(RectTransform) }); Transform transform = val.transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); ((Transform)val2).SetParent((Transform)(object)parent, false); GameObject val3 = Object.Instantiate<GameObject>(((Component)itemInventoryDisplayPrefab).gameObject, (Transform)(object)val2, false); Object.DestroyImmediate((Object)(object)val3.GetComponent<ItemInventoryDisplay>()); Object.DestroyImmediate((Object)(object)val3.GetComponent<LayoutElement>()); Transform transform2 = val3.transform; RectTransform val4 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(1f, 1f); val4.sizeDelta = new Vector2(-60f, 50f); val4.anchoredPosition = new Vector2(0f, -5f); val4.pivot = new Vector2(0f, 1f); ButtonWrapper repeatButton = default(ButtonWrapper); repeatButton = CreateButton(val, (UnityAction)delegate { //IL_0002: 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) QueueManager.ToggleRepeat(itemTier); MarkButton(repeatButton, QueueManager.DoesRepeat(itemTier)); }, ""); RectTransform rectTransform = repeatButton.rectTransform; rectTransform.anchorMin = new Vector2(1f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.sizeDelta = new Vector2(55f, 55f); rectTransform.anchoredPosition = new Vector2(0f, -2.5f); rectTransform.pivot = new Vector2(1f, 1f); GameObject val5 = new GameObject($"{itemTier}RepeatButtonImageHolder", new Type[1] { typeof(RectTransform) }); Transform transform3 = val5.transform; RectTransform val6 = (RectTransform)(object)((transform3 is RectTransform) ? transform3 : null); ((Transform)val6).SetParent((Transform)(object)rectTransform, false); val6.anchorMin = new Vector2(0f, 0f); val6.anchorMax = new Vector2(1f, 1f); val6.sizeDelta = new Vector2(-15f, -15f); RawImage val7 = val5.AddComponent<RawImage>(); val7.texture = (Texture)(object)repeatIconTexture; MarkButton(repeatButton, QueueManager.DoesRepeat(itemTier)); repeatButtonListByTier.Add(itemTier, repeatButton); QueueDisplay queueDisplay = val3.AddComponent<QueueDisplay>(); queueDisplay.itemIconPrefab = itemIconPrefab; queueDisplay.itemIconPrefabWidth = itemInventoryDisplayPrefab.itemIconPrefabWidth; queueDisplay.tier = itemTier; GameObject val8 = Object.Instantiate<GameObject>(commandItemContainer, (Transform)(object)val2, false); RectTransform itemButtonsTransform = default(RectTransform); ref RectTransform reference = ref itemButtonsTransform; Transform transform4 = val8.transform; reference = (RectTransform)(object)((transform4 is RectTransform) ? transform4 : null); GridLayoutGroup component = val8.GetComponent<GridLayoutGroup>(); UIElementAllocator<MPButton> val9 = new UIElementAllocator<MPButton>(itemButtonsTransform, commandItemButton, true, false); if (AutoCommandQueuePickup.config.bigItemButtonContainer.Value) { Object.Destroy((Object)(object)val8.GetComponent<RawImage>()); component.constraint = (Constraint)0; component.startCorner = (Corner)0; component.startAxis = (Axis)0; ((LayoutGroup)component).childAlignment = (TextAnchor)1; component.cellSize *= AutoCommandQueuePickup.config.bigItemButtonScale.Value; itemButtonsTransform.anchoredPosition = new Vector2(0f, 0f); itemButtonsTransform.anchorMin = new Vector2(0f, 0f); itemButtonsTransform.anchorMax = new Vector2(1f, 1f); itemButtonsTransform.sizeDelta = new Vector2(0f, -55f); itemButtonsTransform.pivot = new Vector2(0.5f, 0f); } else { component.constraint = (Constraint)1; component.constraintCount = prefabPickupPickerPanel.maxColumnCount; ((LayoutGroup)component).childAlignment = (TextAnchor)1; itemButtonsTransform.anchorMin = new Vector2(0.5f, 1f); itemButtonsTransform.anchorMax = new Vector2(0.5f, 1f); itemButtonsTransform.anchoredPosition = new Vector2(0f, -55f); itemButtonsTransform.pivot = new Vector2(0f, 1f); itemButtonsTransform.sizeDelta = default(Vector2); } Option[] itemOptions = (Option[])PickupPickerController_GetOptionsFromPickupIndex.Invoke(null, new object[1] { GetPickupIndexOfItemTier(itemTier) }); if (itemOptions != null) { val9.onCreateElement = delegate(int index, MPButton button) { //IL_0008: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown Option val10 = itemOptions[index]; PickupDef pickupDef = PickupCatalog.GetPickupDef(val10.pickupIndex); Image component2 = ((Component)((Component)button).GetComponent<ChildLocator>().FindChild("Icon")).GetComponent<Image>(); if (val10.available && pickupDef != null) { ((Graphic)component2).color = Color.white; component2.sprite = pickupDef.iconSprite; ((Selectable)button).interactable = true; PickupIndex pickupIndex = pickupDef.pickupIndex; ((UnityEvent)((Button)button).onClick).AddListener((UnityAction)delegate { //IL_000d: Unknown result type (might be due to invalid IL or missing references) callback(pickupIndex); LayoutRebuilder.MarkLayoutForRebuild(itemButtonsTransform); }); } else { ((Graphic)component2).color = Color.gray; component2.sprite = missingUnlockIcon; ((Selectable)button).interactable = false; } }; val9.AllocateElements(itemOptions.Length); } return val2; } private void ToggleRepeatButtons() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<ItemTier, ButtonWrapper> item in repeatButtonListByTier) { MarkButton(item.Value, QueueManager.DoesRepeat(item.Key)); } } private RectTransform CreateSaveLoadContainer(RectTransform parent) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SaveLoadContainer", new Type[1] { typeof(RectTransform) }); Transform transform = val.transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); ((Transform)val2).SetParent((Transform)(object)parent, false); float num = 5f; for (int i = 1; (float)i <= num; i++) { int slot = i; float num2 = (num + 1f - (float)slot) * 1.2f / num - 0.6f; ButtonWrapper loadButton = CreateButton(text: $"Load slot {slot} ({AutoCommandQueuePickup.config.PreviewSlot(slot)})", parent: val, onClick: (UnityAction)delegate { AutoCommandQueuePickup.config.LoadQueue(slot); ToggleRepeatButtons(); }); RectTransform rectTransform = loadButton.rectTransform; rectTransform.anchorMin = new Vector2(0.25f, num2); rectTransform.anchorMax = new Vector2(0.495f, num2 + 0.24f); rectTransform.anchoredPosition = default(Vector2); rectTransform.sizeDelta = default(Vector2); RectTransform rectTransform2 = CreateButton(text: $"Save in slot {slot}", parent: val, onClick: (UnityAction)delegate { AutoCommandQueuePickup.config.SaveQueue(slot); loadButton.text = $"Load slot {slot} ({AutoCommandQueuePickup.config.PreviewSlot(slot)})"; }).rectTransform; rectTransform2.anchorMin = new Vector2(0.505f, num2); rectTransform2.anchorMax = new Vector2(0.75f, num2 + 0.24f); rectTransform2.anchoredPosition = default(Vector2); rectTransform2.sizeDelta = default(Vector2); } return val2; } private void DestroyUI() { foreach (GameObject uiElement in uiElements) { Object.Destroy((Object)(object)uiElement); } uiElements.Clear(); repeatButtonListByTier.Clear(); if ((Object)(object)container != (Object)null) { RectTransform component = container.GetComponent<RectTransform>(); RectTransform component2 = origContainer.GetComponent<RectTransform>(); ReparentChildren((Transform)(object)component2, (Transform)(object)component); Object.Destroy((Object)(object)container); Object.Destroy((Object)(object)queueContainer); container = null; } } private void RebuildUI() { //IL_0013: 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: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_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) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Expected O, but got Unknown //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) DestroyUI(); origButtonColors = ((Selectable)commandCancelButton.GetComponent<HGButton>()).colors; ColorBlock val = origButtonColors; ((ColorBlock)(ref val)).disabledColor = ((ColorBlock)(ref val)).disabledColor * selectedColorMult; ((ColorBlock)(ref val)).pressedColor = ((ColorBlock)(ref val)).pressedColor * selectedColorMult; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.7f, 0.55f, 0.1f, 1f); ((ColorBlock)(ref val)).normalColor = val2; ((ColorBlock)(ref val)).highlightedColor = val2; selectedButtonColors = val; container = new GameObject("CommandQueueScoreboardWrapper", new Type[1] { typeof(RectTransform) }); RectTransform component = container.GetComponent<RectTransform>(); origContainer = ((Component)scoreboard).gameObject; RectTransform component2 = origContainer.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)component2, false); component.sizeDelta = new Vector2(0f, 0f); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 0.9f); ReparentChildren((Transform)(object)component, (Transform)(object)component2); queueContainer = new GameObject("CommandQueueContainer", new Type[1] { typeof(RectTransform) }); Transform transform = queueContainer.transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); ((Transform)val3).SetParent((Transform)(object)component2, false); CopyRectTransform(val3, component); Dictionary<ItemTier, string> dictionary = new Dictionary<ItemTier, string> { { (ItemTier)0, "White" }, { (ItemTier)1, "Green" }, { (ItemTier)2, "Red" } }; object[] array = (from a in AutoCommandQueuePickup.config.enabledTabsConfig where a.Value select Enum.Parse(typeof(ItemTier), ((ConfigEntryBase)a).Definition.Key)).ToArray(); float num = (float)array.Length + 1f; int num2 = 0; foreach (ItemTier item in ((IEnumerable<object>)array).Select((Func<object, ItemTier>)((object v) => (ItemTier)v))) { ItemTier tier = item; string text = (dictionary.ContainsKey(tier) ? dictionary[tier] : ((object)(ItemTier)(ref tier)).ToString()); string text2 = text; ButtonWrapper value = CreateButton(queueContainer, (UnityAction)delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SelectedQueue = tier; }, text2); value.rectTransform.anchorMin = new Vector2((float)num2 / num, 8f / 9f); value.rectTransform.anchorMax = new Vector2((float)(num2 + 1) / num, 1f); value.rectTransform.anchoredPosition = default(Vector2); value.rectTransform.sizeDelta = default(Vector2); RectTransform val4 = CreateQueueContainer(tier, val3, delegate(PickupIndex index) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) QueueManager.Enqueue(index); }); val4.anchorMin = new Vector2(0f, 0f); val4.anchorMax = new Vector2(1f, 8f / 9f); val4.sizeDelta = default(Vector2); val4.anchoredPosition = default(Vector2); ((Component)val4).gameObject.SetActive(false); value.onClick += (UnityAction)delegate { //IL_0008: 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) lastActiveTab = tier; }; queueDisplays[tier] = ((Component)val4).gameObject; queueButtons[tier] = value; num2++; } ButtonWrapper value2 = CreateButton(queueContainer, (UnityAction)delegate { SelectedQueue = (ItemTier)5; }, "Saves"); value2.rectTransform.anchorMin = new Vector2((float)num2 / num, 8f / 9f); value2.rectTransform.anchorMax = new Vector2((float)(num2 + 1) / num, 1f); value2.rectTransform.anchoredPosition = default(Vector2); value2.rectTransform.sizeDelta = default(Vector2); RectTransform val5 = CreateSaveLoadContainer(val3); val5.anchorMin = new Vector2(0f, 0f); val5.anchorMax = new Vector2(1f, 8f / 9f); val5.sizeDelta = default(Vector2); val5.anchoredPosition = default(Vector2); ((Component)val5).gameObject.SetActive(false); queueDisplays[(ItemTier)5] = ((Component)val5).gameObject; queueButtons[(ItemTier)5] = value2; selectedQueue = lastActiveTab; queueDisplays[selectedQueue].SetActive(true); ExecuteNextFrame(delegate { //IL_0009: Unknown result type (might be due to invalid IL or missing references) MarkButton(queueButtons[selectedQueue], state: true); }); queueContainer.SetActive(false); scoreboardButton = CreateButton(origContainer, null, "Scoreboard"); scoreboardButton.rectTransform.anchoredPosition = default(Vector2); scoreboardButton.rectTransform.anchorMin = new Vector2(0f, 0.9f); scoreboardButton.rectTransform.anchorMax = new Vector2(0.333f, 1f); scoreboardButton.rectTransform.sizeDelta = default(Vector2); scoreboardButton.onClick += new UnityAction(DisplayScoreboardContainer); queueButton = CreateButton(origContainer, null, "Command Queue"); queueButton.rectTransform.anchoredPosition = default(Vector2); queueButton.rectTransform.anchorMin = new Vector2(0.333f, 0.9f); queueButton.rectTransform.anchorMax = new Vector2(0.667f, 1f); queueButton.rectTransform.sizeDelta = default(Vector2); queueButton.onClick += new UnityAction(DisplayQueueContainer); ExecuteNextFrame(delegate { UpdateButtonColors(); }); } public void DisplayQueueContainer() { container.SetActive(false); queueContainer.SetActive(true); displayingQueues = true; UpdateButtonColors(); } public void DisplayScoreboardContainer() { container.SetActive(true); queueContainer.SetActive(false); displayingQueues = false; UpdateButtonColors(); } public void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!AutoCommandQueuePickup.IsLoaded) { Log.Warning("AutoCommandQueuePickup is not loaded, destroying UIManager"); Object.Destroy((Object)(object)this); return; } repeatIconTexture = new Texture2D(0, 0); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AutoCommandQueuePickup.repeat-solid.png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); ImageConversion.LoadImage(repeatIconTexture, array); } scoreboard = ((Component)this).GetComponent<ScoreboardController>(); hud = ((Component)this).GetComponentInParent<HUD>(); missingUnlockIcon = Resources.Load<Sprite>("Textures/MiscIcons/texUnlockIcon"); itemInventoryDisplayPrefab = scoreboard.stripPrefab.GetComponent<ScoreboardStrip>().itemInventoryDisplay; itemIconPrefab = itemInventoryDisplayPrefab.itemIconPrefab; AutoCommandQueuePickup.PluginUnloaded = (Action)Delegate.Combine(AutoCommandQueuePickup.PluginUnloaded, (Action)delegate { Object.DestroyImmediate((Object)(object)this); }); } private void OnDestroy() { DestroyUI(); Object.Destroy((Object)(object)repeatIconTexture); } private void OnEnable() { RebuildUI(); if (displayingQueues) { DisplayQueueContainer(); } else { DisplayScoreboardContainer(); } } } public abstract class ItemDistributor { public delegate bool TargetFilter(CharacterMaster target); protected ItemDistributor(AutoCommandQueuePickup plugin) { UpdateTargets(); } public abstract CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null); public void DestributeCommandItem(ref CreatePickupInfo pickupInfo, TargetFilter extraFilter = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) CharacterMaster target = GetTarget(pickupInfo.position, ((CreatePickupInfo)(ref pickupInfo)).pickupIndex, extraFilter); if (!((Object)(object)target == (Object)null)) { pickupInfo.position = ((Component)target).transform.position; } } public void DistributeItem(GenericPickupController item, TargetFilter extraFilter = null) { //IL_0008: 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) CharacterMaster target = GetTarget(((Component)item).transform.position, item.pickupIndex, extraFilter); if (!((Object)(object)target == (Object)null)) { AutoCommandQueuePickup.GrantItem(item, target); } } public abstract void UpdateTargets(); public virtual bool IsValid() { return true; } protected bool IsValidTarget(CharacterMaster master) { return AutoCommandQueuePickup.config.CheckTarget(master); } protected bool IsValidTarget(PlayerCharacterMasterController player) { return (Object)(object)player != (Object)null && IsValidTarget(player.master); } protected List<PlayerCharacterMasterController> GetValidTargets() { return PlayerCharacterMasterController.instances.Where(IsValidTarget).ToList(); } public static ItemDistributor GetItemDistributor(Mode mode, AutoCommandQueuePickup plugin) { return mode switch { Mode.Closest => new ClosestDistributor(plugin), Mode.LeastItems => new LeastItemsDistributor(plugin), Mode.Random => new RandomDistributor(plugin), _ => new SequentialDistributor(plugin), }; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } public class OverrideDistributorBehaviour : MonoBehaviour { public ItemDistributor Distributor; } public static class SaveAndLoad { public static void Load(string path) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00db: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { return; } string value = File.ReadAllText(path).Trim(); if (string.IsNullOrEmpty(value)) { return; } QueueManager.ClearAllQueues(); try { using StreamReader streamReader = new StreamReader(path); string text; while ((text = streamReader.ReadLine()) != null) { if (text == "") { continue; } string[] array = text.Split(new char[1] { ',' }); ItemTier tier = (ItemTier)Enum.Parse(typeof(ItemTier), array[0]); bool value2 = Convert.ToBoolean(array[1]); QueueManager.SetRepeat(tier, value2); for (int i = 2; i < array.Length; i++) { if (!string.IsNullOrEmpty(array[i])) { string[] array2 = array[i].Split(new char[1] { '*' }); for (int j = 0; j < int.Parse(array2[1]); j++) { QueueManager.Enqueue(new PickupIndex(Convert.ToInt32(array2[0]))); } } } } } catch (Exception data) { Log.Debug(data); } } public static void Save(string path) { //IL_002a: 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_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) try { string text = ""; ItemTier[] array = (ItemTier[])Enum.GetValues(typeof(ItemTier)); ItemTier[] array2 = array; for (int i = 0; i < array2.Length; i++) { ItemTier val = array2[i]; if (!QueueManager.PeekForItemTier(val)) { continue; } text = text + ((object)(ItemTier)(ref val)).ToString() + "," + QueueManager.DoesRepeat(val) + ","; foreach (QueueManager.QueueEntry item in QueueManager.mainQueues[val]) { text += $"{item.pickupIndex.value}*{item.count},"; } text += "\n"; } if (!File.Exists(path)) { File.Create(path).Dispose(); } using StreamWriter streamWriter = new StreamWriter(path); streamWriter.WriteLine(text); streamWriter.Dispose(); } catch (Exception data) { Log.Debug(data); } } } } namespace AutoCommandQueuePickup.ItemDistributors { internal class ClosestDistributor : ItemDistributor { private CharacterMaster[] targets; public ClosestDistributor(AutoCommandQueuePickup plugin) : base(plugin) { } public override void UpdateTargets() { targets = (from player in GetValidTargets() select player.master).ToArray(); } public override CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) CharacterMaster result = null; float num = float.MaxValue; CharacterMaster[] array = targets; foreach (CharacterMaster val in array) { if (extraFilter == null || extraFilter(val)) { Vector3 val2 = (val.hasBody ? val.GetBodyObject().transform.position : val.deathFootPosition); Vector3 val3 = position - val2; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { result = val; num = sqrMagnitude; } } } return result; } } internal class FixedTargetDistributor : ItemDistributor { private readonly CharacterMaster target; public FixedTargetDistributor(AutoCommandQueuePickup plugin, PlayerCharacterMasterController target) : this(plugin, target.master) { } public FixedTargetDistributor(AutoCommandQueuePickup plugin, CharacterMaster target) : base(plugin) { this.target = target; } public override bool IsValid() { return IsValidTarget(target); } public override void UpdateTargets() { } public override CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null) { if (extraFilter != null && !extraFilter(target)) { return null; } return target; } } internal class LeastItemsDistributor : ItemDistributor { private CharacterMaster[] targets; public LeastItemsDistributor(AutoCommandQueuePickup plugin) : base(plugin) { } public override void UpdateTargets() { List<PlayerCharacterMasterController> validTargets = GetValidTargets(); targets = (CharacterMaster[])(object)new CharacterMaster[validTargets.Count]; for (int i = 0; i < validTargets.Count; i++) { PlayerCharacterMasterController val = validTargets[i]; targets[i] = val.master; } } public override CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) CharacterMaster result = null; int num = int.MaxValue; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef == null) { return targets.First(); } ItemTier tier = ItemCatalog.GetItemDef(pickupDef.itemIndex).tier; CharacterMaster[] array = targets; foreach (CharacterMaster val in array) { if (extraFilter == null || extraFilter(val)) { int totalItemCountOfTier = val.inventory.GetTotalItemCountOfTier(tier); if (totalItemCountOfTier < num) { result = val; num = totalItemCountOfTier; } } } return result; } } internal class RandomDistributor : ItemDistributor { private CharacterMaster[] targets; public RandomDistributor(AutoCommandQueuePickup plugin) : base(plugin) { } public override void UpdateTargets() { targets = (from pcmc in GetValidTargets() select pcmc.master).ToArray(); } public override CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null) { IEnumerable<CharacterMaster> source = targets.AsEnumerable(); if (extraFilter != null) { source = source.Where((CharacterMaster target) => extraFilter(target)); } CharacterMaster[] array = source.ToArray(); return array.ElementAtOrDefault(Random.Range(0, array.Length)); } } internal class SequentialDistributor : ItemDistributor { private int index; private CharacterMaster[] playerDistribution; public SequentialDistributor(AutoCommandQueuePickup plugin) : base(plugin) { } public override void UpdateTargets() { CharacterMaster[] array = playerDistribution; CharacterMaster val = ((array != null) ? array[index] : null); List<PlayerCharacterMasterController> validTargets = GetValidTargets(); playerDistribution = (CharacterMaster[])(object)new CharacterMaster[validTargets.Count]; index = -1; for (int i = 0; i < validTargets.Count; i++) { PlayerCharacterMasterController val2 = validTargets[i]; playerDistribution[i] = val2.master; if ((Object)(object)val2.master == (Object)(object)val) { index = i; } } if (index == -1) { index = Random.Range(0, playerDistribution.Length); } } public override CharacterMaster GetTarget(Vector3 position, PickupIndex pickupIndex, TargetFilter extraFilter = null) { if (playerDistribution.Length == 0) { return null; } CharacterMaster result = null; if (extraFilter != null) { for (int i = 0; i < playerDistribution.Length; i++) { CharacterMaster val = playerDistribution[(index + i) % playerDistribution.Length]; if (extraFilter(val)) { result = val; index = (index + i + 1) % playerDistribution.Length; break; } } } else { result = playerDistribution[index]; index = ++index % playerDistribution.Length; } return result; } } } namespace AutoCommandQueuePickup.Configuration { public class Config { public class ItemTierSet : SortedSet<ItemTier> { public static string Serialize(ItemTierSet self) { return string.Join(", ", self.Select((ItemTier x) => ((object)(ItemTier)(ref x)).ToString())); } public static ItemTierSet Deserialize(string src) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) ItemTierSet itemTierSet = new ItemTierSet(); foreach (string item in from s in src.Split(new char[1] { ',' }) select s.Trim()) { int result2; if (Enum.TryParse<ItemTier>(item, out ItemTier result)) { itemTierSet.Add(result); } else if (int.TryParse(item, out result2)) { itemTierSet.Add((ItemTier)result2); } } return itemTierSet; } public static string SerializeForConfig(string self) { return Serialize(Deserialize(self)); } public override string ToString() { return Serialize(this); } } public readonly AutoCommandQueuePickup Plugin; private readonly ManualLogSource logger; public ConfigEntry<Mode> distributionMode; public ConfigEntry<Distribution> timeOfDistribution; public ItemFilter OnDrop; public ItemFilter OnTeleport; public ConfigEntry<bool> overrideScrapper; public ConfigEntry<bool> overridePrinter; public ConfigEntry<string> enabledTabs; public List<ConfigEntry<bool>> enabledTabsConfig = new List<ConfigEntry<bool>>(); public ConfigEntry<bool> bigItemButtonContainer; public ConfigEntry<float> bigItemButtonScale; public ConfigEntry<bool> rightClickRemovesStack; public ConfigMigrator migrator; public Texture2D ModIcon; public readonly string saveDirectory = Path.Combine(Application.persistentDataPath, "AutoCommandQueuePickup"); private const string fileName = "commandQueueSlot_"; private const string extension = "csv"; public static int totalItems; public ConfigFile config => ((BaseUnityPlugin)Plugin).Config; private bool OnDropReady => OnDrop?.Ready ?? false; private bool OnTeleportReady => OnTeleport?.Ready ?? false; public bool Ready => OnDropReady && OnTeleportReady; public event Action OnConfigReady; public Config(AutoCommandQueuePickup plugin, ManualLogSource _logger) { //IL_0117: 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_013a: 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: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01b0: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01e5: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0216: Expected O, but got Unknown //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown Plugin = plugin; logger = _logger; migrator = new ConfigMigrator(config, this); OnTeleport = new ItemFilter("OnTeleportFilter", config); OnDrop = new ItemFilter("OnDropFilter", config); distributionMode = config.Bind<Mode>("AutoItemPickup", "DistributionMode", Mode.Sequential, "Decide how to distribute items among the players\r\n Sequential - Goes over all players, giving each of them one item\r\n Random - Chooses which player receives the item randomly\r\n Closest - Gives the item to the nearest player\r\n LeastItems - Gives the item to the player with least total items of the item's tier"); timeOfDistribution = config.Bind<Distribution>("AutoItemPickup", "TimeOfDistribution", Distribution.OnDrop, "When should items be distributed?\r\n OnTeleport - When the teleporter is charged\r\n OnDrop - Immediately when the item drops"); overrideScrapper = config.Bind<bool>("AutoItemPickup", "OverrideScrapper", true, "Should items dropped by scrappers be distributed?"); overridePrinter = config.Bind<bool>("AutoItemPickup", "OverridePrinter", true, "Should items dropped by 3D printers be distributed?"); ItemTier[] array = (ItemTier[])Enum.GetValues(typeof(ItemTier)); ItemTier[] array2 = array; foreach (ItemTier val in array2) { ConfigEntry<bool> val2 = config.Bind<bool>("CommandQueue", $"{val}", true, new ConfigDescription($"Should {val} items be queued?", (AcceptableValueBase)null, Array.Empty<object>())); val2.SettingChanged += UpdateSettings; enabledTabsConfig.Add(val2); } bigItemButtonContainer = config.Bind<bool>(new ConfigDefinition("UI", "BigItemSelectionContainer"), true, new ConfigDescription("false: Default command button layout\ntrue: Increase the space for buttons, helps avoid overflow with modded items", (AcceptableValueBase)null, Array.Empty<object>())); bigItemButtonScale = config.Bind<float>(new ConfigDefinition("UI", "BigItemSelectionScale"), 1f, new ConfigDescription("Scale applied to item buttons in the menu - decrease it if your buttons don't fit\nApplies only if BigItemSelectionContainer is true", (AcceptableValueBase)null, Array.Empty<object>())); rightClickRemovesStack = config.Bind<bool>(new ConfigDefinition("UI", "RightClickRemovesStack"), true, new ConfigDescription("Should right-clicking an item in the queue remove the whole stack?", (AcceptableValueBase)null, Array.Empty<object>())); overridePrinter.SettingChanged += UpdateSettings; overrideScrapper.SettingChanged += UpdateSettings; distributionMode.SettingChanged += UpdateSettings; timeOfDistribution.SettingChanged += UpdateSettings; bigItemButtonContainer.SettingChanged += UpdateSettings; bigItemButtonScale.SettingChanged += UpdateSettings; rightClickRemovesStack.SettingChanged += UpdateSettings; config.SettingChanged += ConfigOnSettingChanged; OnTeleport.OnReady += CheckReadyStatus; OnDrop.OnReady += CheckReadyStatus; OnConfigReady += DoMigrationIfReady; TomlTypeConverter.AddConverter(typeof(ItemTierSet), new TypeConverter { ConvertToObject = (string str, Type type) => ItemTierSet.Deserialize(str), ConvertToString = (object obj, Type type) => obj.ToString() }); ModIcon = new Texture2D(2, 2); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AutoCommandQueuePickup.icon.png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array3 = memoryStream.ToArray(); ImageConversion.LoadImage(ModIcon, array3); } if (!Directory.Exists(saveDirectory)) { Directory.CreateDirectory(saveDirectory); } CreateRiskOfOptionsConfig(); DoMigrationIfReady(); } public void CreateRiskOfOptionsConfig() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown