using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.PhotonUtility;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Doomby")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("InteractiveProfile")]
[assembly: AssemblyTitle("InteractiveProfile")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 InteractiveProfile
{
[HarmonyPatch]
internal class Patches
{
public struct ProfileButton
{
public char symbol;
public Color color;
public UnityAction onClick;
public Func<bool> statusChecker;
public Button button;
public ProfileButton(char symbol, Color color, UnityAction onClick, Func<bool> statusChecker = null)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
button = null;
this.symbol = symbol;
this.color = color;
this.onClick = onClick;
this.statusChecker = statusChecker;
}
}
private static readonly Dictionary<EscapePlayerCellUI, List<ProfileButton>> patchedPlayerCells = new Dictionary<EscapePlayerCellUI, List<ProfileButton>>();
private static readonly List<CSteamID> bannedPlayers = new List<CSteamID>();
[HarmonyPostfix]
[HarmonyPatch(typeof(EscapeMenu), "Toggle")]
private static void Toggle_Patch()
{
if (Singleton<EscapeMenu>.Instance.Open)
{
UpdateButtonsStatus();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EscapePlayerHandler), "UpdateList")]
private static void UpdateList_Patch(Dictionary<int, EscapePlayerCellUI> ___m_PlayerCells)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
bool flag = false;
Player[] playerListOthers = PhotonNetwork.PlayerListOthers;
CSteamID cSteamID = default(CSteamID);
Button val = default(Button);
foreach (Player netPlayer in playerListOthers)
{
int actorNumber = netPlayer.ActorNumber;
if (!___m_PlayerCells.TryGetValue(actorNumber, out var value) || patchedPlayerCells.ContainsKey(value) || !SteamAvatarHandler.TryGetSteamIDForPlayer(netPlayer, ref cSteamID))
{
continue;
}
if ((Object)(object)value.playerName != (Object)null && !((Component)value.playerName).TryGetComponent<Button>(ref val))
{
((UnityEvent)((Component)value.playerName).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
GUIUtility.systemCopyBuffer = SteamFriends.GetFriendPersonaName(cSteamID);
});
}
if ((Object)(object)value.playerIcon != (Object)null && !((Component)value.playerIcon).TryGetComponent<Button>(ref val))
{
((UnityEvent)((Component)value.playerIcon).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
SteamFriends.ActivateGameOverlayToUser("steamid", cSteamID);
});
}
int num = 0;
if (PhotonNetwork.IsMasterClient)
{
AddButton(value, num++, new ProfileButton('×', new Color(38f / 51f, 0.23529412f, 0.23529412f), (UnityAction)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
BlockClicked(netPlayer, cSteamID);
}));
}
AddButton(value, num++, new ProfileButton('+', Color.white, (UnityAction)delegate
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (SteamUtils.IsOverlayEnabled())
{
SteamFriends.ActivateGameOverlayToUser("friendadd", cSteamID);
}
else
{
SteamFriends.ActivateGameOverlayToUser("steamid", cSteamID);
}
}, () => !SteamFriends.HasFriend(cSteamID, (EFriendFlags)4)));
flag = true;
}
if (flag)
{
UpdateButtonsStatus();
}
}
private static void UpdateButtonsStatus()
{
List<EscapePlayerCellUI> list = new List<EscapePlayerCellUI>();
foreach (KeyValuePair<EscapePlayerCellUI, List<ProfileButton>> patchedPlayerCell in patchedPlayerCells)
{
foreach (ProfileButton item in patchedPlayerCell.Value)
{
if (item.statusChecker != null)
{
Button button = item.button;
if (!((Object)(object)button != (Object)null))
{
list.Add(patchedPlayerCell.Key);
break;
}
bool active = item.statusChecker();
((Component)button).gameObject.SetActive(active);
}
}
}
foreach (EscapePlayerCellUI item2 in list)
{
patchedPlayerCells.Remove(item2);
}
}
private static GameObject AddButton(EscapePlayerCellUI playerCell, int btnIndex, ProfileButton profileButton)
{
//IL_0016: 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_002c: 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)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Expected O, but got Unknown
//IL_0171: Expected O, but got Unknown
GameObject val = new GameObject("ProfButton " + profileButton.symbol);
val.transform.SetParent(((Component)playerCell).transform);
val.AddComponent<CanvasRenderer>();
TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj).text = profileButton.symbol.ToString();
((Graphic)obj).color = profileButton.color;
((TMP_Text)obj).fontStyle = (FontStyles)1;
((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
((TMP_Text)obj).fontSize = 30f;
float num = ((!((Object)(object)playerCell.kickButton == (Object)null)) ? ((Component)playerCell.kickButton).GetComponent<RectTransform>().sizeDelta.y : (((Component)playerCell).GetComponent<RectTransform>().sizeDelta.y / 3.7f));
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(num, num);
component.pivot = new Vector2(1f, 0f);
component.anchoredPosition = new Vector2((float)(-10 - btnIndex * 30), 10f);
component.anchorMin = new Vector2(1f, 0f);
component.anchorMax = new Vector2(1f, 0f);
((Transform)component).localScale = new Vector3(1f, 1f, 1f);
Button val2 = val.AddComponent<Button>();
((UnityEvent)val2.onClick).AddListener(profileButton.onClick);
profileButton.button = val2;
if (patchedPlayerCells.TryGetValue(playerCell, out var value))
{
value.Add(profileButton);
return val;
}
patchedPlayerCells.Add(playerCell, new List<ProfileButton>(1) { profileButton });
return val;
}
private static void BlockClicked(Player player, CSteamID cSteamID)
{
//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)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
Modal.Show("Block " + player.NickName, "The player won't be able to enter your lobbies until you close the game.\nAre you sure?", (ModalOption[])(object)new ModalOption[2]
{
new ModalOption("yes", (Action)delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
bannedPlayers.Add(cSteamID);
KickPlayer(player);
}),
new ModalOption("cancel", (Action)null)
}, (Action)null);
}
private static void KickPlayer(Player player)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
CustomCommands<CustomCommandType>.SendPackage((CustomCommandPackage<CustomCommandType>)new KickPlayerNotificationPackage(), player);
PhotonNetwork.RaiseEvent((byte)20, (object)player.ActorNumber, RaiseEventOptions.Default, SendOptions.SendReliable);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GlobalPlayerData), "OnPlayerEnteredRoom")]
private static bool OnPlayerEnteredRoom_Patch(Player newPlayer)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
Plugin.MLogger.LogInfo((object)$"New player: {newPlayer.NickName} | {newPlayer.ActorNumber}");
CSteamID item = default(CSteamID);
if (SteamAvatarHandler.TryGetSteamIDForPlayer(newPlayer, ref item) && PhotonNetwork.IsMasterClient && bannedPlayers.Contains(item))
{
Plugin.MLogger.LogWarning((object)("Auto-kick " + newPlayer.NickName + " | "));
KickPlayer(newPlayer);
return false;
}
return true;
}
}
[ContentWarningPlugin("InteractiveProfile", "1.0.3", true)]
[BepInPlugin("InteractiveProfile", "InteractiveProfile", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource MLogger { get; private set; }
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
MLogger = ((BaseUnityPlugin)this).Logger;
new Harmony("InteractiveProfile").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin InteractiveProfile is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "InteractiveProfile";
public const string PLUGIN_NAME = "InteractiveProfile";
public const string PLUGIN_VERSION = "1.0.3";
}
}