using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BetterFriendList;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppPhoton.Pun;
using Il2CppPhoton.Realtime;
using Il2CppRUMBLE.Networking;
using Il2CppRUMBLE.Social.Phone;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyDescription("Slightly improves the friends list by telling you who's online")]
[assembly: AssemblyCopyright("Created by elmish")]
[assembly: AssemblyTrademark(null)]
[assembly: MelonInfo(typeof(global::BetterFriendList.BetterFriendList), "BetterFriendList", "1.0.0", "elmish", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterFriendList")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterFriendList")]
[assembly: AssemblyTitle("BetterFriendList")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace BetterFriendList
{
public static class BuildInfo
{
public const string Name = "BetterFriendList";
public const string Description = "Slightly improves the friends list by telling you who's online";
public const string Author = "elmish";
public const string Company = null;
public const string Version = "1.0.0";
public const string DownloadLink = null;
}
public class BetterFriendList : MelonMod
{
[HarmonyPatch(typeof(PhotonInterfaceCollection), "OnFriendListUpdate", new Type[] { typeof(List<FriendInfo>) })]
public static class Patch
{
public static void Prefix(List<FriendInfo> friendList)
{
List<bool> list = new List<bool>();
Enumerator<FriendInfo> enumerator = friendList.GetEnumerator();
while (enumerator.MoveNext())
{
FriendInfo current = enumerator.Current;
list.Add(current.IsOnline);
}
SetCurrentPageValues(list);
}
}
public static FriendList friendListManager;
public static List<string> currentPageFriendList = new List<string>();
public static bool ConnectedToMaster;
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
MelonCoroutines.Start(OnTrueSceneLoad(buildIndex, sceneName));
}
public IEnumerator OnTrueSceneLoad(int buildIndex, string sceneName)
{
if (sceneName == "Loader")
{
GameObject obj = new GameObject();
obj.AddComponent<BetterFriendListManager>();
Object.DontDestroyOnLoad((Object)(object)obj);
}
if (sceneName == "Gym")
{
yield return (object)new WaitForSeconds(2f);
friendListManager = FriendScreen.GetGameObject().GetComponent<FriendList>();
MelonLogger.Msg((object)1);
((ScrollableList)friendListManager).pageUpButton.OnPressed.AddListener(UnityAction.op_Implicit((Action)delegate
{
MelonCoroutines.Start(BetterFriendListManager.GetFriendList(longerWait: true));
}));
MelonLogger.Msg((object)2);
((ScrollableList)friendListManager).pageDownButton.OnPressed.AddListener(UnityAction.op_Implicit((Action)delegate
{
MelonCoroutines.Start(BetterFriendListManager.GetFriendList(longerWait: true));
}));
MelonLogger.Msg((object)3);
((ScrollableList)friendListManager).scrollUpButton.OnPressed.AddListener(UnityAction.op_Implicit((Action)delegate
{
MelonCoroutines.Start(BetterFriendListManager.GetFriendList(longerWait: true));
}));
MelonLogger.Msg((object)4);
((ScrollableList)friendListManager).scrollDownButton.OnPressed.AddListener(UnityAction.op_Implicit((Action)delegate
{
MelonCoroutines.Start(BetterFriendListManager.GetFriendList(longerWait: true));
}));
MelonCoroutines.Start(BetterFriendListManager.GetFriendList());
}
}
public static void SetCurrentPageValues(List<bool> list)
{
//IL_0070: 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)
MelonLogger.Msg("setting values");
for (int i = 0; i < ((Il2CppArrayBase<ScrollableItem>)(object)((ScrollableList)friendListManager).ScrollableItems).Length; i++)
{
PlayerTag val = ((Il2CppObjectBase)((Il2CppArrayBase<ScrollableItem>)(object)((ScrollableList)friendListManager).ScrollableItems)[i]).Cast<PlayerTag>();
if (list[i])
{
val.rank.text = "Online";
((Graphic)val.rank).color = Color.green;
}
else
{
val.rank.text = "Offline";
((Graphic)val.rank).color = Color.red;
}
}
}
}
[RegisterTypeInIl2Cpp]
public class BetterFriendListManager : MonoBehaviourPunCallbacks
{
public BetterFriendListManager(IntPtr ptr)
: base(ptr)
{
}
public override void OnConnectedToMaster()
{
BetterFriendList.ConnectedToMaster = true;
}
public static IEnumerator GetFriendList(bool longerWait = false)
{
if (longerWait)
{
yield return (object)new WaitForSeconds(1f);
}
if (!PhotonNetwork.InLobby)
{
PhotonNetwork.JoinLobby(TypedLobby.Default);
while (!PhotonNetwork.InLobby)
{
yield return (object)new WaitForFixedUpdate();
}
}
BetterFriendList.currentPageFriendList.Clear();
for (int i = 0; i < ((Il2CppArrayBase<ScrollableItem>)(object)((ScrollableList)BetterFriendList.friendListManager).ScrollableItems).Length; i++)
{
BetterFriendList.currentPageFriendList.Add(((Il2CppObjectBase)((Il2CppArrayBase<ScrollableItem>)(object)((ScrollableList)BetterFriendList.friendListManager).ScrollableItems)[i]).Cast<PlayerTag>().UserData.playFabId);
}
yield return (object)new WaitForFixedUpdate();
PhotonNetwork.FindFriends(Il2CppStringArray.op_Implicit(BetterFriendList.currentPageFriendList.ToArray()));
PhotonNetwork.LeaveLobby();
}
}
}