Decompiled source of GWYFUnleashed v10.0.0

GWYFUnleashed.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("GWYFUnleashed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GWYFUnleashed")]
[assembly: AssemblyTitle("GWYFUnleashed")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GWYFUnleashed;

[BepInPlugin("com.yourname.gwyfunleashed", "GWYFUnleashed", "1.0.0")]
[BepInProcess("Gamble With Your Friends.exe")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static ConfigEntry<float> CfgDayDuration;

	internal static ConfigEntry<float> CfgAddMoney;

	internal static ConfigEntry<float> CfgAddTime;

	internal static ConfigEntry<float> CfgAddTickets;

	internal static ConfigEntry<KeyCode> CfgMenuKey;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		CfgDayDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timer", "DayDurationSeconds", 3600f, "Day length in seconds.");
		CfgAddMoney = ((BaseUnityPlugin)this).Config.Bind<float>("Menu", "DefaultAddMoney", 100000f, "Default $ per button press.");
		CfgAddTime = ((BaseUnityPlugin)this).Config.Bind<float>("Menu", "DefaultAddSeconds", 300f, "Default seconds per button press.");
		CfgAddTickets = ((BaseUnityPlugin)this).Config.Bind<float>("Menu", "DefaultAddTickets", 100f, "Default tickets per button press.");
		CfgMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Menu", "ToggleKey", (KeyCode)277, "Key to open/close the menu.");
		_harmony = new Harmony("com.yourname.gwyfunleashed");
		TryPatch("StartDay", (HarmonyPatchType)1, "StartDay_Pre");
		TryPatch("ServerUpdateMinMaxBetText", (HarmonyPatchType)1, "BetLimits_Pre");
		TryPatch("RpcUpdateMinMaxBetText", (HarmonyPatchType)1, "BetLimits_Pre");
		TryPatch("get_MaxBet", (HarmonyPatchType)2, "MaxBet_Post");
		TryPatch("SetButtons", (HarmonyPatchType)2, "EnableAllButtons_Post");
		TryPatch("RpcEnableAllButtons", (HarmonyPatchType)2, "EnableAllButtons_Post");
		Log.LogInfo((object)"[GWYFUnleashed] Loaded — press INSERT to open menu.");
	}

	private void TryPatch(string methodName, HarmonyPatchType type, string patchMethod)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Invalid comparison between Unknown and I4
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly asm in assemblies)
		{
			foreach (Type item in SafeGetTypes(asm))
			{
				MethodInfo method = item.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (method == null)
				{
					continue;
				}
				try
				{
					MethodInfo method2 = typeof(Patches).GetMethod(patchMethod, BindingFlags.Static | BindingFlags.Public);
					HarmonyMethod val = new HarmonyMethod(method2);
					if ((int)type == 1)
					{
						_harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
					else
					{
						_harmony.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
					Log.LogInfo((object)("[GWYFUnleashed] Patched " + item.Name + "." + methodName));
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("[GWYFUnleashed] Failed " + item.Name + "." + methodName + ": " + ex.Message));
				}
			}
		}
	}

	private void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("GWYFUnleashed_GUI");
		Object.DontDestroyOnLoad((Object)(object)val);
		val.AddComponent<Overlay>();
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	internal static IEnumerable<Type> SafeGetTypes(Assembly asm)
	{
		Type[] types;
		try
		{
			types = asm.GetTypes();
		}
		catch (ReflectionTypeLoadException ex)
		{
			ReflectionTypeLoadException e = ex;
			types = e.Types;
		}
		if (types == null)
		{
			yield break;
		}
		Type[] array = types;
		foreach (Type t in array)
		{
			if (t != null)
			{
				yield return t;
			}
		}
	}
}
internal static class Patches
{
	public static void StartDay_Pre(object __instance)
	{
		FieldInfo field = __instance.GetType().GetField("_gs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field != null)
		{
			object value = field.GetValue(__instance);
			if (value != null)
			{
				FieldInfo field2 = value.GetType().GetField("dayDuration", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field2 != null)
				{
					field2.SetValue(value, Plugin.CfgDayDuration.Value);
					return;
				}
			}
		}
		FieldInfo field3 = __instance.GetType().GetField("dayDuration", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field3 != null)
		{
			field3.SetValue(__instance, Plugin.CfgDayDuration.Value);
		}
	}

	public static void BetLimits_Pre(object[] __args)
	{
		if (__args != null && __args.Length >= 2)
		{
			if (__args[0] is long)
			{
				__args[0] = 0L;
			}
			if (__args[1] is long)
			{
				__args[1] = long.MaxValue;
			}
		}
	}

	public static void MaxBet_Post(object __instance, ref long __result)
	{
		FieldInfo field = __instance.GetType().GetField("baseMaxBet", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field != null)
		{
			try
			{
				field.SetValue(__instance, Convert.ChangeType(long.MaxValue, field.FieldType));
			}
			catch
			{
			}
		}
		__result = long.MaxValue;
	}

	public static void EnableAllButtons_Post(object __instance)
	{
		try
		{
			Type type = __instance.GetType();
			FieldInfo field = type.GetField("_isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(__instance, false);
			}
			FieldInfo field2 = type.GetField("buttonList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(field2 != null) || !(field2.GetValue(__instance) is IList list))
			{
				return;
			}
			foreach (object item in list)
			{
				if (item == null)
				{
					continue;
				}
				PropertyInfo property = item.GetType().GetProperty("IsInteractable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if ((object)property != null && property.CanWrite)
				{
					try
					{
						property.SetValue(item, true);
					}
					catch
					{
					}
				}
				MethodInfo method = item.GetType().GetMethod("set_IsInteractable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null)
				{
					try
					{
						method.Invoke(item, new object[1] { true });
					}
					catch
					{
					}
				}
			}
		}
		catch
		{
		}
	}
}
internal class Overlay : MonoBehaviour
{
	private bool _vis;

	private Rect _win = new Rect(16f, 16f, 310f, 560f);

	private Vector2 _scroll = Vector2.zero;

	private string _moneyIn = "";

	private string _timeIn = "";

	private string _ticketIn = "";

	private string _floorIn = "1";

	private string _status = "";

	private float _statusT;

	private object _gameManager;

	private object _moneyManager;

	private object _elevatorManager;

	private object _newConsole;

	private object _cosmeticsUnlockManager;

	private MethodInfo _miSetNetworkTimer;

	private FieldInfo _fi_timer;

	private FieldInfo _fiBalance;

	private MethodInfo _miAddBalance;

	private FieldInfo _fiTicketBalance;

	private MethodInfo _miAddTicket;

	private MethodInfo _miRemoveTicket;

	private FieldInfo _fiIsLocked;

	private FieldInfo _fiCurrentFloor;

	private MethodInfo _miRpcSetActiveFloorOnly;

	private MethodInfo _miRpcEnableAllButtons;

	private MethodInfo _miServerForceTeleport;

	private MethodInfo _miCmdEnableAllFloors;

	private MethodInfo _miUnlockAllCosmetics;

	private MethodInfo _miUnlockCosmeticDirect;

	private MethodInfo _miGetAllCosmetics;

	private void Update()
	{
		if (_statusT > 0f)
		{
			_statusT -= Time.unscaledDeltaTime;
		}
		if (_gameManager == null || _moneyManager == null || _elevatorManager == null || _newConsole == null || _cosmeticsUnlockManager == null)
		{
			TryCacheReferences();
		}
	}

	private void OnGUI()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_0070: 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)
		Event current = Event.current;
		if (current != null && (int)current.type == 4 && current.keyCode == Plugin.CfgMenuKey.Value)
		{
			_vis = !_vis;
			current.Use();
		}
		if (_vis)
		{
			_win = GUI.Window(48879, _win, new WindowFunction(DrawWindow), "  GWYFUnleashed  (drag me)");
		}
	}

	private void TryCacheReferences()
	{
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly asm in assemblies)
		{
			foreach (Type item in Plugin.SafeGetTypes(asm))
			{
				if (_gameManager == null && item.Name == "GameManager")
				{
					Object val = Object.FindObjectOfType(item);
					if (val != (Object)null)
					{
						_gameManager = val;
						_miSetNetworkTimer = item.GetMethod("set_Network_timer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_fi_timer = item.GetField("_timer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
				}
				if (_moneyManager == null && item.Name == "MoneyManager")
				{
					Object val2 = Object.FindObjectOfType(item);
					if (val2 != (Object)null)
					{
						_moneyManager = val2;
						_fiBalance = item.GetField("balance", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_fiTicketBalance = item.GetField("ticketBalance", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miAddTicket = item.GetMethod("AddTicket", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miRemoveTicket = item.GetMethod("RemoveTicket", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						foreach (MethodInfo methodInfo in methods)
						{
							if (methodInfo.Name == "AddBalance" && (_miAddBalance == null || methodInfo.GetParameters().Length < _miAddBalance.GetParameters().Length))
							{
								_miAddBalance = methodInfo;
							}
						}
					}
				}
				if (_elevatorManager == null && item.Name == "ElevatorManager")
				{
					Object val3 = Object.FindObjectOfType(item);
					if (val3 != (Object)null)
					{
						_elevatorManager = val3;
						_fiCurrentFloor = item.GetField("_currentFloorIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_fiIsLocked = item.GetField("_isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miRpcSetActiveFloorOnly = item.GetMethod("RpcSetActiveFloorOnly", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miRpcEnableAllButtons = item.GetMethod("RpcEnableAllButtons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miServerForceTeleport = item.GetMethod("ServerForceTeleportPlayers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
				}
				if (_newConsole == null && item.Name == "NewConsole")
				{
					Object val4 = Object.FindObjectOfType(item);
					if (val4 != (Object)null)
					{
						_newConsole = val4;
						_miCmdEnableAllFloors = item.GetMethod("CmdEnableAllFloors", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						_miUnlockAllCosmetics = item.GetMethod("UnlockAllCosmetics", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
				}
				if (_cosmeticsUnlockManager == null && item.Name == "CosmeticsUnlockManager")
				{
					Object val5 = Object.FindObjectOfType(item);
					if (val5 != (Object)null)
					{
						_cosmeticsUnlockManager = val5;
						_miUnlockCosmeticDirect = item.GetMethod("UnlockCosmetic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
				}
				if (_miGetAllCosmetics == null && item.Name == "CosmeticDataManager")
				{
					_miGetAllCosmetics = item.GetMethod("GetAllCosmetics", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				}
			}
		}
	}

	private void DrawWindow(int id)
	{
		//IL_0003: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_055f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0558: Unknown result type (might be due to invalid IL or missing references)
		//IL_058f: Unknown result type (might be due to invalid IL or missing references)
		_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(298f),
			GUILayout.Height(520f)
		});
		GUILayout.Space(4f);
		GUILayout.Label("=== COSMETICS ===", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Unlock All Cosmetics", Array.Empty<GUILayoutOption>()))
		{
			UnlockAllCosmetics();
		}
		GUILayout.Space(6f);
		GUILayout.Label("=== MONEY ===", Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Amount $", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		_moneyIn = GUILayout.TextField((_moneyIn == "") ? Plugin.CfgAddMoney.Value.ToString("F0") : _moneyIn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("+ Add", Array.Empty<GUILayoutOption>()))
		{
			GrantMoney(ParseMoney());
		}
		if (GUILayout.Button("- Remove", Array.Empty<GUILayoutOption>()))
		{
			GrantMoney(-ParseMoney());
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Add $1,000,000", Array.Empty<GUILayoutOption>()))
		{
			GrantMoney(1000000L);
		}
		if (GUILayout.Button("Add $1,000,000,000", Array.Empty<GUILayoutOption>()))
		{
			GrantMoney(1000000000L);
		}
		GUILayout.Space(6f);
		GUILayout.Label("=== TICKETS ===", Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Amount", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		_ticketIn = GUILayout.TextField((_ticketIn == "") ? Plugin.CfgAddTickets.Value.ToString("F0") : _ticketIn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("+ Add", Array.Empty<GUILayoutOption>()))
		{
			GrantTickets(ParseTickets());
		}
		if (GUILayout.Button("- Remove", Array.Empty<GUILayoutOption>()))
		{
			GrantTickets(-ParseTickets());
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Add 1,000 Tickets", Array.Empty<GUILayoutOption>()))
		{
			GrantTickets(1000L);
		}
		if (GUILayout.Button("Add 10,000 Tickets", Array.Empty<GUILayoutOption>()))
		{
			GrantTickets(10000L);
		}
		GUILayout.Space(6f);
		GUILayout.Label("=== TIMER ===", Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Seconds", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		_timeIn = GUILayout.TextField((_timeIn == "") ? Plugin.CfgAddTime.Value.ToString("F0") : _timeIn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("- Remove Time", Array.Empty<GUILayoutOption>()))
		{
			SetTimer(ParseTime(), relative: true);
		}
		if (GUILayout.Button("+ Add Time", Array.Empty<GUILayoutOption>()))
		{
			SetTimer(0f - ParseTime(), relative: true);
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Add 10 Minutes", Array.Empty<GUILayoutOption>()))
		{
			SetTimer(-600f, relative: true);
		}
		if (GUILayout.Button("Reset to 1 Hour", Array.Empty<GUILayoutOption>()))
		{
			SetTimer(3600f, relative: false);
		}
		GUILayout.Space(6f);
		GUILayout.Label("=== FLOOR ===", Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Floor (1-4)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		_floorIn = GUILayout.TextField(_floorIn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Go To Floor", Array.Empty<GUILayoutOption>()))
		{
			TryFloor();
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("F1", Array.Empty<GUILayoutOption>()))
		{
			DoFloor(0);
		}
		if (GUILayout.Button("F2", Array.Empty<GUILayoutOption>()))
		{
			DoFloor(1);
		}
		if (GUILayout.Button("F3", Array.Empty<GUILayoutOption>()))
		{
			DoFloor(2);
		}
		if (GUILayout.Button("F4", Array.Empty<GUILayoutOption>()))
		{
			DoFloor(3);
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Unlock All Floors", Array.Empty<GUILayoutOption>()))
		{
			UnlockAllFloors();
		}
		GUILayout.Space(8f);
		Color color = GUI.color;
		GUI.color = (Color)((_statusT > 0f) ? Color.cyan : new Color(0.5f, 0.5f, 0.5f));
		GUILayout.Label((_statusT > 0f) ? _status : "INSERT = open/close  |  scroll for all options", Array.Empty<GUILayoutOption>());
		GUI.color = color;
		GUILayout.EndScrollView();
		GUI.DragWindow();
	}

	private long ParseMoney()
	{
		float result;
		return float.TryParse(_moneyIn, out result) ? ((long)result) : ((long)Plugin.CfgAddMoney.Value);
	}

	private float ParseTime()
	{
		float result;
		return float.TryParse(_timeIn, out result) ? result : Plugin.CfgAddTime.Value;
	}

	private long ParseTickets()
	{
		float result;
		return float.TryParse(_ticketIn, out result) ? ((long)result) : ((long)Plugin.CfgAddTickets.Value);
	}

	private void GrantMoney(long amount)
	{
		if (_moneyManager == null)
		{
			Msg("Load into a game first.");
			return;
		}
		try
		{
			if (_miAddBalance != null)
			{
				ParameterInfo[] parameters = _miAddBalance.GetParameters();
				object[] array = new object[parameters.Length];
				for (int i = 0; i < parameters.Length; i++)
				{
					array[i] = ((i == 0) ? Convert.ChangeType(amount, parameters[i].ParameterType) : (parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null));
				}
				_miAddBalance.Invoke(_moneyManager, array);
			}
			else if (_fiBalance != null)
			{
				long num = Convert.ToInt64(_fiBalance.GetValue(_moneyManager));
				_fiBalance.SetValue(_moneyManager, Math.Max(0L, num + amount));
			}
			long num2 = ((_fiBalance != null) ? Convert.ToInt64(_fiBalance.GetValue(_moneyManager)) : 0);
			Msg($"Balance: {num2:N0}");
		}
		catch (Exception ex)
		{
			try
			{
				if (_fiBalance != null)
				{
					long num3 = Convert.ToInt64(_fiBalance.GetValue(_moneyManager));
					_fiBalance.SetValue(_moneyManager, Math.Max(0L, num3 + amount));
					Msg($"Balance: {Convert.ToInt64(_fiBalance.GetValue(_moneyManager)):N0}");
				}
			}
			catch
			{
				Msg("Money error: " + ex.Message);
			}
		}
	}

	private void GrantTickets(long amount)
	{
		if (_moneyManager == null)
		{
			Msg("Load into a game first.");
			return;
		}
		try
		{
			MethodInfo methodInfo = ((amount >= 0) ? _miAddTicket : _miRemoveTicket);
			long num = Math.Abs(amount);
			if (methodInfo != null)
			{
				ParameterInfo[] parameters = methodInfo.GetParameters();
				object[] array = new object[parameters.Length];
				for (int i = 0; i < parameters.Length; i++)
				{
					array[i] = ((i == 0) ? Convert.ChangeType(num, parameters[i].ParameterType) : (parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null));
				}
				methodInfo.Invoke(_moneyManager, array);
			}
			else if (_fiTicketBalance != null)
			{
				long num2 = Convert.ToInt64(_fiTicketBalance.GetValue(_moneyManager));
				_fiTicketBalance.SetValue(_moneyManager, Math.Max(0L, num2 + amount));
			}
			long num3 = ((_fiTicketBalance != null) ? Convert.ToInt64(_fiTicketBalance.GetValue(_moneyManager)) : 0);
			Msg($"Tickets: {num3:N0}");
		}
		catch (Exception ex)
		{
			Msg("Ticket error: " + ex.Message);
		}
	}

	private void SetTimer(float value, bool relative)
	{
		if (_gameManager == null)
		{
			Msg("Load into a game first.");
			return;
		}
		try
		{
			float num = ((_fi_timer != null) ? ((float)_fi_timer.GetValue(_gameManager)) : 0f);
			float num2 = Math.Max(0f, relative ? (num + value) : value);
			if (_miSetNetworkTimer != null)
			{
				_miSetNetworkTimer.Invoke(_gameManager, new object[1] { num2 });
			}
			else if (_fi_timer != null)
			{
				_fi_timer.SetValue(_gameManager, num2);
			}
			Msg($"Timer = {TimeSpan.FromSeconds(num2):mm\\:ss}");
		}
		catch (Exception ex)
		{
			Msg("Timer error: " + ex.Message);
		}
	}

	private void TryFloor()
	{
		if (int.TryParse(_floorIn, out var result))
		{
			DoFloor(Mathf.Clamp(result - 1, 0, 3));
		}
		else
		{
			Msg("Enter a number 1-4.");
		}
	}

	private void DoFloor(int idx)
	{
		if (_elevatorManager == null)
		{
			Msg("Load into a game first.");
			return;
		}
		try
		{
			if (_fiIsLocked != null)
			{
				_fiIsLocked.SetValue(_elevatorManager, false);
			}
			if (_miServerForceTeleport != null)
			{
				_miServerForceTeleport.Invoke(_elevatorManager, new object[1] { idx });
				Msg($"Teleporting to floor {idx + 1}");
				return;
			}
			if (_fiCurrentFloor != null)
			{
				_fiCurrentFloor.SetValue(_elevatorManager, idx);
			}
			if (_miRpcSetActiveFloorOnly != null)
			{
				_miRpcSetActiveFloorOnly.Invoke(_elevatorManager, new object[1] { idx });
			}
			Msg($"Floor {idx + 1}");
		}
		catch (Exception ex)
		{
			Msg("Floor error: " + ex.Message);
		}
	}

	private void UnlockAllFloors()
	{
		if (_newConsole != null && _miCmdEnableAllFloors != null)
		{
			try
			{
				_miCmdEnableAllFloors.Invoke(_newConsole, null);
				Msg("All floors unlocked!");
				return;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[GWYFUnleashed] CmdEnableAllFloors: " + ex.Message));
			}
		}
		if (_elevatorManager != null)
		{
			if (_fiIsLocked != null)
			{
				_fiIsLocked.SetValue(_elevatorManager, false);
			}
			if (_miRpcEnableAllButtons != null)
			{
				try
				{
					_miRpcEnableAllButtons.Invoke(_elevatorManager, null);
				}
				catch
				{
				}
			}
			Msg("Elevator unlocked.");
		}
		else
		{
			Msg("Load into a game first.");
		}
	}

	private void UnlockAllCosmetics()
	{
		if (_newConsole != null && _miUnlockAllCosmetics != null)
		{
			try
			{
				_miUnlockAllCosmetics.Invoke(_newConsole, null);
				Msg("All cosmetics unlocked!");
				return;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[GWYFUnleashed] UnlockAllCosmetics: " + ex.Message));
			}
		}
		if (_cosmeticsUnlockManager != null && _miUnlockCosmeticDirect != null && _miGetAllCosmetics != null)
		{
			try
			{
				object obj = (_miGetAllCosmetics.IsStatic ? _miGetAllCosmetics.Invoke(null, null) : _miGetAllCosmetics.Invoke(_cosmeticsUnlockManager, null));
				if (obj is IEnumerable enumerable)
				{
					int num = 0;
					foreach (object item in enumerable)
					{
						if (item == null)
						{
							continue;
						}
						FieldInfo field = item.GetType().GetField("cosmeticId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (!(field == null))
						{
							try
							{
								_miUnlockCosmeticDirect.Invoke(_cosmeticsUnlockManager, new object[1] { field.GetValue(item) });
								num++;
							}
							catch
							{
							}
						}
					}
					Msg($"Unlocked {num} cosmetics!");
					return;
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogWarning((object)("[GWYFUnleashed] Cosmetic fallback: " + ex2.Message));
			}
		}
		Msg("Try in the main menu or lobby.");
	}

	private void Msg(string s)
	{
		_status = s;
		_statusT = 3f;
		Plugin.Log.LogInfo((object)("[GWYFUnleashed] " + s));
	}
}
internal static class PluginInfo
{
	public const string PLUGIN_GUID = "com.yourname.gwyfunleashed";

	public const string PLUGIN_NAME = "GWYFUnleashed";

	public const string PLUGIN_VERSION = "1.0.0";
}