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 CDEV PerfectUI v0.4.4
plugins/CDEV.PerfectUI/CDEV.PerfectUI.dll
Decompiled 7 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CDEV.PerfectUI.Look; using CDEV.PerfectUI.Pins; using CDEV.PerfectUI.Windows; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.TextCore.LowLevel; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("gui_framework")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("CDEV.PerfectUI")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.4.0")] [assembly: AssemblyInformationalVersion("0.4.4+efb24945142928ac03192750576c1d4fe797e026")] [assembly: AssemblyProduct("CDEV.PerfectUI")] [assembly: AssemblyTitle("CDEV.PerfectUI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.4.0")] [module: UnverifiableCode] [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 CDEV.PerfectUI { internal static class AmmoBelow { private const string Box = "CDEV_Ammo/Box"; private const float Gap = 3f; private static float _next; private static bool _placed; internal static bool Shown { get; private set; } internal static float Room => 40f; internal static void Tick() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.AmmoUnderCell.Value || !Compass.OnScreen) { if (Shown || _placed) { Remove(); } _placed = false; return; } _placed = true; if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.25f; bool flag = false; HotkeyBar val = Bar(); if ((Object)(object)val != (Object)null) { foreach (ElementData element in val.m_elements) { RectTransform val2 = (RectTransform)(((Object)(object)element?.m_go != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val2 == (Object)null)) { if (val2.anchorMin.y != 0f) { Place(val2, below: true); } flag |= ((Component)val2).gameObject.activeInHierarchy; } } } if (!InventoryGui.IsVisible()) { Shown = flag; } } internal static void Remove() { HotkeyBar val = Bar(); if ((Object)(object)val == (Object)null) { return; } foreach (ElementData element in val.m_elements) { RectTransform val2 = (RectTransform)(((Object)(object)element?.m_go != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 != (Object)null) { Place(val2, below: false); } } Shown = false; } private static HotkeyBar Bar() { if ((Object)(object)Hud.instance == (Object)null) { return null; } HotkeyBar[] componentsInChildren = ((Component)Hud.instance).GetComponentsInChildren<HotkeyBar>(true); foreach (HotkeyBar val in componentsInChildren) { if (((Object)val).name == "HotKeyBar") { return val; } } return null; } private static void Place(RectTransform box, bool below) { //IL_0015: 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_0053: 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) box.anchorMin = new Vector2(0f, below ? 0f : 1f); box.anchorMax = new Vector2(1f, below ? 0f : 1f); box.pivot = new Vector2(0.5f, below ? 1f : 0f); box.anchoredPosition = new Vector2(0f, below ? (-3f) : 3f); } } [HarmonyPatch] internal static class AutoRepair { private sealed class RepairHint : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private UITooltip _vanilla; private void Awake() { _vanilla = ((Component)this).GetComponentInChildren<UITooltip>(true); if ((Object)(object)_vanilla != (Object)null) { ((Behaviour)_vanilla).enabled = false; } } private void OnDestroy() { if ((Object)(object)_vanilla != (Object)null) { ((Behaviour)_vanilla).enabled = true; } } public void OnPointerEnter(PointerEventData eventData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown CategoryTip.Show(InventoryGui.instance, (RectTransform)((Component)this).transform, Translations.Get(Translations.Key.AutoRepair), Translations.Get(Translations.Key.AutoRepairHint)); } public void OnPointerExit(PointerEventData eventData) { CategoryTip.Hide((Object)(object)((Component)this).transform); } private void OnDisable() { CategoryTip.Hide((Object)(object)((Component)this).transform); } } private static readonly List<ItemData> Worn = new List<ItemData>(); private static readonly List<ItemData> Repaired = new List<ItemData>(); internal static bool HidesButton { get { if (ModConfig.AutoRepair.Value && (Object)(object)Player.m_localPlayer != (Object)null) { return (Object)(object)Player.m_localPlayer.GetCurrentCraftingStation() != (Object)null; } return false; } } [HarmonyPostfix] [HarmonyPatch(typeof(InventoryGui), "Show")] private static void Show_Postfix(InventoryGui __instance) { try { if (ModConfig.AutoRepair.Value) { RepairAll(__instance); } } catch (Exception ex) { PerfectUIPlugin.Log.LogWarning((object)("Auto-repair failed: " + ex.Message)); } } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "UpdateRepair")] private static bool UpdateRepair_Prefix(InventoryGui __instance) { if ((Object)(object)__instance.m_repairButton == (Object)null) { return true; } if (HidesButton) { ((Component)__instance.m_repairButton).gameObject.SetActive(false); ((Component)__instance.m_repairPanel).gameObject.SetActive(false); ((Component)__instance.m_repairPanelSelection).gameObject.SetActive(false); return false; } if ((Object)(object)((Component)__instance.m_repairButton).GetComponent<RepairHint>() == (Object)null) { ((Component)__instance.m_repairButton).gameObject.AddComponent<RepairHint>(); } return true; } private static void RepairAll(InventoryGui gui) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)val == (Object)null || !val.m_canRepair || !val.CheckUsable(localPlayer, false)) { return; } Worn.Clear(); Repaired.Clear(); ((Humanoid)localPlayer).GetInventory().GetWornItems(Worn); foreach (ItemData item in Worn) { if (gui.CanRepair(item)) { float maxDurability = item.GetMaxDurability(); ((Character)localPlayer).RaiseSkill((SkillType)107, 1f - item.m_durability / maxDurability); item.m_durability = maxDurability; Repaired.Add(item); } } Worn.Clear(); if (Repaired.Count == 0) { return; } val.m_repairItemDoneEffects.Create(((Component)val).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); ((Character)localPlayer).Message((MessageType)2, Translations.Get(Translations.Key.ItemsRepaired), 0, (Sprite)null, false); foreach (ItemData item2 in Repaired) { ((Character)localPlayer).Message((MessageType)1, Localization.instance.Localize("$msg_repaired", new string[1] { Localization.instance.Localize(item2.m_shared.m_name) }), 0, item2.GetIcon(), false); } Repaired.Clear(); } internal static void Remove() { if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_repairButton != (Object)null) { RepairHint component = ((Component)InventoryGui.instance.m_repairButton).GetComponent<RepairHint>(); if (component != null) { Object.Destroy((Object)(object)component); } } } } [HarmonyPatch] internal static class BuildComfort { internal const int TagId = 9101; private const string ChipName = "CDEV_PerfectUI_Comfort"; private const string GlowName = "CDEV_PerfectUI_GroupGlow"; private static readonly Color Raise = new Color(0.45f, 0.9f, 0.4f); private static readonly Color Same = new Color(0.72f, 0.72f, 0.72f); private static readonly Color Lower = new Color(0.95f, 0.42f, 0.36f); private static readonly Color Unlit = new Color(1f, 0.72f, 0.25f); private static bool _failed; private static float _nextTick; private static readonly List<Piece> Sorted = new List<Piece>(); [HarmonyPostfix] [HarmonyPatch(typeof(ByUsagePieceList), "UpdateAvailableTags")] private static void UpdateAvailableTags_Postfix(ByUsagePieceList __instance, PieceTable pieceTable) { Guard(delegate { __instance.m_availableTags.Remove(9101); if (ModConfig.Comfort && !((Object)(object)pieceTable == (Object)null) && AnyComfort(pieceTable)) { int index = __instance.m_availableTags.Count; for (int i = 0; i < __instance.m_availableTags.Count; i++) { int num = __instance.m_availableTags[i]; if (num >= 0 && num < __instance.m_usageTags.Length && (int)__instance.m_usageTags[num] == 128) { index = i + 1; } } __instance.m_availableTags.Insert(index, 9101); } }); } [HarmonyPrefix] [HarmonyPatch(typeof(ByUsagePieceList), "GetTagDisplayName")] private static bool GetTagDisplayName_Prefix(ByUsagePieceList __instance, int index, ref string __result) { if (index < 0 || index >= __instance.m_availableTags.Count || __instance.m_availableTags[index] != 9101) { return true; } __result = Translations.Get(Translations.Key.ComfortTag); return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ByUsagePieceList), "GetAvailablePiecesWithTag")] private static bool GetAvailablePiecesWithTag_Prefix(int tagId, PieceTable pieceTable, IList<Piece> resultOut) { if (tagId != 9101) { return true; } try { Fill(pieceTable, resultOut); } catch (Exception e) { Log(e); } return false; } private static bool AnyComfort(PieceTable table) { foreach (Piece availablePiece in table.m_availablePieces) { if (IsComfort(availablePiece)) { return true; } } return false; } private static bool IsComfort(Piece piece) { if ((Object)(object)piece != (Object)null && piece.m_comfort > 0 && !piece.m_repairPiece) { return !piece.m_removePiece; } return false; } private static void Fill(PieceTable table, IList<Piece> result) { if ((Object)(object)table == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ComfortRoom.Update(localPlayer, force: false); } Sorted.Clear(); foreach (Piece availablePiece in table.m_availablePieces) { if (IsComfort(availablePiece)) { Sorted.Add(availablePiece); } } Sorted.Sort(delegate(Piece a, Piece b) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) int num = Rank(ComfortRoom.Of(a)).CompareTo(Rank(ComfortRoom.Of(b))); if (num == 0) { ref ComfortGroup comfortGroup = ref a.m_comfortGroup; object target = b.m_comfortGroup; num = ((Enum)Unsafe.As<ComfortGroup, ComfortGroup>(ref comfortGroup)/*cast due to .constrained prefix*/).CompareTo(target); } if (num == 0) { num = b.m_comfort.CompareTo(a.m_comfort); } return (num == 0) ? string.Compare(Localization.instance.Localize(a.m_name), Localization.instance.Localize(b.m_name), StringComparison.InvariantCultureIgnoreCase) : num; }); foreach (Piece item in Sorted) { result.Add(item); } Sorted.Clear(); } private static int Rank(ComfortRoom.Gain gain) { return gain switch { ComfortRoom.Gain.Same => 2, ComfortRoom.Gain.Unlit => 1, ComfortRoom.Gain.Raise => 0, _ => 3, }; } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "UpdatePieceButtons")] private static void UpdatePieceButtons_Postfix(BuildUi __instance) { Guard(delegate { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && ModConfig.Comfort) { ComfortRoom.Update(localPlayer, force: true); } Chips(__instance); Glow(__instance, null); }); } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "OnHoverPiece")] private static void OnHoverPiece_Postfix(BuildUi __instance, BuildUiPieceButton button) { Guard(delegate { Glow(__instance, button); }); } internal static void Tick() { if (Time.unscaledTime < _nextTick) { return; } _nextTick = Time.unscaledTime + 1f; Guard(delegate { Player localPlayer = Player.m_localPlayer; Hud instance = Hud.instance; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_buildUi == (Object)null) && Hud.IsPieceSelectionVisible()) { if (ModConfig.Comfort) { ComfortRoom.Update(localPlayer, force: true); } Chips(instance.m_buildUi); } }); } private static void Chips(BuildUi ui) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) bool flag = ModConfig.Comfort && ModConfig.ComfortChips.Value && !CalculatorTab.Shows(ui); foreach (BuildUiPieceButton pieceButton in ui.m_pieceButtons) { if ((Object)(object)pieceButton == (Object)null) { continue; } Piece piece = pieceButton.Piece; Transform val = ((Component)pieceButton).transform.Find("CDEV_PerfectUI_Comfort"); if (!flag || !IsComfort(piece)) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } continue; } if ((Object)(object)val == (Object)null) { val = MakeChip(((Component)pieceButton).transform); } TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>(true); componentInChildren.text = "+" + piece.m_comfort.ToString(CultureInfo.InvariantCulture); ((Graphic)componentInChildren).color = ColorOf(ComfortRoom.Of(piece)); val.SetAsLastSibling(); ((Component)val).gameObject.SetActive(true); } } private static Transform MakeChip(Transform parent) { //IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Ui.Rect("CDEV_PerfectUI_Comfort", parent); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 0f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.anchoredPosition = new Vector2(-2f, 2f); val.sizeDelta = new Vector2(24f, 15f); val.RoundedImage(new Color(0f, 0f, 0f, 0.62f), 4f, raycast: false); TMP_Text val4 = (TMP_Text)(object)Ui.Label("Value", (Transform)(object)val, "", Fonts.Heading, 12f, Color.white, (TextAlignmentOptions)514); val4.rectTransform.Stretch(); val4.overflowMode = (TextOverflowModes)0; val4.fontStyle = (FontStyles)1; ((Graphic)val4).raycastTarget = false; return (Transform)(object)val; } internal static Color ColorOf(ComfortRoom.Gain gain) { //IL_001d: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return (Color)(gain switch { ComfortRoom.Gain.Same => Same, ComfortRoom.Gain.Unlit => Unlit, ComfortRoom.Gain.Raise => Raise, _ => Lower, }); } private static void Glow(BuildUi ui, BuildUiPieceButton hovered) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) ComfortGroup val = (ComfortGroup)0; if (ModConfig.Comfort && ModConfig.ComfortGlow.Value && (Object)(object)hovered != (Object)null && (Object)(object)hovered.Piece != (Object)null && OnComfortRow(ui)) { val = hovered.Piece.m_comfortGroup; } foreach (BuildUiPieceButton pieceButton in ui.m_pieceButtons) { if ((Object)(object)pieceButton == (Object)null) { continue; } bool flag = (int)val != 0 && (Object)(object)pieceButton != (Object)(object)hovered && (Object)(object)pieceButton.Piece != (Object)null && pieceButton.Piece.m_comfortGroup == val; Transform val2 = ((Component)pieceButton).transform.Find("CDEV_PerfectUI_GroupGlow"); if (!flag) { if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } continue; } if ((Object)(object)val2 == (Object)null) { RectTransform val3 = Ui.Rect("CDEV_PerfectUI_GroupGlow", ((Component)pieceButton).transform).Stretch(2f, 2f, 2f, 2f); val3.RoundedImage(new Color(1f, 0.93f, 0.75f, 0.2f), 4f, raycast: false); val2 = (Transform)(object)val3; } val2.SetSiblingIndex(0); ((Component)val2).gameObject.SetActive(true); } } private static bool OnComfortRow(BuildUi ui) { if (ui.m_currentTagId == 9101 && ui.m_currentPieceList >= 0 && ui.m_currentPieceList < ui.m_pieceLists.Count) { return ui.m_pieceLists[ui.m_currentPieceList] is ByUsagePieceList; } return false; } internal static void Remove() { BuildUi val = (((Object)(object)Hud.instance != (Object)null) ? Hud.instance.m_buildUi : null); if ((Object)(object)val != (Object)null) { Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "CDEV_PerfectUI_Comfort" || ((Object)val2).name == "CDEV_PerfectUI_GroupGlow") { Object.Destroy((Object)(object)((Component)val2).gameObject); } } if (val.m_pieceLists != null) { foreach (IPieceList pieceList in val.m_pieceLists) { ((ByUsagePieceList)(((pieceList is ByUsagePieceList) ? pieceList : null)?)).m_availableTags.Remove(9101); } } if (val.m_currentTagId == 9101) { val.m_currentTagId = -1; } } RoomPanel.Remove(); } private static void Guard(Action action) { try { action(); } catch (Exception e) { Log(e); } } private static void Log(Exception e) { if (!_failed) { _failed = true; PerfectUIPlugin.Log.LogError((object)("Build menu comfort failed: " + e)); } } } internal static class ComfortRoom { internal enum Gain { Raise, Same, Lower, Unlit } internal static readonly List<Piece> Counted = new List<Piece>(); private static readonly List<Piece> Near = new List<Piece>(); private static readonly Dictionary<ComfortGroup, int> GroupBest = new Dictionary<ComfortGroup, int>(); private static readonly HashSet<string> CountedNames = new HashSet<string>(); private static readonly HashSet<string> UnlitNames = new HashSet<string>(); private static float _at = float.MinValue; internal static int Total { get; private set; } internal static bool Sheltered { get; private set; } internal static void Update(Player player, bool force) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (!force && Time.unscaledTime < _at + 0.5f) { return; } _at = Time.unscaledTime; Sheltered = player.InShelter(); Near.Clear(); Counted.Clear(); GroupBest.Clear(); CountedNames.Clear(); UnlitNames.Clear(); Piece.GetAllComfortPiecesInRadius(((Component)player).transform.position, 10f, Near); Near.Sort((Comparison<Piece>)SE_Rested.PieceComfortSort); int num = 0; for (int i = 0; i < Near.Count; i++) { Piece val = Near[i]; if ((Object)(object)val == (Object)null) { continue; } if (val.m_comfort > 0 && val.GetComfort() == 0) { UnlitNames.Add(val.m_name); } if (i <= 0 || !((Object)(object)Near[i - 1] != (Object)null) || (((int)val.m_comfortGroup == 0 || val.m_comfortGroup != Near[i - 1].m_comfortGroup) && !(val.m_name == Near[i - 1].m_name))) { int comfort = val.GetComfort(); if ((int)val.m_comfortGroup != 0) { GroupBest[val.m_comfortGroup] = comfort; } if (comfort > 0) { num += comfort; Counted.Add(val); CountedNames.Add(val.m_name); } } } Counted.Sort((Piece a, Piece b) => b.GetComfort().CompareTo(a.GetComfort())); Near.Clear(); Total = 1 + (Sheltered ? (1 + num) : 0); } internal static Gain Of(Piece prefab) { //IL_0008: 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) int comfort = prefab.m_comfort; if ((int)prefab.m_comfortGroup == 0) { if (!CountedNames.Contains(prefab.m_name)) { if (!UnlitNames.Contains(prefab.m_name)) { return Gain.Raise; } return Gain.Unlit; } return Gain.Same; } int value; int num = (GroupBest.TryGetValue(prefab.m_comfortGroup, out value) ? value : 0); if (comfort > num) { if (!UnlitNames.Contains(prefab.m_name)) { return Gain.Raise; } return Gain.Unlit; } if (comfort != num) { return Gain.Lower; } return Gain.Same; } } internal sealed class RoomPanel : MonoBehaviour { private const string RootName = "CDEV_PerfectUI_RoomComfort"; private static RoomPanel _instance; private RectTransform _rect; private TMP_Text _text; private CanvasGroup _group; private float _next; private readonly StringBuilder _sb = new StringBuilder(); private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; internal static RectTransform Shown { get { if (!((Object)(object)_instance != (Object)null) || !(_instance._group.alpha > 0f)) { return null; } return _instance._rect; } } internal static void Ensure() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006f: 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_0081: 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) if ((Object)(object)_instance != (Object)null) { return; } RectTransform root = PinHost.Root; if (!((Object)(object)root == (Object)null)) { Transform val = ((Transform)root).Find("CDEV_PerfectUI_RoomComfort"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } RectTransform val2 = Ui.Rect("CDEV_PerfectUI_RoomComfort", (Transform)(object)root); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 1f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.RoundedImage(Palette.Surface.WithAlpha(0.78f), 6f, raycast: false); _instance = ((Component)val2).gameObject.AddComponent<RoomPanel>(); _instance._rect = val2; _instance._group = ((Component)val2).gameObject.AddComponent<CanvasGroup>(); _instance._group.blocksRaycasts = false; TMP_Text val5 = (TMP_Text)(object)Ui.Label("Text", (Transform)(object)val2, "", Fonts.BodyMedium, 14f, Palette.Ink, (TextAlignmentOptions)257); val5.rectTransform.Stretch(10f, 10f, 6f, 6f); val5.richText = true; val5.overflowMode = (TextOverflowModes)0; val5.textWrappingMode = (TextWrappingModes)0; Material val6 = Fonts.Shadow(val5.font); if ((Object)(object)val6 != (Object)null) { val5.fontSharedMaterial = val6; } _instance._text = val5; _instance._group.alpha = 0f; } } internal static void Remove() { if ((Object)(object)_instance != (Object)null) { Object.Destroy((Object)(object)((Component)_instance).gameObject); _instance = null; } } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } private void LateUpdate() { try { Player localPlayer = Player.m_localPlayer; bool flag = ModConfig.Comfort && ModConfig.RoomPanel.Value && (Object)(object)localPlayer != (Object)null && ((Character)localPlayer).InPlaceMode() && !((Character)localPlayer).IsDead(); _group.alpha = (flag ? 1f : 0f); if (flag) { Place(); if (!(Time.unscaledTime < _next)) { _next = Time.unscaledTime + 0.5f; ComfortRoom.Update(localPlayer, force: false); Fill(); } } } catch (Exception ex) { ((Behaviour)this).enabled = false; PerfectUIPlugin.Log.LogError((object)("Room comfort panel failed: " + ex)); } } private void Place() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_009a: Expected O, but got Unknown //IL_009d: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; RectTransform val = (RectTransform)(((Object)(object)instance != (Object)null && (Object)(object)instance.m_smallRoot != (Object)null && instance.m_smallRoot.activeInHierarchy) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { _rect.anchoredPosition = new Vector2(-20f, -260f); return; } val.GetWorldCorners(Corners); Vector3 val2 = ((Transform)_rect).parent.InverseTransformPoint(Corners[3]); RectTransform val3 = (RectTransform)((Transform)_rect).parent; Rect rect = val3.rect; float xMax = ((Rect)(ref rect)).xMax; rect = val3.rect; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(xMax, ((Rect)(ref rect)).yMax); _rect.anchoredPosition = new Vector2(val2.x - val4.x, val2.y - val4.y - 6f); } private void Fill() { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) _sb.Length = 0; _sb.Append("<color=#E8B04A><b>").Append(Translations.Get(Translations.Key.ComfortRoom).Replace("{0}", ComfortRoom.Total.ToString(CultureInfo.InvariantCulture))).Append("</b></color>"); Line(Translations.Get(Translations.Key.ComfortBase), 1); if (ComfortRoom.Sheltered) { Line(Translations.Get(Translations.Key.ComfortShelter), 1); foreach (Piece item in ComfortRoom.Counted) { if ((Object)(object)item != (Object)null) { Line(Localization.instance.Localize(item.m_name), item.GetComfort()); } } } else { _sb.Append("\n<color=#F06B5C>").Append(Translations.Get(Translations.Key.ComfortNoShelter)).Append("</color>"); } _text.text = _sb.ToString(); _text.ForceMeshUpdate(false, false); Vector2 preferredValues = _text.GetPreferredValues(_text.text); _rect.sizeDelta = new Vector2(Mathf.Min(preferredValues.x, 360f) + 20f, preferredValues.y + 12f); } private void Line(string name, int value) { _sb.Append('\n').Append(name).Append(" <color=#BDBDBD>+") .Append(value.ToString(CultureInfo.InvariantCulture)) .Append("</color>"); } } internal static class BuildField { internal static TMP_InputField Original { get { if (!((Object)(object)Hud.instance != (Object)null) || !((Object)(object)Hud.instance.m_buildUi != (Object)null)) { return null; } return (TMP_InputField)(object)Hud.instance.m_buildUi.m_searchField; } } internal static TMP_InputField Copy(Transform parent, string name) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown TMP_InputField original = Original; if ((Object)(object)original == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(((Component)original).gameObject, parent); ((Object)val).name = name; Transform val2 = val.transform.Find("SearchBarHint"); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } TMP_InputField component = val.GetComponent<TMP_InputField>(); component.onValueChanged = new OnChangeEvent(); component.onEndEdit = new SubmitEvent(); component.onSubmit = new SubmitEvent(); component.onSelect = new SelectionEvent(); component.onDeselect = new SelectionEvent(); GuiInputField val3 = (GuiInputField)(object)((component is GuiInputField) ? component : null); if (val3 != null) { val3.OnInputSubmit = new OnInputSubmitEvent(); } component.SetTextWithoutNotify(""); return component; } } [HarmonyPatch] internal static class BuildMarks { internal sealed class SeeAllOnDoubleClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0 && eventData.clickCount >= 2) { Guard(delegate { SeeAll(((Object)(object)Hud.instance != (Object)null) ? Hud.instance.m_buildUi : null); }); } } } private const string DotName = "CDEV_PerfectUI_New"; private static readonly List<Piece> Temp = new List<Piece>(); private static bool _failed; private static bool _cleared; [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "UpdatePieceButtons")] private static void UpdatePieceButtons_Postfix(BuildUi __instance) { Guard(delegate { Pieces(__instance); Tags(__instance); }); } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "UpdateTagButtons")] private static void UpdateTagButtons_Postfix(BuildUi __instance) { Guard(delegate { Tags(__instance); }); } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "OnSelectPiece")] private static void OnSelectPiece_Postfix(BuildUi __instance, Piece piece) { Guard(delegate { Seen(__instance, piece); }); } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "OnNavigatedToPieceButton")] private static void OnNavigatedToPieceButton_Postfix(BuildUi __instance, BuildUiPieceButton button) { Guard(delegate { Seen(__instance, ((Object)(object)button != (Object)null) ? button.Piece : null); }); } [HarmonyPostfix] [HarmonyPatch(typeof(BuildUi), "OnHoverPiece")] private static void OnHoverPiece_Postfix(BuildUi __instance, BuildUiPieceButton button) { if (ModConfig.BuildNewMarksClear.Value == ModConfig.MarkClear.OnHover && !((Object)(object)button == (Object)null)) { Guard(delegate { Seen(__instance, button.Piece); }); } } private static void Guard(Action action) { if (!ModConfig.BuildNewMarks.Value) { if (!_cleared) { Remove(); } _cleared = true; return; } _cleared = false; try { action(); } catch (Exception ex) { if (!_failed) { _failed = true; PerfectUIPlugin.Log.LogError((object)("Build menu marks failed: " + ex)); } } } private static void Seen(BuildUi ui, Piece piece) { if ((Object)(object)piece != (Object)null && NewRecipes.MarkSeen(Player.m_localPlayer, piece.m_name)) { Pieces(ui); Tags(ui); } } internal static void SeeAll(BuildUi ui) { Player localPlayer = Player.m_localPlayer; PieceTable val = (((Object)(object)ui != (Object)null) ? ui.m_currentBuildTool : null); if ((Object)(object)localPlayer == (Object)null || (Object)(object)val == (Object)null) { return; } List<string> list = new List<string>(); foreach (GameObject piece in val.m_pieces) { Piece val2 = (((Object)(object)piece != (Object)null) ? piece.GetComponent<Piece>() : null); if ((Object)(object)val2 != (Object)null) { list.Add(val2.m_name); } } if (NewRecipes.MarkSeen(localPlayer, (IEnumerable<string>)list) > 0) { Pieces(ui); Tags(ui); } } private static void Pieces(BuildUi ui) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; foreach (BuildUiPieceButton pieceButton in ui.m_pieceButtons) { if ((Object)(object)pieceButton != (Object)null) { Dot(((Component)pieceButton).transform, (Object)(object)localPlayer != (Object)null && (Object)(object)pieceButton.Piece != (Object)null && NewRecipes.IsNew(localPlayer, pieceButton.Piece.m_name), new Vector2(0f, 1f), new Vector2(8f, -8f), 10f); } } } private static void Tags(BuildUi ui) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; PieceTable currentBuildTool = ui.m_currentBuildTool; if ((Object)(object)localPlayer == (Object)null || (Object)(object)currentBuildTool == (Object)null || ui.m_pieceLists == null || ui.m_currentPieceList < 0 || ui.m_currentPieceList >= ui.m_pieceLists.Count) { return; } IPieceList list = ui.m_pieceLists[ui.m_currentPieceList]; foreach (BuildUiTagButton tagButton in ui.m_tagButtons) { if ((Object)(object)tagButton != (Object)null && (Object)(object)tagButton != (Object)(object)ui.m_addFavoriteTagButton) { Dot(((Component)tagButton).transform, AnyNew(localPlayer, list, tagButton.m_tagId, currentBuildTool), new Vector2(1f, 0.5f), new Vector2(-10f, 0f), 9f); } } BuildUiTagButton showAllTagsButton = ui.m_showAllTagsButton; if ((Object)(object)showAllTagsButton != (Object)null) { Dot(((Component)showAllTagsButton).transform, AnyNew(localPlayer, list, -1, currentBuildTool), new Vector2(1f, 0.5f), new Vector2(-10f, 0f), 9f); SeeAllOnDoubleClick component = ((Component)showAllTagsButton).GetComponent<SeeAllOnDoubleClick>(); if ((Object)(object)component == (Object)null) { ((Component)showAllTagsButton).gameObject.AddComponent<SeeAllOnDoubleClick>(); } else if (!((Behaviour)component).enabled) { ((Behaviour)component).enabled = true; } } if (ui.m_tabButtons == null) { return; } for (int i = 0; i < ui.m_tabButtons.Count && i < ui.m_pieceLists.Count; i++) { Button val = ui.m_tabButtons[i]; if ((Object)(object)val != (Object)null) { Dot(((Component)val).transform, AnyNew(localPlayer, ui.m_pieceLists[i], -1, currentBuildTool), new Vector2(1f, 1f), new Vector2(-8f, -8f), 9f); } } } private static bool AnyNew(Player player, IPieceList list, int tagId, PieceTable tool) { Temp.Clear(); try { list.GetAvailablePiecesWithTag(tagId, tool, (IList<Piece>)Temp); } catch (Exception) { Temp.Clear(); } foreach (Piece item in Temp) { if ((Object)(object)item != (Object)null && NewRecipes.IsNew(player, item.m_name)) { Temp.Clear(); return true; } } Temp.Clear(); return false; } private static void Dot(Transform parent, bool on, Vector2 anchor, Vector2 position, float size) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Transform val = parent.Find("CDEV_PerfectUI_New"); if (!on) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } return; } if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("CDEV_PerfectUI_New", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.layer = ((Component)parent).gameObject.layer; RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent(parent, false); Vector2 anchorMin = (val3.anchorMax = anchor); val3.anchorMin = anchorMin; val3.pivot = new Vector2(0.5f, 0.5f); val3.anchoredPosition = position; val3.sizeDelta = new Vector2(size, size); Image component = val2.GetComponent<Image>(); component.sprite = Sprites.Circle; ((Graphic)component).color = RowMarks.NewColor; ((Graphic)component).raycastTarget = false; val = (Transform)(object)val3; } val.SetAsLastSibling(); ((Component)val).gameObject.SetActive(true); } internal static void Remove() { BuildUi val = (((Object)(object)Hud.instance != (Object)null) ? Hud.instance.m_buildUi : null); if ((Object)(object)val == (Object)null) { return; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "CDEV_PerfectUI_New") { Object.Destroy((Object)(object)((Component)val2).gameObject); } } SeeAllOnDoubleClick[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<SeeAllOnDoubleClick>(true); foreach (SeeAllOnDoubleClick seeAllOnDoubleClick in componentsInChildren2) { Object.Destroy((Object)(object)seeAllOnDoubleClick); } } } internal enum Category { All, Weapons, Shields, Armor, Utility, Ammo, Tools, Food, Meads, Materials, Other } internal static class Categories { internal const int Count = 11; private static readonly string[] IconItems = new string[11] { null, "SwordIron", "ShieldBronzeBuckler", "ArmorIronChest", "BeltStrength", "ArrowWood", "Hammer", "CookedMeat", "MeadHealthMinor", "Bronze", null }; private static readonly HashSet<string> SiegeAmmo = new HashSet<string>(); private static ZNetScene _siegeAmmoFrom; internal static Category Of(Recipe recipe) { //IL_0012: 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_0018: 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_0080: Expected I4, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Invalid comparison between Unknown and I4 SharedData shared = recipe.m_item.m_itemData.m_shared; ItemType itemType = shared.m_itemType; switch (itemType - 1) { case 2: case 3: case 13: case 21: if ((int)shared.m_skillType == 12 || (int)shared.m_skillType == 104) { return Category.Tools; } if (!(((DamageTypes)(ref shared.m_damages)).GetTotalDamage() > 0f)) { return Category.Other; } return Category.Weapons; case 4: return Category.Shields; case 5: case 6: case 10: case 11: case 16: return Category.Armor; case 17: case 23: return Category.Utility; case 8: case 22: return Category.Ammo; case 14: case 18: return Category.Tools; case 1: if (!(shared.m_food > 0f) && !(shared.m_foodStamina > 0f) && !(shared.m_foodEitr > 0f)) { return Category.Meads; } return Category.Food; case 0: case 15: if (IsSiegeAmmo(recipe.m_item)) { return Category.Ammo; } if ((int)shared.m_itemType != 1) { return Category.Other; } return Category.Materials; default: return Category.Other; } } private static bool IsSiegeAmmo(ItemDrop item) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (((Object)item).name.IndexOf("ammo", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((Object)(object)_siegeAmmoFrom != (Object)(object)ZNetScene.instance) { _siegeAmmoFrom = ZNetScene.instance; SiegeAmmo.Clear(); if ((Object)(object)_siegeAmmoFrom != (Object)null) { foreach (GameObject prefab in _siegeAmmoFrom.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Turret component = prefab.GetComponent<Turret>(); if (component != null && component.m_allowedAmmo != null) { foreach (AmmoType item2 in component.m_allowedAmmo) { if ((Object)(object)item2.m_ammo != (Object)null) { SiegeAmmo.Add(((Object)item2.m_ammo).name); } } } Catapult component2 = prefab.GetComponent<Catapult>(); if (component2 != null && (Object)(object)component2.m_defaultAmmo != (Object)null) { SiegeAmmo.Add(((Object)component2.m_defaultAmmo).name); } } } } return SiegeAmmo.Contains(((Object)item).name); } internal static Sprite Icon(Category category) { string text = IconItems[(int)category]; if (text == null || (Object)(object)ObjectDB.instance == (Object)null) { return null; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if (!((Object)(object)val != (Object)null)) { return null; } return val.m_itemData.GetIcon(); } internal static string RecipesWord() { return Translations.Get(Translations.Key.Recipes); } internal static string Name(Category category) { return Translations.Get((Translations.Key)(0 + category)); } } internal sealed class CategoryButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private const float IconInset = 0.14f; internal RectTransform Rect; private Image _icon; private Image _selected; private GameObject _newDot; private InventoryGui _gui; private string _tipTitle; private string _tipText; private bool _hovered; private bool _active; private Vector2 _rest; private float _shift; private bool _placed; private const float RestShift = 6f; private const float OutShift = 1f; private static readonly Color ActiveTint = new Color(1f, 0.63f, 0.24f, 0.07f); private const float TintInset = 4f; private const float SlideSpeed = 18f; internal static CategoryButton Create(Category category, RectTransform parent, Button template, Action<Category> clicked) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025e: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Expected O, but got Unknown //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Expected O, but got Unknown //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Expected O, but got Unknown //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0582: 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_035a: Expected O, but got Unknown GameObject val = new GameObject("CDEV_Category_" + category, new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val.layer = ((Component)parent).gameObject.layer; RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)parent, false); GameObject val3; Button val7; if ((Object)(object)template != (Object)null) { val3 = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)val2, false); UIGamePad[] componentsInChildren = val3.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val4 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val4); } ButtonImageColor[] componentsInChildren2 = val3.GetComponentsInChildren<ButtonImageColor>(true); foreach (ButtonImageColor val5 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val5); } UITooltip[] componentsInChildren3 = val3.GetComponentsInChildren<UITooltip>(true); foreach (UITooltip val6 in componentsInChildren3) { Object.DestroyImmediate((Object)(object)val6); } val7 = val3.GetComponent<Button>(); } else { val3 = new GameObject("Button", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent((Transform)(object)val2, false); ((Graphic)val3.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f); val7 = val3.AddComponent<Button>(); } ((Object)val3).name = "Button"; val3.SetActive(true); Image component = val3.GetComponent<Image>(); float num = (((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null && component.pixelsPerUnit > 0f) ? (component.sprite.border.z / (component.pixelsPerUnit * component.pixelsPerUnitMultiplier)) : 0f); num = ((num > 0f) ? Mathf.Clamp(num, 2f, 16f) : 8f); RectTransform val8 = (RectTransform)val3.transform; val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.pivot = new Vector2(0.5f, 0.5f); val8.offsetMin = Vector2.zero; val8.offsetMax = new Vector2(num, 0f); ((Transform)val8).localScale = Vector3.one; val7.onClick = new ButtonClickedEvent(); ((UnityEvent)val7.onClick).AddListener((UnityAction)delegate { clicked(category); }); ((Selectable)val7).interactable = true; Button obj = val7; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; CategoryButton categoryButton = val.AddComponent<CategoryButton>(); categoryButton.Rect = val2; Transform val9 = val3.transform.Find("Text"); if ((Object)(object)val9 != (Object)null) { ((Component)val9).gameObject.SetActive(false); } Transform val10 = val3.transform.Find("Image"); categoryButton._icon = (((Object)(object)val10 != (Object)null) ? ((Component)val10).GetComponent<Image>() : null); if ((Object)(object)categoryButton._icon == (Object)null) { GameObject val11 = new GameObject("Image", new Type[2] { typeof(RectTransform), typeof(Image) }); val11.transform.SetParent(val3.transform, false); categoryButton._icon = val11.GetComponent<Image>(); } ((Component)categoryButton._icon).gameObject.SetActive(true); ((Graphic)categoryButton._icon).raycastTarget = false; ((Graphic)categoryButton._icon).color = Color.white; categoryButton._icon.preserveAspect = true; Stretch((RectTransform)((Component)categoryButton._icon).transform, 0.14f); ((RectTransform)((Component)categoryButton._icon).transform).offsetMax = new Vector2(0f - num, 0f); GameObject val12 = new GameObject("CDEV_Selected", new Type[2] { typeof(RectTransform), typeof(Image) }); val12.layer = val3.layer; val12.transform.SetParent(val3.transform, false); val12.transform.SetSiblingIndex(0); categoryButton._selected = val12.GetComponent<Image>(); ((Graphic)categoryButton._selected).raycastTarget = false; ((Graphic)categoryButton._selected).color = ActiveTint; RectTransform val13 = (RectTransform)val12.transform; Stretch(val13, 0f); val13.offsetMin = new Vector2(4f, 4f); val13.offsetMax = new Vector2(0f - num, -4f); val12.SetActive(false); GameObject val14 = new GameObject("CDEV_New", new Type[2] { typeof(RectTransform), typeof(Image) }); val14.layer = val3.layer; RectTransform val15 = (RectTransform)val14.transform; ((Transform)val15).SetParent(val3.transform, false); Vector2 val16 = default(Vector2); ((Vector2)(ref val16))..ctor(0f, 1f); val15.anchorMax = val16; val15.anchorMin = val16; val15.anchoredPosition = new Vector2(8f, -8f); val15.sizeDelta = new Vector2(9f, 9f); Image component2 = val14.GetComponent<Image>(); component2.sprite = Sprites.Circle; ((Graphic)component2).color = RowMarks.NewColor; ((Graphic)component2).raycastTarget = false; categoryButton._newDot = val14; val14.SetActive(false); categoryButton._gui = InventoryGui.instance; return categoryButton; } internal void SetIcon(Sprite sprite) { _icon.sprite = sprite; ((Behaviour)_icon).enabled = (Object)(object)sprite != (Object)null; } internal void SetNew(bool isNew) { _newDot.SetActive(isNew); } internal void SetSelected(bool selected) { _active = selected; ((Component)_selected).gameObject.SetActive(selected); } internal void SetRest(Vector2 position) { //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_003f: 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_0054: Unknown result type (might be due to invalid IL or missing references) _rest = position; if (!_placed) { _placed = true; _shift = ((_hovered || _active) ? 1f : 6f); } Rect.anchoredPosition = _rest + new Vector2(_shift, 0f); } private void Update() { //IL_007c: 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_0091: Unknown result type (might be due to invalid IL or missing references) if (!_placed) { return; } float num = ((_hovered || _active) ? 1f : 6f); if (Mathf.Abs(_shift - num) < 0.05f) { if (_shift == num) { return; } _shift = num; } else { _shift = Mathf.Lerp(_shift, num, 1f - Mathf.Exp(-18f * Time.unscaledDeltaTime)); } Rect.anchoredPosition = _rest + new Vector2(_shift, 0f); if (_hovered && _tipTitle != null) { CategoryTip.Show(_gui, Rect, _tipTitle, _tipText); } } internal void SetTooltip(string name, int count) { _tipTitle = name; _tipText = Categories.RecipesWord() + ": " + count; if (_hovered) { CategoryTip.Show(_gui, Rect, _tipTitle, _tipText); } } public void OnPointerEnter(PointerEventData eventData) { _hovered = true; if (_tipTitle != null) { CategoryTip.Show(_gui, Rect, _tipTitle, _tipText); } } public void OnPointerExit(PointerEventData eventData) { _hovered = false; CategoryTip.Hide((Object)(object)Rect); } private void OnDisable() { _hovered = false; CategoryTip.Hide((Object)(object)Rect); } private static void Stretch(RectTransform rt, float inset) { //IL_0003: 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_0031: 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_0047: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = new Vector2(inset, inset); rt.anchorMax = new Vector2(1f - inset, 1f - inset); rt.pivot = new Vector2(0.5f, 0.5f); rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } } internal static class CategoryTip { private const float PadX = 10f; private const float PadY = 6f; private const float Gap = 8f; private static readonly Color DefaultGold = new Color(1f, 0.713f, 0.361f, 1f); private static GameObject _root; private const float MaxTextWidth = 380f; private static TMP_Text _title; private static TMP_Text _text; private static string _shownTitle; private static string _shownText; private static Object _owner; internal static void Show(InventoryGui gui, RectTransform button, string title, string text, bool above = false, bool leftAligned = false, bool centred = false, Transform host = null) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null && !Build(gui)) { return; } Transform val = (((Object)(object)host != (Object)null) ? host : (((Object)(object)gui != (Object)null && (Object)(object)gui.m_crafting != (Object)null) ? ((Transform)gui.m_crafting).parent : null)); if ((Object)(object)val != (Object)null && (Object)(object)_root.transform.parent != (Object)(object)val) { _root.transform.SetParent(val, false); Transform[] componentsInChildren = _root.GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { ((Component)val2).gameObject.layer = ((Component)val).gameObject.layer; } } _owner = (Object)(object)button; if (!_root.activeSelf) { _root.SetActive(true); } _root.transform.SetAsLastSibling(); if (title != _shownTitle || text != _shownText) { _shownTitle = title; _shownText = text; _title.text = title; _text.text = text; _text.textWrappingMode = (TextWrappingModes)0; Vector2 preferredValues = _text.GetPreferredValues(text); if (preferredValues.x > 380f) { _text.textWrappingMode = (TextWrappingModes)1; preferredValues = _text.GetPreferredValues(text, 380f, 0f); preferredValues.x = 380f; } RectTransform val3 = (RectTransform)_text.transform; val3.sizeDelta = new Vector2(-20f, preferredValues.y + 4f); float num = Mathf.Max(_title.preferredWidth, preferredValues.x) + 20f; float num2 = _title.preferredHeight + preferredValues.y + 12f; ((RectTransform)_root.transform).sizeDelta = new Vector2(Mathf.Ceil(num), Mathf.Ceil(num2)); } RectTransform val4 = (RectTransform)_root.transform; Rect rect = button.rect; if (above) { val4.pivot = new Vector2(centred ? 0.5f : (leftAligned ? 0f : 1f), 0f); _root.transform.position = ((Transform)button).TransformPoint(new Vector3(centred ? ((Rect)(ref rect)).center.x : (leftAligned ? ((Rect)(ref rect)).xMin : ((Rect)(ref rect)).xMax), ((Rect)(ref rect)).yMax + 8f, 0f)); } else { val4.pivot = new Vector2(1f, 0.5f); _root.transform.position = ((Transform)button).TransformPoint(new Vector3(((Rect)(ref rect)).xMin - 8f, ((Rect)(ref rect)).center.y, 0f)); } } internal static void Hide(Object button = null) { if ((Object)(object)_root != (Object)null && _root.activeSelf && (button == (Object)null || button == _owner)) { _root.SetActive(false); } } internal static void DestroyAll() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _shownTitle = null; _shownText = null; _owner = null; } private static bool Build(InventoryGui gui) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_crafting == (Object)null || (Object)(object)((Transform)gui.m_crafting).parent == (Object)null) { return false; } Transform val = ((Transform)gui.m_crafting).parent.Find("CDEV_PerfectUI_Tip"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } _root = new GameObject("CDEV_PerfectUI_Tip", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)_root.transform; ((Transform)val2).SetParent(((Transform)gui.m_crafting).parent, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(1f, 0.5f); GameObject val4 = ((gui.m_recipeRequirementList != null && gui.m_recipeRequirementList.Length != 0) ? gui.m_recipeRequirementList[0] : null); Image val5 = (((Object)(object)val4 != (Object)null) ? val4.GetComponent<Image>() : null); Image val6 = _root.AddComponent<Image>(); val6.sprite = (((Object)(object)val5 != (Object)null) ? val5.sprite : null); val6.type = (Type)1; ((Graphic)val6).color = new Color(0.85f, 0.62f, 0.3f, 0.55f); ((Graphic)val6).raycastTarget = false; GameObject val7 = new GameObject("Fill", new Type[1] { typeof(RectTransform) }); RectTransform val8 = (RectTransform)val7.transform; ((Transform)val8).SetParent((Transform)(object)val2, false); val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.offsetMin = new Vector2(1f, 1f); val8.offsetMax = new Vector2(-1f, -1f); Image val9 = val7.AddComponent<Image>(); val9.sprite = val6.sprite; val9.type = (Type)1; ((Graphic)val9).color = new Color(0.07f, 0.055f, 0.04f, 0.94f); ((Graphic)val9).raycastTarget = false; object obj; if (!((Object)(object)val4 != (Object)null)) { obj = null; } else { Transform obj2 = val4.transform.Find("res_name"); obj = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); } TMP_Text val10 = (TMP_Text)obj; _title = Text("Title", val2, gui.m_containerName, 17f, 6f); ((Graphic)_title).color = (((Object)(object)gui.m_minStationLevelIcon != (Object)null && ((Graphic)gui.m_minStationLevelIcon).color.a > 0f) ? ((Graphic)gui.m_minStationLevelIcon).color : DefaultGold); _text = Text("Text", val2, ((Object)(object)val10 != (Object)null) ? val10 : gui.m_containerName, 15f, 26f); ((Graphic)_text).color = new Color(0.9f, 0.88f, 0.84f); _root.SetActive(false); return true; } private static TMP_Text Text(string name, RectTransform parent, TMP_Text style, float size, float top) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0039: 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_0063: 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_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)parent, false); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.sizeDelta = new Vector2(0f, size + 4f); val2.anchoredPosition = new Vector2(0f, 0f - top); TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)style != (Object)null) { ((TMP_Text)val3).font = style.font; ((TMP_Text)val3).fontSharedMaterial = style.fontSharedMaterial; } ((TMP_Text)val3).fontSize = size; ((TMP_Text)val3).alignment = (TextAlignmentOptions)514; ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; ((Graphic)val3).raycastTarget = false; return (TMP_Text)(object)val3; } } internal static class CenterMessage { [HarmonyPatch(typeof(MessageHud), "ShowMessage")] private static class CenterIcon { private static void Postfix(MessageHud __instance, MessageType type, Sprite icon) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0078: 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_0096: 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_00e6: 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_00ec: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if ((int)type != 2 || !ModConfig.CenterMessages.Value) { return; } try { TMP_Text c = __instance.m_messageCenterText; if ((Object)(object)c == (Object)null) { return; } Transform val = c.transform.Find("CDEV_PerfectUI_CenterIcon"); if ((Object)(object)val == (Object)null) { RectTransform val2 = Ui.Rect("CDEV_PerfectUI_CenterIcon", c.transform).Place(new Vector2(0.5f, 1f), new Vector2(0f, 122f), new Vector2(88f, 88f)); CanvasGroup val3 = ((Component)val2).gameObject.AddComponent<CanvasGroup>(); val3.blocksRaycasts = false; val3.interactable = false; RectTransform val4 = Gems.Gem(val2, "Gem", Vector2.zero, 88f, 0.95f); Vector2 anchorMin = (val4.anchorMax = new Vector2(0.5f, 0.5f)); val4.anchorMin = anchorMin; val4.anchoredPosition = Vector2.zero; Image val6 = Ui.Rect("Icon", (Transform)(object)val4).Place(new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(52f, 52f)).Image(null, Color.white); val6.preserveAspect = true; ((Component)val2).gameObject.AddComponent<LevelSlam>().Build(val2, val4, val6); FollowAlpha followAlpha = ((Component)val2).gameObject.AddComponent<FollowAlpha>(); followAlpha.Source = c; followAlpha.Group = val3; followAlpha.Lift = 118f; val = (Transform)(object)val2; } ((Component)val.Find("Gem/Icon")).GetComponent<Image>().sprite = icon; ((Component)val).gameObject.SetActive((Object)(object)icon != (Object)null && ModConfig.CenterIcon.Value); ((Component)val).GetComponent<LevelSlam>().Show(_level); if (!string.IsNullOrEmpty(_level) && ((Component)val).gameObject.activeSelf) { __instance._crossFadeTextBuffer?.RemoveAll((CrossFadeText f) => (Object)(object)f.text == (Object)(object)c); ((Graphic)c).CrossFadeAlpha(1f, 0f, true); } } catch (Exception ex) { PerfectUIPlugin.Log.LogError((object)("Centre message icon failed: " + ex)); } finally { _level = null; } } } private sealed class LevelSlam : MonoBehaviour { private const float Fall = 0.28f; private const float Jolt = 0.35f; private const float Burst = 0.45f; private const float From = 5f; private const float FadeOut = 1.2f; private RectTransform _gem; private RectTransform _flash; private Image _icon; private Image _flashImage; private TMP_Text _number; private float _start = -100f; private bool _on; private bool _fading; private static float Wait => ModConfig.SkillUpIconSeconds.Value; private static float Hold => Mathf.Max(ModConfig.SkillUpSeconds.Value, Wait + 0.28f + 0.35f); internal void Build(RectTransform holder, RectTransform gem, Image icon) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_008d: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) _gem = gem; _icon = icon; _flash = Ui.Rect("Burst", (Transform)(object)holder).Place(new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(88f, 88f)); _flashImage = _flash.Image(Sprites.DiamondEdge, new Color(1f, 0.85f, 0.55f, 0f)); _number = (TMP_Text)(object)Ui.Label("Level", (Transform)(object)holder, "", Fonts.Heading, 40f, Palette.Accent, (TextAlignmentOptions)514); _number.rectTransform.Place(new Vector2(0.5f, 0.5f), new Vector2(0f, 1f), new Vector2(88f, 88f)); _number.overflowMode = (TextOverflowModes)0; Material val = Fonts.Shadow(Fonts.Heading); if ((Object)(object)val != (Object)null) { _number.fontSharedMaterial = val; } Show(null); } internal void Show(string level) { _on = !string.IsNullOrEmpty(level); _fading = false; _number.text = level ?? ""; _start = Time.unscaledTime; Pose(_on ? 0f : (-1f)); } private void LateUpdate() { if (!_on) { return; } float num = Time.unscaledTime - _start; Pose(num); if (!_fading && num >= Hold) { _fading = true; TMP_Text val = (((Object)(object)MessageHud.instance != (Object)null) ? MessageHud.instance.m_messageCenterText : null); if ((Object)(object)val != (Object)null) { ((Graphic)val).CrossFadeAlpha(0f, 1.2f, true); } } } private void Pose(float t) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00aa: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) float num = ((t < 0f) ? (-1f) : ((t - Wait) / 0.28f)); bool flag = num >= 1f; if (num < 0f) { SetAlpha(_number, 0f); } else { float num2 = Mathf.Clamp01(num); float num3 = Mathf.Lerp(5f, 1f, num2 * num2); ((Transform)_number.rectTransform).localScale = new Vector3(num3, num3, 1f); SetAlpha(_number, Mathf.Clamp01(num2 * 3f)); } if (num < 0f) { ((Transform)_number.rectTransform).localScale = Vector3.one; } Color color = ((Graphic)_icon).color; ((Graphic)_icon).color = new Color(color.r, color.g, color.b, flag ? 0f : 1f); float num4 = (flag ? (t - Wait - 0.28f) : (-1f)); float num5 = 1f; if (num4 >= 0f && num4 < 0.35f) { float num6 = num4 / 0.35f; num5 = 1f - 0.16f * Mathf.Sin(num6 * (float)Math.PI * 2f) * (1f - num6); } ((Transform)_gem).localScale = new Vector3(num5, num5, 1f); if (flag) { ((Transform)_number.rectTransform).localScale = new Vector3(num5, num5, 1f); } if (num4 >= 0f && num4 < 0.45f) { float num7 = num4 / 0.45f; float num8 = Mathf.Lerp(1f, 1.9f, 1f - (1f - num7) * (1f - num7)); ((Transform)_flash).localScale = new Vector3(num8, num8, 1f); ((Graphic)_flashImage).color = new Color(1f, 0.85f, 0.55f, 0.9f * (1f - num7)); } else { ((Graphic)_flashImage).color = new Color(1f, 0.85f, 0.55f, 0f); } } private static void SetAlpha(TMP_Text t, float a) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Color color = ((Graphic)t).color; ((Graphic)t).color = new Color(color.r, color.g, color.b, a); } } [HarmonyPatch(typeof(Player), "Message")] private static class SkillUp { private const string Head = "$msg_skillup "; private static bool Prefix(Player __instance, ref MessageType type, ref string msg, int amount, Sprite icon, bool log) { if (!ModConfig.SkillUpInCenter.Value || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || msg == null || !msg.StartsWith("$msg_skillup ", StringComparison.Ordinal)) { return true; } int num = msg.LastIndexOf(": ", StringComparison.Ordinal); if (num <= "$msg_skillup ".Length) { return true; } if (Calm.Hold(__instance, msg.Substring("$msg_skillup ".Length, num - "$msg_skillup ".Length), type, msg, amount, icon, log)) { return false; } type = (MessageType)2; string text = Localization.instance.Localize(msg.Substring("$msg_skillup ".Length, num - "$msg_skillup ".Length)); string text2 = msg.Substring(num + 2); string text3 = Localization.instance.Localize("$msg_skillup ".Trim()).Trim().TrimEnd(':', ' '); msg = "<size=50%><color=#A99A84>" + text3 + "</color></size>\n" + text; if (ModConfig.CenterIcon.Value && ModConfig.SkillUpLevelSlam.Value && (Object)(object)icon != (Object)null && ModConfig.CenterMessages.Value) { _level = text2; } else { msg = msg + " <color=#E9A53C>" + text2 + "</color>"; } Calm.Shown(); return true; } } private static class Calm { private sealed class Held { internal string Skill; internal string Msg; internal MessageType Type; internal int Amount; internal Sprite Icon; internal bool Log; } private const float QuietFor = 1.5f; private const float Check = 0.25f; private static readonly List<Held> Waiting = new List<Held>(); private static Player _owner; private static bool _releasing; private static bool _fight; private static float _shownAt = -100f; private static float _quietSince = -1f; private static float _checkAt; private static float Showing => Mathf.Max(ModConfig.SkillUpSeconds.Value, ModConfig.SkillUpIconSeconds.Value + 0.63f) + 1.2f; internal static bool Hold(Player p, string skill, MessageType type, string msg, int amount, Sprite icon, bool log) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (_releasing || !ModConfig.SkillUpWaitForCalm.Value) { return false; } if (Waiting.Count == 0 && Time.unscaledTime - _shownAt >= Showing && !InFight(p)) { return false; } if ((Object)(object)_owner != (Object)(object)p) { Waiting.Clear(); } _owner = p; Held held = Waiting.Find((Held h) => h.Skill == skill); if (held == null) { List<Held> waiting = Waiting; Held obj = new Held { Skill = skill }; held = obj; waiting.Add(obj); } held.Type = type; held.Msg = msg; held.Amount = amount; held.Icon = icon; held.Log = log; return true; } internal static void Shown() { _shownAt = Time.unscaledTime; } internal static void Tick() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (Waiting.Count == 0) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer != (Object)(object)_owner || !ModConfig.SkillUpInCenter.Value) { Waiting.Clear(); return; } float unscaledTime = Time.unscaledTime; if (((Character)localPlayer).IsDead() || (ModConfig.SkillUpWaitForCalm.Value && InFight(localPlayer))) { _quietSince = -1f; return; } if (_quietSince < 0f) { _quietSince = unscaledTime; } if (unscaledTime - _quietSince < 1.5f || unscaledTime - _shownAt < Showing) { return; } Held held = Waiting[0]; Waiting.RemoveAt(0); _releasing = true; try { ((Character)localPlayer).Message(held.Type, held.Msg, held.Amount, held.Icon, held.Log); } catch (Exception ex) { PerfectUIPlugin.Log.LogError((object)("Held skill-up failed: " + ex)); } finally { _releasing = false; } } internal static void Clear() { Waiting.Clear(); } private static bool InFight(Player p) { //IL_0037: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (unscaledTime < _checkAt) { return _fight; } _checkAt = unscaledTime + 0.25f; _fight = false; float value = ModConfig.SkillUpCalmRange.Value; Vector3 position = ((Component)p).transform.position; foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)null || (Object)(object)allCharacter == (Object)(object)p || allCharacter.IsPlayer() || allCharacter.IsDead() || allCharacter.IsTamed()) { continue; } Vector3 val = ((Component)allCharacter).transform.position - position; if (!(((Vector3)(ref val)).sqrMagnitude > value * value)) { BaseAI baseAI = allCharacter.GetBaseAI(); if ((Object)(object)baseAI != (Object)null && baseAI.IsAlerted() && baseAI.IsEnemy((Character)(object)p)) { _fight = true; break; } } } return _fight; } } internal sealed class FollowAlpha : MonoBehaviour { internal TMP_Text Source; internal Graphic Target; internal CanvasGroup Group; internal float Lift; private float _base = float.NaN; private void LateUpdate() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_0150: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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) if ((Object)(object)Source == (Object)null || ((Object)(object)Target == (Object)null && (Object)(object)Group == (Object)null)) { return; } float num = ((string.IsNullOrEmpty(Source.text) || !((Behaviour)Source).isActiveAndEnabled) ? 0f : (((Graphic)Source).color.a * ((Graphic)Source).canvasRenderer.GetAlpha())); if (Lift > 0f && num > 0f) { RectTransform val = (RectTransform)((Component)this).transform; if (float.IsNaN(_base)) { _base = val.anchoredPosition.y; } Bounds textBounds = Source.textBounds; float y = ((Bounds)(ref textBounds)).max.y; Rect rect = Source.rectTransform.rect; float num2 = y - ((Rect)(ref rect)).yMax; val.anchoredPosition = new Vector2(val.anchoredPosition.x, Mathf.Max(_base, num2 + Lift)); } if ((Object)(object)Group != (Object)null) { Group.alpha = num; return; } Color color = Target.color; if (!Mathf.Approximately(color.a, num)) { Target.color = new Color(color.r, color.g, color.b, num); } } } private const string BraidName = "CDEV_Braid"; private static MessageHud _done; private const string IconName = "CDEV_PerfectUI_CenterIcon"; private static string _level; internal static void Ensure() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) MessageHud instance = MessageHud.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance == (Object)(object)_done || !ModConfig.CenterMessages.Value) { return; } _done = instance; TMP_Text messageCenterText = instance.m_messageCenterText; if ((Object)(object)messageCenterText == (Object)null || (Object)(object)messageCenterText.transform.Find("CDEV_Braid") != (Object)null) { return; } try { Revert.Keep((Component)(object)messageCenterText); Text(messageCenterText, Fonts.Heading, 38f, Palette.Ink); messageCenterText.characterSpacing = 8f; messageCenterText.textWrappingMode = (TextWrappingModes)0; messageCenterText.overflowMode = (TextOverflowModes)0; RectTransform val = Ui.Rect("CDEV_Braid", messageCenterText.transform).Place(new Vector2(0.5f, 1f), new Vector2(0f, 26f), new Vector2(420f, 16f)); Color accent = Palette.Accent; Sprite pixel = Sprites.Pixel; Color? fallbackColor = Palette.Accent; Image target = val.Tex("BraidLineHorisontalMedium", accent, raycast: false, null, pixel, fallbackColor); FollowAlpha followAlpha = ((Component)val).gameObject.AddComponent<FollowAlpha>(); followAlpha.Source = messageCenterText; followAlpha.Target = (Graphic)(object)target; followAlpha.Lift = 22f; } catch (Exception ex) { PerfectUIPlugin.Log.LogError((object)("Centre message restyle failed: " + ex)); } } internal static void Remove() { MessageHud instance = MessageHud.instance; object obj; if (instance == null) { obj = null; } else { TMP_Text messageCenterText = instance.m_messageCenterText; obj = ((messageCenterText != null) ? messageCenterText.transform : null); } Transform val = (Transform)obj; Transform val2 = ((val != null) ? val.Find("CDEV_Braid") : null); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent<FollowAlpha>() != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } Transform val3 = ((val != null) ? val.Find("CDEV_PerfectUI_CenterIcon") : null); if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)((Component)val3).gameObject); } _done = null; Calm.Clear(); } private static void Text(TMP_Text t, TMP_FontAsset font, float size, Color color) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)font == (Object)null)) { t.font = font; Material val = Fonts.Shadow(font); t.fontSharedMaterial = (((Object)(object)val != (Object)null) ? val : ((TMP_Asset)font).material); t.fontStyle = (FontStyles)16; t.fontSize = size; ((Graphic)t).color = new Color(color.r, color.g, color.b, ((Graphic)t).color.a); Outline[] components = ((Component)t).GetComponents<Outline>(); foreach (Outline val2 in components) { ((Behaviour)val2).enabled = false; } } } internal static void Tick() { Calm.Tick(); } } [HarmonyPatch(typeof(TMP_InputField), "OnEnable")] internal static class ClearEverywhere { private const float MinWidth = 130f; private static void Postfix(TMP_InputField __instance) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //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_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) if (!ModConfig.ClearButtons.Value) { return; } try { if (!((Object)(object)__instance == (Object)null) && !__instance.readOnly && (!((Object)(object)Console.instance != (Object)null) || !((Object)(object)__instance == (Object)(object)((Terminal)Console.instance).m_input)) && (!((Object)(object)Chat.instance != (Object)null) || !((Object)(object)__instance == (Object)(object)((Terminal)Chat.instance).m_input))) { RectTransform val = (RectTransform)((Component)__instance).transform; Rect rect = val.rect; if (!(((Rect)(ref rect)).width < 130f)) { rect = val.rect; ClearButton.Attach(__instance, null, 0f, Mathf.Clamp(((Rect)(ref rect)).height, 18f, 30f)); } } } catch (Exception ex) { PerfectUIPlugin.Log.LogWarning((object)("Clear button on a field failed: " + ex.Message)); } } internal static void Remove() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ClearButton[] array = Resources.FindObjectsOfTypeAll<ClearButton>(); foreach (ClearButton clearButton in array) { if ((Object)(object)clearButton != (Object)null) { Scene scene = ((Component)clearButton).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { clearButton.Detach(); } } } } internal static void Scan() { if (ModConfig.ClearButtons.Value) { TMP_InputField[] array = Object.FindObjectsByType<TMP_InputField>((FindObjectsSortMode)0); foreach (TMP_InputField _instance in array) { Postfix(_instance); } } } } internal sealed class Compass : MonoBehaviour { private const string RootName = "CDEV_PerfectUI_Compass"; private const string UIOverhaulName = "CDEV_UIOverhaul_Compass"; private const float Margin = 47f; private const float Top = 0f; private const float Height = 32f; private const float Grow = 0.4f; private const float GrowWidth = 22f; private static Compass _instance; private RectTransform _strip; private CanvasGroup _group; private readonly List<(RectTransform rt, float angle, CanvasGroup g, RectTransform label)> _marks = new List<(RectTransform, float, CanvasGroup, RectTransform)>(); private float _shown = float.NaN; private static Sprite _tapered; private const float PinSize = 22f; private const float Clear = 30f; private const float DistanceShow = 150f; private const float DistanceFull = 80f; private RectTransform _pinLayer; private readonly List<Image> _pinPool = new List<Image>(); private readonly List<float> _pinX = new List<float>(); private TextMeshProUGUI _distance; private int _distanceShown = -1; private static float Span => ModConfig.CompassDegrees.Value; internal static bool OnScreen { get { if ((Object)(object)_instance != (Object)null) { return true; } Hud instance = Hud.instance; Transform val = (((Object)(object)instance != (Object)null && (Object)(object)instance.m_rootObject != (Object)null) ? instance.m_rootObject.transform.Find("CDEV_UIOverhaul_Compass") : null); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject.activeSelf; } return false; } } private static Sprite TaperedLine { get { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0147: 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_00fe: 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) if (Object.op_Implicit((Object)(object)_tapered)) { return _tapered; } Texture2D val = new Texture2D(512, 10, (TextureFormat)4, false) { name = "CDEV.PerfectUI.compass", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[5120]; for (int i = 0; i < 512; i++) { float num = Mathf.Abs((float)i + 0.5f - 256f) / 256f; float num2 = Mathf.Exp((0f - num) * num * 18f); float num3 = Mathf.Lerp(1.2f, 6.5f, num2); float num4 = Mathf.Lerp(0.45f, 1f, num2); for (int j = 0; j < 10; j++) { float num5 = Mathf.Abs((float)j + 0.5f - 5f); float num6 = Mathf.Clamp01(num3 / 2f - num5 + 0.5f); array[j * 512 + i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num6 * num4 * 255f)); } } val.SetPixels32(array); val.Apply(false, true); _tapered = Sprite.Create(val, new Rect(0f, 0f, 512f, 10f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)_tapered).name = ((Object)val).name; ((Object)_tapered).hideFlags = (HideFlags)61; return _tapered; } } internal static void Ensure() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance != (Object)null || !ModConfig.Compass.Value) { return; } Hud instance = Hud.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_rootObject == (Object)null) { return; } Transform transform = instance.m_rootObject.transform; if (!((Object)(object)transform.Find("CDEV_UIOverhaul_Compass") != (Object)null)) { Transform val = transform.Find("CDEV_PerfectUI_Compass"); if ((O