Please disclose if your mod was created primarily 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 SearsCatalog v1.8.0
SearsCatalog.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SearsCatalog")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SearsCatalog")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cc8e41cd-c04e-45b6-b9e5-de60df83a8eb")] [assembly: AssemblyFileVersion("1.8.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.8.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SearsCatalog { public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<int> BuildHudPanelRows { get; private set; } public static ConfigEntry<int> BuildHudPanelColumns { get; private set; } public static ConfigEntry<Vector2> BuildHudPanelPosition { get; private set; } public static ConfigEntry<float> BuildHudPanelScrollSensitivity { get; private set; } public static ConfigEntry<Vector2> CategoriesRectPosition { get; private set; } public static ConfigEntry<Vector2> CategoriesRectSizeDelta { get; private set; } public static ConfigEntry<bool> TabBorderIsEnabled { get; private set; } public static ConfigEntry<Vector2> TabBorderRectPosition { get; private set; } public static ConfigEntry<Vector2> TabBorderRectSizeDelta { get; private set; } public static ConfigEntry<bool> InputHelpIsEnabled { get; private set; } public static ConfigEntry<Vector2> InputHelpRectPosition { get; private set; } public static ConfigEntry<Vector2> InputHelpRectSizeDelta { get; private set; } public static void BindConfig(ConfigFile config) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); BuildHudPanelRows = config.BindInOrder("BuildHud.Panel", "buildHudPanelRows", 6, "BuildHud.Panel visible rows (vanilla: 6).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 14)); BuildHudPanelRows.OnSettingChanged<int>(BuildHudController.SetupBuildHudPanel); BuildHudPanelColumns = config.BindInOrder("BuildHud.Panel", "buildHudPanelColumns", 15, "BuildHud.Panel visible columns (vanilla: 15).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 26)); BuildHudPanelColumns.OnSettingChanged<int>(BuildHudController.SetupBuildHudPanel); BuildHudPanelPosition = config.BindInOrder<Vector2>("BuildHud.Panel", "buildHudPanelPosition", Vector2.zero, "BuildHud.Panel position relative to center of the screen."); BuildHudPanelPosition.OnSettingChanged((Action<Vector2>)BuildHudController.SetBuildPanelPosition); BuildHudPanelScrollSensitivity = config.BindInOrder("BuildHud.Panel", "buildHudPanelScrollSensitivity", 1400f, "BuildHud.Panel scroll-sensitivity when using the mouse-wheel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3000f)); BuildHudPanelScrollSensitivity.OnSettingChanged<float>(BuildHudController.SetBuildPanelScrollSensitivity); CategoriesRectPosition = config.BindInOrder<Vector2>("BuildHud.Panel.Categories", "categoriesRectPosition", new Vector2(0f, -39f), "Hud.m_pieceCategoryRoot<RectTransform>.anchoredPosition value (vanilla is X: 0, Y: -39)."); CategoriesRectPosition.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); CategoriesRectSizeDelta = config.BindInOrder<Vector2>("BuildHud.Panel.Categories", "categoriesRectSizeDelta", new Vector2(-20f, 32.8127f), "Hud.m_pieceCategoryRoot<RectTransform>.sizeDelta value (vanilla is X: -180, Y: 32.8127)."); CategoriesRectSizeDelta.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); TabBorderIsEnabled = config.BindInOrder("BuildHud.Panel.TabBorder", "tabBorderIsEnabled", defaultValue: true, "Hud.m_pieceCategoryRoot.TabBorder<GameObject>.activeSelf value (vanilla is: true)."); TabBorderIsEnabled.OnSettingChanged<bool>(BuildHudController.HandleCategoriesConfigChange); TabBorderRectPosition = config.BindInOrder<Vector2>("BuildHud.Panel.TabBorder", "tabBorderRectPosition", new Vector2(0f, -31.056f), "Hud.m_pieceCategoryRoot.TabBorder<RectTransform>.anchoredPosition value (vanilla is X: 0, Y: -31.056)."); TabBorderRectPosition.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); TabBorderRectSizeDelta = config.BindInOrder<Vector2>("BuildHud.Panel.TabBorder", "tabBorderSizeDelta", new Vector2(-30f, 4f), "Hud.m_pieceCategoryRoot.TabBorder<RectTransform>.sizeDelta value (vanilla is X: 130, Y: 4)."); TabBorderRectSizeDelta.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); InputHelpIsEnabled = config.BindInOrder("BuildHud.Panel.InputHelp", "inputHelpIsEnabled", defaultValue: false, "Hud.m_pieceSelectionWindow.InputHelp<GameObject>.activeSelf value (vanilla is: true)."); InputHelpIsEnabled.OnSettingChanged<bool>(BuildHudController.HandleCategoriesConfigChange); InputHelpRectPosition = config.BindInOrder<Vector2>("BuildHud.Panel.InputHelp", "inputHelpRectPosition", new Vector2(-89.84f, -278.5f), "Hud.m_pieceSelectionWindow.InputHelp<RectTransform>.anchoredPosition value (vanilla is X: -89.84, Y: -278.5)."); InputHelpRectPosition.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); InputHelpRectSizeDelta = config.BindInOrder<Vector2>("BuildHud.Panel.InputHelp", "inputHelpRectSizeDelta", new Vector2(-984f, 100f), "Hud.m_pieceSelectionWindow.InputHelp<RectTransform>.sizeDelta value (vanilla is X: -984, Y: 100)."); InputHelpRectSizeDelta.OnSettingChanged<Vector2>(BuildHudController.HandleCategoriesConfigChange); } } public static class BuildHudController { public static int BuildHudColumns { get; set; } = 15; public static int BuildHudRows { get; set; } = 0; public static bool BuildHudNeedRefresh { get; set; } = false; public static bool BuildHudNeedIconLayoutRefresh { get; set; } = false; public static bool BuildHudNeedIconRecenter { get; set; } = false; public static RectTransform BuildHudPanelTransform { get; set; } public static Scrollbar BuildHudScrollbar { get; set; } public static ScrollRect BuildHudScrollRect { get; set; } public static GameObject BuildHudPanelResizer { get; set; } public static void CenterOnSelectedIndex() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer.Ref<Player>()?.m_buildPieces) || !Object.op_Implicit((Object)(object)Hud.m_instance)) { return; } Vector2Int selectedIndex = Player.m_localPlayer.m_buildPieces.GetSelectedIndex(); int num = BuildHudColumns * ((Vector2Int)(ref selectedIndex)).y + ((Vector2Int)(ref selectedIndex)).x; if (num >= 0 && num < Hud.m_instance.m_pieceIcons.Count) { PieceIconData val = Hud.m_instance.m_pieceIcons[num]; if (Object.op_Implicit((Object)(object)val.m_go)) { ScrollRectUtils.EnsureVisibility(BuildHudScrollRect, val.m_go.GetComponent<RectTransform>()); } } } public static void ResizeBuildHudPanel(Vector2 sizeDelta) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) float pieceIconSpacing = Hud.m_instance.m_pieceIconSpacing; PluginConfig.BuildHudPanelColumns.Value = Mathf.Max(Mathf.FloorToInt((sizeDelta.x - 35f) / pieceIconSpacing), 1); PluginConfig.BuildHudPanelRows.Value = Mathf.Max(Mathf.FloorToInt((sizeDelta.y - 70f) / pieceIconSpacing), 1); BuildHudNeedRefresh = true; } public static void SetupBuildHudPanel() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Hud.m_instance) && Object.op_Implicit((Object)(object)BuildHudPanelTransform)) { BuildHudColumns = PluginConfig.BuildHudPanelColumns.Value; BuildHudRows = 0; float pieceIconSpacing = Hud.m_instance.m_pieceIconSpacing; BuildHudPanelTransform.SetSizeDelta(new Vector2((float)BuildHudColumns * pieceIconSpacing + 35f, (float)PluginConfig.BuildHudPanelRows.Value * pieceIconSpacing + 70f)); BuildHudNeedRefresh = true; TriggerJotunnCategoryRebuild(Player.m_localPlayer); } } public static void SetupPieceSelectionWindow(Hud hud) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0059: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Transform)hud.m_pieceListRoot).parent; Resources val = default(Resources); val.standard = UIResources.GetSprite("UISprite"); Scrollbar component = DefaultControls.CreateScrollbar(val).GetComponent<Scrollbar>(); ((Component)component).transform.SetParent(parent, false); ((Component)component).GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.one) .SetPivot(Vector2.one) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(10f, 0f)); component.direction = (Direction)2; ((Component)component).GetComponent<Image>().SetColor(new Color(0f, 0f, 0f, 0.6f)); ((Component)component.handleRect).GetComponent<Image>().SetColor(new Color(1f, 1f, 1f, 0.9f)); ((Component)parent).GetComponent<RectTransform>().OffsetSizeDelta(new Vector2(10f, 0f)); ScrollRect obj = ((Component)parent).gameObject.AddComponent<ScrollRect>(); obj.SetContent<ScrollRect>(hud.m_pieceListRoot).SetViewport<ScrollRect>(((Component)parent).GetComponent<RectTransform>()).SetVerticalScrollbar<ScrollRect>(component) .SetVerticalScrollbarVisibility<ScrollRect>((ScrollbarVisibility)0) .SetMovementType<ScrollRect>((MovementType)2) .SetInertia<ScrollRect>(inertia: false) .SetScrollSensitivity<ScrollRect>(PluginConfig.BuildHudPanelScrollSensitivity.Value); Image val2 = default(Image); if (!((Component)hud.m_pieceListRoot).TryGetComponent<Image>(ref val2)) { val2 = ((Component)hud.m_pieceListRoot).gameObject.AddComponent<Image>(); ((Graphic)val2).color = Color.clear; } SetupCategories(hud); SetupTabBorder(hud); SetupInputHelp(hud); GameObject gameObject = ((Component)hud.m_pieceSelectionWindow.transform.parent).gameObject; RectTransform component2 = gameObject.GetComponent<RectTransform>(); component2.SetPosition(PluginConfig.BuildHudPanelPosition.Value); PanelDragger panelDragger = gameObject.AddComponent<PanelDragger>(); panelDragger.TargetRectTransform = component2; panelDragger.OnPanelEndDrag += HandlePanelEndDrag; PanelResizer panelResizer = UIBuilder.CreateResizer((Transform)(object)component2).AddComponent<PanelResizer>(); panelResizer.TargetRectTransform = component2; panelResizer.OnPanelEndResize += HandlePanelEndResize; BuildHudPanelTransform = component2; BuildHudScrollbar = component; BuildHudScrollRect = obj; BuildHudNeedRefresh = true; } private static void SetupCategories(Hud hud) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) hud.m_pieceCategoryRoot.GetComponent<RectTransform>().SetPosition(PluginConfig.CategoriesRectPosition.Value).SetSizeDelta(PluginConfig.CategoriesRectSizeDelta.Value); } private static void SetupTabBorder(Hud hud) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Transform obj = hud.m_pieceCategoryRoot.transform.Find("TabBorder"); ((Component)obj).gameObject.SetActive(PluginConfig.TabBorderIsEnabled.Value); ((Component)obj).GetComponent<RectTransform>().SetPosition(PluginConfig.TabBorderRectPosition.Value).SetSizeDelta(PluginConfig.TabBorderRectSizeDelta.Value); } private static void SetupInputHelp(Hud hud) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Transform obj = hud.m_pieceSelectionWindow.transform.Find("InputHelp"); ((Component)obj).gameObject.SetActive(PluginConfig.InputHelpIsEnabled.Value); ((Component)obj).GetComponent<RectTransform>().SetPosition(PluginConfig.InputHelpRectPosition.Value).SetSizeDelta(PluginConfig.InputHelpRectSizeDelta.Value); } private static void TriggerJotunnCategoryRebuild(Player player) { if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)player.m_buildPieces)) { ((Humanoid)player).SetPlaceMode(player.m_buildPieces); } } private static void HandlePanelEndDrag(object sender, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) PluginConfig.BuildHudPanelPosition.Value = Vector2.op_Implicit(position); } private static void HandlePanelEndResize(object sender, Vector2 sizeDelta) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ResizeBuildHudPanel(sizeDelta); TriggerJotunnCategoryRebuild(Player.m_localPlayer); } public static void SetBuildPanelPosition(Vector2 position) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)BuildHudPanelTransform)) { BuildHudPanelTransform.anchoredPosition = position; } } public static void SetBuildPanelScrollSensitivity(float scrollSensitivity) { if (Object.op_Implicit((Object)(object)BuildHudScrollRect)) { BuildHudScrollRect.scrollSensitivity = scrollSensitivity; } } public static void HandleCategoriesConfigChange() { Hud instance = Hud.m_instance; if (Object.op_Implicit((Object)(object)instance)) { SetupCategories(instance); SetupTabBorder(instance); SetupInputHelp(instance); TriggerJotunnCategoryRebuild(Player.m_localPlayer); } } } public static class ScrollRectUtils { public static void EnsureVisibility(ScrollRect scrollRect, RectTransform child, float padding = 0f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) Rect rect = scrollRect.viewport.rect; float height = ((Rect)(ref rect)).height; Vector2 anchoredPosition = scrollRect.content.anchoredPosition; float y = child.anchoredPosition.y; rect = child.rect; float num = y - ((Rect)(ref rect)).height; float num2 = 0f - anchoredPosition.y - padding; float num3 = 0f - anchoredPosition.y - height + padding; float num4 = ((y > num2) ? (num2 - y) : ((num < num3) ? (num3 - num) : 0f)); anchoredPosition.y += num4; scrollRect.content.anchoredPosition = anchoredPosition; } } [HarmonyPatch(typeof(Hud))] internal static class HudPatch { [CompilerGenerated] private sealed class <SetupBuildHudPanelDelayed>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetupBuildHudPanelDelayed>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = _waitOneSecond; <>1__state = 1; return true; case 1: <>1__state = -1; BuildHudController.SetupBuildHudPanel(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly WaitForSeconds _waitOneSecond = new WaitForSeconds(1f); [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(Hud __instance) { if (PluginConfig.IsModEnabled.Value) { BuildHudController.SetupPieceSelectionWindow(__instance); ((MonoBehaviour)__instance).StartCoroutine(SetupBuildHudPanelDelayed()); } } [IteratorStateMachine(typeof(<SetupBuildHudPanelDelayed>d__2))] private static IEnumerator SetupBuildHudPanelDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetupBuildHudPanelDelayed>d__2(0); } [HarmonyPostfix] [HarmonyPatch("TogglePieceSelection")] private static void TogglePieceSelectionPostfix(Hud __instance) { if (PluginConfig.IsModEnabled.Value && __instance.m_pieceSelectionWindow.activeSelf) { BuildHudController.CenterOnSelectedIndex(); } } [HarmonyPrefix] [HarmonyPatch("UpdatePieceList")] private static void UpdatePieceListPrefix(Hud __instance, PieceCategory category, ref bool __state) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value) { __state = __instance.m_lastPieceCategory == category; } } [HarmonyPostfix] [HarmonyPatch("UpdatePieceList")] private static void UpdatePieceListPostfix(Hud __instance, bool __state) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) if (PluginConfig.IsModEnabled.Value && BuildHudController.BuildHudNeedIconLayoutRefresh) { BuildHudController.BuildHudNeedIconLayoutRefresh = false; foreach (PieceIconData pieceIcon in __instance.m_pieceIcons) { pieceIcon.m_go.GetComponent<RectTransform>().SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.up) .SetPivot(Vector2.up); } } if (PluginConfig.IsModEnabled.Value && (!__state || BuildHudController.BuildHudNeedIconRecenter)) { BuildHudController.BuildHudNeedIconRecenter = false; BuildHudController.CenterOnSelectedIndex(); } } [HarmonyTranspiler] [HarmonyPatch("UpdatePieceList")] private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler1(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Player), "GetBuildPieces", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (get-build-pieces)") .Advance(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "GetBuildPiecesDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void GetBuildPiecesDelegate(List<Piece> buildPieces) { if (PluginConfig.IsModEnabled.Value) { BuildHudController.BuildHudRows = buildPieces.Count / BuildHudController.BuildHudColumns + ((buildPieces.Count % BuildHudController.BuildHudColumns != 0) ? 1 : 0); } } [HarmonyTranspiler] [HarmonyPatch("UpdatePieceList")] private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler2(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0031: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (grid-columns)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "GridColumnsDelegate", (Type[])null, (Type[])null)) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null) }) .ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (grid-rows)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "GridRowsDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("UpdatePieceList")] private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler3(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (piece-icons-count)") .Advance(3) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "PieceIconsCountMultiplyDelegate", (Type[])null, (Type[])null)) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Hud), "m_pieceIcons"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(List<PieceIconData>), "Clear", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (piece-icons-clear)") .Advance(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "PieceIconsClearPostDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int PieceIconsCountMultiplyDelegate(int value) { if (PluginConfig.IsModEnabled.Value && BuildHudController.BuildHudNeedRefresh) { return -1; } return value; } private static void PieceIconsClearPostDelegate(Hud hud) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value) { hud.m_pieceListRoot.sizeDelta = new Vector2(hud.m_pieceIconSpacing * (float)BuildHudController.BuildHudColumns, hud.m_pieceIconSpacing * (float)BuildHudController.BuildHudRows); BuildHudController.BuildHudNeedRefresh = false; BuildHudController.BuildHudNeedIconLayoutRefresh = true; BuildHudController.BuildHudNeedIconRecenter = true; } } [HarmonyTranspiler] [HarmonyPatch("GetSelectedGrid")] private static IEnumerable<CodeInstruction> GetSelectedGridTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0031: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Hud.GetSelectedGrid()! (grid-columns)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "GridColumnsDelegate", (Type[])null, (Type[])null)) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }) .ThrowIfInvalid("Could not patch Hud.GetSelectedGrid()! (grid-rows)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "GridRowsDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int GridColumnsDelegate(int columns) { if (!PluginConfig.IsModEnabled.Value) { return columns; } return BuildHudController.BuildHudColumns; } private static int GridRowsDelegate(int rows) { if (!PluginConfig.IsModEnabled.Value) { return rows; } return BuildHudController.BuildHudRows; } } [HarmonyPatch(typeof(PieceTable))] internal static class PieceTablePatch { [HarmonyPostfix] [HarmonyPatch("SetCategory")] private static void SetCategoryPostfix() { if (PluginConfig.IsModEnabled.Value) { BuildHudController.BuildHudNeedRefresh = true; } } [HarmonyPostfix] [HarmonyPatch("PrevCategory")] private static void PrevCategoryPostfix() { if (PluginConfig.IsModEnabled.Value) { BuildHudController.BuildHudNeedRefresh = true; } } [HarmonyPostfix] [HarmonyPatch("NextCategory")] private static void NextCategoryPostfix() { if (PluginConfig.IsModEnabled.Value) { BuildHudController.BuildHudNeedRefresh = true; } } [HarmonyTranspiler] [HarmonyPatch("GetPiece", new Type[] { typeof(PieceCategory), typeof(Vector2Int) })] private static IEnumerable<CodeInstruction> GetPieceTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarga_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Vector2Int), "y"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null) }).ThrowIfInvalid("Could not patch PieceTable.GetPiece()! (get-y)") .Advance(3) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "GetPieceGetYDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int GetPieceGetYDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudColumns; } [HarmonyTranspiler] [HarmonyPatch("GetPieceIndex")] private static IEnumerable<CodeInstruction> GetPieceIndexTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0031: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null) }).ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (column-a)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "GetPieceIndexColumnDelegate", (Type[])null, (Type[])null)) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null) }) .ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (column-b)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "GetPieceIndexColumnDelegate", (Type[])null, (Type[])null)) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null) }) .ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (column-c)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "GetPieceIndexColumnDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int GetPieceIndexColumnDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudColumns; } [HarmonyTranspiler] [HarmonyPatch("LeftPiece")] private static IEnumerable<CodeInstruction> LeftPieceTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0031: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(14), (string)null) }).ThrowIfInvalid("Could not patch PieceTable.LeftPiece()! (column)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "LeftPieceDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int LeftPieceDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudColumns - 1; } [HarmonyTranspiler] [HarmonyPatch("RightPiece")] private static IEnumerable<CodeInstruction> RightPieceTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0031: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null) }).ThrowIfInvalid("Could not patch PieceTable.RightPiece()! (column)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "RightPieceDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int RightPieceDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudColumns; } [HarmonyTranspiler] [HarmonyPatch("UpPiece")] private static IEnumerable<CodeInstruction> UpPieceTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_5, (object)null, (string)null) }).ThrowIfInvalid("Could not patch PieceTable.UpPiece()! (row)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "UpPieceDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int UpPieceDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudRows - 1; } [HarmonyTranspiler] [HarmonyPatch("DownPiece")] private static IEnumerable<CodeInstruction> DownPieceTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null) }).ThrowIfInvalid("Could not patch PieceTable.DownPiece()! (row)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PieceTablePatch), "DownPieceDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static int DownPieceDelegate(int value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return BuildHudController.BuildHudRows; } [HarmonyPostfix] [HarmonyPatch("LeftPiece")] [HarmonyPatch("RightPiece")] [HarmonyPatch("UpPiece")] [HarmonyPatch("DownPiece")] private static void ControllerPiecePostfix() { if (PluginConfig.IsModEnabled.Value) { BuildHudController.CenterOnSelectedIndex(); } } } [HarmonyPatch(typeof(Player))] internal static class PlayerPatch { [HarmonyTranspiler] [HarmonyPatch("UpdateBuildGuiInput")] private static IEnumerable<CodeInstruction> UpdateBuildGuiInputTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Player.UpdateBuildGuiInput()! (get-mouse-scroll-wheel)") .Repeat((Action<CodeMatcher>)InsertGetMouseScrollWheelDelegate, (Action<string>)null) .InstructionEnumeration(); } private static void InsertGetMouseScrollWheelDelegate(CodeMatcher matcher) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown matcher.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "GetAxisDelegate", (Type[])null, (Type[])null)) }); } private static float GetAxisDelegate(float result) { if (!PluginConfig.IsModEnabled.Value) { return result; } return 0f; } } [BepInPlugin("redseiko.valheim.searscatalog", "SearsCatalog", "1.8.0")] public sealed class SearsCatalog : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.searscatalog"; public const string PluginName = "SearsCatalog"; public const string PluginVersion = "1.8.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.searscatalog"); } } } namespace ComfyLib { public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } } public static class ObjectExtensions { public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object { foreach (T val in unityObjects) { if (((Object)val).name == name) { return val; } } throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}"); } public static T Ref<T>(this T unityObject) where T : Object { if (!Object.op_Implicit((Object)(object)unityObject)) { return default(T); } return unityObject; } public static T SetName<T>(this T unityObject, string name) where T : Object { ((Object)unityObject).name = name; return unityObject; } } public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Vector2 _lastMousePosition; public RectTransform TargetRectTransform; public event EventHandler<Vector3> OnPanelEndDrag; public void OnBeginDrag(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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_0041: Unknown result type (might be due to invalid IL or missing references) Vector2 val = eventData.position - _lastMousePosition; if (Object.op_Implicit((Object)(object)TargetRectTransform)) { RectTransform targetRectTransform = TargetRectTransform; ((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, 0f); } _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)TargetRectTransform)) { this.OnPanelEndDrag?.Invoke(this, Vector2.op_Implicit(TargetRectTransform.anchoredPosition)); } } } public sealed class PanelResizer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler { [CompilerGenerated] private sealed class <LerpCanvasGroupAlpha>d__10 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PanelResizer <>4__this; public float lerpDuration; public float targetAlpha; private float <timeElapsed>5__2; private float <sourceAlpha>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LerpCanvasGroupAlpha>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; PanelResizer panelResizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timeElapsed>5__2 = 0f; <sourceAlpha>5__3 = panelResizer._canvasGroup.alpha; break; case 1: <>1__state = -1; break; } if (<timeElapsed>5__2 < lerpDuration) { float num2 = <timeElapsed>5__2 / lerpDuration; num2 = num2 * num2 * (3f - 2f * num2); panelResizer._canvasGroup.SetAlpha(Mathf.Lerp(<sourceAlpha>5__3, targetAlpha, num2)); <timeElapsed>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } panelResizer._canvasGroup.SetAlpha(targetAlpha); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private CanvasGroup _canvasGroup; private float _targetAlpha; private Vector2 _lastMousePosition; private Coroutine _lerpAlphaCoroutine; public RectTransform TargetRectTransform; private Vector2 _originalPivot; public event EventHandler<Vector2> OnPanelEndResize; private void Awake() { _canvasGroup = ((Component)this).GetComponent<CanvasGroup>(); } private void SetCanvasGroupAlpha(float alpha) { if (_lerpAlphaCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_lerpAlphaCoroutine); _lerpAlphaCoroutine = null; } if (_canvasGroup.alpha != alpha) { _lerpAlphaCoroutine = ((MonoBehaviour)this).StartCoroutine(LerpCanvasGroupAlpha(alpha, 0.25f)); } } [IteratorStateMachine(typeof(<LerpCanvasGroupAlpha>d__10))] private IEnumerator LerpCanvasGroupAlpha(float targetAlpha, float lerpDuration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LerpCanvasGroupAlpha>d__10(0) { <>4__this = this, targetAlpha = targetAlpha, lerpDuration = lerpDuration }; } public void OnPointerEnter(PointerEventData eventData) { _targetAlpha = 1f; SetCanvasGroupAlpha(_targetAlpha); } public void OnPointerExit(PointerEventData eventData) { _targetAlpha = 0f; if (!eventData.dragging) { SetCanvasGroupAlpha(_targetAlpha); } } public void OnBeginDrag(PointerEventData eventData) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) SetCanvasGroupAlpha(1f); _lastMousePosition = eventData.position; _originalPivot = TargetRectTransform.pivot; SetPivot(TargetRectTransform, new Vector2(0f, 1f)); } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Vector2 val = _lastMousePosition - eventData.position; if (Object.op_Implicit((Object)(object)TargetRectTransform)) { RectTransform targetRectTransform = TargetRectTransform; targetRectTransform.sizeDelta += new Vector2(-1f * val.x, val.y); } SetCanvasGroupAlpha(1f); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) SetCanvasGroupAlpha(_targetAlpha); this.OnPanelEndResize?.Invoke(this, TargetRectTransform.sizeDelta); SetPivot(TargetRectTransform, _originalPivot); } private void SetPivot(RectTransform rectTransform, Vector2 pivot) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector2.op_Implicit(rectTransform.pivot - pivot); Rect rect = rectTransform.rect; ((Vector3)(ref val)).Scale(Vector2.op_Implicit(((Rect)(ref rect)).size)); ((Vector3)(ref val)).Scale(((Transform)rectTransform).localScale); val = ((Transform)rectTransform).rotation * val; rectTransform.pivot = pivot; ((Transform)rectTransform).localPosition = ((Transform)rectTransform).localPosition - val; } } public static class UIBuilder { public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((TMP_Text)obj.SetName<TextMeshProUGUI>("Label").SetRichText<TextMeshProUGUI>(richText: true).SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false) .SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0) .SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0) .SetColor<TextMeshProUGUI>(Color.white) .SetFontSize<TextMeshProUGUI>(16f)).SetText(string.Empty); return obj; } public static TextMeshProUGUI CreateTMPHeaderLabel(Transform parentTransform) { TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.headerText, parentTransform, false); ((TMP_Text)obj.SetName<TextMeshProUGUI>("Label").SetRichText<TextMeshProUGUI>(richText: true).SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false) .SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0) .SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0) .SetFontSize<TextMeshProUGUI>(32f)).SetText(string.Empty); return obj; } public static GameObject CreateResizer(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0079: 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_00b3: 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_00ce: 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_00ea: 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_0111: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right) .SetPivot(Vector2.right) .SetSizeDelta(new Vector2(42.5f, 42.5f)) .SetPosition(new Vector2(10f, -10f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(new Color(1f, 1f, 1f, 0.95f)); val.AddComponent<Shadow>().SetEffectDistance(new Vector2(2f, -2f)); val.AddComponent<CanvasGroup>().SetAlpha(0f); TextMeshProUGUI obj = CreateTMPLabel(val.transform); obj.SetName<TextMeshProUGUI>("Icon"); ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj.SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)514).SetFontSize<TextMeshProUGUI>(24f).SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0)).SetText("<rotate=-45>↔</rotate>"); return val; } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class LayoutGroupExtensions { public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)(object)layoutGroup).childAlignment = alignment; return layoutGroup; } public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetMaterial(this Image image, Material material) { ((Graphic)image).material = material; return image; } public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier) { image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class LayoutElementExtensions { public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } } public static class RectMask2DExtensions { public static RectMask2D SetSoftness(this RectMask2D rectMask2d, Vector2Int softness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectMask2d.softness = softness; return rectMask2d; } } public static class RectTransformExtensions { public static RectTransform OffsetPosition(this RectTransform rectTransform, Vector2 offset) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition += offset; return rectTransform; } public static RectTransform OffsetSizeDelta(this RectTransform rectTransform, Vector2 offset) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta += offset; return rectTransform; } public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).spriteState = spriteState; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class ShadowExtensions { public static Shadow SetEffectColor(this Shadow shadow, Color effectColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectColor = effectColor; return shadow; } public static Shadow SetEffectDistance(this Shadow shadow, Vector2 effectDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectDistance = effectDistance; return shadow; } } public static class ScrollRectExtensions { public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect { ((ScrollRect)scrollRect).content = content; return scrollRect; } public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect { ((ScrollRect)scrollRect).horizontal = horizontal; return scrollRect; } public static T SetInertia<T>(this T scrollRect, bool inertia) where T : ScrollRect { ((ScrollRect)scrollRect).inertia = inertia; return scrollRect; } public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).movementType = movementType; return scrollRect; } public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect { ((ScrollRect)scrollRect).scrollSensitivity = sensitivity; return scrollRect; } public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect { ((ScrollRect)scrollRect).vertical = vertical; return scrollRect; } public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect { ((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar; return scrollRect; } public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect { ((ScrollRect)scrollRect).verticalNormalizedPosition = position; return scrollRect; } public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility; return scrollRect; } public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect { ((ScrollRect)scrollRect).viewport = viewport; return scrollRect; } } public static class TextMeshProExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } } public static class UIResources { public static readonly ResourceCache<Sprite> SpriteCache = new ResourceCache<Sprite>(); public static readonly ResourceCache<Material> MaterialCache = new ResourceCache<Material>(); public static Sprite GetSprite(string spriteName) { return SpriteCache.GetResource(spriteName); } public static Material GetMaterial(string materialName) { return MaterialCache.GetResource(materialName); } } public sealed class ResourceCache<T> where T : Object { private readonly Dictionary<string, T> _cache = new Dictionary<string, T>(); public T GetResource(string resourceName) { if (!_cache.TryGetValue(resourceName, out var value)) { value = Resources.FindObjectsOfTypeAll<T>().FirstByNameOrThrow(resourceName); _cache[resourceName] = value; } return value; } } public static class ReflectionUtils { public static MethodInfo GetFirstMatchingMethod(Type type, string methodName, params Type[][] parameterTypesList) { foreach (Type[] types in parameterTypesList) { MethodInfo method = type.GetMethod(methodName, AccessTools.allDeclared, null, types, null); if (method != null) { return method; } } return null; } } }