using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExtendedLateCompany;
using ExtendedLateCompany.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
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("Happyness.ExtendedLateCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("ExtendedLateCompany")]
[assembly: AssemblyTitle("Happyness.ExtendedLateCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class DebugUI : MonoBehaviour
{
[HarmonyPatch(typeof(QuickMenuManager))]
public class QuickMenuPatch
{
[HarmonyPatch("OpenQuickMenu")]
[HarmonyPostfix]
public static void OnOpenQuickMenu()
{
SetMenuForAll(value: true);
}
[HarmonyPatch("CloseQuickMenu")]
[HarmonyPostfix]
public static void OnCloseQuickMenu()
{
SetMenuForAll(value: false);
}
}
public static DebugUI Instance;
private static bool _menuOpen;
private Rect _windowRect = new Rect(1000f, 20f, 300f, 200f);
public static void SetMenuForAll(bool value)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
if ((Object)(object)GameNetworkManager.Instance != (Object)null && !NetworkManager.Singleton.IsHost)
{
_menuOpen = false;
return;
}
if (!Object.op_Implicit((Object)(object)Instance))
{
GameObject val = new GameObject("ExtendedLateCompany_UI");
Object.DontDestroyOnLoad((Object)(object)val);
Instance = val.AddComponent<DebugUI>();
}
_menuOpen = value;
}
public void HideMenu()
{
_menuOpen = false;
}
private void Awake()
{
if (!NetworkManager.Singleton.IsHost)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
((Behaviour)this).enabled = true;
}
private void OnGUI()
{
//IL_0012: 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_0032: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (_menuOpen)
{
_windowRect = GUILayout.Window(0, _windowRect, new WindowFunction(DrawWindow), "ExtendedLateCompany Config", Array.Empty<GUILayoutOption>());
}
}
private void DrawWindow(int windowID)
{
global::ExtendedLateCompany.ExtendedLateCompany.LateJoin.Value = GUILayout.Toggle(global::ExtendedLateCompany.ExtendedLateCompany.LateJoin.Value, "Enable Late Joiners", Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Apply and Refresh", Array.Empty<GUILayoutOption>()))
{
((BaseUnityPlugin)global::ExtendedLateCompany.ExtendedLateCompany.Instance).Config.Save();
LobbyManager.RefreshLobbyVisibility();
}
GUI.DragWindow();
}
}
namespace ExtendedLateCompany
{
[BepInPlugin("Happyness.ExtendedLateCompany", "ExtendedLateCompany", "1.1.1")]
internal class ExtendedLateCompany : BaseUnityPlugin
{
public static ConfigEntry<bool> LateJoin;
public static ExtendedLateCompany Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony Harmony { get; set; }
public void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("Happyness.ExtendedLateCompany");
val.PatchAll(typeof(ExtendedLateCompany).Assembly);
Logger.LogInfo((object)"Extended Late Company has loaded!");
SceneManager.sceneLoaded += OnSceneLoaded;
LateJoin = ((BaseUnityPlugin)this).Config.Bind<bool>("LateJoin", "EnableLateJoin", true, "Enable or disable Late Joiners");
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
if (((Scene)(ref scene)).name == "MainMenu" || ((Scene)(ref scene)).name == "InitScene" || ((Scene)(ref scene)).name == "InitSceneLaunchOptions")
{
if ((Object)(object)DebugUI.Instance != (Object)null)
{
DebugUI.Instance.HideMenu();
}
}
else if (!((Object)(object)DebugUI.Instance != (Object)null))
{
GameObject val = new GameObject("ExtendedLateCompany_UI");
Object.DontDestroyOnLoad((Object)(object)val);
val.AddComponent<DebugUI>();
}
}
}
[HarmonyPatch]
public class ForceRendererEnabled
{
private static readonly string[] forbiddenNames = new string[11]
{
"PlayerPhysicsBox", "LineOfSightCube", "LineOfSightCubeSmall", "LineOfSight2", "MapDot", "MapDirectionIndicator", "BeamUp", "BeamOutRedBuildup", "BeamOutRed", "Circle",
"CopyHeldProp"
};
[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
[HarmonyPostfix]
public static void FixInvisiblePlayer(int assignedPlayerObjectId)
{
try
{
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[assignedPlayerObjectId];
if ((Object)(object)val == (Object)null)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC] ERROR in FRE: Player object is NULL for playerID {assignedPlayerObjectId}");
}
else if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer)
{
PlayerScript playerScript = ((Component)val).GetComponent<PlayerScript>();
if ((Object)(object)playerScript == (Object)null)
{
try
{
playerScript = ((Component)val).gameObject.AddComponent<PlayerScript>();
}
catch (Exception arg)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC] ERROR in FRE: Failed to add PlayerScript to player {((Object)val).name}: {arg}");
return;
}
}
if ((Object)(object)playerScript != (Object)null)
{
playerScript.FixRenderersClientRpc();
}
else
{
ExtendedLateCompany.Logger.LogError((object)("[ELC] ERROR in FRE: PlayerScript is still null for player " + ((Object)val).name));
}
}
else if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
ExtendedLateCompany.Logger.LogError((object)"[ELC] ERROR in FRE: NetworkManager.Singleton is null");
}
}
catch (Exception arg2)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC] EXCEPTION in FRE: {arg2}");
}
}
public static void EnableRenderersAndResetState(GameObject player)
{
if ((Object)(object)player == (Object)null)
{
ExtendedLateCompany.Logger.LogError((object)"[ELC] ERROR in FRE: player GameObject is null in EnableRenderersAndResetState");
return;
}
try
{
SkinnedMeshRenderer[] componentsInChildren = player.GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer val in componentsInChildren)
{
if (!ShouldSkipRenderer(((Object)((Component)val).gameObject).name))
{
((Renderer)val).enabled = true;
}
}
Renderer[] componentsInChildren2 = player.GetComponentsInChildren<Renderer>(true);
foreach (Renderer val2 in componentsInChildren2)
{
if (!ShouldSkipRenderer(((Object)((Component)val2).gameObject).name))
{
val2.enabled = true;
}
}
Animator componentInChildren = player.GetComponentInChildren<Animator>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
((Behaviour)componentInChildren).enabled = true;
}
if (!player.activeSelf)
{
player.SetActive(true);
}
PlayerControllerB component = player.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null)
{
component.health = 100;
component.bleedingHeavily = false;
component.criticallyInjured = false;
component.disableMoveInput = false;
component.disableLookInput = false;
component.disableInteract = false;
if ((Object)(object)component.playerBodyAnimator != (Object)null)
{
component.playerBodyAnimator.SetBool("Limp", false);
}
}
else
{
ExtendedLateCompany.Logger.LogError((object)("[ELC] ERROR in FRE: PlayerControllerB component missing on player " + ((Object)player).name));
}
}
catch (Exception arg)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC] EXCEPTION in FRE in EnableRenderersAndResetState: {arg}");
}
}
private static bool ShouldSkipRenderer(string name)
{
string[] array = forbiddenNames;
foreach (string b in array)
{
if (string.Equals(name, b, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
}
public class PlayerScript : NetworkBehaviour
{
[ClientRpc]
public void FixRenderersClientRpc()
{
ForceRendererEnabled.EnableRenderersAndResetState(((Component)this).gameObject);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Happyness.ExtendedLateCompany";
public const string PLUGIN_NAME = "ExtendedLateCompany";
public const string PLUGIN_VERSION = "1.1.1";
}
}
namespace ExtendedLateCompany.Patches
{
[HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")]
[HarmonyWrapSafe]
internal static class LeaveLobbyAtGameStart_Patch
{
[HarmonyPrefix]
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
[HarmonyWrapSafe]
internal static class ConnectionApproval_Patch
{
[HarmonyPostfix]
private static void Postfix(ref ConnectionApprovalRequest request, ref ConnectionApprovalResponse response)
{
if (request.ClientNetworkId != NetworkManager.Singleton.LocalClientId && LobbyManager.currentLobbyVisible && response.Reason == "Game has already started!")
{
ExtendedLateCompany.Logger.LogInfo((object)$"[ELC GNM] Allowing late joiner {request.ClientNetworkId}");
response.Reason = "";
response.Approved = true;
}
}
}
public static class LobbyManager
{
public static bool currentLobbyVisible = true;
public static void RefreshLobbyVisibility()
{
if (NetworkManager.Singleton.IsServer && !((Object)(object)StartOfRound.Instance == (Object)null))
{
bool value = ExtendedLateCompany.LateJoin.Value;
bool inShipPhase = StartOfRound.Instance.inShipPhase;
if (!value)
{
SetLobbyVisible(visible: false);
return;
}
if (!inShipPhase)
{
SetLobbyVisible(visible: false);
return;
}
bool lobbyVisible = StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length;
SetLobbyVisible(lobbyVisible);
}
}
public static void SetLobbyVisible(bool visible)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkManager.Singleton.IsServer || currentLobbyVisible == visible)
{
return;
}
currentLobbyVisible = visible;
ExtendedLateCompany.Logger.LogInfo((object)$"[ELC LM] Lobby visibility changed to: {visible}");
if (GameNetworkManager.Instance.currentLobby.HasValue)
{
Lobby value = GameNetworkManager.Instance.currentLobby.Value;
try
{
((Lobby)(ref value)).SetData("joinable", visible ? "true" : "false");
}
catch (Exception ex)
{
ExtendedLateCompany.Logger.LogError((object)("[ELC LM] Failed to set lobby data: " + ex.Message));
}
GameNetworkManager.Instance.SetLobbyJoinable(visible);
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
if (Object.op_Implicit((Object)(object)val))
{
val.inviteFriendsTextAlpha.alpha = (visible ? 1f : 0.2f);
}
}
}
public static void OnPlayerJoined()
{
RefreshLobbyVisibility();
}
public static void OnPlayerLeft()
{
RefreshLobbyVisibility();
}
public static void OnShipPhaseChanged(bool inShipPhaseNow)
{
RefreshLobbyVisibility();
}
}
[HarmonyWrapSafe]
public static class PlayerNameFixPatch
{
public static class SpectateModUtils
{
public static void ClearSpectateBox(PlayerControllerB leavingPlayer)
{
KeyValuePair<Animator, PlayerControllerB> keyValuePair = HUDManager.Instance.spectatingPlayerBoxes.FirstOrDefault((KeyValuePair<Animator, PlayerControllerB> x) => (Object)(object)x.Value == (Object)(object)leavingPlayer);
if ((Object)(object)keyValuePair.Key != (Object)null)
{
GameObject gameObject = ((Component)keyValuePair.Key).gameObject;
RawImage component = gameObject.GetComponent<RawImage>();
if ((Object)(object)component != (Object)null)
{
component.texture = null;
}
TextMeshProUGUI componentInChildren = gameObject.GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)componentInChildren).text = "";
}
HUDManager.Instance.spectatingPlayerBoxes.Remove(keyValuePair.Key);
Object.Destroy((Object)(object)gameObject);
}
}
}
private static readonly Queue<ulong> pendingJoinedSteamIds = new Queue<ulong>();
private static ManualCameraRenderer manualCamera = null;
private static void RefreshAllPlayerNames()
{
StartOfRound instance = StartOfRound.Instance;
GameNetworkManager instance2 = GameNetworkManager.Instance;
if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance2 == (Object)null) && !instance2.disableSteam && instance.allPlayerScripts != null)
{
UpdateQuickMenuNames();
UpdateBillboardNames();
UpdateMapScreenName();
}
}
private static void UpdateQuickMenuNames()
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
if ((Object)(object)val == (Object)null)
{
return;
}
for (int i = 0; i < instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val2 = instance.allPlayerScripts[i];
PlayerListSlot val3 = val.playerListSlots[i];
if (val2.playerSteamId == 0)
{
if (val3.slotContainer.activeSelf)
{
val3.slotContainer.SetActive(false);
}
continue;
}
if (!val3.slotContainer.activeSelf)
{
val3.slotContainer.SetActive(true);
}
Friend val4 = new Friend(SteamId.op_Implicit(val2.playerSteamId));
string name = ((Friend)(ref val4)).Name;
if (!(name == "[unknown]") && ((TMP_Text)val3.usernameHeader).text != name)
{
((TMP_Text)val3.usernameHeader).text = name;
val3.playerSteamId = val2.playerSteamId;
}
}
}
private static void UpdateBillboardNames()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
StartOfRound instance = StartOfRound.Instance;
PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.playerSteamId != 0)
{
Friend val2 = new Friend(SteamId.op_Implicit(val.playerSteamId));
string name = ((Friend)(ref val2)).Name;
if (!(name == "[unknown]") && val.playerUsername != name)
{
val.playerUsername = name;
((TMP_Text)val.usernameBillboardText).text = name;
}
}
}
}
private static void UpdateMapScreenName()
{
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)manualCamera != (Object)null && (Object)(object)manualCamera.targetedPlayer != (Object)null)
{
PlayerControllerB targetedPlayer = manualCamera.targetedPlayer;
if (((TMP_Text)instance.mapScreenPlayerName).text != targetedPlayer.playerUsername)
{
((TMP_Text)instance.mapScreenPlayerName).text = targetedPlayer.playerUsername;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")]
public static void LobbyJoinedPatch(Lobby lobby, Friend friend)
{
//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_002c: 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)
if (SteamId.op_Implicit(friend.Id) != 0)
{
lock (pendingJoinedSteamIds)
{
pendingJoinedSteamIds.Enqueue(SteamId.op_Implicit(friend.Id));
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
public static void NewPlayerValuesPatch()
{
RefreshAllPlayerNames();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
public static void PlayerConnectedPatch()
{
RefreshAllPlayerNames();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
public static void ConnectToPlayerPatch(PlayerControllerB __instance)
{
ulong num = 0uL;
lock (pendingJoinedSteamIds)
{
if (pendingJoinedSteamIds.Count > 0)
{
num = pendingJoinedSteamIds.Dequeue();
}
}
if (num != 0)
{
try
{
__instance.SendNewPlayerValuesServerRpc(num);
}
catch (Exception arg)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC PName] Failed to call SendNewPlayerValuesServerRpc: {arg}");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "StartGame")]
public static void StartGamePatch()
{
RefreshAllPlayerNames();
}
}
[HarmonyPatch(typeof(QuickMenuManager), "DisableInviteFriendsButton")]
internal static class DisableInviteFriendsButton_Patch
{
[HarmonyPrefix]
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")]
internal static class InviteFriendsButton_Patch
{
[HarmonyPrefix]
private static bool Prefix()
{
if (LobbyManager.currentLobbyVisible && !GameNetworkManager.Instance.disableSteam)
{
GameNetworkManager.Instance.InviteFriendsUI();
}
return false;
}
}
[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
internal static class RefreshMenuNamesPatch
{
[HarmonyPostfix]
private static void Postfix()
{
NameSync.ApplyNames();
}
}
public static class NameSync
{
public static void ApplyNames()
{
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
if (val?.playerListSlots == null)
{
return;
}
PlayerListSlot[] playerListSlots = val.playerListSlots;
foreach (PlayerListSlot val2 in playerListSlots)
{
if (val2 == null)
{
continue;
}
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val3 in allPlayerScripts)
{
if (val3?.playerSteamId == val2.playerSteamId)
{
((TMP_Text)val2.usernameHeader).text = val3.playerUsername;
break;
}
}
}
}
}
internal static class StartOfRoundPatch
{
[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
[HarmonyWrapSafe]
private static class OnPlayerConnectedClientRpc_Patch
{
private static void UpdateControlledState()
{
for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
{
if ((i == 0 || !((NetworkBehaviour)StartOfRound.Instance.allPlayerScripts[i]).IsOwnedByServer) && !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead)
{
StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled = true;
}
}
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>();
bool flag = false;
bool flag2 = false;
bool flag3 = false;
foreach (CodeInstruction instruction in instructions)
{
if (!flag3)
{
if (!flag && instruction.opcode == OpCodes.Call)
{
object operand = instruction.operand;
if (operand != null && operand.ToString().Contains("setPlayerToSpawnPosition"))
{
flag = true;
goto IL_00e2;
}
}
if (flag && instruction.opcode == OpCodes.Ldc_I4_0)
{
flag2 = true;
continue;
}
if (flag2 && instruction.opcode == OpCodes.Ldloc_0)
{
flag2 = false;
flag3 = true;
list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(OnPlayerConnectedClientRpc_Patch), "UpdateControlledState", (Type[])null, (Type[])null)));
}
}
goto IL_00e2;
IL_00e2:
if (!flag2)
{
list.Add(instruction);
}
}
if (!flag3)
{
ExtendedLateCompany.Logger.LogError((object)"ELC SoR: Failed to transpile OnPlayerConnectedClientRpc");
}
return list.AsEnumerable();
}
[HarmonyPostfix]
private static void Postfix()
{
if (StartOfRound.Instance.connectedPlayersAmount + 1 >= StartOfRound.Instance.allPlayerScripts.Length)
{
LobbyManager.SetLobbyVisible(visible: false);
}
}
}
[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
[HarmonyWrapSafe]
private static class OnPlayerDC_Patch
{
[HarmonyPostfix]
private static void Postfix(int playerObjectNumber)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
if (StartOfRound.Instance.inShipPhase && StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length)
{
LobbyManager.SetLobbyVisible(visible: true);
}
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectNumber];
val.activatingItem = false;
val.bleedingHeavily = false;
val.clampLooking = false;
val.criticallyInjured = false;
val.Crouch(false);
val.disableInteract = false;
val.DisableJetpackControlsLocally();
val.disableLookInput = false;
val.disableMoveInput = false;
val.DisablePlayerModel(((Component)val).gameObject, true, true);
val.disableSyncInAnimation = false;
val.externalForceAutoFade = Vector3.zero;
val.freeRotationInInteractAnimation = false;
val.hasBeenCriticallyInjured = false;
val.health = 100;
((Behaviour)val.helmetLight).enabled = false;
val.holdingWalkieTalkie = false;
val.inAnimationWithEnemy = null;
val.inShockingMinigame = false;
val.inSpecialInteractAnimation = false;
val.inVehicleAnimation = false;
val.isClimbingLadder = false;
val.isSinking = false;
val.isUnderwater = false;
Animator mapRadarDotAnimator = val.mapRadarDotAnimator;
if (mapRadarDotAnimator != null)
{
mapRadarDotAnimator.SetBool("dead", false);
}
Animator playerBodyAnimator = val.playerBodyAnimator;
if (playerBodyAnimator != null)
{
playerBodyAnimator.SetBool("Limp", false);
}
val.ResetZAndXRotation();
val.sinkingValue = 0f;
val.speakingToWalkieTalkie = false;
AudioSource statusEffectAudio = val.statusEffectAudio;
if (statusEffectAudio != null)
{
statusEffectAudio.Stop();
}
((Collider)val.thisController).enabled = true;
((Component)val).transform.SetParent(StartOfRound.Instance.playersContainer);
val.twoHanded = false;
val.voiceMuffledByEnemy = false;
}
}
[HarmonyPatch(typeof(StartOfRound), "StartGame")]
private static class StartGame_Patch
{
[HarmonyPrefix]
private static void Prefix()
{
if (NetworkManager.Singleton.IsHost)
{
LobbyManager.SetLobbyVisible(visible: false);
}
}
}
[HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")]
private static class SetShipReadyToLand_Patch
{
[HarmonyPostfix]
private static void Postfix()
{
if (!NetworkManager.Singleton.IsHost)
{
return;
}
bool lobbyVisible = StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length;
LobbyManager.SetLobbyVisible(lobbyVisible);
ExtendedLateCompany.Logger.LogWarning((object)(lobbyVisible + "if true open lobby."));
try
{
GameNetworkManager.Instance.connectedPlayers = StartOfRound.Instance.connectedPlayersAmount + 1;
}
catch (Exception arg)
{
ExtendedLateCompany.Logger.LogError((object)$"[ELC SoR] SetShipReadyToLand: failed to set GameNetworkManager.connectedPlayers: {arg}");
}
}
}
}
}