using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.InteropTypes.Fields;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LegacyLobby.Components;
using LegacyLobby.Extensions;
using Localization;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LegacyLobby")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyProduct("LegacyLobby")]
[assembly: AssemblyTitle("LegacyLobby")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace LegacyLobby
{
[HarmonyWrapSafe]
[HarmonyPatch(typeof(CM_PageLoadout), "Setup")]
public static class CM_PageLoadout__Setup__Patch
{
public static void Postfix(CM_PageLoadout __instance)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
Transform obj = __instance.m_readyButtonAlign.FindExactChild("DecorText");
((Component)obj).gameObject.SetActive(true);
Object.Instantiate<Transform>(obj, ((Component)__instance.m_dropButton).transform).localPosition = Vector3.zero;
obj.SetParent(((Component)__instance.m_readyButton).transform, true);
}
}
[HarmonyWrapSafe]
[HarmonyPatch(typeof(CM_PageRundown_New), "OnEnable")]
public static class CM_PageRundown_New__OnEnable__Patch
{
private static readonly int NOISE_MASK = Shader.PropertyToID("_NoiseMask");
private static readonly int BACKGROUND_DESAT = Shader.PropertyToID("_BackgroundDesat");
private static readonly int BACKGROUND_COLOR = Shader.PropertyToID("_BackgroundColor");
private static readonly int DISTORTION_MIN = Shader.PropertyToID("_DistortionMin");
private static readonly int DISTORTION_MAX = Shader.PropertyToID("_DistortionMax");
private static readonly int SCANLINE_OVERLAY = Shader.PropertyToID("_ScanlineOverlay");
public static void Postfix(CM_PageRundown_New __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)CM_Camera.Current == (Object)null)
{
return;
}
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Noise.png");
byte[] bytes = Resources.NoiseTexture;
if (File.Exists(text))
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Using custom noise texture: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
}
l.LogWarning(val);
bytes = File.ReadAllBytes(text);
}
try
{
Plugin.LoadImage(bytes, out var tex);
if ((Object)(object)tex == (Object)null)
{
throw new Exception("Image error idk, send help");
}
Material mat = ((Component)CM_Camera.Current).gameObject.GetComponent<UI_ScenePost>().mat;
mat.SetTexture(NOISE_MASK, (Texture)(object)tex);
mat.SetFloat(BACKGROUND_DESAT, 5f);
mat.SetColor(BACKGROUND_COLOR, new Color(0.55f, 0.7f, 0.73f, 0.2f));
mat.SetFloat(DISTORTION_MIN, 0.01f);
mat.SetFloat(DISTORTION_MAX, 0.03f);
mat.SetFloat(SCANLINE_OVERLAY, 0f);
}
catch (Exception ex)
{
Plugin.L.LogError((object)"OOPS");
Plugin.L.LogError((object)ex);
}
}
}
[HarmonyWrapSafe]
[HarmonyPatch(typeof(CM_PlayerLobbyBar), "SetupFromPage")]
public static class CM_PlayerLobbyBar__SetupFromPage__Patch
{
private const float BASE_POS = -166f;
private const float OFFSET = 160f;
public static void Postfix(CM_PlayerLobbyBar __instance)
{
//IL_008d: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: 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_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance == (Object)null))
{
Transform transform = __instance.m_hasPlayerRoot.transform;
GameObject corners = __instance.m_corners;
corners.transform.SetParent(transform, true);
((Renderer)((Component)corners.transform.FindExactChild("CornerBL")).GetComponent<SpriteRenderer>()).sortingLayerName = "Default";
((Renderer)((Component)corners.transform.FindExactChild("CornerBR")).GetComponent<SpriteRenderer>()).sortingLayerName = "Default";
corners.SetActive(false);
FixGUIX(transform);
__instance.m_statusText.transform.localPosition = new Vector3(-15f, -620f, 0f);
((TMP_Text)__instance.m_statusText).m_textAlignment = (TextAlignmentOptions)4097;
transform.FindExactChild("Inventory_Header").localPosition = new Vector3(-5000f, -5000f, 0f);
Transform transform2 = ((Component)__instance.m_clothesButton).transform;
transform2.localPosition = new Vector3(transform2.localPosition.x, -70000f, transform2.localPosition.z);
Transform slotStandardAlign = __instance.m_slotStandardAlign;
Transform slotSpecialAlign = __instance.m_slotSpecialAlign;
Transform slotClassAlign = __instance.m_slotClassAlign;
Transform slotMeleeAlign = __instance.m_slotMeleeAlign;
float x = slotStandardAlign.localPosition.x;
float z = slotStandardAlign.localPosition.z;
slotStandardAlign.localPosition = new Vector3(x, -166f, z);
slotSpecialAlign.localPosition = new Vector3(x, -326f, z);
slotClassAlign.localPosition = new Vector3(x, -486f, z);
slotMeleeAlign.localPosition = new Vector3(x, -646f, z);
Vector3 localPosition = ((Component)__instance.m_permissionButton).transform.localPosition;
((Component)__instance.m_permissionButton).transform.localPosition = new Vector3(localPosition.x, 470f, localPosition.z);
}
}
private static void FixGUIX(Transform playerRoot)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
Transform obj = playerRoot.FindExactChild("GuixPillar");
obj.localPosition = new Vector3(25f, -25f, 0f);
((Component)obj).gameObject.SetActive(false);
((Component)obj.FindExactChild("BrainScan (1)")).gameObject.SetActive(true);
((Component)obj.FindExactChild("lobby-brainxray-top")).gameObject.SetActive(true);
Transform self = obj.FindExactChild("Corners (3)");
Transform val = self.FindExactChild("CornerTR");
val.localPosition = new Vector3(val.localPosition.x, 132f, val.localPosition.z);
Transform val2 = self.FindExactChild("CornerTL");
val2.localPosition = new Vector3(val2.localPosition.x, 132f, val2.localPosition.z);
}
}
[HarmonyWrapSafe]
[HarmonyPatch(typeof(CM_BoosterImplantSlotHolder), "UpdateBoosterImplantInventory")]
public static class CM_BoosterImplantSlotHolder__SetupSlotItems__Patch
{
public const string CLOTHES_BUTTON_NAME = "Custom_Clothes_Button_Booster_Style";
public static void Postfix(CM_BoosterImplantSlotHolder __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
bool isForceDefaultVanityInstalled = Plugin.IsForceDefaultVanityInstalled;
int num = (isForceDefaultVanityInstalled ? 2 : 3);
Enumerator<BoosterImplantCategory, CM_BoosterImplantSlot> enumerator = __instance.m_categorySlots.GetEnumerator();
while (enumerator.MoveNext())
{
((Component)enumerator.Current.Value).transform.localPosition = new Vector3(400f, (float)(-10 + 160 * num), 0f);
num--;
}
if (!isForceDefaultVanityInstalled)
{
ClothesButton.GetOrSetupFromLobbyBar(((Component)__instance).GetComponentInParent<CM_PlayerLobbyBar>())?.CheckUpdateAndToggleState();
}
}
}
[HarmonyWrapSafe]
[HarmonyPatch(typeof(CM_ExtraCamera), "CheckInitialized")]
public static class CM_ExtraCamera_CheckInitialized_Patch
{
public static void Postfix()
{
((Behaviour)((Component)CM_ExtraCamera.Current).GetComponent<UI_ScenePost>()).enabled = false;
}
}
[HarmonyWrapSafe]
[HarmonyPatch(typeof(_DoPlayIntro_d__111), "MoveNext")]
public static class CM_PlayerLobbyBar__DoIntro__Patch
{
public static void Postfix(_DoPlayIntro_d__111 __instance)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(69, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hi from enumerator patch uwu - Blinking in GUIX & Corner UI elements.");
}
l.LogDebug(val);
if (__instance.__1__state != 1)
{
return;
}
CM_PlayerLobbyBar _4__this = __instance.__4__this;
GameObject gameObject = ((Component)_4__this.m_hasPlayerRoot.transform.FindExactChild("GuixPillar")).gameObject;
gameObject.SetActive(false);
CoroutineManager.BlinkIn(gameObject, 1.5f);
CoroutineManager.BlinkIn(_4__this.m_corners, 1.6f);
SNet_Player player = _4__this.m_player;
if (player != null && player.IsLocal)
{
ClothesButton orSetupFromLobbyBar = ClothesButton.GetOrSetupFromLobbyBar(_4__this);
if ((Object)(object)orSetupFromLobbyBar != (Object)null)
{
CoroutineManager.BlinkIn(((Component)orSetupFromLobbyBar).gameObject, 1.1f);
}
}
}
}
[BepInPlugin("dev.aurirex.gtfo.legacylobby", "LegacyLobby", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string GUID = "dev.aurirex.gtfo.legacylobby";
public const string NAME = "LegacyLobby";
public const string VERSION = "1.1.0";
public const string FORCE_DEFAULT_VANITY_GUID = "JarheadHME.ForceDefaultVanity";
internal static ManualLogSource L;
private static Harmony _harmony;
internal static bool IsForceDefaultVanityInstalled { get; private set; }
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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
L = ((BasePlugin)this).Log;
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(8, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("LegacyLobby");
}
log.LogMessage(val);
IsForceDefaultVanityInstalled = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("JarheadHME.ForceDefaultVanity");
ClassInjector.RegisterTypeInIl2Cpp<ClothesButton>();
_harmony = new Harmony("dev.aurirex.gtfo.legacylobby");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
}
public static void LoadImage(byte[] bytes, out Texture2D tex)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
tex = new Texture2D(2, 2);
ImageConversion.LoadImage(tex, Il2CppStructArray<byte>.op_Implicit(bytes), false);
((Object)(object)tex).DontDestroyAndSetHideFlags();
}
}
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("LegacyLobby.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] NoiseTexture => (byte[])ResourceManager.GetObject("NoiseTexture", resourceCulture);
internal Resources()
{
}
}
}
namespace LegacyLobby.Extensions
{
internal static class ExtensionMethods
{
public static IEnumerable<Transform> Children(this Transform self)
{
for (int i = 0; i < self.childCount; i++)
{
yield return self.GetChild(i);
}
}
public static Transform FindExactChild(this Transform self, string name)
{
return self.Children().FirstOrDefault((Func<Transform, bool>)((Transform c) => ((Object)c).name == name));
}
public static T GetOrAddComponent<T>(this GameObject self) where T : Component
{
T val = self.GetComponent<T>();
if ((Object)(object)val == (Object)null)
{
val = self.AddComponent<T>();
}
return val;
}
public static void DontDestroyAndSetHideFlags(this Object obj)
{
Object.DontDestroyOnLoad(obj);
obj.hideFlags = (HideFlags)61;
}
}
}
namespace LegacyLobby.Components
{
public class ClothesButton : MonoBehaviour
{
public const string CLOTHES_BUTTON_NAME = "Custom_Clothes_Button_Booster_Style";
private static Sprite _icon;
public Il2CppReferenceField<CM_PlayerLobbyBar> _rf_playerLobbyBar;
public Il2CppReferenceField<CM_Item> _rf_item;
public Il2CppReferenceField<GameObject> _rf_box;
public Il2CppReferenceField<TextMeshPro> _rf_text;
public Il2CppReferenceField<GameObject> _rf_attentionIcon;
[HideFromIl2Cpp]
private CM_PlayerLobbyBar _playerLobbyBar
{
get
{
return _rf_playerLobbyBar.Get();
}
set
{
_rf_playerLobbyBar.Set(value);
}
}
[HideFromIl2Cpp]
private CM_Item _item
{
get
{
return _rf_item.Get();
}
set
{
_rf_item.Set(value);
}
}
[HideFromIl2Cpp]
private GameObject _box
{
get
{
return _rf_box.Get();
}
set
{
_rf_box.Set(value);
}
}
[HideFromIl2Cpp]
private TextMeshPro _text
{
get
{
return _rf_text.Get();
}
set
{
_rf_text.Set(value);
}
}
[HideFromIl2Cpp]
private GameObject _attentionIcon
{
get
{
return _rf_attentionIcon.Get();
}
set
{
_rf_attentionIcon.Set(value);
}
}
public void Awake()
{
if (!((Object)(object)_playerLobbyBar == (Object)null))
{
CheckUpdateAndToggleState();
}
}
public static ClothesButton GetOrSetupFromLobbyBar(CM_PlayerLobbyBar lobbyBar)
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.IsForceDefaultVanityInstalled)
{
return null;
}
if ((Object)(object)lobbyBar == (Object)null || (Object)(object)lobbyBar.m_hasPlayerRoot == (Object)null)
{
return null;
}
Transform transform = lobbyBar.m_hasPlayerRoot.transform;
Transform obj = transform.FindExactChild("Custom_Clothes_Button_Booster_Style");
GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
if ((Object)(object)val != (Object)null)
{
return val.GetComponent<ClothesButton>();
}
CM_BoosterImplantSlot val2 = GOUtil.SpawnChildAndGetComp<CM_BoosterImplantSlot>(lobbyBar.m_boosterImplantSlotHolder.m_boosterImplantSlotPrefab, transform);
val = ((Component)val2).gameObject;
((Object)val).name = "Custom_Clothes_Button_Booster_Style";
((Object)(object)val).DontDestroyAndSetHideFlags();
Transform transform2 = val.transform;
transform2.localPosition = new Vector3(342f, -500f, 0f);
Object.Destroy((Object)(object)val2);
((Component)transform2.FindExactChild("ImplantStateText")).gameObject.SetActive(false);
((Component)transform2.FindExactChild("BoosterIcon")).gameObject.SetActive(false);
if ((Object)(object)_icon == (Object)null)
{
_icon = ((Component)MainMenuGuiLayer.Current.PageRundownNew).GetComponentInChildren<CM_RundownVanityItemDropsNext>(true).m_icon.sprite;
}
return val.AddComponent<ClothesButton>().Setup();
}
private ClothesButton Setup()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
_playerLobbyBar = ((Component)((Component)this).transform).GetComponentInParent<CM_PlayerLobbyBar>();
_item = ((Component)this).gameObject.AddComponent<CM_Item>();
((RectTransformComp)_item).Setup();
_box = ((Component)((Component)this).transform.FindExactChild("Box")).gameObject;
_item.m_hoverSpriteArray = ((Il2CppObjectBase)((Component)_box.transform).GetComponentsInChildren<SpriteRenderer>(true)).Cast<Il2CppReferenceArray<SpriteRenderer>>();
_item.m_alphaSpriteOnHover = true;
_item.m_alphaTextOnHover = false;
_item.m_onBtnPress = new UnityEvent();
_item.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
{
Plugin.L.LogWarning((object)"Clothes Button pressed!");
_playerLobbyBar.ShowClothesSelect();
});
_text = ((Component)((Component)this).transform.FindExactChild("ImplantCategoryName")).GetComponent<TextMeshPro>();
_attentionIcon = ((Component)((Component)this).transform.FindExactChild("AttentionIcon")).gameObject;
Transform obj = ((Component)this).transform.FindExactChild("EmptyIcon");
obj.localRotation = Quaternion.identity;
SpriteRenderer component = ((Component)obj).GetComponent<SpriteRenderer>();
component.sprite = _icon;
component.size = new Vector2(125f, 125f);
CheckUpdateAndToggleState();
((Component)this).gameObject.SetActive(false);
return this;
}
public void CheckUpdateAndToggleState()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
((TMP_Text)_text).SetText(Text.Get(Text.MainMenu_Lobby_PlayerBar_Apparel), true);
CM_PlayerLobbyBar playerLobbyBar = _playerLobbyBar;
bool? obj;
if (playerLobbyBar == null)
{
obj = null;
}
else
{
SNet_Player player = playerLobbyBar.m_player;
obj = ((player != null) ? new bool?(player.IsLocal) : null);
}
bool? flag = obj;
bool valueOrDefault = flag.GetValueOrDefault();
bool flag2 = valueOrDefault && (int)GameStateManager.CurrentStateName != 6 && (int)GameStateManager.CurrentStateName != 10 && !GameStateManager.IsReady;
if (((Behaviour)this).isActiveAndEnabled)
{
((Component)this).gameObject.SetActive(valueOrDefault);
}
if (valueOrDefault)
{
_item.SetButtonEnabled(flag2);
_box.SetActive(flag2);
bool active = AnyNewItems();
_attentionIcon.SetActive(active);
}
}
private static bool AnyNewItems()
{
VanityItemInventory vanityItemsInventory = PersistentInventoryManager.Current.m_vanityItemsInventory;
return ((IEnumerable<VanityItem>)((vanityItemsInventory != null) ? vanityItemsInventory.m_backednItems : null)?.ToArray()).Any((VanityItem item) => (item.flags & 2) == 0) ?? false;
}
}
}