using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AreWeMissingSomeone.Patches;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
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: AssemblyTitle("AreWeMissingSomeone")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AreWeMissingSomeone")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("49AE569B-088B-41B6-9CA2-8FDDA6AFAFF8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AreWeMissingSomeone
{
[BepInPlugin("Demi.AreWeMissingSomeone", "Are We Missing Someone ?", "0.0.1.1")]
public class AreWeMissingSomeone : BaseUnityPlugin
{
private const string ModGuid = "Demi.AreWeMissingSomeone";
private const string ModName = "Are We Missing Someone ?";
private const string ModVersion = "0.0.1.1";
private readonly Harmony _harmony = new Harmony("Demi.AreWeMissingSomeone");
private static AreWeMissingSomeone _instance;
private ManualLogSource _mls;
private void Awake()
{
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
_mls = Logger.CreateLogSource("Demi.AreWeMissingSomeone");
_mls.LogInfo((object)"Are we missing someone is loaded!");
_harmony.PatchAll(typeof(AreWeMissingSomeone));
_harmony.PatchAll(typeof(LeverPatch));
}
public static AreWeMissingSomeone GetInstance()
{
return _instance;
}
public ManualLogSource GetLogSource()
{
return _mls;
}
}
}
namespace AreWeMissingSomeone.Patches
{
[HarmonyPatch(typeof(StartMatchLever))]
public class LeverPatch : NetworkBehaviour
{
private static InteractTrigger _triggerScript;
private static StartOfRound _playersManager;
private static readonly ManualLogSource Mls = AreWeMissingSomeone.GetInstance().GetLogSource();
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(ref InteractTrigger ___triggerScript, ref StartOfRound ___playersManager)
{
_triggerScript = ___triggerScript;
_playersManager = ___playersManager;
if ((Object)(object)_triggerScript == (Object)null)
{
Mls.LogError((object)"Trigger script is null!!");
}
if ((Object)(object)_playersManager == (Object)null)
{
Mls.LogError((object)"Players manager is null!!");
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void LeverUpdatePatch()
{
if (_playersManager.localPlayerController.isInHangarShipRoom && _playersManager.shipHasLanded && !_playersManager.inShipPhase)
{
List<PlayerControllerB> list = _playersManager.OtherClients.FindAll((PlayerControllerB playerManager) => playerManager.isPlayerControlled && !playerManager.isPlayerDead);
int num = list.Count((PlayerControllerB playersManagerOtherClient) => playersManagerOtherClient.isInHangarShipRoom);
int count = list.Count;
Mls.LogInfo((object)$"Players in ship: {num}");
Mls.LogInfo((object)$"Other client count: {count}");
if (num != count)
{
_triggerScript.hoverTip = $"[ {num + 1} out of {count + 1} onboard are you sure you want to leave ? ]";
}
}
}
}
}