using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Keybound.Cards; using Keybound.Compat; using Keybound.Core; using Keybound.Effects; using Keybound.UI; using Microsoft.CodeAnalysis; using TMPro; using UnboundLib.Cards; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: AssemblyCompany("Keybound")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+146ac727a7fc6b83f382d57f53cce40478349c58")] [assembly: AssemblyProduct("Keybound Mod for ROUNDS")] [assembly: AssemblyTitle("Keybound")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Keybound { internal static class KLog { private static ManualLogSource Logger => Plugin.Logger; internal static void Section(string title) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)"====================="); } ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("[Keybound] " + title)); } ManualLogSource logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)"====================="); } } internal static void Line(string message) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)("[Keybound] " + message)); } } internal static void Warn(string message) { ManualLogSource logger = Logger; if (logger != null) { logger.LogWarning((object)("[Keybound] " + message)); } } internal static void Error(string message) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("[Keybound] " + message)); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Keybound", "Keybound Mod for ROUNDS", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static string PluginDirectory { get; private set; } private void Awake() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? ""; KLog.Section("Plugin Awake"); KLog.Line("PluginDirectory = " + PluginDirectory); new Harmony("Keybound").PatchAll(); ((Component)this).gameObject.AddComponent(); GameObject val = new GameObject("KB_UIRoot"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); val.AddComponent(); KLog.Line("Plugin Keybound loaded."); } private void Start() { KeyboundCardRegistrar.RegisterAll(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Keybound"; public const string PLUGIN_NAME = "Keybound Mod for ROUNDS"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Keybound.UI { public class EffectStackOverlay : MonoBehaviour { private sealed class PlayerEffectRow { internal GameObject Root; private RectTransform _slotRow; private readonly List _slots = new List(); private Action _onHover; private Action _onHoverExit; internal static PlayerEffectRow Create(Transform parent, int playerID, Action onHover, Action onHoverExit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GameObject val = new GameObject($"EffectRow_P{playerID}"); val.transform.SetParent(parent, false); val.AddComponent(); LayoutElement obj = val.AddComponent(); obj.preferredHeight = 35f; obj.minHeight = 35f; HorizontalLayoutGroup obj2 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 6f; ((LayoutGroup)obj2).childAlignment = (TextAnchor)5; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; return new PlayerEffectRow { Root = val, _slotRow = val.GetComponent(), _onHover = onHover, _onHoverExit = onHoverExit }; } internal void Refresh(IReadOnlyList bindings) { Root.SetActive(true); EnsureSlotCount(bindings.Count); for (int i = 0; i < bindings.Count; i++) { _slots[i].Bind(bindings[i]); } for (int j = bindings.Count; j < _slots.Count; j++) { _slots[j].Root.SetActive(false); } } private void EnsureSlotCount(int count) { while (_slots.Count < count) { EffectSlotView item = EffectSlotView.Create((Transform)(object)_slotRow, _onHover, _onHoverExit); _slots.Add(item); } } } private sealed class EffectSlotView : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { internal GameObject Root; private Image _bg; private TextMeshProUGUI _label; private static readonly Color CooldownRed = new Color(0.55f, 0.12f, 0.12f, 0.95f); private static readonly Color ReadyGreen = new Color(0.12f, 0.55f, 0.18f, 0.95f); private static readonly Color BorderRed = new Color(0.95f, 0.2f, 0.2f, 1f); private static readonly Color BorderGreen = new Color(0.2f, 1f, 0.2f, 1f); private KeyboundBinding _binding; private Action _onHover; private Action _onHoverExit; internal static EffectSlotView Create(Transform parent, Action onHover, Action onHoverExit) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("EffectSlot"); val.transform.SetParent(parent, false); val.AddComponent().sizeDelta = new Vector2(35f, 35f); LayoutElement obj = val.AddComponent(); obj.preferredWidth = 35f; obj.preferredHeight = 35f; EffectSlotView effectSlotView = val.AddComponent(); effectSlotView._onHover = onHover; effectSlotView._onHoverExit = onHoverExit; effectSlotView.Root = val; effectSlotView.Build(); return effectSlotView; } private void Build() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) _bg = ((Component)this).gameObject.AddComponent(); ((Graphic)_bg).color = CooldownRed; Outline obj = ((Component)_bg).gameObject.AddComponent(); ((Shadow)obj).effectColor = BorderRed; ((Shadow)obj).effectDistance = new Vector2(3f, -3f); _label = UIHelper.CreateText(((Component)this).transform, "Abbr", "—", 12, (TextAlignmentOptions)514); } internal void Bind(KeyboundBinding binding) { _binding = binding; ((TMP_Text)_label).text = Abbreviate(binding.CardName); RefreshVisual(); } private void Update() { if (_binding != null) { RefreshVisual(); } } private void RefreshVisual() { //IL_0018: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) float num = 1f - _binding.CooldownFill(); ((Graphic)_bg).color = Color.Lerp(CooldownRed, ReadyGreen, num); Outline obj = ((Component)_bg).GetComponent() ?? ((Component)_bg).gameObject.AddComponent(); ((Shadow)obj).effectColor = (_binding.IsReady() ? BorderGreen : BorderRed); ((Shadow)obj).effectDistance = new Vector2(3f, -3f); } public void OnPointerEnter(PointerEventData _) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (_binding != null) { _onHover?.Invoke(_binding, ((Component)this).transform.position); } } public void OnPointerExit(PointerEventData _) { _onHoverExit?.Invoke(); } private static string Abbreviate(string name) { if (string.IsNullOrEmpty(name)) { return "?"; } if (name.Length == 1) { return name.ToUpper(); } return char.ToUpper(name[0]) + name.Substring(1, 1).ToLower(); } } public static EffectStackOverlay instance; private const float RowHeight = 35f; private const float RowSpacing = 4f; private const float SlotSize = 35f; private Canvas _canvas; private RectTransform _container; private readonly Dictionary _playerRows = new Dictionary(); private GameObject _hoverCard; private void Awake() { instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BuildUI(); ((Component)_canvas).gameObject.SetActive(false); } private void BuildUI() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown _canvas = UIHelper.CreateFullscreenCanvas("KB_EffectStack", 45); _container = UIHelper.CreatePanel(((Component)_canvas).transform, "EffectContainer", new Vector2(0.55f, 0.02f), new Vector2(0.98f, 0.3f)); VerticalLayoutGroup obj = ((Component)_container).gameObject.AddComponent(); ((LayoutGroup)obj).childAlignment = (TextAnchor)8; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f; ((LayoutGroup)obj).padding = new RectOffset(0, 4, 4, 0); } public void RefreshAll() { if ((Object)(object)EffectStackManager.instance == (Object)null) { HideAll(); return; } bool flag = false; HashSet hashSet = new HashSet(); foreach (KeyValuePair> allBinding in EffectStackManager.instance.GetAllBindings()) { hashSet.Add(allBinding.Key); GetOrCreateRow(allBinding.Key).Refresh(allBinding.Value); flag = true; } foreach (KeyValuePair playerRow in _playerRows) { if (!hashSet.Contains(playerRow.Key)) { playerRow.Value.Root.SetActive(false); } } if (!flag) { HideAll(); } else { ((Component)_canvas).gameObject.SetActive(true); } } public void Refresh(int playerID) { RefreshAll(); } public void HideAll() { ClearHover(); foreach (PlayerEffectRow value in _playerRows.Values) { value.Root.SetActive(false); } if ((Object)(object)_canvas != (Object)null) { ((Component)_canvas).gameObject.SetActive(false); } } private void Update() { if (!((Object)(object)_canvas == (Object)null) && ((Component)_canvas).gameObject.activeSelf && !IsGameActive()) { HideAll(); } } private PlayerEffectRow GetOrCreateRow(int playerID) { if (_playerRows.TryGetValue(playerID, out var value)) { return value; } value = PlayerEffectRow.Create((Transform)(object)_container, playerID, OnSlotHover, OnSlotHoverExit); _playerRows[playerID] = value; return value; } private void OnSlotHover(KeyboundBinding binding, Vector3 worldPos) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) ClearHover(); if ((Object)(object)CardChoice.instance == (Object)null) { return; } CardInfo val = binding.Card ?? FindCardTemplate(binding.CardName); if ((Object)(object)val == (Object)null) { return; } _hoverCard = CardChoice.instance.AddCardVisual(val, worldPos); if (!((Object)(object)_hoverCard == (Object)null)) { Collider2D[] componentsInChildren = ((Component)_hoverCard.transform.root).GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } Canvas componentInChildren = _hoverCard.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.sortingLayerName = "MostFront"; } RectTransform component = ((Component)UIHelper.CreateText(_hoverCard.transform, "KeyLabel", "Bound to " + KeybindModalUI.FormatKey(binding.Key), 18, (TextAlignmentOptions)1026, (Color?)new Color(0.75f, 0.9f, 1f))).GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 0.18f); Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; } } private void OnSlotHoverExit() { ClearHover(); } private void ClearHover() { if ((Object)(object)_hoverCard != (Object)null) { Object.Destroy((Object)(object)_hoverCard); _hoverCard = null; } } private static CardInfo FindCardTemplate(string cardName) { if (CardChoice.instance?.cards == null) { return null; } CardInfo[] cards = CardChoice.instance.cards; foreach (CardInfo val in cards) { if ((Object)(object)val != (Object)null && val.cardName == cardName) { return val; } } return null; } private static bool IsGameActive() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } if (!GameManager.instance.isPlaying) { return false; } if (PlayerManager.instance?.players == null || PlayerManager.instance.players.Count == 0) { return false; } return true; } } public class KeybindModalUI : MonoBehaviour { public static KeybindModalUI instance; private const int KeyA = 97; private const int KeyZ = 122; private const int KeyAlpha0 = 48; private const int KeyAlpha9 = 57; private Canvas _canvas; private TextMeshProUGUI _messageText; private Button _bindButton; private Image _bindImage; private TextMeshProUGUI _bindLabel; private Action _onConfirm; private Action _onCancel; private int _pickerID; private CardInfo _card; private int? _pendingKey; private static readonly Color PanelBg = new Color(0.04f, 0.06f, 0.12f, 1f); private static readonly Color CancelBg = new Color(0.4f, 0.1f, 0.1f, 0.95f); private static readonly Color BindReadyBg = new Color(0.1f, 0.45f, 0.12f, 0.95f); private static readonly Color BindGrayBg = new Color(0.18f, 0.18f, 0.18f, 0.55f); private void Awake() { instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BuildUI(); ((Component)_canvas).gameObject.SetActive(false); } private void BuildUI() { //IL_0025: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0155: 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_016b: 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_019a: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) _canvas = UIHelper.CreateFullscreenCanvas("KB_KeybindModal", 190); UIHelper.CreatePanel(((Component)_canvas).transform, "Dim", Vector2.zero, Vector2.one, (Color?)new Color(0f, 0f, 0f, 0.55f)); RectTransform val = UIHelper.CreatePanel(((Component)_canvas).transform, "Panel", new Vector2(0.25f, 0.35f), new Vector2(0.75f, 0.65f), PanelBg); UIHelper.CreateText((Transform)(object)val, "Title", "Bind Key", 28, (TextAlignmentOptions)258, (Color?)new Color(0.9f, 0.93f, 1f)); _messageText = UIHelper.CreateText((Transform)(object)val, "Message", "Press a key to bind this effect.", 22, (TextAlignmentOptions)4098, (Color?)new Color(0.88f, 0.92f, 1f)); RectTransform component = ((Component)_messageText).GetComponent(); component.anchorMin = new Vector2(0.05f, 0.35f); component.anchorMax = new Vector2(0.95f, 0.75f); Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; ((UnityEvent)UIHelper.CreateButton((Transform)(object)val, "CancelBtn", "[Cancel]", new Vector2(0.08f, 0.1f), new Vector2(0.42f, 0.28f), 20, CancelBg).onClick).AddListener(new UnityAction(OnCancelClicked)); GameObject val2 = new GameObject("BindBtn"); val2.transform.SetParent((Transform)(object)val, false); RectTransform obj = val2.AddComponent(); obj.anchorMin = new Vector2(0.58f, 0.1f); obj.anchorMax = new Vector2(0.92f, 0.28f); offsetMin = (obj.offsetMax = Vector2.zero); obj.offsetMin = offsetMin; _bindImage = val2.AddComponent(); ((Graphic)_bindImage).color = BindGrayBg; _bindButton = val2.AddComponent