using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CruiserTerminal.NetcodePatcher;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[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("CruiserTerminal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d22cdfd552146068ac0428edd8dda454a3d5581a")]
[assembly: AssemblyProduct("CruiserTerminal")]
[assembly: AssemblyTitle("CruiserTerminal")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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;
}
}
}
namespace CruiserTerminal
{
public class CruiserTerminal : MonoBehaviour
{
public bool cruiserTerminalInUse;
public GameObject canvasMainContainer;
public Terminal terminalScript;
public GameObject cruiserTerminal;
public InteractTrigger interactTrigger;
public InteractTrigger terminalInteractTrigger;
public AudioSource cruiserTerminalAudio;
public AudioClip[] cruiserKeyboardClips;
public AudioClip[] cruiserSyncedAudios;
public PlayerActions playerActions;
public GameObject terminalPos;
public AudioClip enterTerminalSFX;
public AudioClip leaveTerminalSFX;
public Light terminalLight;
public VehicleController cruiserController;
private float timeSinceLastKeyboardPress;
private CTNetworkHandler CTNH;
private void Awake()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
playerActions = new PlayerActions();
MovementActions movement = playerActions.Movement;
((MovementActions)(ref movement)).Enable();
}
private void Start()
{
cruiserTerminalInUse = false;
canvasMainContainer = GameObject.Find("Environment/HangarShip/Terminal/Canvas");
terminalScript = GameObject.Find("Environment/HangarShip/Terminal/TerminalTrigger/TerminalScript").GetComponent<Terminal>();
cruiserTerminal = ((Component)this).gameObject;
interactTrigger = GameObject.Find("CruiserTerminal(Clone)/TerminalTrigger/Trigger").GetComponent<InteractTrigger>();
CTNH = ((Component)this).gameObject.GetComponent<CTNetworkHandler>();
terminalInteractTrigger = ((Component)terminalScript).gameObject.GetComponent<InteractTrigger>();
cruiserTerminalAudio = GameObject.Find("CruiserTerminal(Clone)/TerminalTrigger/TerminalAudio").GetComponent<AudioSource>();
cruiserKeyboardClips = terminalScript.keyboardClips;
cruiserSyncedAudios = terminalScript.syncedAudios;
terminalPos = GameObject.Find("terminalPosition");
enterTerminalSFX = terminalScript.enterTerminalSFX;
leaveTerminalSFX = terminalScript.leaveTerminalSFX;
terminalLight = GameObject.Find("CruiserTerminal(Clone)/terminalLight").GetComponent<Light>();
cruiserController = GameObject.Find("CompanyCruiser(Clone)").GetComponent<VehicleController>();
}
private void Update()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
cruiserTerminal.transform.position = terminalPos.transform.position;
cruiserTerminal.transform.rotation = terminalPos.transform.rotation;
if (cruiserTerminalInUse && !cruiserController.carDestroyed)
{
if (((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame && timeSinceLastKeyboardPress > 0.07f)
{
timeSinceLastKeyboardPress = 0f;
RoundManager.PlayRandomClip(cruiserTerminalAudio, cruiserKeyboardClips, true, 1f, 0, 1000);
}
timeSinceLastKeyboardPress += Time.deltaTime;
}
}
internal GameObject MoveCanvas()
{
return Object.Instantiate<GameObject>(GameObject.Find("Environment/HangarShip/Terminal/Canvas/MainContainer"), GameObject.Find("CruiserTerminal(Clone)/Canvas").transform);
}
public void BeginUsingCruiserTerminal()
{
cruiserController.SetVehicleCollisionForPlayer(false, GameNetworkManager.Instance.localPlayerController);
if (!cruiserController.carDestroyed)
{
((MonoBehaviour)this).StartCoroutine(waitUntilFrameEndToSetActive(active: true));
terminalScript.BeginUsingTerminal();
CTNH.SetCruiserTerminalInUseServerRpc(inUse: true);
cruiserTerminalInUse = true;
HUDManager.Instance.PingHUDElement(HUDManager.Instance.Clock, 1f, 1f, 0.2f);
}
}
public void QuitCruiserTerminal()
{
SetCruiserTerminalNoLongerInUse();
terminalScript.QuitTerminal(true);
interactTrigger.StopSpecialAnimation();
}
public void SetCruiserTerminalNoLongerInUse()
{
CTPlugin.mls.LogMessage((object)"terminal no longer in use!!!");
CTNH.SetCruiserTerminalInUseServerRpc(inUse: false);
cruiserController.SetVehicleCollisionForPlayer(true, GameNetworkManager.Instance.localPlayerController);
cruiserTerminalInUse = false;
((MonoBehaviour)this).StartCoroutine(waitUntilFrameEndToSetActive(active: false));
HUDManager.Instance.PingHUDElement(HUDManager.Instance.Clock, 0f, 1f, 1f);
}
private void OnEnable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
MovementActions movement = playerActions.Movement;
((MovementActions)(ref movement)).OpenMenu.performed += PressESC;
}
private void OnDisable()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
CTPlugin.mls.LogInfo((object)"Terminal disabled, disabling ESC key listener");
MovementActions movement = playerActions.Movement;
((MovementActions)(ref movement)).OpenMenu.performed -= PressESC;
}
private void PressESC(CallbackContext context)
{
interactTrigger.StopSpecialAnimation();
if (((CallbackContext)(ref context)).performed && cruiserTerminalInUse)
{
QuitCruiserTerminal();
}
}
private IEnumerator waitUntilFrameEndToSetActive(bool active)
{
if (active)
{
canvasMainContainer.transform.SetParent(cruiserTerminal.transform);
canvasMainContainer.transform.localPosition = new Vector3(-0.03f, 1.4f, 0.011f);
canvasMainContainer.transform.localScale = new Vector3(0.004f, 0.0043f, 0.0016f);
canvasMainContainer.transform.localRotation = Quaternion.Euler(new Vector3(0f, 90f, 0f));
}
else
{
canvasMainContainer.transform.SetParent(((Component)terminalScript).gameObject.transform.parent.parent);
canvasMainContainer.transform.localPosition = new Vector3(-0.516f, 0.284f, 1.284f);
canvasMainContainer.transform.localScale = new Vector3(0.0015f, 0.0015f, 0.0016f);
canvasMainContainer.transform.localRotation = Quaternion.Euler(new Vector3(0f, 78.0969f, 90f));
}
yield return (object)new WaitForEndOfFrame();
}
}
public static class CTFunctions
{
public static void Spawn()
{
if (!Object.op_Implicit((Object)(object)GameObject.Find("CruiserTerminal(Clone)")))
{
GameObject val = GameObject.Find("CompanyCruiser(Clone)");
NetworkObject component = val.GetComponent<NetworkObject>();
CTPlugin.mls.LogInfo((object)("cruiserNO is null = " + ((Object)(object)component == (Object)null)));
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val2 = Object.Instantiate<GameObject>(CTPlugin.terminalPrefab);
val2.GetComponent<NetworkObject>().Spawn(false);
}
}
}
}
public class CTNetworkHandler : NetworkBehaviour
{
public CruiserTerminal cruiserTerminal;
internal bool repeatCheckInteractable;
internal bool repeatCheck;
internal static CTNetworkHandler Instance { get; private set; }
private void Start()
{
cruiserTerminal = ((Component)this).gameObject.GetComponent<CruiserTerminal>();
repeatCheck = false;
repeatCheckInteractable = false;
}
public override void OnNetworkSpawn()
{
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
CTNetworkHandler instance = Instance;
if (instance != null)
{
((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
}
}
Instance = this;
((NetworkBehaviour)this).OnNetworkSpawn();
}
[ServerRpc(RequireOwnership = false)]
public void SetCruiserTerminalInteractableServerRpc(bool isInteractable)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2664732933u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isInteractable, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2664732933u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && repeatCheckInteractable != isInteractable)
{
repeatCheckInteractable = isInteractable;
SetCruiserTerminalInteractableClientRpc(isInteractable);
}
}
}
[ClientRpc]
public void SetCruiserTerminalInteractableClientRpc(bool isInteractable)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1065638584u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isInteractable, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1065638584u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
cruiserTerminal.interactTrigger.interactable = isInteractable;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SetCruiserTerminalInUseServerRpc(bool inUse)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1599773948u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inUse, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1599773948u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && repeatCheck != inUse)
{
repeatCheck = inUse;
CTPlugin.mls.LogMessage((object)("sending inUse to clients: " + inUse));
SetCruiserTerminalInUseClientRpc(inUse);
}
}
}
[ClientRpc]
public void SetCruiserTerminalInUseClientRpc(bool inUse)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(670020231u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inUse, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 670020231u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
CTPlugin.mls.LogMessage((object)("cruiser terminal in use: " + inUse));
((Behaviour)cruiserTerminal.terminalLight).enabled = inUse;
if (inUse)
{
cruiserTerminal.cruiserTerminalAudio.PlayOneShot(cruiserTerminal.enterTerminalSFX);
}
else
{
cruiserTerminal.cruiserTerminalAudio.PlayOneShot(cruiserTerminal.leaveTerminalSFX);
}
cruiserTerminal.interactTrigger.interactable = !inUse;
cruiserTerminal.terminalInteractTrigger.interactable = !inUse;
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CTNetworkHandler()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2664732933u, new RpcReceiveHandler(__rpc_handler_2664732933));
NetworkManager.__rpc_func_table.Add(1065638584u, new RpcReceiveHandler(__rpc_handler_1065638584));
NetworkManager.__rpc_func_table.Add(1599773948u, new RpcReceiveHandler(__rpc_handler_1599773948));
NetworkManager.__rpc_func_table.Add(670020231u, new RpcReceiveHandler(__rpc_handler_670020231));
}
private static void __rpc_handler_2664732933(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool cruiserTerminalInteractableServerRpc = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cruiserTerminalInteractableServerRpc, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((CTNetworkHandler)(object)target).SetCruiserTerminalInteractableServerRpc(cruiserTerminalInteractableServerRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1065638584(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool cruiserTerminalInteractableClientRpc = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cruiserTerminalInteractableClientRpc, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((CTNetworkHandler)(object)target).SetCruiserTerminalInteractableClientRpc(cruiserTerminalInteractableClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1599773948(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool cruiserTerminalInUseServerRpc = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cruiserTerminalInUseServerRpc, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((CTNetworkHandler)(object)target).SetCruiserTerminalInUseServerRpc(cruiserTerminalInUseServerRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_670020231(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool cruiserTerminalInUseClientRpc = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref cruiserTerminalInUseClientRpc, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((CTNetworkHandler)(object)target).SetCruiserTerminalInUseClientRpc(cruiserTerminalInUseClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "CTNetworkHandler";
}
}
public static class CTPatches
{
private static CruiserTerminal cterminal;
[HarmonyPostfix]
[HarmonyPatch(typeof(VehicleController), "Awake")]
private static void StartPatch()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
CTFunctions.Spawn();
Object obj = CTPlugin.mainAssetBundle.LoadAsset("terminalPosition.prefab");
GameObject val = Object.Instantiate<GameObject>((GameObject)(object)((obj is GameObject) ? obj : null));
((Object)val).name = "terminalPosition";
val.transform.SetParent(GameObject.Find("CompanyCruiser(Clone)").transform);
val.transform.localPosition = new Vector3(1.293f, 0.938f, -3.274f);
cterminal = GameObject.Find("CruiserTerminal(Clone)").GetComponent<CruiserTerminal>();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
private static void AddPrefabsToNetwork()
{
CTPlugin.terminalPrefab = CTPlugin.mainAssetBundle.LoadAsset<GameObject>("CruiserTerminal.prefab");
CTPlugin.terminalPrefab.AddComponent<CTNetworkHandler>();
NetworkManager.Singleton.AddNetworkPrefab(CTPlugin.terminalPrefab);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(VehicleController), "DestroyCar")]
private static void DestroyCarPatch()
{
if (cterminal.cruiserTerminalInUse)
{
cterminal.QuitCruiserTerminal();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Terminal), "OnDisable")]
[HarmonyPatch(typeof(VehicleController), "OnDisable")]
private static void TerminalOnDisablePostfix()
{
CTPlugin.mls.LogInfo((object)"Destroying the terminal in a cruiser");
Object.Destroy((Object)(object)GameObject.Find("CruiserTerminal(Clone)"));
Object.Destroy((Object)(object)GameObject.Find("terminalPosition"));
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Terminal), "SetTerminalInUseClientRpc")]
private static void SetTerminalInUsePatch(ref bool ___terminalInUse)
{
if ((Object)(object)cterminal != (Object)null)
{
((Component)cterminal).gameObject.GetComponent<CTNetworkHandler>().SetCruiserTerminalInteractableServerRpc(!___terminalInUse);
CTPlugin.mls.LogInfo((object)("cruiser terminal interactable = " + !___terminalInUse));
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ManualCameraRenderer), "MeetsCameraEnabledConditions")]
private static void MeetsCameraEnabledConditionsPatch(ref bool __result)
{
if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)cterminal == (Object)null) && cterminal.cruiserTerminalInUse)
{
__result = true;
}
}
}
[BepInPlugin("mborsh.CruiserTerminal", "CruiserTerminal", "1.0.0")]
public class CTPlugin : BaseUnityPlugin
{
private const string modGUID = "mborsh.CruiserTerminal";
private const string modName = "CruiserTerminal";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("mborsh.CruiserTerminal");
public static ManualLogSource mls;
public static AssetBundle mainAssetBundle;
private static CTPlugin Instance;
public static GameObject terminalPrefab;
private static void NetcodePatcher()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
private void Awake()
{
NetcodePatcher();
Instance = this;
mls = Logger.CreateLogSource("Cruiser Terminal");
mls = ((BaseUnityPlugin)this).Logger;
mls.LogInfo((object)"Cruiser Terminal loaded. Patching.");
harmony.PatchAll(typeof(CTPatches));
if (!LoadAssetBundle())
{
mls.LogError((object)"Failed to load asset bundle! Abort mission!");
}
static bool LoadAssetBundle()
{
mls.LogInfo((object)"Loading AssetBundle...");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "CruiserTerminal"));
if ((Object)(object)mainAssetBundle == (Object)null)
{
return false;
}
mls.LogInfo((object)("AssetBundle " + ((Object)mainAssetBundle).name + " loaded from " + directoryName + "."));
return true;
}
}
}
}
namespace CruiserTerminal.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}