using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LoadingInfo.Patches;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("chuxiaaaa")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("LoadingInfo")]
[assembly: AssemblyFileVersion("1.0.9.0")]
[assembly: AssemblyInformationalVersion("1.0.9+11a936a70019caef8815bf830c97cbfab66bfb07")]
[assembly: AssemblyProduct("LoadingInfo")]
[assembly: AssemblyTitle("LoadingInfo")]
[assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.9.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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;
}
}
}
[BepInPlugin("LoadingInfo", "LoadingInfo", "1.0.9")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Log;
public static ConfigEntry<float> LoadTextY { get; set; }
public static ConfigEntry<float> LoadingTipsY { get; set; }
public static ConfigEntry<int> NameMaxLength { get; set; }
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(typeof(RoundManagerPatch), (string)null);
Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch), (string)null);
Harmony.CreateAndPatchAll(typeof(HUDManagerPatch), (string)null);
LoadTextY = ((BaseUnityPlugin)this).Config.Bind<float>("LoadTipCompat", "LoadTextY", 100f, (ConfigDescription)null);
LoadingTipsY = ((BaseUnityPlugin)this).Config.Bind<float>("LoadTipCompat", "LoadingTipsY", 0f, (ConfigDescription)null);
NameMaxLength = ((BaseUnityPlugin)this).Config.Bind<int>("LoadingInfo", "NameMaxLength", -1, (ConfigDescription)null);
Log.LogInfo((object)"Plugin LoadingInfo is loaded!");
}
}
internal static class LCMPluginInfo
{
public const string PLUGIN_GUID = "LoadingInfo";
public const string PLUGIN_NAME = "LoadingInfo";
public const string PLUGIN_VERSION = "1.0.9";
}
namespace LoadingInfo.Patches
{
[HarmonyPatch(typeof(RoundManager))]
[HarmonyWrapSafe]
public static class RoundManagerPatch
{
public static List<ulong> CallFinishedGeneratingLevelServerRpc { get; set; } = new List<ulong>();
[HarmonyPrefix]
[HarmonyPatch("__rpc_handler_192551691")]
public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return FinishedGeneratingLevelServerRpc(rpcParams.Server.Receive.SenderClientId);
}
public static bool FinishedGeneratingLevelServerRpc(ulong clientId)
{
if (GameNetworkManager.Instance.connectedPlayers == 1)
{
return true;
}
if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
return true;
}
if (!CallFinishedGeneratingLevelServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId)
{
CallFinishedGeneratingLevelServerRpc.Add(clientId);
}
int num = RoundManager.Instance.playersFinishedGeneratingFloor.Count + 1;
List<string> list = new List<string>();
List<ulong> list2 = new List<ulong>();
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.isPlayerControlled && !val.isHostPlayerObject && !CallFinishedGeneratingLevelServerRpc.Contains(val.actualClientId))
{
list.Add(val.playerUsername);
list2.Add(val.actualClientId);
}
}
if (num != GameNetworkManager.Instance.connectedPlayers)
{
list = list.GetRange(0, (list.Count > 3) ? 3 : list.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Random seed: {0}\r\n\r\nPlayers loaded: {1}/{2}\r\n{3}", HUDManager.Instance.playersManager.randomMapSeed, num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list));
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
HUDManager.Instance.AddTextToChatOnServer(string.Format("<size=0>LoadingInfo,1,{0},{1},{2},{3}</size>", clientId, num, GameNetworkManager.Instance.connectedPlayers, string.Join(";", list2)), -1);
}
}
else
{
((TMP_Text)HUDManager.Instance.loadingText).text = $"Random seed: {HUDManager.Instance.playersManager.randomMapSeed}\r\n\r\nAll players loaded!";
CallFinishedGeneratingLevelServerRpc = new List<ulong>();
}
return true;
}
}
[HarmonyPatch(typeof(HUDManager))]
[HarmonyWrapSafe]
public static class HUDManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
[HarmonyAfter(new string[] { "Enova.LoadingTips" })]
public static void SetLoadingTips(HUDManager __instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Systems/UI/Canvas/LoadingText/LoadingTips");
if ((Object)(object)val != (Object)null)
{
GameObject val2 = GameObject.Find("Systems/UI/Canvas/LoadingText/LoadText");
RectTransform component = val2.GetComponent<RectTransform>();
component.anchoredPosition3D = new Vector3(component.anchoredPosition3D.x, component.anchoredPosition3D.y + Plugin.LoadTextY.Value, component.anchoredPosition3D.z);
RectTransform component2 = val.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0f);
component2.anchorMax = new Vector2(0.5f, 0f);
component2.pivot = new Vector2(0.5f, 0f);
component2.anchoredPosition = new Vector2(0f, Plugin.LoadingTipsY.Value);
}
}
[HarmonyPatch("AddChatMessage")]
[HarmonyPrefix]
public static bool AddChatMessage(string chatMessage, string nameOfUserWhoTyped = "", int playerWhoSent = -1, bool dontRepeat = false)
{
if (chatMessage.StartsWith("<size=0>LoadingInfo,"))
{
return false;
}
return true;
}
[HarmonyPatch("AddTextMessageClientRpc")]
[HarmonyPrefix]
public static bool AddTextMessageClientRpc(string chatMessage)
{
if (chatMessage.StartsWith("<size=0>LoadingInfo,"))
{
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
return true;
}
Plugin.Log.LogInfo((object)("LoadingInfoCmd:" + chatMessage));
string[] array = chatMessage.Replace("<size=0>LoadingInfo,", "").Replace("</size>", "").Split(",");
switch (array[0])
{
case "1":
{
List<string> list2 = new List<string>();
if (!string.IsNullOrWhiteSpace(array[4]))
{
string[] array3 = array[4].Split(";");
foreach (string s2 in array3)
{
list2.Add(StartOfRound.Instance.allPlayerScripts[int.Parse(s2)].playerUsername);
}
list2 = list2.GetRange(0, (list2.Count > 3) ? 3 : list2.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list2 = list2.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Random seed: {0}\r\n\r\nPlayers loaded: {1}/{2}\r\n{3}", HUDManager.Instance.playersManager.randomMapSeed, array[2], array[3], string.Join(",", list2));
}
else
{
((TMP_Text)HUDManager.Instance.loadingText).text = $"Random seed: {HUDManager.Instance.playersManager.randomMapSeed}\r\n\r\nAll players loaded!";
}
break;
}
case "2":
{
List<string> list3 = new List<string>();
if (!string.IsNullOrWhiteSpace(array[4]))
{
((Behaviour)HUDManager.Instance.loadingText).enabled = true;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = true;
string[] array4 = array[4].Split(";");
foreach (string s3 in array4)
{
list3.Add(StartOfRound.Instance.allPlayerScripts[int.Parse(s3)].playerUsername);
}
list3 = list3.GetRange(0, (list3.Count > 3) ? 3 : list3.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list3 = list3.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for Client...\r\n\r\nPlayers loaded: {0}/{1}\r\n{2}", array[2], array[3], string.Join(",", list3));
}
else
{
((Behaviour)HUDManager.Instance.loadingText).enabled = false;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = false;
}
break;
}
case "3":
{
List<string> list = new List<string>();
if (!string.IsNullOrWhiteSpace(array[4]))
{
string[] array2 = array[4].Split(";");
foreach (string s in array2)
{
list.Add(StartOfRound.Instance.allPlayerScripts[int.Parse(s)].playerUsername);
}
list = list.GetRange(0, (list.Count > 3) ? 3 : list.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for crew...\r\n\r\nPlayers loaded: {0}/{1}\r\n{2}", array[2], array[3], string.Join(",", list));
}
else
{
((TMP_Text)HUDManager.Instance.loadingText).text = $"Waiting for crew...\r\n\r\nAll players loaded!";
}
break;
}
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyWrapSafe]
public static class StartOfRoundPatch
{
public static List<ulong> CallPlayerLoadedServerRpc { get; set; } = new List<ulong>();
public static List<ulong> CallPlayerHasRevivedServerRpc { get; set; } = new List<ulong>();
[HarmonyPrefix]
[HarmonyPatch("__rpc_handler_4249638645")]
public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return PlayerLoadedServerRpc(rpcParams.Server.Receive.SenderClientId);
}
public static bool PlayerLoadedServerRpc(ulong clientId)
{
if (GameNetworkManager.Instance.connectedPlayers == 1)
{
return true;
}
if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
return true;
}
if (!((Behaviour)HUDManager.Instance.loadingText).enabled)
{
return true;
}
if (!CallPlayerLoadedServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId)
{
CallPlayerLoadedServerRpc.Add(clientId);
}
int num = StartOfRound.Instance.fullyLoadedPlayers.Count + 1;
List<string> list = new List<string>();
List<ulong> list2 = new List<ulong>();
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.isPlayerControlled && !val.isHostPlayerObject && !CallPlayerLoadedServerRpc.Contains(val.actualClientId))
{
list.Add(val.playerUsername);
list2.Add(val.playerClientId);
}
}
if (num != GameNetworkManager.Instance.connectedPlayers)
{
list = list.GetRange(0, (list.Count > 3) ? 3 : list.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for crew...\r\n\r\nPlayers loaded: {0}/{1}\r\n{2}", num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list));
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
HUDManager.Instance.AddTextToChatOnServer(string.Format("<size=0>LoadingInfo,3,{0},{1},{2},{3}</size>", clientId, num, GameNetworkManager.Instance.connectedPlayers, string.Join(";", list2)), -1);
}
}
else
{
((TMP_Text)HUDManager.Instance.loadingText).text = $"Waiting for crew...\r\n\r\nAll players loaded!";
CallPlayerLoadedServerRpc = new List<ulong>();
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch("PassTimeToNextDay")]
public static void PassTimeToNextDay()
{
PlayerHasRevivedServerRpc(0uL);
}
[HarmonyPostfix]
[HarmonyPatch("AllPlayersHaveRevivedClientRpc")]
public static void AllPlayersHaveRevivedClientRpc()
{
((Behaviour)HUDManager.Instance.loadingText).enabled = false;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = false;
}
[HarmonyPostfix]
[HarmonyPatch("EndPlayersFiredSequenceClientRpc")]
public static void EndPlayersFiredSequenceClientRpc()
{
((Behaviour)HUDManager.Instance.loadingText).enabled = false;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = false;
}
[HarmonyPrefix]
[HarmonyPatch("__rpc_handler_3083945322")]
public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return PlayerHasRevivedServerRpc(rpcParams.Server.Receive.SenderClientId);
}
private static bool PlayerHasRevivedServerRpc(ulong clientId)
{
if (GameNetworkManager.Instance.connectedPlayers == 1)
{
return true;
}
if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
return true;
}
if (!CallPlayerHasRevivedServerRpc.Contains(clientId) && clientId != NetworkManager.Singleton.LocalClientId)
{
CallPlayerHasRevivedServerRpc.Add(clientId);
}
int num = StartOfRound.Instance.playersRevived + 1;
List<string> list = new List<string>();
List<ulong> list2 = new List<ulong>();
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.isPlayerControlled && !val.isHostPlayerObject && !CallPlayerHasRevivedServerRpc.Contains(val.actualClientId))
{
list.Add(val.playerUsername);
list2.Add(val.playerClientId);
}
}
if (num < GameNetworkManager.Instance.connectedPlayers)
{
list = list.GetRange(0, (list.Count > 3) ? 3 : list.Count);
if (Plugin.NameMaxLength.Value != -1)
{
list = list.Select((string x) => x.Substring(0, (x.Length > Plugin.NameMaxLength.Value) ? Plugin.NameMaxLength.Value : x.Length)).ToList();
}
((Behaviour)HUDManager.Instance.loadingText).enabled = true;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = true;
((TMP_Text)HUDManager.Instance.loadingText).text = string.Format("Waiting for Client...\r\n\r\nPlayers loaded: {0}/{1}\r\n{2}", num, GameNetworkManager.Instance.connectedPlayers, string.Join(",", list));
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
HUDManager.Instance.AddTextToChatOnServer(string.Format("<size=0>LoadingInfo,2,{0},{1},{2},{3}</size>", clientId, num, GameNetworkManager.Instance.connectedPlayers, string.Join(";", list2)), -1);
}
}
else
{
CallPlayerHasRevivedServerRpc = new List<ulong>();
((Behaviour)HUDManager.Instance.loadingText).enabled = false;
((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled = false;
}
return true;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}