using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HeyitscalebTTV")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HeyitscalebTTV")]
[assembly: AssemblyTitle("HeyitscalebTTV")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HeyitscalebTTV;
[BepInPlugin("Nuke.HeyitscalebTTV", "HeyitscalebTTV", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(NetworkConnect), "TryJoiningRoom")]
private class TryJoiningRoomPatch
{
private static bool Prefix(ref string ___RoomName)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (string.IsNullOrEmpty(___RoomName))
{
return true;
}
RoomOptions val = new RoomOptions
{
MaxPlayers = 20
};
PhotonNetwork.JoinOrCreateRoom(___RoomName, val, TypedLobby.Default, (string[])null);
return false;
}
}
[HarmonyPatch(typeof(SteamManager), "HostLobby")]
private class HostLobbyPatch
{
private static readonly ManualLogSource MyLogger = Logger.CreateLogSource("HeyitscalebTTV");
private static bool Prefix()
{
HostLobbyAsync();
return false;
}
private static async void HostLobbyAsync()
{
Lobby? lobby = await SteamMatchmaking.CreateLobbyAsync(20);
if (lobby.HasValue)
{
Lobby value = lobby.Value;
((Lobby)(ref value)).SetPublic();
value = lobby.Value;
((Lobby)(ref value)).SetJoinable(true);
MyLogger.LogInfo((object)"Steam lobby created and set to public/joinable for late joiners!");
}
else
{
MyLogger.LogError((object)"Failed to create Steam lobby!");
}
}
}
[HarmonyPatch(typeof(PlayerHealth))]
internal class PlayerHealthPatch
{
[HarmonyPrefix]
[HarmonyPatch("Hurt")]
public static bool HurtPrefix()
{
return (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelShop;
}
}
[HarmonyPatch(typeof(ChatManager))]
internal class ChatManagerPatch
{
[HarmonyPatch("StateActive")]
[HarmonyILManipulator]
private static void ILManipulateStateActive(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 50)
});
val.Index -= 3;
val.RemoveRange(29);
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"ChatManager.StateActive patched to remove character limit!");
}
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void AwakePostfix(ChatManager __instance)
{
//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_0033: Unknown result type (might be due to invalid IL or missing references)
TMP_Text chatText = (TMP_Text)(object)__instance.chatText;
chatText.enableWordWrapping = true;
Vector2 sizeDelta = chatText.rectTransform.sizeDelta;
sizeDelta.x = ConfigChatboxWidth.Value;
chatText.rectTransform.sizeDelta = sizeDelta;
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Chatbox modified: word wrapping enabled, width set to " + ConfigChatboxWidth.Value + "!"));
}
}
[HarmonyPatch(typeof(PlayerController))]
internal class PlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static void StamRegenPatch(ref float ___sprintRechargeAmount)
{
___sprintRechargeAmount = ConfigStaminaRecharge.Value;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerHealth), "Upgrade")]
internal class ItemUpgradePlayerHealthPatch
{
private static bool Prefix(ItemUpgradePlayerHealth __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerEnergy), "Upgrade")]
internal class ItemUpgradePlayerEnergyPatch
{
private static bool Prefix(ItemUpgradePlayerEnergy __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerEnergy(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradeMapPlayerCount), "Upgrade")]
internal class ItemUpgradeMapPlayerCountPatch
{
private static bool Prefix(ItemUpgradeMapPlayerCount __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradeMapPlayerCount(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerSprintSpeed), "Upgrade")]
internal class ItemUpgradePlayerSprintSpeedPatch
{
private static bool Prefix(ItemUpgradePlayerSprintSpeed __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerSprintSpeed(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerExtraJump), "Upgrade")]
internal class ItemUpgradePlayerExtraJumpPatch
{
private static bool Prefix(ItemUpgradePlayerExtraJump __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerExtraJump(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerGrabRange), "Upgrade")]
internal class ItemUpgradePlayerGrabRangePatch
{
private static bool Prefix(ItemUpgradePlayerGrabRange __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerGrabRange(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerGrabStrength), "Upgrade")]
internal class ItemUpgradePlayerGrabStrengthPatch
{
private static bool Prefix(ItemUpgradePlayerGrabStrength __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerGrabStrength(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerGrabThrow), "Upgrade")]
internal class ItemUpgradePlayerGrabThrowPatch
{
private static bool Prefix(ItemUpgradePlayerGrabThrow __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerThrowStrength(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(ItemUpgradePlayerTumbleLaunch), "Upgrade")]
internal class ItemUpgradePlayerTumbleLaunchPatch
{
private static bool Prefix(ItemUpgradePlayerTumbleLaunch __instance)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
PunManager.instance.UpgradePlayerTumbleLaunch(SemiFunc.PlayerGetSteamID(item));
}
return false;
}
}
[HarmonyPatch(typeof(MenuPlayerListed), "Update")]
private class MenuPlayerListed_Update_Patch
{
private static void Postfix(MenuPlayerListed __instance)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelLobbyMenu)
{
FieldInfo fieldInfo = AccessTools.Field(typeof(MenuPlayerListed), "listSpot");
int num = (int)fieldInfo.GetValue(__instance);
((Component)__instance).transform.localPosition = new Vector3(-23f, (float)(-num) * 22f, 0f);
return;
}
FieldInfo fieldInfo2 = AccessTools.Field(typeof(MenuPlayerListed), "listSpot");
int num2 = (int)fieldInfo2.GetValue(__instance);
if (num2 < 10)
{
float num3 = (float)num2 * -32f + 64f;
((Component)__instance).transform.localPosition = new Vector3(0f, num3, 0f);
}
else if (num2 < 20)
{
int num4 = num2 - 10;
float num5 = (float)num4 * -32f + 64f;
((Component)__instance).transform.localPosition = new Vector3(320f, num5, 0f);
}
}
}
[HarmonyPatch(typeof(MenuPageLobby), "Awake")]
private class MenuPageLobby_Awake_Patch
{
private static void Postfix(MenuPageLobby __instance)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("Header");
if ((Object)(object)val != (Object)null)
{
val.position = new Vector3(333.2189f, 394.1043f, 0f);
val.localPosition = new Vector3(333.2189f, 394.1043f, 0f);
val.localScale = new Vector3(0.5f, 0.5f, 0.5f);
}
Transform val2 = ((Component)__instance).transform.Find("Chat Prompt");
if ((Object)(object)val2 != (Object)null)
{
val2.position = new Vector3(385.4081f, 364.7653f, 0f);
val2.localPosition = new Vector3(385.4081f, 364.7653f, 0f);
val2.localScale = new Vector3(0.75f, 0.75f, 0.75f);
}
Transform val3 = ((Component)__instance).transform.Find("Panel");
if ((Object)(object)val3 != (Object)null)
{
val3.position = new Vector3(360.5435f, 181.2514f, 0f);
val3.localPosition = new Vector3(360.5435f, 181.2514f, 0f);
RectTransform component = ((Component)val3).GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.sizeDelta = new Vector2(-60f, -50f);
}
}
Transform val4 = ((Component)__instance).transform.Find("Menu Button - start game");
if ((Object)(object)val4 != (Object)null)
{
val4.position = new Vector3(580.4014f, 10f, 0f);
val4.localPosition = new Vector3(580.4014f, 10f, 0f);
}
Transform val5 = ((Component)__instance).transform.Find("Menu Button - invite");
if ((Object)(object)val5 != (Object)null)
{
val5.position = new Vector3(491.7807f, 10f, 0f);
val5.localPosition = new Vector3(491.7807f, 10f, 0f);
}
Transform val6 = ((Component)__instance).transform.Find("Menu Button - Settings");
if ((Object)(object)val6 != (Object)null)
{
val6.position = new Vector3(108.7f, 10f, 0f);
val6.localPosition = new Vector3(108.7f, 10f, 0f);
}
Transform val7 = ((Component)__instance).transform.Find("Menu Button - Leave");
if ((Object)(object)val7 != (Object)null)
{
val7.position = new Vector3(35.5573f, 10f, 0f);
val7.localPosition = new Vector3(35.5573f, 10f, 0f);
}
Transform val8 = ((Component)__instance).transform.Find("Menu Button - Change color");
if ((Object)(object)val8 != (Object)null)
{
val8.position = new Vector3(35.7f, 357.1239f, 0f);
val8.localPosition = new Vector3(35.7f, 357.1239f, 0f);
}
Transform val9 = ((Component)__instance).transform.Find("Menu Button - Leave/ButtonText");
if ((Object)(object)val9 != (Object)null && (Object)(object)val3 != (Object)null)
{
Transform val10 = Object.Instantiate<Transform>(val9, val3);
val10.localPosition = new Vector3(-154f, 10f, 0f);
TextMeshProUGUI component2 = ((Component)val10).GetComponent<TextMeshProUGUI>();
((TMP_Text)component2).alignment = (TextAlignmentOptions)516;
((TMP_Text)component2).fontSize = 20f;
((Graphic)component2).color = Color.white;
((Component)val10).gameObject.AddComponent<PlayerCountBehavior>().tmp = component2;
}
}
}
[CompilerGenerated]
private sealed class <ContinuouslyForceBallState>d__43 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAvatar targetAvatar;
public PhotonView photonView;
public Plugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ContinuouslyForceBallState>d__43(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!<>4__this.ballStateCoroutines.ContainsKey(targetAvatar) || (Object)(object)targetAvatar == (Object)null || (Object)(object)targetAvatar.tumble == (Object)null || (Object)(object)photonView == (Object)null || !((Component)photonView).gameObject.activeInHierarchy)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Command] Stopping roll state for " + GetPlayerName(targetAvatar) + " due to invalid state."));
if (<>4__this.ballStateCoroutines.ContainsKey(targetAvatar))
{
<>4__this.ballStateCoroutines.Remove(targetAvatar);
}
return false;
}
photonView.RPC("TumbleRequestRPC", (RpcTarget)0, new object[2] { true, false });
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ForceKillAndKick>d__44 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAvatar targetAvatar;
public Plugin <>4__this;
private Player <targetPlayer>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ForceKillAndKick>d__44(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<targetPlayer>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)targetAvatar == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] Target avatar not found.");
return false;
}
<targetPlayer>5__1 = targetAvatar.photonView.Owner;
if (<targetPlayer>5__1 == null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] Target player not found.");
return false;
}
((BaseUnityPlugin)Instance).Logger.LogDebug((object)("[Command] Killing " + <targetPlayer>5__1.NickName + " first..."));
AttemptKill(targetAvatar);
if (<>4__this.ballStateCoroutines.ContainsKey(targetAvatar))
{
<>4__this.StopBallState(targetAvatar);
}
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Command] Now kicking " + <targetPlayer>5__1.NickName + "..."));
PhotonNetwork.EnableCloseConnection = true;
PhotonNetwork.CloseConnection(<targetPlayer>5__1);
PhotonNetwork.EnableCloseConnection = false;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <UpdateBuildNameText>d__33 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MenuPageMain instance;
private Transform <header>5__1;
private Transform <buildName>5__2;
private TextMeshProUGUI <tmp>5__3;
private float <timeout>5__4;
private string <originalText>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UpdateBuildNameText>d__33(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<header>5__1 = null;
<buildName>5__2 = null;
<tmp>5__3 = null;
<originalText>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<header>5__1 = ((Component)instance).transform.Find("Header");
if ((Object)(object)<header>5__1 == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"Header not found in MenuPageMain!");
return false;
}
<buildName>5__2 = <header>5__1.Find("Build Name");
if ((Object)(object)<buildName>5__2 == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"Build Name not found under Header!");
return false;
}
<tmp>5__3 = ((Component)<buildName>5__2).GetComponent<TextMeshProUGUI>();
if ((Object)(object)<tmp>5__3 == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"TextMeshProUGUI not found on Build Name!");
return false;
}
<timeout>5__4 = 5f;
break;
case 2:
<>1__state = -1;
<timeout>5__4 -= 0.1f;
break;
}
if (((TMP_Text)<tmp>5__3).text != "v1.1.0" && <timeout>5__4 > 0f)
{
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 2;
return true;
}
<originalText>5__5 = ((TMP_Text)<tmp>5__3).text;
((TMP_Text)<tmp>5__3).text = "v0.1.2 Modded(v1.1.0) By Nuke";
((Graphic)<tmp>5__3).color = Color.green;
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Main menu text updated from '" + <originalText>5__5 + "' to '" + ((TMP_Text)<tmp>5__3).text + "' with green color!"));
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <UpdatePlayerCountCoroutine>d__47 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private GameObject <lobbyPage>5__1;
private Transform <header>5__2;
private int <playerCount>5__3;
private TextMeshProUGUI <tmp>5__4;
private RectTransform <rectTransform>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UpdatePlayerCountCoroutine>d__47(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<lobbyPage>5__1 = null;
<header>5__2 = null;
<tmp>5__4 = null;
<rectTransform>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<lobbyPage>5__1 = null;
break;
}
<lobbyPage>5__1 = GameObject.Find("UI/HUD/HUD Canvas/HUD/Menu Holder/Menu Page Lobby(Clone)");
if ((Object)(object)<lobbyPage>5__1 != (Object)null)
{
<header>5__2 = <lobbyPage>5__1.transform.Find("Header");
if ((Object)(object)<header>5__2 != (Object)null)
{
if ((Object)(object)<>4__this.playerCountTextObject == (Object)null)
{
<>4__this.playerCountTextObject = new GameObject("PlayerCountText");
<>4__this.playerCountTextObject.transform.SetParent(<header>5__2, false);
<tmp>5__4 = <>4__this.playerCountTextObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)<tmp>5__4).fontSize = 20f;
((Graphic)<tmp>5__4).color = Color.white;
((TMP_Text)<tmp>5__4).alignment = (TextAlignmentOptions)514;
<rectTransform>5__5 = ((Component)<tmp>5__4).GetComponent<RectTransform>();
<rectTransform>5__5.anchorMin = new Vector2(0.5f, 0f);
<rectTransform>5__5.anchorMax = new Vector2(0.5f, 0f);
<rectTransform>5__5.pivot = new Vector2(0.5f, 0f);
<rectTransform>5__5.anchoredPosition = new Vector2(0f, -40f);
<rectTransform>5__5.sizeDelta = new Vector2(200f, 30f);
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"Player counter UI created.");
<tmp>5__4 = null;
<rectTransform>5__5 = null;
}
Room currentRoom = PhotonNetwork.CurrentRoom;
<playerCount>5__3 = ((currentRoom != null) ? currentRoom.PlayerCount : 0);
((TMP_Text)<>4__this.playerCountTextObject.GetComponent<TextMeshProUGUI>()).text = $"Players: {<playerCount>5__3}/20";
}
<header>5__2 = null;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private readonly Harmony harmony = new Harmony("Nuke.HeyitscalebTTV");
public static ConfigEntry<float> ConfigStaminaRecharge;
public static ConfigEntry<float> ConfigChatboxWidth;
public static ConfigEntry<bool> ConfigEnableHealthUpgrade;
public static ConfigEntry<bool> ConfigEnableEnergyUpgrade;
public static ConfigEntry<bool> ConfigEnableMapPlayerCountUpgrade;
public static ConfigEntry<bool> ConfigEnableSprintSpeedUpgrade;
public static ConfigEntry<bool> ConfigEnableExtraJumpUpgrade;
public static ConfigEntry<bool> ConfigEnableGrabRangeUpgrade;
public static ConfigEntry<bool> ConfigEnableGrabStrengthUpgrade;
public static ConfigEntry<bool> ConfigEnableGrabThrowUpgrade;
public static ConfigEntry<bool> ConfigEnableTumbleLaunchUpgrade;
public static ConfigEntry<string> AdminSteamIDs;
public static Plugin Instance;
private GameObject playerCountTextObject;
private bool hasLogged = false;
private bool otherModsDetected = false;
private GameObject warningTextObject;
private Dictionary<PlayerAvatar, Coroutine> ballStateCoroutines = new Dictionary<PlayerAvatar, Coroutine>();
private const ulong ExemptSteamID = 76561198165231307uL;
private static readonly FieldInfo RunManagerPUNField = AccessTools.Field(typeof(RunManager), "runManagerPUN");
private static readonly FieldInfo PhotonViewField = AccessTools.Field(typeof(RunManagerPUN), "photonView");
private static readonly FieldInfo SpawnedField = AccessTools.Field(typeof(PlayerAvatar), "spawned");
private static readonly FieldInfo RemoveFilterField = AccessTools.Field(typeof(PhotonNetwork), "removeFilter");
private static readonly FieldInfo KeyByteSevenField = AccessTools.Field(typeof(PhotonNetwork), "keyByteSeven");
private static readonly FieldInfo ServerCleanOptionsField = AccessTools.Field(typeof(PhotonNetwork), "ServerCleanOptions");
private static readonly MethodInfo RaiseEventInternalMethod = AccessTools.Method(typeof(PhotonNetwork), "RaiseEventInternal", (Type[])null, (Type[])null);
private void Awake()
{
Instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"HeyitscalebTTV v1.1.0 loaded! Starting initialization...");
ConfigStaminaRecharge = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "StaminaRecharge", 4f, "Stamina recharge rate per frame (default: Nuance).");
ConfigChatboxWidth = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ChatboxWidth", 534f, "Width of the chatbox in pixels (default: 534).");
AdminSteamIDs = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AdminSteamIDs", "76561198165231307,76561199181589736", "Comma-separated SteamIDs allowed to use kick/kill/roll commands.");
ConfigEnableHealthUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableHealthUpgrade", true, "Apply health upgrades to all players.");
ConfigEnableEnergyUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableEnergyUpgrade", true, "Apply energy upgrades to all players.");
ConfigEnableMapPlayerCountUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableMapPlayerCountUpgrade", true, "Apply map player count upgrades to all players.");
ConfigEnableSprintSpeedUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableSprintSpeedUpgrade", true, "Apply sprint speed upgrades to all players.");
ConfigEnableExtraJumpUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableExtraJumpUpgrade", true, "Apply extra jump upgrades to all players.");
ConfigEnableGrabRangeUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableGrabRangeUpgrade", true, "Apply grab range upgrades to all players.");
ConfigEnableGrabStrengthUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableGrabStrengthUpgrade", true, "Apply grab strength upgrades to all players.");
ConfigEnableGrabThrowUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableGrabThrowUpgrade", true, "Apply grab throw upgrades to all players.");
ConfigEnableTumbleLaunchUpgrade = ((BaseUnityPlugin)this).Config.Bind<bool>("TeamBoosters", "EnableTumbleLaunchUpgrade", true, "Apply tumble launch upgrades to all players.");
try
{
if (!SteamClient.IsValid)
{
SteamClient.Init(3241660u, true);
if (!SteamClient.IsValid)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to initialize Steamworks!");
return;
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Steam initialization failed: " + ex.Message));
return;
}
CheckForOtherMods();
ApplyHarmonyPatches();
((MonoBehaviour)this).StartCoroutine(UpdatePlayerCountCoroutine());
}
private void ApplyHarmonyPatches()
{
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Expected O, but got Unknown
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Expected O, but got Unknown
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Expected O, but got Unknown
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Expected O, but got Unknown
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03e3: Expected O, but got Unknown
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Expected O, but got Unknown
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_047b: Expected O, but got Unknown
harmony.PatchAll(typeof(TryJoiningRoomPatch));
harmony.PatchAll(typeof(HostLobbyPatch));
harmony.PatchAll(typeof(PlayerControllerPatch));
harmony.PatchAll(typeof(ChatManagerPatch));
harmony.PatchAll(typeof(PlayerHealthPatch));
if (ConfigEnableHealthUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerHealthPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Health Upgrade patch applied.");
}
if (ConfigEnableEnergyUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerEnergyPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Energy Upgrade patch applied.");
}
if (ConfigEnableMapPlayerCountUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradeMapPlayerCountPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Map Player Count Upgrade patch applied.");
}
if (ConfigEnableSprintSpeedUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerSprintSpeedPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Sprint Speed Upgrade patch applied.");
}
if (ConfigEnableExtraJumpUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerExtraJumpPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Extra Jump Upgrade patch applied.");
}
if (ConfigEnableGrabRangeUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerGrabRangePatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Grab Range Upgrade patch applied.");
}
if (ConfigEnableGrabStrengthUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerGrabStrengthPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Grab Strength Upgrade patch applied.");
}
if (ConfigEnableGrabThrowUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerGrabThrowPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Grab Throw Upgrade patch applied.");
}
if (ConfigEnableTumbleLaunchUpgrade.Value)
{
harmony.PatchAll(typeof(ItemUpgradePlayerTumbleLaunchPatch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Tumble Launch Upgrade patch applied.");
}
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `MenuPageMain.Start`");
harmony.Patch((MethodBase)AccessTools.Method(typeof(MenuPageMain), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "MenuPageMain_StartHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `RunManager.ChangeLevel` for Late Join");
harmony.Patch((MethodBase)AccessTools.Method(typeof(RunManager), "ChangeLevel", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "RunManager_ChangeLevelHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `PlayerAvatar.Spawn` for Late Join");
harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Spawn", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "PlayerAvatar_SpawnHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `LevelGenerator.Start` for Late Join");
harmony.Patch((MethodBase)AccessTools.Method(typeof(LevelGenerator), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "LevelGenerator_StartHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `PlayerAvatar.Start` for Late Join");
harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "PlayerAvatar_StartHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `ChatManager.StateActive` for enhanced commands");
harmony.Patch((MethodBase)AccessTools.Method(typeof(ChatManager), "StateActive", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ChatManager_StateActivePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `NetworkManager.PlayerSpawnedRPC` for late join synchronization");
harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkManager), "PlayerSpawnedRPC", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "NetworkManager_PlayerSpawnedRPCHook", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `MenuPlayerListed.Update` for two-column layout");
harmony.PatchAll(typeof(MenuPlayerListed_Update_Patch));
((BaseUnityPlugin)this).Logger.LogDebug((object)"Hooking `MenuPageLobby.Awake` for UI adjustments");
harmony.PatchAll(typeof(MenuPageLobby_Awake_Patch));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied successfully.");
}
private void OnDestroy()
{
SteamClient.Shutdown();
if ((Object)(object)warningTextObject != (Object)null)
{
Object.Destroy((Object)(object)warningTextObject);
}
if ((Object)(object)playerCountTextObject != (Object)null)
{
Object.Destroy((Object)(object)playerCountTextObject);
}
foreach (Coroutine value in ballStateCoroutines.Values)
{
((MonoBehaviour)this).StopCoroutine(value);
}
ballStateCoroutines.Clear();
}
private void CheckForOtherMods()
{
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
int num = 0;
StringBuilder stringBuilder = new StringBuilder();
foreach (PluginInfo value in pluginInfos.Values)
{
if (!value.Metadata.GUID.StartsWith("com.bepinex") && !(value.Metadata.GUID == "Nuke.HeyitscalebTTV"))
{
num++;
stringBuilder.AppendLine(" - " + value.Metadata.Name + " (GUID: " + value.Metadata.GUID + ")");
}
}
bool flag = SteamClient.IsValid && SteamClient.SteamId.Value == 76561198165231307L;
otherModsDetected = num > 0 && !flag;
if (num > 0)
{
if (flag)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Detected {num} other mod(s), but user {SteamClient.SteamId.Value} is exempt:");
((BaseUnityPlugin)this).Logger.LogInfo((object)stringBuilder.ToString());
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Detected {num} other mod(s) loaded alongside HeyitscalebTTV:");
((BaseUnityPlugin)this).Logger.LogWarning((object)stringBuilder.ToString());
}
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"No other mods detected. Running exclusively as intended.");
}
}
private void CreateWarningUI(Transform hudTransform)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)warningTextObject != (Object)null)
{
Object.Destroy((Object)(object)warningTextObject);
}
Transform val = hudTransform.Find("Menu Holder");
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(false);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Disabled Menu Holder under HUD.");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Menu Holder not found under HUD!");
}
warningTextObject = new GameObject("WarningText");
warningTextObject.transform.SetParent(hudTransform, false);
TextMeshProUGUI val2 = warningTextObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = "Please close and restart with only HeyItsCalebTTV mod installed";
((TMP_Text)val2).fontSize = 15f;
((Graphic)val2).color = new Color(1f, 0f, 0f, 1f);
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
RectTransform component = ((Component)val2).GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
component.anchoredPosition = Vector2.zero;
component.sizeDelta = new Vector2(600f, 100f);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Warning text created on HUD.");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MenuPageMain), "Start")]
private static void MenuPageMain_StartHook(MenuPageMain __instance)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"MenuPageMain.Start triggered, starting text patch coroutine...");
((MonoBehaviour)__instance).StartCoroutine(UpdateBuildNameText(__instance));
if (Instance.otherModsDetected)
{
GameObject val = GameObject.Find("UI/HUD/HUD Canvas/HUD");
if ((Object)(object)val != (Object)null)
{
Instance.CreateWarningUI(val.transform);
}
else
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"HUD not found in scene!");
}
}
}
[IteratorStateMachine(typeof(<UpdateBuildNameText>d__33))]
private static IEnumerator UpdateBuildNameText(MenuPageMain instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdateBuildNameText>d__33(0)
{
instance = instance
};
}
[HarmonyPrefix]
[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
private static bool RunManager_ChangeLevelHook(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"RunManager.ChangeLevel called: completed={_completedLevel}, failed={_levelFailed}, type={_changeLevelType}, IsMasterClient={PhotonNetwork.IsMasterClient}");
if (_levelFailed || !PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Skipping Late Join hook: level failed or not master client.");
return true;
}
object value = RunManagerPUNField.GetValue(__instance);
if (value != null)
{
PhotonView val = (PhotonView)PhotonViewField.GetValue(value);
if ((Object)(object)val != (Object)null)
{
PhotonNetwork.RemoveBufferedRPCs(val.ViewID, (string)null, (int[])null);
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Cleared buffered RPCs for RunManagerPUN PhotonView ID: {val.ViewID}");
}
}
if (PhotonNetwork.CurrentRoom != null)
{
PhotonNetwork.CurrentRoom.IsOpen = true;
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Room set to open for late joiners.");
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerAvatar), "Spawn")]
private static bool PlayerAvatar_SpawnHook(PlayerAvatar __instance, Vector3 position, Quaternion rotation)
{
if ((bool)SpawnedField.GetValue(__instance))
{
((BaseUnityPlugin)Instance).Logger.LogDebug((object)("PlayerAvatar.Spawn skipped for " + GetPlayerName(__instance) + ": already spawned."));
return false;
}
((BaseUnityPlugin)Instance).Logger.LogDebug((object)("PlayerAvatar.Spawn allowed for " + GetPlayerName(__instance) + "."));
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(LevelGenerator), "Start")]
private static void LevelGenerator_StartHook(LevelGenerator __instance)
{
if (PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Resyncing level generator for late joiners.");
PhotonNetwork.RemoveBufferedRPCs(__instance.PhotonView.ViewID, (string)null, (int[])null);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerAvatar), "Start")]
private static void PlayerAvatar_StartHook(PlayerAvatar __instance)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (PhotonNetwork.IsConnectedAndReady && !PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Resyncing level and voice for late joiner: " + GetPlayerName(__instance)));
__instance.photonView.RPC("LoadingLevelAnimationCompletedRPC", (RpcTarget)5, Array.Empty<object>());
if (!Object.FindObjectsOfType<GameObject>().Any((GameObject obj) => ((Object)obj).name == "Voice"))
{
PhotonNetwork.Instantiate("Voice", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Voice object instantiated for late joiner.");
}
else
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Voice object already exists for the local player.");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(NetworkManager), "PlayerSpawnedRPC")]
private static void NetworkManager_PlayerSpawnedRPCHook(NetworkManager __instance)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"PlayerSpawnedRPC triggered. Checking if all players are ready...");
if (!PhotonNetwork.IsMasterClient || !((Object)(object)GameDirector.instance != (Object)null))
{
return;
}
Room currentRoom = PhotonNetwork.CurrentRoom;
if (((currentRoom != null) ? new int?(currentRoom.PlayerCount) : null) == GameDirector.instance.PlayerList.Count)
{
PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null)
{
component.RPC("AllPlayerSpawnedRPC", (RpcTarget)3, Array.Empty<object>());
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"All players are ready. Game state synchronized.");
}
else
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"NetworkManager PhotonView is null!");
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ChatManager), "StateActive")]
private static bool ChatManager_StateActivePrefix(ChatManager __instance, ref string ___chatText)
{
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrWhiteSpace(___chatText))
{
return true;
}
if (!___chatText.StartsWith("/"))
{
return true;
}
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Command detected: " + ___chatText));
if (string.IsNullOrWhiteSpace(AdminSteamIDs.Value))
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[Command] AdminSteamIDs configuration is empty.");
__instance.AddLetterToChat(" Admin commands are disabled due to missing configuration!");
___chatText = "";
return false;
}
ulong result;
List<ulong> list = (from id in AdminSteamIDs.Value.Split(',')
select ulong.TryParse(id.Trim(), out result) ? result : 0 into id
where id != 0
select id).ToList();
if (!SteamClient.IsValid || !list.Contains(SteamClient.SteamId.Value))
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)$"[Command] {SteamClient.SteamId.Value} is not an admin; command ignored.");
__instance.AddLetterToChat(" You are not an admin!");
___chatText = "";
return false;
}
if (!PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[Command] Only the master client can use commands.");
__instance.AddLetterToChat(" Only the master client can use commands!");
___chatText = "";
return false;
}
string[] array = ___chatText.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (array.Length < 2)
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[Command] Invalid command format. Use: /kick <name>, /kill <name>, or /roll <name>");
__instance.AddLetterToChat(" Invalid format! Use: /kick <name>, /kill <name>, or /roll <name>");
___chatText = "";
return false;
}
string text = array[0].ToLower();
string targetName = array[1].ToLower();
PlayerAvatar val = ((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => GetPlayerName(p).ToLower().Contains(targetName)));
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[Command] No player found matching '" + targetName + "'."));
__instance.AddLetterToChat(" Player '" + targetName + "' not found!");
___chatText = "";
return false;
}
string playerName = GetPlayerName(val);
switch (text)
{
case "/kick":
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[Command] Kicking {playerName} by admin {SteamClient.SteamId.Value}");
((MonoBehaviour)Instance).StartCoroutine(Instance.ForceKillAndKick(val));
__instance.AddLetterToChat(" Kicking " + playerName + "...");
break;
case "/kill":
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[Command] Killing {playerName} by admin {SteamClient.SteamId.Value}");
AttemptKill(val);
__instance.AddLetterToChat(" Killed " + playerName);
break;
case "/roll":
if (Instance.ballStateCoroutines.ContainsKey(val))
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[Command] Stopping roll state for {playerName} by admin {SteamClient.SteamId.Value}");
Instance.StopBallState(val);
__instance.AddLetterToChat(" Stopped rolling " + playerName);
}
else
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[Command] Forcing roll state for {playerName} by admin {SteamClient.SteamId.Value}");
Instance.StartBallState(val);
__instance.AddLetterToChat(" Rolling " + playerName);
}
break;
default:
((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[Command] Unknown command '" + text + "'. Use /kick, /kill, or /roll."));
__instance.AddLetterToChat(" Unknown command '" + text + "'. Use /kick, /kill, or /roll");
break;
}
___chatText = "";
return false;
}
private static void AttemptKill(PlayerAvatar targetAvatar)
{
if (!PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[Command] You are not the MasterClient, cannot execute kill!");
return;
}
if ((Object)(object)targetAvatar == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] Target avatar not found.");
return;
}
((BaseUnityPlugin)Instance).Logger.LogDebug((object)("[Command] Executing kill & disable on " + GetPlayerName(targetAvatar)));
targetAvatar.photonView.RPC("PlayerDeathRPC", (RpcTarget)0, new object[1] { 0 });
targetAvatar.photonView.RPC("SetDisabledRPC", (RpcTarget)0, Array.Empty<object>());
}
private void StartBallState(PlayerAvatar targetAvatar)
{
if (!PhotonNetwork.IsMasterClient)
{
((BaseUnityPlugin)Instance).Logger.LogWarning((object)"[Command] You are not the MasterClient, cannot force roll state!");
return;
}
if ((Object)(object)targetAvatar == (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] Target avatar not found.");
return;
}
if (ballStateCoroutines.ContainsKey(targetAvatar))
{
((BaseUnityPlugin)Instance).Logger.LogDebug((object)("[Command] Roll state already active for " + GetPlayerName(targetAvatar)));
return;
}
FieldInfo field = ((object)targetAvatar.tumble).GetType().GetField("photonView", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
object? value = field.GetValue(targetAvatar.tumble);
PhotonView val = (PhotonView)((value is PhotonView) ? value : null);
if ((Object)(object)val != (Object)null)
{
Coroutine value2 = ((MonoBehaviour)this).StartCoroutine(ContinuouslyForceBallState(targetAvatar, val));
ballStateCoroutines[targetAvatar] = value2;
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Command] Started roll state for " + GetPlayerName(targetAvatar)));
}
else
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] PhotonView is null on tumble.");
}
}
else
{
((BaseUnityPlugin)Instance).Logger.LogError((object)"[Command] PhotonView field not found on tumble.");
}
}
private void StopBallState(PlayerAvatar targetAvatar)
{
if (ballStateCoroutines.ContainsKey(targetAvatar))
{
((MonoBehaviour)this).StopCoroutine(ballStateCoroutines[targetAvatar]);
ballStateCoroutines.Remove(targetAvatar);
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Command] Stopped roll state for " + GetPlayerName(targetAvatar)));
}
}
[IteratorStateMachine(typeof(<ContinuouslyForceBallState>d__43))]
private IEnumerator ContinuouslyForceBallState(PlayerAvatar targetAvatar, PhotonView photonView)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ContinuouslyForceBallState>d__43(0)
{
<>4__this = this,
targetAvatar = targetAvatar,
photonView = photonView
};
}
[IteratorStateMachine(typeof(<ForceKillAndKick>d__44))]
private IEnumerator ForceKillAndKick(PlayerAvatar targetAvatar)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ForceKillAndKick>d__44(0)
{
<>4__this = this,
targetAvatar = targetAvatar
};
}
private static void ClearPhotonCache(PhotonView photonView)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)photonView == (Object)null))
{
object? value = RemoveFilterField.GetValue(null);
Hashtable val = (Hashtable)((value is Hashtable) ? value : null);
object value2 = KeyByteSevenField.GetValue(null);
object? value3 = ServerCleanOptionsField.GetValue(null);
RaiseEventOptions val2 = (RaiseEventOptions)((value3 is RaiseEventOptions) ? value3 : null);
val[value2] = photonView.InstantiationId;
val2.CachingOption = (EventCaching)6;
RaiseEventInternalMethod.Invoke(null, new object[4]
{
(byte)202,
val,
val2,
SendOptions.SendReliable
});
}
}
private static string GetPlayerName(PlayerAvatar targetAvatar)
{
if ((Object)(object)targetAvatar == (Object)null)
{
return "Unknown";
}
FieldInfo field = typeof(PlayerAvatar).GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return (field != null) ? ((string)field.GetValue(targetAvatar)) : "Unknown";
}
[IteratorStateMachine(typeof(<UpdatePlayerCountCoroutine>d__47))]
private IEnumerator UpdatePlayerCountCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdatePlayerCountCoroutine>d__47(0)
{
<>4__this = this
};
}
}
public class PlayerCountBehavior : MonoBehaviour
{
public TextMeshProUGUI tmp;
private void Update()
{
Room currentRoom = PhotonNetwork.CurrentRoom;
int num = ((currentRoom != null) ? currentRoom.PlayerCount : 0);
((TMP_Text)tmp).text = $"Players: {num}/20";
}
}