using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VerboseCompanyFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VerboseCompanyFix")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ce891458-a722-4ec7-9a6d-223d03125e00")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Azx.VerboseCompanyFix", "Verbose Company Fix", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RenderOrderFix : BaseUnityPlugin
{
private Harmony _h;
private static Transform _menuContainer;
private static Transform _title;
private static GameObject _mainButtons;
private static TextMeshProUGUI _titleTmp;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
_h = new Harmony("Azx.VerboseCompanyFix");
MethodInfo methodInfo = AccessTools.Method(typeof(MenuManager), "Update", (Type[])null, (Type[])null);
Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo);
if (patchInfo != null)
{
Patch[] array = patchInfo.Prefixes.ToArray();
foreach (Patch val in array)
{
string text = (val.owner ?? "").ToLowerInvariant();
string text2 = val.PatchMethod?.DeclaringType?.FullName ?? "";
if (text.Contains("verbosecompany") || text2.Contains("VerboseCompany.TitleText_MenuManagerPatch"))
{
_h.Unpatch((MethodBase)methodInfo, val.PatchMethod);
}
}
}
MethodInfo methodInfo2 = AccessTools.Method(typeof(MenuManager), "Start", (Type[])null, (Type[])null);
_h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(RenderOrderFix), "MenuStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
_h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(RenderOrderFix), "MenuUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static void MenuStartPostfix()
{
TryFixAndToggle();
}
private static void MenuUpdatePostfix()
{
TryFixAndToggle();
}
private static void TryFixAndToggle()
{
if ((Object)(object)_menuContainer == (Object)null)
{
GameObject val = GameObject.Find("Canvas/MenuContainer");
_menuContainer = (((Object)(object)val != (Object)null) ? val.transform : null);
}
if ((Object)(object)_menuContainer == (Object)null)
{
return;
}
if ((Object)(object)_title == (Object)null)
{
_title = _menuContainer.Find("TitleObj");
}
if (!((Object)(object)_title == (Object)null))
{
_title.SetAsFirstSibling();
if ((Object)(object)_titleTmp == (Object)null)
{
_titleTmp = ((Component)_title).GetComponentInChildren<TextMeshProUGUI>(true);
}
if ((Object)(object)_titleTmp != (Object)null)
{
((Graphic)_titleTmp).raycastTarget = false;
}
if ((Object)(object)_mainButtons == (Object)null)
{
_mainButtons = GameObject.Find("Canvas/MenuContainer/MainButtons");
}
bool flag = (Object)(object)_mainButtons != (Object)null && _mainButtons.activeSelf;
GameObject gameObject = ((Component)_title).gameObject;
if (gameObject.activeSelf != flag)
{
gameObject.SetActive(flag);
}
}
}
}