Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TokenManager v1.0.0
TokenManager.dll
Decompiled 34 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TokenManager")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TokenManager")] [assembly: AssemblyTitle("TokenManager")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TokenManager { internal static class InputBlock { private const BindingFlags All = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public static bool Active; public static float GraceUntil; private static readonly string[] Methods = new string[12] { "KeyDown", "KeyUp", "KeyHold", "KeyPullAndPush", "KeyPullAndPushAnalog", "GetMovement", "GetMovementX", "GetMovementY", "GetScrollY", "GetMouseX", "GetMouseY", "GetRawMouseDelta" }; private static bool PressBlocked { get { if (!Active) { return Time.unscaledTime < GraceUntil; } return true; } } public static void Install(Harmony harmony) { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown int num = 0; Type type = AccessTools.TypeByName("InputManager"); if (type == null) { Plugin.Log.LogWarning((object)"InputManager not found - game input is not blocked while the window is open."); } else { foreach (MethodInfo item in from x in type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where Methods.Contains(x.Name) select x) { string text; if (item.Name == "KeyDown" && item.ReturnType == typeof(bool)) { text = "KeyDownPrefix"; } else if (item.ReturnType == typeof(bool)) { text = "BoolPrefix"; } else if (item.ReturnType == typeof(float)) { text = "FloatPrefix"; } else { if (!(item.ReturnType == typeof(Vector2))) { continue; } text = "Vector2Prefix"; } try { harmony.Patch((MethodBase)item, new HarmonyMethod(typeof(InputBlock), text, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not block InputManager." + item.Name + ": " + ex.Message)); } } } Type type2 = AccessTools.TypeByName("CursorManager"); MethodInfo methodInfo = ((type2 != null) ? AccessTools.Method(type2, "Unlock", (Type[])null, (Type[])null) : null); if (methodInfo != null) { try { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(InputBlock), "UnlockPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Could not patch CursorManager.Unlock: " + ex2.Message)); } } Plugin.Log.LogInfo((object)$"Input block ready ({num} input methods)."); } private static bool KeyDownPrefix(ref bool __result) { if (!PressBlocked) { return true; } __result = false; return false; } private static bool BoolPrefix(ref bool __result) { if (!Active) { return true; } __result = false; return false; } private static bool FloatPrefix(ref float __result) { if (!Active) { return true; } __result = 0f; return false; } private static bool Vector2Prefix(ref Vector2 __result) { //IL_000a: 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) if (!Active) { return true; } __result = Vector2.zero; return false; } private static bool UnlockPrefix() { return !Active; } } [BepInPlugin("purtzel_hd.tokenmanager", "TokenManager", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Plugin Instance; internal static ConfigEntry<KeyCode> Taste; internal static ConfigEntry<int> DeleteHoldTime; private void Awake() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00bc: Expected O, but got Unknown //IL_00c1: 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_00cc: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Instance = this; Taste = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Window Key", (KeyCode)288, "Key to open/close the window"); DeleteHoldTime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Delete Hold Time", 800, new ConfigDescription("How long (in ms) you have to hold the × button or \"Delete all tokens\" to delete (0 - 2000, in steps of 50). 0 = delete with one click.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2000), Array.Empty<object>())); SnapHoldTime(); DeleteHoldTime.SettingChanged += delegate { SnapHoldTime(); }; RemoveOldConfigEntries(); Settings.Load(); Harmony val = new Harmony("purtzel_hd.tokenmanager"); InputBlock.Install(val); Tokens.Install(val); GameObject val2 = new GameObject("TokenManager"); Object.DontDestroyOnLoad((Object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.AddComponent<Fenster>(); Log.LogInfo((object)$"TokenManager loaded. Window key: {Taste.Value}"); } internal static bool IsUsed(int color) { if (color >= 0 && color < 4) { return Settings.Use[color]; } return false; } internal static bool IsBlocked(int color) { if (color >= 0 && color < 4) { return Settings.BlockRewards[color]; } return false; } internal static bool IsInfinite(int color) { if (color >= 0) { return Settings.InfiniteColor == color; } return false; } private void RemoveOldConfigEntries() { try { if (AccessTools.Property(typeof(ConfigFile), "OrphanedEntries")?.GetValue(((BaseUnityPlugin)this).Config) is IDictionary { Count: >0 } dictionary) { dictionary.Clear(); ((BaseUnityPlugin)this).Config.Save(); } } catch (Exception ex) { Log.LogWarning((object)("Cleaning the config failed: " + ex.Message)); } } private static void SnapHoldTime() { int value = DeleteHoldTime.Value; int num = Mathf.Clamp(Mathf.RoundToInt((float)value / 50f) * 50, 0, 2000); if (num != value) { DeleteHoldTime.Value = num; } } } internal class Fenster : MonoBehaviour { private const float WinW = 770f; private const float WinH = 430f; private const BindingFlags AllInst = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags AllStatic = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private bool _open; private bool _toggleQueued; private bool _closeQueued; private bool _keyHeld; private bool _deleteAllQueued; private int _useQueued = -1; private int _addQueued = -1; private int _deleteQueued = -1; private int _infiniteQueued = -1; private int _blockQueued = -1; private Rect _rect; private float _nextKeep; private readonly string[] _amount = new string[4] { "1", "1", "1", "1" }; private int _focusedField = -1; private static readonly int DeleteHash = "TokenManagerDelete".GetHashCode(); private const int DeleteAllIndex = 100; private static readonly GUIContent XContent = new GUIContent("×"); private static readonly GUIContent DeleteAllContent = new GUIContent("Delete all tokens"); private static readonly GUIContent InfiniteContent = new GUIContent("Infinite"); private static readonly GUIContent BlockContent = new GUIContent("Don't receive"); private const float RowH = 58f; private int _holdIndex = -1; private int _holdControl; private float _holdStart; private bool _lookupDone; private FieldInfo _cursorInstance; private FieldInfo _cursorTimer; private FieldInfo _menuCursorInstance; private FieldInfo _menuInstance; private FieldInfo _menuCurrentPage; private MethodInfo _menuCursorHide; private MethodInfo _menuCursorHideReset; private GUIStyle _windowStyle; private GUIStyle _headerStyle; private GUIStyle _hintStyle; private GUIStyle _smallStyle; private GUIStyle _rowStyle; private GUIStyle _filledStyle; private GUIStyle _outlineStyle; private GUIStyle _holdFillStyle; private GUIStyle _fieldStyle; private GUIStyle _checkStyle; private GUIStyle _checkLabelStyle; private GUIStyle _keyHintStyle; private GUIStyle _countStyle; private GUIStyle[] _colorNameStyle; private Texture2D[] _coin; private Texture2D _lineTex; private static readonly Color Orange = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue)); private static readonly Color Dark = Color32.op_Implicit(new Color32((byte)24, (byte)26, (byte)34, byte.MaxValue)); private static readonly Color Light = Color32.op_Implicit(new Color32((byte)200, (byte)205, (byte)220, byte.MaxValue)); private static readonly Color Grey = Color32.op_Implicit(new Color32((byte)138, (byte)142, (byte)160, byte.MaxValue)); private Texture2D _checkMark; private const float CoinRingPart = 0.238f; private void Update() { if (_open) { CursorKeep(); } if (Time.unscaledTime >= _nextKeep) { _nextKeep = Time.unscaledTime + 0.25f; try { Tokens.Keep(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Token check failed: " + ex.Message)); _nextKeep = Time.unscaledTime + 5f; } } } private void LateUpdate() { if (_open) { CursorKeep(); } } private void SetOpen(bool open) { if (_open == open) { return; } _open = open; InputBlock.Active = open; CancelHold(); if (open) { CursorTake(); return; } GUI.FocusControl((string)null); _focusedField = -1; for (int i = 0; i < _amount.Length; i++) { if (_amount[i].Length == 0) { _amount[i] = "1"; } } InputBlock.GraceUntil = Time.unscaledTime + 0.25f; CursorRelease(); } private void CursorTake() { SetUnlockTimer(9999f); CursorKeep(); } private void CursorKeep() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) LookupGame(); try { object obj = _cursorInstance?.GetValue(null); if (obj != null && _cursorTimer != null && (float)_cursorTimer.GetValue(obj) < 1000f) { _cursorTimer.SetValue(obj, 9999f); } } catch { } if ((int)Cursor.lockState != 0) { Cursor.lockState = (CursorLockMode)0; } if (!Cursor.visible) { Cursor.visible = true; } try { object? obj3 = _menuCursorInstance?.GetValue(null); Object val = (Object)((obj3 is Object) ? obj3 : null); if (val != (Object)null) { _menuCursorHide?.Invoke(val, new object[1] { 0.1f }); } } catch { } } private void CursorRelease() { LookupGame(); bool flag = false; try { object obj = _menuInstance?.GetValue(null); flag = obj != null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null; } catch { } Cursor.visible = false; SetUnlockTimer(flag ? 0.1f : 0f); try { object? obj3 = _menuCursorInstance?.GetValue(null); Object val = (Object)((obj3 is Object) ? obj3 : null); if (val != (Object)null) { _menuCursorHideReset?.Invoke(val, null); } } catch { } } private void SetUnlockTimer(float value) { LookupGame(); try { object obj = _cursorInstance?.GetValue(null); if (obj != null) { _cursorTimer?.SetValue(obj, value); } } catch { } } private void LookupGame() { if (!_lookupDone) { _lookupDone = true; Type type = AccessTools.TypeByName("CursorManager"); _cursorInstance = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _cursorTimer = type?.GetField("unlockTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type2 = AccessTools.TypeByName("MenuCursor"); _menuCursorInstance = type2?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _menuCursorHide = ((type2 != null) ? AccessTools.Method(type2, "OverrideHide", (Type[])null, (Type[])null) : null); _menuCursorHideReset = ((type2 != null) ? AccessTools.Method(type2, "OverrideHideReset", (Type[])null, (Type[])null) : null); Type type3 = AccessTools.TypeByName("MenuManager"); _menuInstance = type3?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _menuCurrentPage = type3?.GetField("currentMenuPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } private void CancelHold() { if (_holdControl != 0 && GUIUtility.hotControl == _holdControl) { GUIUtility.hotControl = 0; } _holdIndex = -1; _holdControl = 0; } private void OnGUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_003d: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_00f2: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if ((int)current.rawType == 1 && current.button == 0 && _holdIndex >= 0 && Plugin.DeleteHoldTime.Value > 0) { CancelHold(); } if ((int)current.type == 4 && current.keyCode == Plugin.Taste.Value) { if (!_keyHeld) { _toggleQueued = true; _keyHeld = true; } current.Use(); } else if ((int)current.type == 5 && current.keyCode == Plugin.Taste.Value) { _keyHeld = false; } else if (_open && (int)current.type == 4 && (int)current.keyCode == 27) { _closeQueued = true; current.Use(); } if ((int)current.type == 8) { HandleQueued(); } if (_open) { Styles(); float num = Mathf.Clamp((float)Screen.height / 1080f, 1f, 3f); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; if (((Rect)(ref _rect)).width < 1f) { _rect = new Rect((num2 - 770f) / 2f, (num3 - 430f) / 2f, 770f, 430f); } _rect = GUI.Window(733207, _rect, new WindowFunction(Zeichnen), "Token<color=#FF8C00>Manager</color>", _windowStyle); } } private void HandleQueued() { if (_toggleQueued) { _toggleQueued = false; SetOpen(!_open); } if (_closeQueued) { _closeQueued = false; SetOpen(open: false); } try { if (_useQueued >= 0) { int useQueued = _useQueued; _useQueued = -1; Settings.Use[useQueued] = !Settings.Use[useQueued]; Settings.Save(); } if (_addQueued >= 0) { int addQueued = _addQueued; _addQueued = -1; int amount = Amount(addQueued); Tokens.Add(addQueued, amount); _amount[addQueued] = amount.ToString(); } if (_deleteQueued >= 0) { int deleteQueued = _deleteQueued; _deleteQueued = -1; CancelHold(); Tokens.DeleteColor(deleteQueued); } if (_infiniteQueued >= 0) { int infiniteQueued = _infiniteQueued; _infiniteQueued = -1; Tokens.ToggleInfinite(infiniteQueued); } if (_blockQueued >= 0) { int blockQueued = _blockQueued; _blockQueued = -1; Settings.BlockRewards[blockQueued] = !Settings.BlockRewards[blockQueued]; Settings.Save(); } if (_deleteAllQueued) { _deleteAllQueued = false; Tokens.DeleteAll(); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private int Amount(int c) { if (!int.TryParse(_amount[c], out var result)) { return 1; } return Mathf.Clamp(result, 1, 999); } private static string CleanAmount(string typed) { StringBuilder stringBuilder = new StringBuilder(3); foreach (char c in typed) { if (char.IsDigit(c) && (stringBuilder.Length != 0 || c != '0')) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private void Zeichnen(int id) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; GUI.color = new Color(1f, 0.55f, 0f, 0.35f); GUI.DrawTexture(new Rect(3f, 42f, 764f, 1f), (Texture)(object)_lineTex); GUI.color = Color.white; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Your tokens", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("Hold × to delete", _hintStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); List<int> list = Tokens.List(); if (list == null) { GUILayout.Space(20f); GUILayout.Label("Your tokens are not loaded yet. Start the game to the main menu first.", _smallStyle, Array.Empty<GUILayoutOption>()); } int value = Plugin.DeleteHoldTime.Value; int focused = -1; for (int i = 0; i < 4; i++) { Row(i, value, list != null, ref focused); } _focusedField = focused; for (int j = 0; j < 4; j++) { if (_amount[j].Length == 0 && _focusedField != j) { _amount[j] = "1"; } } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(DeleteAllContent, _outlineStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(30f) }); if (HoldButton(rect, DeleteAllContent, 100, value, list != null && Tokens.NormalTotal() > 0)) { _deleteAllQueued = true; } GUILayout.FlexibleSpace(); GUILayout.Label($"{Plugin.Taste.Value} = close", _keyHintStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUILayout.Space(12f); if (GUILayout.Button("Close", _outlineStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(30f) })) { _toggleQueued = true; } GUILayout.EndHorizontal(); if ((int)current.type == 0 && current.button == 0) { GUI.FocusControl((string)null); } GUI.DragWindow(new Rect(0f, 0f, 10000f, 42f)); } private void Row(int c, int holdMs, bool loaded, ref int focused) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Invalid comparison between Unknown and I4 //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Invalid comparison between Unknown and I4 //IL_02c7: 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_01ed: Invalid comparison between Unknown and I4 //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0351: 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_0379: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; Rect rect = GUILayoutUtility.GetRect(10f, 58f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(58f) }); GUILayout.Space(8f); if ((int)current.type == 7) { _rowStyle.Draw(rect, false, false, false, false); } float num = ((Rect)(ref rect)).x + 12f; float num2 = ((Rect)(ref rect)).y + 29f; if ((int)current.type == 7) { GUI.DrawTexture(new Rect(num, num2 - 18f, 36f, 36f), (Texture)(object)_coin[c]); } num += 46f; int num3 = (loaded ? Tokens.NormalCount(c) : 0); GUIContent val = new GUIContent(Tokens.Names[c]); GUIContent val2 = new GUIContent(string.Format("{0} token{1}", num3, (num3 == 1) ? "" : "s")); float num4 = _colorNameStyle[c].CalcHeight(val, 110f); float num5 = _countStyle.CalcHeight(val2, 110f); float num6 = num2 - (num4 + num5) / 2f; GUI.Label(new Rect(num, num6, 110f, num4), val, _colorNameStyle[c]); GUI.Label(new Rect(num, num6 + num4, 110f, num5), val2, _countStyle); num += 122f; GUI.enabled = loaded; bool flag = Plugin.IsUsed(c); if (GUI.Button(new Rect(num, num2 - 15f, 104f, 30f), flag ? "Redeem" : "Don't redeem", flag ? _filledStyle : _outlineStyle)) { _useQueued = c; } num += 120f; if (_focusedField == c && (int)current.type == 4 && ((int)current.keyCode == 13 || (int)current.keyCode == 271)) { GUI.FocusControl((string)null); current.Use(); } string text = "TokenAmount" + c; GUI.SetNextControlName(text); string typed = GUI.TextField(new Rect(num, num2 - 15f, 52f, 30f), _amount[c], 3, _fieldStyle); _amount[c] = CleanAmount(typed); if (GUI.GetNameOfFocusedControl() == text) { focused = c; } num += 58f; if (GUI.Button(new Rect(num, num2 - 15f, 60f, 30f), "Add", _outlineStyle)) { _addQueued = c; } Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref rect)).xMax - 12f - 38f, num2 - 15f, 38f, 30f); if (HoldButton(r, XContent, c, holdMs, loaded && num3 > 0)) { _deleteQueued = c; } float x = _checkLabelStyle.CalcSize(InfiniteContent).x; Rect label = default(Rect); ((Rect)(ref label))..ctor(((Rect)(ref r)).x - 16f - x, num2 - 10f, x, 20f); Rect box = default(Rect); ((Rect)(ref box))..ctor(((Rect)(ref label)).x - 8f - 18f, num2 - 9f, 18f, 18f); if (CheckboxAt(box, label, Plugin.IsInfinite(c), InfiniteContent)) { _infiniteQueued = c; } float x2 = _checkLabelStyle.CalcSize(BlockContent).x; Rect label2 = default(Rect); ((Rect)(ref label2))..ctor(((Rect)(ref box)).x - 22f - x2, num2 - 10f, x2, 20f); Rect box2 = default(Rect); ((Rect)(ref box2))..ctor(((Rect)(ref label2)).x - 8f - 18f, num2 - 9f, 18f, 18f); if (CheckboxAt(box2, label2, Plugin.IsBlocked(c), BlockContent)) { _blockQueued = c; } GUI.enabled = true; } private bool CheckboxAt(Rect box, Rect label, bool on, GUIContent text) { //IL_0000: 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_0020: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) bool result = GUI.Button(box, GUIContent.none, _checkStyle); if (on && (int)Event.current.type == 7) { GUI.DrawTexture(box, (Texture)(object)_checkMark); } if (GUI.Button(label, text, _checkLabelStyle)) { result = true; } return result; } private bool HoldButton(Rect r, GUIContent content, int index, int holdMs, bool usable) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected I4, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_005d: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) int controlID = GUIUtility.GetControlID(DeleteHash, (FocusType)2); Event current = Event.current; bool flag = _holdIndex == index; bool result = false; if (!usable) { if (flag) { CancelHold(); } if ((int)current.type == 7) { Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.35f); _outlineStyle.Draw(r, content, false, false, false, false); GUI.color = color; } return false; } EventType typeForControl = current.GetTypeForControl(controlID); switch ((int)typeForControl) { default: { if ((int)typeForControl != 7) { break; } bool flag2 = ((Rect)(ref r)).Contains(current.mousePosition); if (flag && holdMs > 0 && !flag2) { CancelHold(); flag = false; } _outlineStyle.Draw(r, content, flag2, flag, false, false); if (flag && holdMs > 0) { float num = Mathf.Clamp01((Time.unscaledTime - _holdStart) * 1000f / (float)holdMs); if (num > 0f) { GUI.BeginGroup(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * num, ((Rect)(ref r)).height)); _holdFillStyle.Draw(new Rect(0f, 0f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), content, false, false, false, false); GUI.EndGroup(); } if (num >= 1f) { result = true; CancelHold(); } } break; } case 0: if (current.button == 0 && ((Rect)(ref r)).Contains(current.mousePosition)) { GUIUtility.hotControl = controlID; _holdIndex = index; _holdControl = controlID; _holdStart = Time.unscaledTime; current.Use(); } break; case 3: if (GUIUtility.hotControl == controlID) { current.Use(); } break; case 1: if (GUIUtility.hotControl == controlID || flag) { if (holdMs <= 0 && flag && ((Rect)(ref r)).Contains(current.mousePosition)) { result = true; } CancelHold(); GUIUtility.hotControl = 0; current.Use(); } break; case 2: break; } return result; } private void Styles() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //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_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_004d: 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_005b: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0088: 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_00a2: Expected O, but got Unknown //IL_00cf: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_0153: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01b3: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_028d: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown //IL_030e: Expected O, but got Unknown //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Expected O, but got Unknown //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Expected O, but got Unknown //IL_03df: Expected O, but got Unknown //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: 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_0475: 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_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Expected O, but got Unknown //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Expected O, but got Unknown //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Expected O, but got Unknown //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Expected O, but got Unknown //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0762: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Expected O, but got Unknown //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Expected O, but got Unknown //IL_078c: Expected O, but got Unknown //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_07fc: Unknown result type (might be due to invalid IL or missing references) //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Expected O, but got Unknown //IL_080d: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_081c: Expected O, but got Unknown //IL_0821: Expected O, but got Unknown //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_0841: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0887: Expected O, but got Unknown //IL_0892: Unknown result type (might be due to invalid IL or missing references) if (_windowStyle == null) { Texture2D background = Rounded(64, 14f, 3f, Color32.op_Implicit(new Color32((byte)24, (byte)26, (byte)34, (byte)242)), Orange); _windowStyle = new GUIStyle(GUI.skin.window) { fontSize = 17, fontStyle = (FontStyle)1, richText = true, alignment = (TextAnchor)1, border = new RectOffset(18, 18, 18, 18), padding = new RectOffset(18, 18, 52, 16), contentOffset = new Vector2(0f, -40f) }; _windowStyle.normal.background = background; _windowStyle.onNormal.background = background; _windowStyle.normal.textColor = Color.white; _windowStyle.onNormal.textColor = Color.white; _lineTex = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _lineTex.SetPixel(0, 0, Color.white); _lineTex.Apply(); _headerStyle = new GUIStyle(GUI.skin.label) { fontSize = 17, fontStyle = (FontStyle)1, margin = new RectOffset(0, 0, 4, 8) }; _headerStyle.normal.textColor = Color.white; _hintStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, wordWrap = false, alignment = (TextAnchor)5, margin = _headerStyle.margin, padding = new RectOffset(0, 0, 0, 0) }; _hintStyle.normal.textColor = Grey; _hintStyle.fixedHeight = _headerStyle.CalcHeight(new GUIContent("Ag"), 300f); _smallStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, wordWrap = true, margin = new RectOffset(4, 4, 2, 4), padding = new RectOffset(0, 0, 1, 4), clipping = (TextClipping)0 }; _smallStyle.normal.textColor = Grey; _countStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, wordWrap = false, margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0) }; _countStyle.normal.textColor = Grey; _colorNameStyle = (GUIStyle[])(object)new GUIStyle[4]; _coin = (Texture2D[])(object)new Texture2D[4]; for (int i = 0; i < 4; i++) { _colorNameStyle[i] = new GUIStyle(GUI.skin.label) { fontSize = 15, fontStyle = (FontStyle)1, wordWrap = false, margin = new RectOffset(0, 0, 4, 0), padding = new RectOffset(0, 0, 0, 2) }; _colorNameStyle[i].normal.textColor = Tokens.ColorOf[i]; _coin[i] = Coin(72, Tokens.CoinMain[i], Tokens.CoinRing[i]); } Texture2D background2 = Rounded(32, 9f, 0f, Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue))); _rowStyle = new GUIStyle { border = new RectOffset(12, 12, 12, 12), padding = new RectOffset(12, 12, 9, 9), margin = new RectOffset(0, 0, 0, 8) }; _rowStyle.normal.background = background2; Texture2D val = Rounded(32, 8f, 0f, Orange, Orange); _filledStyle = Button(13, val, Rounded(32, 8f, 0f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)170, (byte)60, byte.MaxValue)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)170, (byte)60, byte.MaxValue))), Rounded(32, 8f, 0f, Color32.op_Implicit(new Color32((byte)220, (byte)115, (byte)0, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)220, (byte)115, (byte)0, byte.MaxValue))), Dark); _outlineStyle = Button(13, Rounded(32, 8f, 2f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, (byte)0)), Orange), Rounded(32, 8f, 2f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, (byte)40)), Orange), Rounded(32, 8f, 2f, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, (byte)80)), Orange), Orange); _outlineStyle.margin = new RectOffset(4, 4, 6, 6); _filledStyle.margin = _outlineStyle.margin; _holdFillStyle = Button(_outlineStyle.fontSize, val, val, val, Dark); Texture2D background3 = Rounded(32, 8f, 1f, Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)61, (byte)64, (byte)80, byte.MaxValue))); Texture2D background4 = Rounded(32, 8f, 1f, Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue)), Orange); _fieldStyle = new GUIStyle(GUI.skin.textField) { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, border = new RectOffset(10, 10, 10, 10), padding = new RectOffset(6, 6, 6, 6), margin = _outlineStyle.margin }; _fieldStyle.normal.background = background3; _fieldStyle.hover.background = background3; _fieldStyle.focused.background = background4; _fieldStyle.onNormal.background = background3; _fieldStyle.onFocused.background = background4; _fieldStyle.normal.textColor = Color.white; _fieldStyle.hover.textColor = Color.white; _fieldStyle.focused.textColor = Color.white; _fieldStyle.onFocused.textColor = Color.white; Texture2D background5 = Rounded(32, 6f, 2f, Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)61, (byte)64, (byte)80, byte.MaxValue))); Texture2D background6 = Rounded(32, 6f, 2f, Color32.op_Implicit(new Color32((byte)38, (byte)40, (byte)51, byte.MaxValue)), Orange); _checkStyle = new GUIStyle { border = new RectOffset(8, 8, 8, 8), margin = new RectOffset(0, 8, 12, 12) }; _checkStyle.normal.background = background5; _checkStyle.hover.background = background6; _checkStyle.active.background = background6; _checkMark = Tick(64); _checkLabelStyle = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, wordWrap = false, margin = new RectOffset(0, 0, 12, 12), padding = new RectOffset(0, 0, 0, 0) }; _checkLabelStyle.normal.textColor = Light; _checkLabelStyle.hover.textColor = Color.white; _keyHintStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, alignment = (TextAnchor)4, wordWrap = false, margin = _outlineStyle.margin }; _keyHintStyle.normal.textColor = Light; } } private static GUIStyle Button(int fontSize, Texture2D normal, Texture2D hover, Texture2D active, Color text) { //IL_000a: 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_0016: 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_0024: 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_0037: Expected O, but got Unknown //IL_0037: 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_004f: 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_0067: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button) { fontSize = fontSize, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, border = new RectOffset(10, 10, 10, 10) }; val.normal.background = normal; val.hover.background = hover; val.active.background = active; val.focused.background = normal; val.normal.textColor = text; val.hover.textColor = text; val.active.textColor = text; val.focused.textColor = text; return val; } private static Texture2D Coin(int size, Color main, Color ring) { //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_0010: 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) //IL_0020: Expected O, but got Unknown //IL_0066: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size / 2f; float num2 = (float)size / 2f - 1f; float num3 = num2 * 0.76199996f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num4 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)); Color val2 = Color.Lerp(main, ring, Mathf.Clamp01(num4 - num3 + 0.5f)); val2.a = Mathf.Clamp01(num2 - num4 + 0.5f); array[i * size + j] = val2; } } val.SetPixels(array); val.Apply(false, true); return val; } private static Texture2D Tick(int size) { //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_0010: 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) //IL_0020: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; Vector2 a = new Vector2(0.22f, 0.5f) * (float)size; Vector2 val2 = new Vector2(0.42f, 0.3f) * (float)size; Vector2 b = new Vector2(0.78f, 0.72f) * (float)size; float num = (float)size * 0.075f; Vector2 p = default(Vector2); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { ((Vector2)(ref p))..ctor((float)j + 0.5f, (float)i + 0.5f); float num2 = Mathf.Min(SegDist(p, a, val2), SegDist(p, val2, b)); float num3 = Mathf.Clamp01(num - num2 + 0.5f); array[i * size + j] = new Color(Orange.r, Orange.g, Orange.b, num3); } } val.SetPixels(array); val.Apply(false, true); return val; } private static float SegDist(Vector2 p, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0008: 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_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) Vector2 val = b - a; float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude); return Vector2.Distance(p, a + val * num); } private static Texture2D Rounded(int size, float radius, float borderWidth, Color fill, Color border) { //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_0010: 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) //IL_0020: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size / 2f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Mathf.Abs((float)j + 0.5f - num) - (num - radius); float num3 = Mathf.Abs((float)i + 0.5f - num) - (num - radius); Vector2 val2 = new Vector2(Mathf.Max(num2, 0f), Mathf.Max(num3, 0f)); float num4 = ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(num2, num3), 0f); float num5 = radius - num4; if (num5 <= -0.5f) { array[i * size + j] = Color.clear; continue; } Color val3 = ((borderWidth > 0f) ? Color.Lerp(border, fill, Mathf.Clamp01(num5 - borderWidth + 0.5f)) : fill); val3.a *= Mathf.Clamp01(num5 + 0.5f); array[i * size + j] = val3; } } val.SetPixels(array); val.Apply(false, true); return val; } } internal static class Settings { public static readonly bool[] Use = new bool[4] { true, true, true, true }; public static readonly bool[] BlockRewards = new bool[4]; public static int InfiniteColor = -1; private static string FilePath => Path.Combine(Paths.ConfigPath, "purtzel_hd.tokenmanager.settings.txt"); public static void Load() { try { if (!File.Exists(FilePath)) { return; } string[] array = File.ReadAllLines(FilePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text.StartsWith("#")) { continue; } int num = text.IndexOf('='); if (num <= 0) { continue; } string text2 = text.Substring(0, num).Trim(); string text3 = text.Substring(num + 1).Trim(); for (int j = 0; j < 4; j++) { string text4 = Key(j); if (text2 == "Use" + text4 && bool.TryParse(text3, out var result)) { Use[j] = result; } if (text2 == "BlockRewards" + text4 && bool.TryParse(text3, out var result2)) { BlockRewards[j] = result2; } } if (text2 == "InfiniteColor" && int.TryParse(text3, out var result3)) { InfiniteColor = ((result3 >= 0 && result3 < 4) ? result3 : (-1)); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Reading the settings failed: " + ex.Message)); } } public static void Save() { try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("# TokenManager - these settings are changed in the F7 window"); for (int i = 0; i < 4; i++) { stringBuilder.AppendLine($"Use{Key(i)}={Use[i]}"); } for (int j = 0; j < 4; j++) { stringBuilder.AppendLine($"BlockRewards{Key(j)}={BlockRewards[j]}"); } stringBuilder.AppendLine($"InfiniteColor={InfiniteColor}"); File.WriteAllText(FilePath, stringBuilder.ToString()); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Saving the settings failed: " + ex.Message)); } } private static string Key(int color) { return Tokens.Names[color].Replace(" ", ""); } } internal static class Tokens { public const int Colors = 4; public static readonly string[] Names = new string[4] { "Common", "Uncommon", "Rare", "Ultra Rare" }; public static readonly Color[] ColorOf = (Color[])(object)new Color[4] { Color32.op_Implicit(new Color32((byte)0, (byte)200, (byte)7, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)3, (byte)152, (byte)203, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)189, (byte)6, (byte)187, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)184, (byte)144, (byte)5, byte.MaxValue)) }; public static readonly Color[] CoinMain = (Color[])(object)new Color[4] { Color32.op_Implicit(new Color32((byte)0, (byte)142, (byte)2, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)0, (byte)112, (byte)142, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)143, (byte)0, (byte)129, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)142, (byte)114, (byte)0, byte.MaxValue)) }; public static readonly Color[] CoinRing = (Color[])(object)new Color[4] { Color32.op_Implicit(new Color32((byte)0, (byte)190, (byte)3, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)0, (byte)147, (byte)190, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)190, (byte)0, (byte)171, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)188, (byte)150, (byte)0, byte.MaxValue)) }; private const BindingFlags Inst = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags Stat = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static bool _ready; private static FieldInfo _mmInstance; private static FieldInfo _mmTokens; private static FieldInfo _mmSaveReady; private static FieldInfo _uiInstance; private static FieldInfo _uiTokenObjects; private static FieldInfo _elRarity; private static MethodInfo _mmSave; private static MethodInfo _uiSetup; private static MethodInfo _elSetup; private static readonly List<int> MovedFrom = new List<int>(); private static float _movedTime; private static int _lastInfinite = int.MinValue; private static bool _removingInfinite; public static void Install(Harmony harmony) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ab: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown Init(); Type type = AccessTools.TypeByName("MetaManager"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "CosmeticTokenAdd", (Type[])null, (Type[])null) : null); MethodInfo methodInfo2 = ((type != null) ? AccessTools.Method(type, "CosmeticTokenRemove", (Type[])null, (Type[])null) : null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Tokens), "AddPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Tokens), "RemovePrefix", (Type[])null), new HarmonyMethod(typeof(Tokens), "RemovePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo == null || methodInfo2 == null) { Plugin.Log.LogError((object)"MetaManager.CosmeticTokenAdd/Remove not found - Don't receive and Infinite do not work (game update?)."); } Type type2 = AccessTools.TypeByName("CosmeticShopMachine"); MethodInfo methodInfo3 = ((type2 != null) ? AccessTools.Method(type2, "StateIdle", (Type[])null, (Type[])null) : null); MethodInfo methodInfo4 = ((type2 != null) ? AccessTools.Method(type2, "InfoTextTriggerLogic", (Type[])null, (Type[])null) : null); MethodInfo methodInfo5 = ((type2 != null) ? AccessTools.Method(type2, "Interact", (Type[])null, (Type[])null) : null); HarmonyMethod val = new HarmonyMethod(typeof(Tokens), "UsableCountTranspiler", (Type[])null); try { if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo4 != null) { harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo5 != null) { harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(typeof(Tokens), "InteractPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Patching the cosmetic machine failed: {arg}"); } if (methodInfo3 == null || methodInfo4 == null || methodInfo5 == null) { Plugin.Log.LogError((object)"CosmeticShopMachine not found - Redeem / Don't redeem does not work (game update?)."); } } private static void Init() { if (!_ready) { _ready = true; Type type = AccessTools.TypeByName("MetaManager"); _mmInstance = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _mmTokens = type?.GetField("cosmeticTokens", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _mmSaveReady = type?.GetField("saveReady", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _mmSave = ((type != null) ? AccessTools.Method(type, "Save", (Type[])null, (Type[])null) : null); Type type2 = AccessTools.TypeByName("CosmeticTokenUI"); _uiInstance = type2?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _uiSetup = ((type2 != null) ? AccessTools.Method(type2, "Setup", (Type[])null, (Type[])null) : null); _uiTokenObjects = type2?.GetField("tokenObjects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type3 = AccessTools.TypeByName("CosmeticTokenUIElement"); _elRarity = type3?.GetField("rarity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _elSetup = ((type3 != null) ? AccessTools.Method(type3, "Setup", (Type[])null, (Type[])null) : null); if (_uiTokenObjects == null || _elRarity == null || _elSetup == null) { Plugin.Log.LogWarning((object)"Token icons can not be recolored (game update?) - the coins on screen may show wrong colors."); } if (_mmTokens == null) { Plugin.Log.LogError((object)"MetaManager.cosmeticTokens not found (game update?)."); } } } public static List<int> List() { Init(); object obj = _mmInstance?.GetValue(null); if (obj == null) { return null; } if (_mmSaveReady != null && !(bool)_mmSaveReady.GetValue(obj)) { return null; } return _mmTokens?.GetValue(obj) as List<int>; } public static int Count(int color) { List<int> list = List(); if (list == null) { return 0; } int num = 0; foreach (int item in list) { if (item == color) { num++; } } return num; } public static int NormalCount(int color) { List<int> list = List(); if (list == null) { return 0; } return Count(color) - ((InfiniteIndex(list) >= 0 && list[InfiniteIndex(list)] == color) ? 1 : 0); } public static int NormalTotal() { List<int> list = List(); if (list == null) { return 0; } return list.Count - ((InfiniteIndex(list) >= 0) ? 1 : 0); } private static int InfiniteIndex(List<int> l) { int infiniteColor = Settings.InfiniteColor; if (infiniteColor < 0 || infiniteColor >= 4 || _lastInfinite != infiniteColor) { return -1; } int num = l.Count - 1 - MovedFrom.Count; if (num < 0 || num >= l.Count || l[num] != infiniteColor) { return -1; } return num; } private static int TopIndex(List<int> l) { return Mathf.Clamp(l.Count - MovedFrom.Count - ((InfiniteIndex(l) >= 0) ? 1 : 0), 0, l.Count); } public static void Add(int color, int amount) { List<int> list = List(); if (list != null && amount > 0 && color >= 0 && color < 4) { for (int i = 0; i < amount; i++) { list.Insert(TopIndex(list), color); } Refresh(list); } } public static void DeleteColor(int color) { List<int> list = List(); if (list == null) { return; } RestoreMoved(list); int num = InfiniteIndex(list); List<int> list2 = new List<int>(list.Count); for (int i = 0; i < list.Count; i++) { if (list[i] != color || i == num) { list2.Add(list[i]); } } list.Clear(); list.AddRange(list2); Refresh(list); } public static void DeleteAll() { List<int> list = List(); if (list != null) { RestoreMoved(list); int num = InfiniteIndex(list); int num2 = ((num >= 0) ? list[num] : (-1)); list.Clear(); if (num2 >= 0) { list.Add(num2); } Refresh(list); } } public static void ToggleInfinite(int color) { Settings.InfiniteColor = ((Settings.InfiniteColor == color) ? (-1) : color); Settings.Save(); Keep(); } public static void Keep() { List<int> list = List(); if (list != null) { bool flag = false; if (MovedFrom.Count > 0 && Time.unscaledTime - _movedTime > 30f) { RestoreMoved(list); flag = true; } if (SyncInfinite(list)) { flag = true; } if (flag) { Refresh(list); } else { RecolorNow(list); } } } private static bool SyncInfinite(List<int> l) { int num = Settings.InfiniteColor; if (num < -1 || num >= 4) { num = -1; } if (_lastInfinite == int.MinValue) { _lastInfinite = num; } if (_lastInfinite != num) { bool flag = false; if (_lastInfinite >= 0) { int num2 = l.Count - 1 - MovedFrom.Count; if (num2 >= 0 && num2 < l.Count && l[num2] == _lastInfinite) { l.RemoveAt(num2); flag = true; } } _lastInfinite = num; if (num >= 0) { l.Insert(Mathf.Clamp(l.Count - MovedFrom.Count, 0, l.Count), num); flag = true; } if (flag) { Plugin.Log.LogInfo((object)((num >= 0) ? ("Infinite token: " + Names[num]) : "Infinite token off")); } return flag; } if (num < 0 || InfiniteIndex(l) >= 0) { return false; } l.Insert(Mathf.Clamp(l.Count - MovedFrom.Count, 0, l.Count), num); return true; } private static void RestoreMoved(List<int> l) { int num = MovedFrom.Count - 1; while (num >= 0 && l.Count != 0) { int item = l[l.Count - 1]; l.RemoveAt(l.Count - 1); l.Insert(Mathf.Clamp(MovedFrom[num], 0, l.Count), item); num--; } MovedFrom.Clear(); } private static void Refresh(List<int> l) { try { object? obj = _uiInstance?.GetValue(null); Object val = (Object)((obj is Object) ? obj : null); if (val != (Object)null) { Recolor(val, l); _uiSetup?.Invoke(val, null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Updating the token icons failed: " + ex.Message)); } try { object obj2 = _mmInstance?.GetValue(null); if (obj2 != null) { _mmSave?.Invoke(obj2, null); } } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Saving failed: " + ex2.Message)); } } private static void RecolorNow(List<int> l) { try { object? obj = _uiInstance?.GetValue(null); Object val = (Object)((obj is Object) ? obj : null); if (val != (Object)null) { Recolor(val, l); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Recoloring the token icons failed: " + ex.Message)); } } private static void Recolor(Object ui, List<int> l) { if (_uiTokenObjects == null || _elRarity == null || _elSetup == null || !(_uiTokenObjects.GetValue(ui) is IList { Count: var count } list)) { return; } int count2 = l.Count; List<int> list2 = new List<int>(); if (count > count2) { int[] array = new int[4]; foreach (int item in l) { if (item >= 0 && item < 4) { array[item]++; } } for (int i = 0; i < count; i++) { int num = RarityOf(list[i]); if (num >= 0 && num < 4) { if (array[num] > 0) { array[num]--; } else { list2.Add(num); } } } } int num2 = 0; for (int j = 0; j < count; j++) { int color; if (j < count2) { color = l[j]; } else { if (num2 >= list2.Count) { break; } color = list2[num2++]; } SetColor(list, j, color); } } private static int RarityOf(object element) { Object val = (Object)((element is Object) ? element : null); if (val == null || val == (Object)null) { return -1; } return Convert.ToInt32(_elRarity.GetValue(element)); } private static void SetColor(IList shown, int i, int color) { object? obj = shown[i]; Object val = (Object)((obj is Object) ? obj : null); if (!(val == (Object)null) && color >= 0 && color < 4 && RarityOf(val) != color) { _elRarity.SetValue(val, Enum.ToObject(_elRarity.FieldType, color)); object obj2 = ((i > 0) ? shown[i - 1] : null); Object val2 = (Object)((obj2 is Object) ? obj2 : null); if (val2 != null && val2 == (Object)null) { obj2 = null; } _elSetup.Invoke(val, new object[1] { obj2 }); } } private static bool AddPrefix(object[] __args) { try { int num = Convert.ToInt32(__args[0]); if (Plugin.IsBlocked(num)) { Plugin.Log.LogInfo((object)(((num >= 0 && num < 4) ? Names[num] : num.ToString()) + " token from the game blocked.")); return false; } List<int> list = List(); if (list == null || TopIndex(list) == list.Count) { return true; } list.Insert(TopIndex(list), num); Refresh(list); return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Token from the game: " + ex.Message)); return true; } } private static void InteractPrefix() { try { List<int> list = List(); if (list == null) { return; } RestoreMoved(list); int num = list.Count - 1; for (int num2 = num; num2 >= 0; num2--) { if (Plugin.IsUsed(list[num2])) { if (num2 != num) { int item = list[num2]; list.RemoveAt(num2); list.Add(item); MovedFrom.Add(num2); _movedTime = Time.unscaledTime; } break; } } RecolorNow(list); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Choosing the token failed: " + ex.Message)); } } private static void RemovePrefix() { _removingInfinite = false; try { List<int> list = List(); if (list != null && list.Count != 0) { if (MovedFrom.Count > 0) { MovedFrom.RemoveAt(MovedFrom.Count - 1); } else { _removingInfinite = InfiniteIndex(list) == list.Count - 1; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Token check failed: " + ex.Message)); } } private static void RemovePostfix() { if (!_removingInfinite) { return; } _removingInfinite = false; try { List<int> list = List(); int infiniteColor = Settings.InfiniteColor; if (list != null && infiniteColor >= 0 && infiniteColor < 4) { list.Insert(Mathf.Clamp(list.Count - MovedFrom.Count, 0, list.Count), infiniteColor); Refresh(list); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Infinite token failed: " + ex.Message)); } } private static IEnumerable<CodeInstruction> UsableCountTranspiler(IEnumerable<CodeInstruction> instructions) { Init(); MethodInfo getCount = AccessTools.PropertyGetter(typeof(List<int>), "Count"); MethodInfo usable = AccessTools.Method(typeof(Tokens), "UsableCount", (Type[])null, (Type[])null); CodeInstruction prev = null; int replaced = 0; foreach (CodeInstruction instruction in instructions) { if (prev != null && _mmTokens != null && CodeInstructionExtensions.LoadsField(prev, _mmTokens, false) && CodeInstructionExtensions.Calls(instruction, getCount)) { instruction.opcode = OpCodes.Call; instruction.operand = usable; replaced++; } prev = instruction; yield return instruction; } if (replaced == 0) { Plugin.Log.LogWarning((object)"Cosmetic machine: token count not found (game update?) - Don't redeem may not block the machine."); } } public static int UsableCount(List<int> l) { if (l == null) { return 0; } int num = 0; foreach (int item in l) { if (Plugin.IsUsed(item)) { num++; } } return num; } } }