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 CraftQueue v0.1.1
CraftQueue.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.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 CraftQueue { [BepInPlugin("com.luuca.craftqueue", "CraftQueue", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CraftQueuePlugin : BaseUnityPlugin { public const string Guid = "com.luuca.craftqueue"; public const string Name = "CraftQueue"; public const string Version = "0.1.1"; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> QueueKey; internal static ConfigEntry<KeyCode> CancelKey; internal static ConfigEntry<int> QueueCount; internal static ConfigEntry<float> MaxMoveDistance; internal static ConfigEntry<int> UiStep; internal static ConfigEntry<LanguageMode> Language; internal const int MaxQueue = 999; private Harmony _harmony; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; QueueKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "QueueKey", (KeyCode)287, "Key that starts a queue with the selected recipe. The crafting window must be open."); CancelKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "CancelKey", (KeyCode)288, "Key that cancels the running queue and the current craft."); QueueCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "QueueCount", 5, new ConfigDescription("Number of crafts in a row. The panel's slider also sets it.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>())); UiStep = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "ShiftStep", 10, new ConfigDescription("How much -/+ add or remove while Shift is held.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 100), Array.Empty<object>())); MaxMoveDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxMoveDistance", 3f, new ConfigDescription("Meters the player can walk away before the queue stops.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>())); Language = ((BaseUnityPlugin)this).Config.Bind<LanguageMode>("UI", "Language", LanguageMode.Auto, "Language of the mod's texts. Auto follows the game's language (Spanish if the game is in Spanish, English otherwise)."); _harmony = new Harmony("com.luuca.craftqueue"); _harmony.PatchAll(typeof(CraftQueuePlugin).Assembly); Log.LogInfo((object)(string.Format("{0} {1} cargado. Tecla={2}, cancelar={3}, cantidad={4}, ", "CraftQueue", "0.1.1", QueueKey.Value, CancelKey.Value, QueueCount.Value) + $"CraftFromChests presente={Chainloader_HasCraftFromChests()}")); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(QueueKey.Value)) { CraftQueueState.StartFromKey(); } else if (Input.GetKeyDown(CancelKey.Value)) { CraftQueueState.CancelByUser(Loc.T("cancel_by_key")); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static bool Chainloader_HasCraftFromChests() { return Chainloader.PluginInfos.ContainsKey("toxo.craftfromchests"); } } internal static class CraftQueueState { private static readonly FieldInfo FTimer = AccessTools.Field(typeof(InventoryGui), "m_craftTimer"); private static readonly FieldInfo FSelected = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe"); private static readonly MethodInfo MOnCraftPressed = AccessTools.Method(typeof(InventoryGui), "OnCraftPressed", (Type[])null, (Type[])null); private static readonly MethodInfo MOnCraftCancel = AccessTools.Method(typeof(InventoryGui), "OnCraftCancelPressed", (Type[])null, (Type[])null); private static bool _active; private static bool _inFlight; private static bool _pending; private static int _remaining; private static Recipe _recipe; private static int _countBefore; private static Vector3 _startPos; public static bool Active => _active; public static int Remaining => _remaining; public static void StartFromKey() { if (!_active) { TryStart(CraftQueuePlugin.QueueCount.Value); } } public static void CancelByUser(string reason) { if (_active) { bool inFlight = _inFlight; Stop(reason); InventoryGui instance = InventoryGui.instance; if (inFlight && (Object)(object)instance != (Object)null && GetTimer(instance) >= 0f) { MOnCraftCancel.Invoke(instance, null); } } } public static void StartFromUi(int count) { if (!_active) { TryStart(count); } } public static int MaxCraftable(Player player, Recipe recipe, int cap) { int num = 0; int num2 = cap; while (num < num2) { int num3 = (num + num2 + 1) / 2; if (CanCraftAmount(player, recipe, num3)) { num = num3; } else { num2 = num3 - 1; } } return num; } private static bool CanCraftAmount(Player player, Recipe recipe, int n) { if (!player.HaveRequirements(recipe, false, 1, n)) { return false; } int num = default(int); ItemData val = default(ItemData); int amount = recipe.GetAmount(1, ref num, ref val, n); if (recipe.m_requireOnlyOneIngredient && val == null) { return false; } return ((Humanoid)player).GetInventory().CanAddItem(((Component)recipe.m_item).gameObject, amount); } private static void TryStart(int count) { //IL_00ec: 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) InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)instance == (Object)null) && !((Object)(object)localPlayer == (Object)null) && InventoryGui.IsVisible() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus())) { if (GetTimer(instance) >= 0f) { CraftQueuePlugin.Log.LogInfo((object)"Ya hay un crafteo en curso; no se inicia la cola."); return; } if (!TryGetSelected(instance, out var recipe, out var itemData) || (Object)(object)recipe == (Object)null) { CraftQueuePlugin.Log.LogInfo((object)"No hay receta seleccionada."); return; } if (itemData != null) { CraftQueuePlugin.Log.LogInfo((object)"La cola no soporta mejoras de objetos."); return; } if (!localPlayer.HaveRequirements(recipe, false, 1, 1)) { ((Character)localPlayer).Message((MessageType)2, Loc.T("missing_materials_msg"), 0, (Sprite)null, false); CraftQueuePlugin.Log.LogInfo((object)("Faltan materiales para " + ((Object)recipe).name + ".")); return; } _recipe = recipe; _remaining = count; _startPos = ((Component)localPlayer).transform.position; _pending = false; _inFlight = false; _active = true; CraftQueuePlugin.Log.LogInfo((object)$"Cola iniciada: {((Object)recipe).name} x{_remaining}"); StartOne(instance, localPlayer); } } private static void StartOne(InventoryGui gui, Player player) { _countBefore = CountResult(player); MOnCraftPressed.Invoke(gui, null); if (GetTimer(gui) < 0f) { Stop(Loc.T("r_start_failed")); return; } _inFlight = true; CraftQueuePlugin.Log.LogInfo((object)$"Crafteo lanzado. Restantes (incluido este): {_remaining}"); } public static void AfterDoCrafting() { if (!_active || !_inFlight) { return; } _inFlight = false; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Stop(Loc.T("r_no_player")); return; } int num = CountResult(localPlayer); if (num <= _countBefore) { Stop(Loc.T("r_no_result")); return; } _remaining--; CraftQueuePlugin.Log.LogInfo((object)$"Crafteo completado ({_countBefore} -> {num}). Quedan {_remaining}."); if (_remaining <= 0) { Stop(Loc.T("r_done")); } else { _pending = true; } } public static void AfterGuiUpdate(InventoryGui gui) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!_active) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { Stop(Loc.T("r_player_unavailable")); return; } if (!InventoryGui.IsVisible()) { Stop(Loc.T("r_gui_closed")); return; } if (Vector3.Distance(((Component)localPlayer).transform.position, _startPos) > CraftQueuePlugin.MaxMoveDistance.Value) { Stop(Loc.T("r_moved")); return; } float timer = GetTimer(gui); if (_inFlight && timer < 0f) { Stop(Loc.T("r_manual_cancel")); } else if (_pending && timer < 0f) { _pending = false; if (!TryGetSelected(gui, out var recipe, out var _) || (Object)(object)recipe != (Object)(object)_recipe) { Stop(Loc.T("r_recipe_changed")); } else if (!localPlayer.HaveRequirements(_recipe, false, 1, 1)) { Stop(Loc.T("r_no_materials")); } else { StartOne(gui, localPlayer); } } } public static void Stop(string reason) { if (_active) { _active = false; _inFlight = false; _pending = false; CraftQueuePlugin.Log.LogInfo((object)$"Cola detenida: {reason}. Restantes sin hacer: {_remaining}"); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Loc.T("stopped", reason), 0, (Sprite)null, false); } _recipe = null; } } private static float GetTimer(InventoryGui gui) { return (float)FTimer.GetValue(gui); } private static int CountResult(Player player) { return ((Humanoid)player).GetInventory().CountItems(_recipe.m_item.m_itemData.m_shared.m_name, -1, true); } internal static bool TryGetSelected(InventoryGui gui, out Recipe recipe, out ItemData itemData) { recipe = null; itemData = null; object value = FSelected.GetValue(gui); if (value == null) { return false; } Type type = value.GetType(); object? obj = type.GetProperty("Recipe")?.GetValue(value, null); recipe = (Recipe)((obj is Recipe) ? obj : null); object? obj2 = type.GetProperty("ItemData")?.GetValue(value, null); itemData = (ItemData)((obj2 is ItemData) ? obj2 : null); return true; } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] internal static class DoCraftingPatch { private static void Postfix() { CraftQueueState.AfterDoCrafting(); } } [HarmonyPatch(typeof(Character), "ApplyDamage")] internal static class ApplyDamagePatch { private static void Postfix(Character __instance, HitData hit) { if (CraftQueueState.Active && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && hit.GetTotalDamage() > 0.1f) { CraftQueueState.Stop(Loc.T("r_damage")); } } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class GuiUpdatePatch { private static void Postfix(InventoryGui __instance) { CraftQueueState.AfterGuiUpdate(__instance); CraftQueueUi.Refresh(__instance); } } internal static class CraftQueueUi { [CompilerGenerated] private static class <>O { public static UnityAction <0>__TogglePopup; public static UnityAction <1>__StartQueue; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__23_0; public static UnityAction <>9__24_0; public static UnityAction <>9__24_1; public static UnityAction <>9__24_2; public static UnityAction<float> <>9__31_0; internal void <Build>b__23_0() { CraftQueueState.CancelByUser(Loc.T("cancel_by_button")); } internal void <BuildPopup>b__24_0() { Step(-1); } internal void <BuildPopup>b__24_1() { Step(1); } internal void <BuildPopup>b__24_2() { SetCount(_max); } internal void <BuildSlider>b__31_0(float v) { SetCount(Mathf.RoundToInt(v)); } } private const float CraftWidth = 0.62f; private const float CancelStart = 0.76f; private const float PopupHeight = 96f; private const float PopupFontSize = 18f; private static RectTransform _panel; private static Button _queueButton; private static GameObject _popup; private static TMP_Text _label; private static Slider _slider; private static Button _startButton; private static Button _cancelButton; private static TMP_Text _cancelText; private static TMP_Text _progressText; private static string _progressOriginal; private static RectTransform _progressRt; private static Vector2 _progressOriginalMax; private static bool _layoutLogged; private static bool _popupLogged; private static int _count = 1; private static int _max; private static Recipe _popupRecipe; public static void Refresh(InventoryGui gui) { //IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_craftButton == (Object)null) { return; } if ((Object)(object)_queueButton == (Object)null || (Object)(object)_popup == (Object)null || (Object)(object)_cancelButton == (Object)null) { Build(gui); } if ((Object)(object)_queueButton == (Object)null || (Object)(object)_cancelButton == (Object)null) { return; } Recipe recipe; ItemData itemData; bool flag = InventoryGui.IsVisible() && CraftQueueState.TryGetSelected(gui, out recipe, out itemData) && (Object)(object)recipe != (Object)null && itemData == null; RectTransform val = (RectTransform)((Component)gui.m_craftButton).transform; val.anchorMax = new Vector2(flag ? 0.62f : 1f, 1f); val.offsetMax = new Vector2(flag ? (-2f) : 0f, 0f); bool flag2 = flag && ((Component)gui.m_craftButton).gameObject.activeSelf && !CraftQueueState.Active; if (((Component)_queueButton).gameObject.activeSelf != flag2) { ((Component)_queueButton).gameObject.SetActive(flag2); } if (_popup.activeSelf) { CraftQueueState.TryGetSelected(gui, out var recipe2, out var _); if (!flag || CraftQueueState.Active || (Object)(object)recipe2 != (Object)(object)_popupRecipe) { ClosePopup(); } } bool flag3 = InventoryGui.IsVisible() && CraftQueueState.Active; if (((Component)_cancelButton).gameObject.activeSelf != flag3) { ((Component)_cancelButton).gameObject.SetActive(flag3); if (flag3) { ((Component)_cancelButton).transform.SetAsLastSibling(); } } if (flag3 && (Object)(object)_cancelText != (Object)null) { _cancelText.text = string.Format("{0}\n({1})", Loc.T("cancel_button"), CraftQueueState.Remaining); } ApplyProgressLayout(flag3); } private static void ApplyProgressLayout(bool queueActive) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_progressRt != (Object)null) { Vector2 val; if (!queueActive) { val = _progressOriginalMax; } else { Vector2 progressOriginalMax = _progressOriginalMax; Rect rect = _panel.rect; val = progressOriginalMax - new Vector2(((Rect)(ref rect)).width * 0.24000001f, 0f); } Vector2 val2 = val; if (_progressRt.offsetMax != val2) { _progressRt.offsetMax = val2; } } if ((Object)(object)_progressText != (Object)null && _progressOriginal != null) { string text = (queueActive ? (_progressOriginal + " " + Loc.T("progress_queue", CraftQueueState.Remaining)) : _progressOriginal); if (_progressText.text != text) { _progressText.text = text; } } } private static void Build(InventoryGui gui) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_01b0: 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_01b5: 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_01eb: Unknown result type (might be due to invalid IL or missing references) Button craftButton = gui.m_craftButton; _panel = (RectTransform)((Component)craftButton).transform.parent; RectTransform panel = _panel; string label = Loc.T("queue_button"); Vector2 anchorMin = new Vector2(0.62f, 0f); Vector2 anchorMax = new Vector2(1f, 1f); Vector2 offsetMin = new Vector2(2f, 0f); Vector2 zero = Vector2.zero; object obj = <>O.<0>__TogglePopup; if (obj == null) { UnityAction val = TogglePopup; <>O.<0>__TogglePopup = val; obj = (object)val; } _queueButton = MakeButton(craftButton, (Transform)(object)panel, "Queue", label, anchorMin, anchorMax, offsetMin, zero, (UnityAction)obj, Loc.T("queue_tip")); BuildPopup(craftButton); RectTransform panel2 = _panel; string label2 = Loc.T("cancel_button"); Vector2 anchorMin2 = new Vector2(0.76f, 0f); Vector2 anchorMax2 = new Vector2(1f, 1f); Vector2 offsetMin2 = new Vector2(2f, 0f); Vector2 zero2 = Vector2.zero; object obj2 = <>c.<>9__23_0; if (obj2 == null) { UnityAction val2 = delegate { CraftQueueState.CancelByUser(Loc.T("cancel_by_button")); }; <>c.<>9__23_0 = val2; obj2 = (object)val2; } _cancelButton = MakeButton(craftButton, (Transform)(object)panel2, "Cancel", label2, anchorMin2, anchorMax2, offsetMin2, zero2, (UnityAction)obj2, Loc.T("cancel_tip"), 16f); _cancelText = ((Component)_cancelButton).GetComponentInChildren<TMP_Text>(true); ((Component)_cancelButton).gameObject.SetActive(false); Transform craftProgressPanel = gui.m_craftProgressPanel; _progressText = (((Object)(object)craftProgressPanel != (Object)null) ? ((Component)craftProgressPanel).GetComponentInChildren<TMP_Text>(true) : null); _progressOriginal = (((Object)(object)_progressText != (Object)null) ? _progressText.text : null); _progressRt = (RectTransform)(object)((craftProgressPanel is RectTransform) ? craftProgressPanel : null); _progressOriginalMax = (((Object)(object)_progressRt != (Object)null) ? _progressRt.offsetMax : Vector2.zero); if (!_layoutLogged) { _layoutLogged = true; ManualLogSource log = CraftQueuePlugin.Log; string name = ((Object)_panel).name; Rect rect = _panel.rect; log.LogInfo((object)($"[UI] panel '{name}' size={((Rect)(ref rect)).size}; texto de progreso: " + (((Object)(object)_progressText != (Object)null) ? ("'" + ((Object)_progressText).name + "' = '" + _progressText.text + "'") : "no encontrado"))); } CraftQueuePlugin.Log.LogInfo((object)"Boton de cola y panel creados en la interfaz de crafteo."); } private static void BuildPopup(Button craftTemplate) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00eb: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Expected O, but got Unknown _popup = ((Component)NewRect("CraftQueue_Popup", (Transform)(object)_panel)).gameObject; RectTransform val = (RectTransform)_popup.transform; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0.5f, 0f); val.sizeDelta = new Vector2(0f, 96f); val.anchoredPosition = new Vector2(0f, 4f); ((Graphic)_popup.AddComponent<Image>()).color = new Color(0.09f, 0.07f, 0.05f, 0.97f); Outline obj = _popup.AddComponent<Outline>(); ((Shadow)obj).effectColor = new Color(0.65f, 0.5f, 0.25f, 1f); ((Shadow)obj).effectDistance = new Vector2(2f, -2f); TMP_Text componentInChildren = ((Component)craftTemplate).GetComponentInChildren<TMP_Text>(true); RectTransform rt = NewRect("Label", _popup.transform); Anchor(rt, 0f, 0.66f, 1f, 1f, new Vector2(10f, 0f), new Vector2(-10f, -4f)); _label = NewText(rt, componentInChildren, (TextAlignmentOptions)513, 18f); RectTransform val2 = NewRect("Row2", _popup.transform); Anchor(val2, 0f, 0.35f, 1f, 0.64f, new Vector2(10f, 0f), new Vector2(-10f, 0f)); Vector2 anchorMin = new Vector2(0f, 0f); Vector2 anchorMax = new Vector2(0.11f, 1f); Vector2 zero = Vector2.zero; Vector2 zero2 = Vector2.zero; object obj2 = <>c.<>9__24_0; if (obj2 == null) { UnityAction val3 = delegate { Step(-1); }; <>c.<>9__24_0 = val3; obj2 = (object)val3; } MakeButton(craftTemplate, (Transform)(object)val2, "Minus", "-", anchorMin, anchorMax, zero, zero2, (UnityAction)obj2, Loc.T("minus_tip"), 18f); _slider = BuildSlider(val2); Vector2 anchorMin2 = new Vector2(0.89f, 0f); Vector2 anchorMax2 = new Vector2(1f, 1f); Vector2 zero3 = Vector2.zero; Vector2 zero4 = Vector2.zero; object obj3 = <>c.<>9__24_1; if (obj3 == null) { UnityAction val4 = delegate { Step(1); }; <>c.<>9__24_1 = val4; obj3 = (object)val4; } MakeButton(craftTemplate, (Transform)(object)val2, "Plus", "+", anchorMin2, anchorMax2, zero3, zero4, (UnityAction)obj3, Loc.T("plus_tip"), 18f); RectTransform val5 = NewRect("Row3", _popup.transform); Anchor(val5, 0f, 0.05f, 1f, 0.33f, new Vector2(10f, 0f), new Vector2(-10f, 0f)); string label = Loc.T("max_button"); Vector2 anchorMin3 = new Vector2(0f, 0f); Vector2 anchorMax3 = new Vector2(0.3f, 1f); Vector2 zero5 = Vector2.zero; Vector2 zero6 = Vector2.zero; object obj4 = <>c.<>9__24_2; if (obj4 == null) { UnityAction val6 = delegate { SetCount(_max); }; <>c.<>9__24_2 = val6; obj4 = (object)val6; } MakeButton(craftTemplate, (Transform)(object)val5, "Max", label, anchorMin3, anchorMax3, zero5, zero6, (UnityAction)obj4, Loc.T("max_tip"), 18f); string label2 = Loc.T("start_button"); Vector2 anchorMin4 = new Vector2(0.32f, 0f); Vector2 anchorMax4 = new Vector2(1f, 1f); Vector2 zero7 = Vector2.zero; Vector2 zero8 = Vector2.zero; object obj5 = <>O.<1>__StartQueue; if (obj5 == null) { UnityAction val7 = StartQueue; <>O.<1>__StartQueue = val7; obj5 = (object)val7; } _startButton = MakeButton(craftTemplate, (Transform)(object)val5, "Start", label2, anchorMin4, anchorMax4, zero7, zero8, (UnityAction)obj5, Loc.T("start_tip"), 18f); _popup.SetActive(false); } private static void TogglePopup() { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) if (_popup.activeSelf) { ClosePopup(); return; } InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null || !CraftQueueState.TryGetSelected(instance, out var recipe, out var itemData) || (Object)(object)recipe == (Object)null || itemData != null) { return; } _popupRecipe = recipe; _max = CraftQueueState.MaxCraftable(localPlayer, recipe, 999); CraftQueuePlugin.Log.LogInfo((object)$"Panel de cola abierto: {((Object)recipe).name}, maximo={_max}"); _count = ((_max < 1) ? 1 : Mathf.Clamp(CraftQueuePlugin.QueueCount.Value, 1, _max)); ((Selectable)_slider).interactable = _max > 1; _slider.minValue = 1f; _slider.maxValue = Mathf.Max(2, _max); ((Selectable)_startButton).interactable = _max >= 1; _popup.SetActive(true); _popup.transform.SetAsLastSibling(); ApplyCount(); if (!_popupLogged) { _popupLogged = true; TMP_Text[] componentsInChildren = _popup.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val in componentsInChildren) { ManualLogSource log = CraftQueuePlugin.Log; object[] obj = new object[4] { ((Object)val.transform.parent).name, ((Object)val).name, val.text, null }; Rect rect = val.rectTransform.rect; obj[3] = ((Rect)(ref rect)).size; log.LogInfo((object)(string.Format("[UI] texto '{0}/{1}' = '{2}' tam={3} ", obj) + $"fuente={val.fontSize} color={((Graphic)val).color} activo={((Component)val).gameObject.activeInHierarchy}")); } } } private static void ClosePopup() { if ((Object)(object)_popup != (Object)null) { _popup.SetActive(false); } } private static void StartQueue() { if (_max >= 1) { CraftQueuePlugin.QueueCount.Value = _count; ClosePopup(); CraftQueueState.StartFromUi(_count); } } private static void Step(int direction) { int num = ((!Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303)) ? 1 : CraftQueuePlugin.UiStep.Value); SetCount(_count + direction * num); } private static void SetCount(int value) { _count = ((_max < 1) ? 1 : Mathf.Clamp(value, 1, _max)); ApplyCount(); } private static void ApplyCount() { if ((Object)(object)_slider != (Object)null) { _slider.SetValueWithoutNotify((float)_count); } if ((Object)(object)_label != (Object)null) { _label.text = ((_max < 1) ? Loc.T("label_none") : Loc.T("label_count", _count, _max)); } } private static Slider BuildSlider(RectTransform parent) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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) RectTransform val = NewRect("Slider", (Transform)(object)parent); Anchor(val, 0.13f, 0f, 0.87f, 1f, Vector2.zero, Vector2.zero); RectTransform obj = NewRect("Background", (Transform)(object)val); Anchor(obj, 0f, 0.35f, 1f, 0.65f, Vector2.zero, Vector2.zero); ((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = new Color(0.22f, 0.18f, 0.13f, 1f); RectTransform val2 = NewRect("Fill Area", (Transform)(object)val); Anchor(val2, 0f, 0.35f, 1f, 0.65f, new Vector2(0f, 0f), new Vector2(0f, 0f)); RectTransform val3 = NewRect("Fill", (Transform)(object)val2); val3.anchorMin = Vector2.zero; val3.anchorMax = new Vector2(0f, 1f); val3.sizeDelta = Vector2.zero; ((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = new Color(0.8f, 0.6f, 0.25f, 1f); RectTransform val4 = NewRect("Handle Slide Area", (Transform)(object)val); Anchor(val4, 0f, 0f, 1f, 1f, new Vector2(8f, 0f), new Vector2(-8f, 0f)); RectTransform val5 = NewRect("Handle", (Transform)(object)val4); val5.anchorMin = Vector2.zero; val5.anchorMax = new Vector2(0f, 1f); val5.sizeDelta = new Vector2(16f, 0f); Image val6 = ((Component)val5).gameObject.AddComponent<Image>(); ((Graphic)val6).color = new Color(0.95f, 0.85f, 0.55f, 1f); Slider obj2 = ((Component)val).gameObject.AddComponent<Slider>(); obj2.fillRect = val3; obj2.handleRect = val5; ((Selectable)obj2).targetGraphic = (Graphic)(object)val6; obj2.direction = (Direction)0; obj2.wholeNumbers = true; obj2.minValue = 1f; obj2.maxValue = 2f; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj2).navigation = navigation; ((UnityEvent<float>)(object)obj2.onValueChanged).AddListener((UnityAction<float>)delegate(float v) { SetCount(Mathf.RoundToInt(v)); }); return obj2; } private static Button MakeButton(Button template, Transform parent, string name, string label, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, UnityAction onClick, string tooltip, float fixedFontSize = 0f) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_017e: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); ((Object)val).name = "CraftQueue_" + name; val.SetActive(true); UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } foreach (Transform item in val.transform) { Transform val2 = item; string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("hint") || text.Contains("gamepad")) { ((Component)val2).gameObject.SetActive(false); } } UITooltip component = val.GetComponent<UITooltip>(); if ((Object)(object)component != (Object)null) { component.m_text = tooltip; } RectTransform val3 = (RectTransform)val.transform; val3.anchorMin = anchorMin; val3.anchorMax = anchorMax; val3.pivot = new Vector2(0.5f, 0.5f); val3.offsetMin = offsetMin; val3.offsetMax = offsetMax; TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; if (fixedFontSize > 0f) { RectTransform rectTransform = componentInChildren.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(2f, 0f); rectTransform.offsetMax = new Vector2(-2f, 0f); componentInChildren.margin = Vector4.zero; componentInChildren.alignment = (TextAlignmentOptions)514; componentInChildren.textWrappingMode = (TextWrappingModes)0; componentInChildren.enableAutoSizing = false; componentInChildren.fontSize = fixedFontSize; ((Component)componentInChildren).gameObject.SetActive(true); } else { componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMax = Mathf.Min(componentInChildren.fontSize, 20f); componentInChildren.fontSizeMin = 8f; } } Button component2 = val.GetComponent<Button>(); component2.onClick = new ButtonClickedEvent(); ((UnityEvent)component2.onClick).AddListener(onClick); ((Selectable)component2).interactable = true; return component2; } private static RectTransform NewRect(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0042: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); return (RectTransform)val.transform; } private static void Anchor(RectTransform rt, float x0, float y0, float x1, float y1, Vector2 offMin, Vector2 offMax) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) rt.anchorMin = new Vector2(x0, y0); rt.anchorMax = new Vector2(x1, y1); rt.offsetMin = offMin; rt.offsetMax = offMax; } private static TMP_Text NewText(RectTransform rt, TMP_Text template, TextAlignmentOptions align, float size) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)rt).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)template != (Object)null) { ((TMP_Text)val).font = template.font; ((TMP_Text)val).fontSharedMaterial = template.fontSharedMaterial; ((Graphic)val).color = ((Graphic)template).color; } ((TMP_Text)val).alignment = align; ((TMP_Text)val).fontSize = size; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((Graphic)val).raycastTarget = false; return (TMP_Text)(object)val; } } internal enum LanguageMode { Auto, English, Spanish } internal static class Loc { private static readonly Dictionary<string, string> En = new Dictionary<string, string> { ["queue_button"] = "Queue", ["queue_tip"] = "Queued crafting", ["cancel_button"] = "Cancel", ["cancel_tip"] = "Cancels the queue and the current craft", ["cancel_by_button"] = "cancelled with the button", ["cancel_by_key"] = "cancelled with the key", ["minus_tip"] = "Less (Shift: faster)", ["plus_tip"] = "More (Shift: faster)", ["max_button"] = "Max", ["max_tip"] = "Maximum amount you can craft right now", ["start_button"] = "Start", ["start_tip"] = "Start the queue", ["progress_queue"] = "(queue: {0} left)", ["label_none"] = "Not enough for a single unit", ["label_count"] = "Amount: {0} / {1}", ["missing_materials_msg"] = "Queue: missing materials", ["stopped"] = "Queue stopped: {0}", ["r_start_failed"] = "could not start the craft (inventory full?)", ["r_no_player"] = "no player", ["r_no_result"] = "the craft did not produce the item (materials, space or DLC)", ["r_done"] = "queue completed", ["r_player_unavailable"] = "player not available", ["r_gui_closed"] = "window closed", ["r_moved"] = "the player moved", ["r_manual_cancel"] = "craft cancelled by hand", ["r_recipe_changed"] = "the selected recipe changed", ["r_no_materials"] = "missing materials", ["r_damage"] = "the player took damage" }; private static readonly Dictionary<string, string> Es = new Dictionary<string, string> { ["queue_button"] = "Cola", ["queue_tip"] = "Crafteo en cola", ["cancel_button"] = "Cancelar", ["cancel_tip"] = "Cancela la cola y el crafteo actual", ["cancel_by_button"] = "cancelada con el botón", ["cancel_by_key"] = "cancelada con la tecla", ["minus_tip"] = "Menos (Shift: más rápido)", ["plus_tip"] = "Más (Shift: más rápido)", ["max_button"] = "Máx", ["max_tip"] = "Máxima cantidad posible ahora", ["start_button"] = "Iniciar", ["start_tip"] = "Empezar la cola", ["progress_queue"] = "(cola: restan {0})", ["label_none"] = "No alcanza para ninguna unidad", ["label_count"] = "Cantidad: {0} / {1}", ["missing_materials_msg"] = "Cola: faltan materiales", ["stopped"] = "Cola detenida: {0}", ["r_start_failed"] = "no se pudo iniciar el crafteo (¿inventario lleno?)", ["r_no_player"] = "sin jugador", ["r_no_result"] = "el crafteo no produjo el objeto (materiales, espacio o DLC)", ["r_done"] = "cola completada", ["r_player_unavailable"] = "jugador no disponible", ["r_gui_closed"] = "ventana cerrada", ["r_moved"] = "el jugador se movió", ["r_manual_cancel"] = "crafteo cancelado a mano", ["r_recipe_changed"] = "cambió la receta seleccionada", ["r_no_materials"] = "faltan materiales", ["r_damage"] = "el jugador recibió daño" }; public static bool IsSpanish() { return CraftQueuePlugin.Language.Value switch { LanguageMode.English => false, LanguageMode.Spanish => true, _ => ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null) == "Spanish", }; } public static string T(string key, params object[] args) { if (!(IsSpanish() ? Es : En).TryGetValue(key, out var value) && !En.TryGetValue(key, out value)) { return key; } if (args.Length != 0) { return string.Format(value, args); } return value; } } }