using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LethalAPI.LibTerminal;
using LethalAPI.LibTerminal.Attributes;
using LethalAPI.LibTerminal.Models;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using syntax_z.ejectPlayer.Patches;
[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("syntax_z.ejectPlayer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+cf25d2958ab0e4cc837ddbd65a4119c0311cfa5d")]
[assembly: AssemblyProduct("syntax_z.ejectPlayer")]
[assembly: AssemblyTitle("syntax_z.ejectPlayer")]
[assembly: AssemblyVersion("1.2.0.0")]
[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;
}
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace syntax_z.ejectPlayer
{
[BepInPlugin("syntax_z.ejectPlayer", "syntax_z.ejectPlayer", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "syntax_z.ejectPlayer";
private const string modName = "syntax_z.ejectPlayer";
private const string modVersion = "1.2.0";
private readonly Harmony _harmony = new Harmony("syntax_z.ejectPlayer");
public static Plugin? Instance;
private TerminalModRegistry? TCommands;
public static bool localEject = false;
public static readonly LethalServerMessage<string> customServerMessage = new LethalServerMessage<string>("ejectingPlayers", (Action<string, ulong>)ReceiveByServer);
public static readonly LethalClientMessage<string> customClientMessage = new LethalClientMessage<string>("ejectingPlayers", (Action<string>)ReceiveFromServer, (Action<string, ulong>)ReceiveFromClient);
public static LethalNetworkVariable<string> globalMessage = new LethalNetworkVariable<string>("globalMessage");
public static LethalNetworkVariable<bool> tempEject = new LethalNetworkVariable<bool>("tempEject");
private void Awake()
{
PatchAllStuff();
TCommands = TerminalRegistry.CreateTerminalRegistry();
TCommands.RegisterFrom<Plugin>(this);
}
private void PatchAllStuff()
{
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(StartMatchLeverPatch));
_harmony.PatchAll(typeof(HUDManagerPatch));
}
private static void ReceiveFromServer(string data)
{
string text = data.Split('/')[1];
string text2 = $"{GameNetworkManager.Instance.localPlayerController.playerClientId}";
string value = data.Split('/')[2];
globalMessage.Value = value;
if (text == text2)
{
StartOfRoundPatch.notsafe = true;
}
localEject = true;
}
private static void ReceiveFromClient(string data, ulong id)
{
}
private static void ReceiveByServer(string data, ulong id)
{
if (data.Contains("eject/"))
{
customServerMessage.SendAllClients(data, true);
}
}
[TerminalCommand("list", false)]
[CommandInfo("Display list of users to eject", "")]
public string listCommand()
{
string text = "";
foreach (KeyValuePair<ulong, int> clientPlayer in StartOfRound.Instance.ClientPlayerList)
{
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[clientPlayer.Key]];
text += $"{val.playerUsername} || ID: {val.playerClientId}\n";
}
return text;
}
[TerminalCommand("eject", false)]
[CommandInfo("eg. eject (playerID) (message)", "")]
public string ejectCommand(ulong playerID, [RemainingText] string msg)
{
if (!StartOfRound.Instance.ClientPlayerList.Keys.Contains(playerID))
{
return "Invalid. Type \"list\" to see the available IDs";
}
if (GameNetworkManager.Instance.localPlayerController.playersManager.travellingToNewLevel || !GameNetworkManager.Instance.localPlayerController.playersManager.inShipPhase)
{
return "Can't eject player at this moment";
}
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.playerClientId == playerID)
{
customClientMessage.SendServer($"eject/{playerID}/{msg}");
return "ejecting player from ship";
}
}
return "Something went wrong. Make sure you're typing the correct number.";
}
[TerminalCommand("rnd_eject", false)]
[CommandInfo("eject a random player from the ship", "")]
public string rndEjectCommand()
{
if (GameNetworkManager.Instance.localPlayerController.playersManager.travellingToNewLevel || !GameNetworkManager.Instance.localPlayerController.playersManager.inShipPhase)
{
return "Can't eject player at this moment";
}
Random random = new Random();
ulong key = (ulong)random.Next(0, StartOfRound.Instance.ClientPlayerList.Keys.ToArray().Length);
ulong num = (ulong)StartOfRound.Instance.ClientPlayerList[key];
customClientMessage.SendServer($"eject/{num}/Ejected");
return "ejecting a random player from the ship";
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "syntax_z.ejectPlayer";
public const string PLUGIN_NAME = "syntax_z.ejectPlayer";
public const string PLUGIN_VERSION = "1.2.0";
}
}
namespace syntax_z.ejectPlayer.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
private static string defaultHeader = "YOU ARE FIRED.";
private static string defaultSub = "You did not meet the profit quota before the deadline.";
[HarmonyPatch(typeof(HUDManager), "ShowPlayersFiredScreen")]
[HarmonyPrefix]
private static void ShowEjectScreen(ref Animator ___playersFiredAnimator)
{
if (StartOfRoundPatch.currentlyEjectingPlayer)
{
((TMP_Text)((Component)((Component)___playersFiredAnimator).gameObject.transform.Find("MaskImage").Find("HeaderText")).GetComponent<TextMeshProUGUI>()).text = Plugin.globalMessage.Value;
((TMP_Text)((Component)((Component)___playersFiredAnimator).gameObject.transform.Find("MaskImage").Find("HeaderText (1)")).GetComponent<TextMeshProUGUI>()).text = "";
}
else
{
((TMP_Text)((Component)((Component)___playersFiredAnimator).gameObject.transform.Find("MaskImage").Find("HeaderText")).GetComponent<TextMeshProUGUI>()).text = defaultHeader;
((TMP_Text)((Component)((Component)___playersFiredAnimator).gameObject.transform.Find("MaskImage").Find("HeaderText (1)")).GetComponent<TextMeshProUGUI>()).text = defaultSub;
}
}
}
[HarmonyPatch(typeof(StartMatchLever))]
internal class StartMatchLeverPatch
{
[HarmonyPatch(typeof(StartMatchLever), "Update")]
[HarmonyPrefix]
private static bool UpdatePatch(ref StartMatchLever __instance)
{
if (__instance.playersManager.travellingToNewLevel || !__instance.playersManager.inShipPhase)
{
return true;
}
if (StartOfRoundPatch.currentlyEjectingPlayer)
{
__instance.triggerScript.interactable = false;
Terminal val = Object.FindObjectOfType<Terminal>();
if (val.terminalInUse)
{
val.QuitTerminal();
}
}
else
{
__instance.triggerScript.interactable = true;
}
return true;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
public static bool notsafe;
public static bool currentlyEjectingPlayer;
[HarmonyPatch(typeof(StartOfRound), "Update")]
[HarmonyPostfix]
private static void UpdatePatch(ref StartOfRound __instance)
{
if (Plugin.localEject)
{
Plugin.localEject = false;
currentlyEjectingPlayer = true;
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(EjectPlayer(__instance));
}
}
private static IEnumerator EjectPlayer(StartOfRound __instance)
{
yield return (object)new WaitForSeconds(5f);
((Component)__instance.shipAnimatorObject).gameObject.GetComponent<Animator>().SetBool("AlarmRinging", true);
__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(false);
__instance.shipDoorAudioSource.PlayOneShot(__instance.alarmSFX);
yield return (object)new WaitForSeconds(9.37f);
__instance.shipDoorsAnimator.SetBool("OpenInOrbit", true);
__instance.shipDoorAudioSource.PlayOneShot(__instance.airPressureSFX);
__instance.starSphereObject.SetActive(true);
__instance.starSphereObject.transform.position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
yield return (object)new WaitForSeconds(0.25f);
if (notsafe)
{
__instance.hangarDoorsClosed = false;
__instance.suckingPlayersOutOfShip = true;
__instance.suckingFurnitureOutOfShip = true;
SuckLocalPlayerOutOfShipDoor(__instance);
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true;
GameNetworkManager.Instance.localPlayerController.DropAllHeldItems(true, false);
HUDManager.Instance.UIAudio.PlayOneShot(__instance.suckedIntoSpaceSFX);
}
yield return (object)new WaitForSeconds(6f);
HUDManager.Instance.ShowPlayersFiredScreen(true);
yield return (object)new WaitForSeconds(3.5f);
__instance.shipDoorAudioSource.Stop();
__instance.speakerAudioSource.Stop();
__instance.starSphereObject.SetActive(false);
__instance.shipDoorAudioSource.Stop();
__instance.suckingFurnitureOutOfShip = false;
__instance.suckingPlayersOutOfShip = false;
__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(true);
__instance.shipDoorsAnimator.SetBool("OpenInOrbit", false);
((Component)__instance.shipAnimatorObject).gameObject.GetComponent<Animator>().SetBool("AlarmRinging", false);
__instance.suckingPower = 0f;
HUDManager.Instance.ShowPlayersFiredScreen(false);
if (notsafe)
{
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = false;
GameNetworkManager.Instance.localPlayerController.TeleportPlayer(__instance.playerSpawnPositions[GameNetworkManager.Instance.localPlayerController.playerClientId].position, false, 0f, false, true);
}
notsafe = false;
Plugin.localEject = false;
currentlyEjectingPlayer = false;
}
private static void SuckLocalPlayerOutOfShipDoor(StartOfRound __instance)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
__instance.suckingPower += Time.deltaTime * 2f;
GameNetworkManager.Instance.localPlayerController.fallValue = 0f;
GameNetworkManager.Instance.localPlayerController.fallValueUncapped = 0f;
if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, __instance.middleOfShipNode.position) < 25f)
{
if (Physics.Linecast(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, __instance.shipDoorNode.position, __instance.collidersAndRoomMask))
{
GameNetworkManager.Instance.localPlayerController.externalForces = Vector3.Normalize(__instance.middleOfShipNode.position - ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) * 350f;
}
else
{
GameNetworkManager.Instance.localPlayerController.externalForces = Vector3.Normalize(__instance.middleOfSpaceNode.position - ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) * (350f / Vector3.Distance(__instance.moveAwayFromShipNode.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position)) * (__instance.suckingPower / 2.25f);
}
}
else
{
GameNetworkManager.Instance.localPlayerController.externalForces = Vector3.Scale(Vector3.one, new Vector3(-1f, 0f, Random.Range(-0.7f, 0.7f))) * 70f;
}
}
}
}