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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TinyAdmin.MYGUI;
using TinyAdmin.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TinyAdmin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Tine Admin")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("TinyAdmin")]
[assembly: AssemblyTitle("TinyAdmin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 TinyAdmin
{
[BepInPlugin("TinyAdmin", "TinyAdmin", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("TinyAdmin");
public static ManualLogSource Log;
internal static GameObject myGUIObject;
internal static Plugin Instance;
internal bool adminMenuOpen = false;
internal bool canOpenAdminMenu = false;
internal bool menuExists = false;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TinyAdmin is loaded!");
Log = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll(typeof(GameNetworkManagerPatch));
harmony.PatchAll(typeof(QuickMenuManagerPatch));
}
}
public class AdminTools
{
public static Dictionary<int, string> GetAllPlayers()
{
int num = 0;
Dictionary<int, string> dictionary = new Dictionary<int, string>();
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
dictionary.Add(num, val.playerUsername);
num++;
}
return dictionary;
}
public static void KickBanByID(int ID)
{
Plugin.Log.LogInfo((object)$"Kicking player: {ID}");
if (ID != 0)
{
StartOfRound.Instance.KickPlayer(ID);
}
}
public static void KickBanByName(string Name)
{
int num = 0;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.playerUsername == Name)
{
KickBanByID(num);
}
num++;
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TinyAdmin";
public const string PLUGIN_NAME = "TinyAdmin";
public const string PLUGIN_VERSION = "0.0.1";
}
}
namespace TinyAdmin.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatch
{
[HarmonyPatch("SteamMatchmaking_OnLobbyCreated")]
[HarmonyPrefix]
public static void lobbyCreatedPatch()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (!Plugin.Instance.menuExists)
{
Plugin.Log.LogInfo((object)"GUI didn't exist, creating");
Plugin.myGUIObject = new GameObject("AdminGUI");
Object.DontDestroyOnLoad((Object)(object)Plugin.myGUIObject);
((Object)Plugin.myGUIObject).hideFlags = (HideFlags)61;
Plugin.myGUIObject.AddComponent<AdminMenu>();
Plugin.Instance.menuExists = true;
}
Plugin.Instance.canOpenAdminMenu = true;
Plugin.Log.LogInfo((object)"GUI Created");
}
}
[HarmonyPatch(typeof(QuickMenuManager))]
internal class QuickMenuManagerPatch
{
[HarmonyPatch("OpenQuickMenu")]
[HarmonyPrefix]
public static void openMenu()
{
Plugin.Log.LogInfo((object)"opening menu");
Plugin.Instance.adminMenuOpen = true;
}
[HarmonyPatch("CloseQuickMenu")]
[HarmonyPrefix]
public static void closeMenu()
{
Plugin.Log.LogInfo((object)"closing menu");
Plugin.Instance.adminMenuOpen = false;
}
[HarmonyPatch("LeaveGameConfirm")]
[HarmonyPrefix]
public static void destroyMenuOnLeave()
{
Plugin.Instance.canOpenAdminMenu = false;
Plugin.Instance.adminMenuOpen = false;
}
}
}
namespace TinyAdmin.MYGUI
{
internal class AdminMenu : MonoBehaviour
{
public bool isMenuOpen;
private float MENUWIDTH = 800f;
private float MENUHEIGHT = 400f;
private float MENUX;
private float MENUY;
private float ITEMWIDTH = 300f;
private float CENTERX;
private float scrollStart;
private GUIStyle menuStyle;
private GUIStyle kickButtonStyle;
private GUIStyle labelStyle;
private GUIStyle hScrollStyle;
private GUIStyle vScrollStyle;
private Vector2 scrollPosition;
private void Awake()
{
isMenuOpen = false;
MENUWIDTH = Screen.width / 6;
MENUHEIGHT = Screen.width / 4;
ITEMWIDTH = MENUWIDTH / 1.2f;
MENUX = (float)Screen.width - MENUWIDTH;
MENUY = (float)(Screen.height / 2) - MENUHEIGHT / 2f;
CENTERX = MENUX + (MENUWIDTH / 2f - ITEMWIDTH / 2f);
scrollStart = MENUY + 30f;
}
private Texture2D MakeTex(int width, int height, Color col)
{
//IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
Color[] array = (Color[])(object)new Color[width * height];
for (int i = 0; i < array.Length; i++)
{
array[i] = col;
}
Texture2D val = new Texture2D(width, height);
val.SetPixels(array);
val.Apply();
return val;
}
private void IntitializeMenu()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0086: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
if (menuStyle == null)
{
menuStyle = new GUIStyle(GUI.skin.box);
kickButtonStyle = new GUIStyle(GUI.skin.button);
labelStyle = new GUIStyle(GUI.skin.label);
hScrollStyle = new GUIStyle(GUI.skin.horizontalScrollbar);
vScrollStyle = new GUIStyle(GUI.skin.verticalScrollbar);
menuStyle.normal.textColor = Color.white;
menuStyle.normal.background = MakeTex(2, 2, new Color(0.01f, 0.01f, 0.1f, 0.9f));
menuStyle.fontSize = 18;
((Object)menuStyle.normal.background).hideFlags = (HideFlags)61;
kickButtonStyle.normal.textColor = Color.white;
kickButtonStyle.normal.background = MakeTex(2, 2, new Color(0.3f, 0.01f, 0.1f, 0.9f));
kickButtonStyle.hover.background = MakeTex(2, 2, new Color(0.4f, 0.01f, 0.1f, 0.9f));
kickButtonStyle.fontSize = 22;
((Object)kickButtonStyle.normal.background).hideFlags = (HideFlags)61;
labelStyle.normal.textColor = Color.white;
labelStyle.normal.background = MakeTex(2, 2, new Color(0.01f, 0.01f, 0.1f, 0f));
labelStyle.fontSize = 24;
labelStyle.alignment = (TextAnchor)4;
((Object)labelStyle.normal.background).hideFlags = (HideFlags)61;
hScrollStyle.normal.background = MakeTex(2, 2, new Color(0.01f, 0.01f, 0.1f, 0f));
}
}
private void OnGUI()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
if (menuStyle == null)
{
IntitializeMenu();
}
if (!Plugin.Instance.canOpenAdminMenu || !Plugin.Instance.adminMenuOpen)
{
return;
}
GUI.Box(new Rect(MENUX, MENUY, MENUWIDTH, MENUHEIGHT), "TinyAdmin Kick Menu", menuStyle);
scrollPosition = GUI.BeginScrollView(new Rect(MENUX, MENUY + 30f, MENUWIDTH, MENUHEIGHT - 50f), scrollPosition, new Rect(MENUX, scrollStart, ITEMWIDTH, (float)(AdminTools.GetAllPlayers().Count * 30)), false, true, hScrollStyle, vScrollStyle);
try
{
foreach (KeyValuePair<int, string> allPlayer in AdminTools.GetAllPlayers())
{
if (GUI.Button(new Rect(CENTERX, MENUY + 30f + (float)(allPlayer.Key * 30), ITEMWIDTH, 30f), allPlayer.Value))
{
AdminTools.KickBanByID(allPlayer.Key);
}
}
}
catch (Exception ex)
{
Plugin.Log.LogInfo((object)ex.Message);
}
GUI.EndScrollView();
}
}
}