using System;
using System.Collections;
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 EnhancedRadarBooster.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnhancedRadarBooster")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mod for Lethal Company, that enhance Radar Booster")]
[assembly: AssemblyFileVersion("1.8.1.0")]
[assembly: AssemblyInformationalVersion("1.8.1+b1750139631ee349537d67a49d4d2b8a83999b57")]
[assembly: AssemblyProduct("EnhancedRadarBooster")]
[assembly: AssemblyTitle("EnhancedRadarBooster")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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;
}
}
}
namespace EnhancedRadarBooster
{
public class Config
{
public static ConfigEntry<bool> eRBNHEnabled;
public static ConfigEntry<bool> mapRangeRBEnabled;
public static ConfigEntry<float> mapRangeRBMultiplier;
public static ConfigEntry<bool> mapRangeRBSync;
public static ConfigEntry<bool> tpRBEnabled;
public static ConfigEntry<bool> itpRBEnabled;
public static ConfigEntry<bool> itpToRBEnabled;
public static ConfigEntry<bool> tpRBSync;
public static ConfigEntry<bool> remoteScrapRBFlashEnabled;
public static ConfigEntry<float> remoteScrapRBFlashRange;
public static ConfigEntry<bool> remoteScrapRBFlashSync;
public static bool eRBNHEnabledValue;
public static bool mapRangeRBEnabledValue;
public static float mapRangeRBMultiplierValue;
public static bool mapRangeRBSyncValue;
public static bool tpRBEnabledValue;
public static bool itpRBEnabledValue;
public static bool itpToRBEnabledValue;
public static bool tpRBSyncValue;
public static bool remoteScrapRBFlashEnabledValue;
public static float remoteScrapRBFlashRangeValue;
public static bool remoteScrapRBFlashSyncValue;
public static bool isHostHaveERBValue;
private static bool isLocalConfig = true;
public static void Bind()
{
eRBNHEnabled = Plugin.config.Bind<bool>("Networking", "ERBNHEnabled", true, "Enable mod Networking?\nRequired to enable features of [All clients] type.\nWill require having this mod to join lobby.");
mapRangeRBEnabled = Plugin.config.Bind<bool>("Map", "MapRangeRBEnabled", true, "Will Radar Booster provide a bigger vision range on Map Monitor?\n[One Client]");
mapRangeRBMultiplier = Plugin.config.Bind<float>("Map", "MapRangeRBMultiplier", 2f, "How much will be increased vision range on Map Monitor.\nSuggested values between x1.5-x2. Bigger values can prevent some thing model objects from showing on map.");
mapRangeRBSync = Plugin.config.Bind<bool>("Map", "MapRangeRBSync", false, "Will synchronize Map settings with all connected clients to have same values?\nIf Host then will force sync settings with all Clients.\nIf Client then will get settings from Host.");
tpRBEnabled = Plugin.config.Bind<bool>("Teleportation", "TpRBEnabled", true, "Will selected Radar Booster be teleported back to ship by Teleporter?\n[All Clients]");
itpRBEnabled = Plugin.config.Bind<bool>("Teleportation", "ITpRBEnabled", true, "Will Radar Booster be teleported to random location in facility by Inverse Teleporter?\n[All Clients]");
itpToRBEnabled = Plugin.config.Bind<bool>("Teleportation", "ITpToRBEnabled", true, "When Radar Booster selected on Ship Monitor and Inverse Teleporter activated, will Player be teleported to selected Radar Booster instead of random location?\n[One Client]");
tpRBSync = Plugin.config.Bind<bool>("Teleportation", "TpRBSync", true, "Will synchronize Teleportation settings with all connected clients to have same values?\nIf Host then will force sync settings with all Clients.\nIf Client then will get settings from Host.");
remoteScrapRBFlashEnabled = Plugin.config.Bind<bool>("Remote", "RemoteScrapRBFlashEnabled", true, "Can Remote scrap trigger Radar Booster Flash?\n[One Client, but will make it work for everyone in lobby even without being host]");
remoteScrapRBFlashRange = Plugin.config.Bind<float>("Remote", "RemoteScrapRBFlashRange", 16f, "Radius around player with Remote in which all Radar Boosters Flash will be triggered.\nSuggested values between 1-20.");
remoteScrapRBFlashSync = Plugin.config.Bind<bool>("Remote", "RemoteScrapRBFlashSync", true, "Will synchronize Remote settings with all connected clients to have same values?\nIf Host then will force sync settings with all Clients.\nIf Client then will get settings from Host.");
LoadFromConfig();
}
private static void LoadFromConfig()
{
eRBNHEnabledValue = eRBNHEnabled?.Value ?? true;
mapRangeRBEnabledValue = mapRangeRBEnabled?.Value ?? true;
mapRangeRBMultiplierValue = mapRangeRBMultiplier?.Value ?? 2f;
mapRangeRBSyncValue = mapRangeRBSync?.Value ?? false;
tpRBEnabledValue = tpRBEnabled?.Value ?? true;
itpRBEnabledValue = itpRBEnabled?.Value ?? true;
itpToRBEnabledValue = itpToRBEnabled?.Value ?? true;
tpRBSyncValue = tpRBSync?.Value ?? true;
remoteScrapRBFlashEnabledValue = remoteScrapRBFlashEnabled?.Value ?? true;
remoteScrapRBFlashRangeValue = remoteScrapRBFlashRange?.Value ?? 16f;
remoteScrapRBFlashSyncValue = remoteScrapRBFlashSync?.Value ?? true;
isLocalConfig = true;
}
public static FastBufferWriter WriteBuff()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
if (!isLocalConfig)
{
LoadFromConfig();
}
FastBufferWriter result = default(FastBufferWriter);
((FastBufferWriter)(ref result))..ctor(17, (Allocator)2, -1);
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref eRBNHEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref tpRBEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref itpRBEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref itpToRBEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref tpRBSyncValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref mapRangeRBEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref mapRangeRBSyncValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref remoteScrapRBFlashEnabledValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref remoteScrapRBFlashSyncValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref mapRangeRBMultiplierValue, default(ForPrimitives));
((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref remoteScrapRBFlashRangeValue, default(ForPrimitives));
return result;
}
public static void ReadBuff(FastBufferReader reader)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
string text = "";
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
eRBNHEnabledValue = flag;
text += $"\neRBNHEnabled = {eRBNHEnabledValue} / {eRBNHEnabled.Value}";
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
bool flag3 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
bool flag4 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag4, default(ForPrimitives));
bool flag5 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag5, default(ForPrimitives));
tpRBSyncValue = flag5 || tpRBSyncValue;
text += $"tpRBSync = {tpRBSyncValue}";
if (tpRBSyncValue)
{
tpRBEnabledValue = flag2;
itpRBEnabledValue = flag3;
itpToRBEnabledValue = flag4;
}
text += $"\ntpRBEnabled = {tpRBEnabledValue} / {tpRBEnabled.Value}";
text += $"\nitpRBEnabled = {itpRBEnabledValue} / {itpRBEnabled.Value}";
text += $"\nitpToRBEnabled = {itpToRBEnabledValue} / {itpToRBEnabled.Value}";
bool flag6 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag6, default(ForPrimitives));
bool flag7 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag7, default(ForPrimitives));
mapRangeRBSyncValue = flag7 || mapRangeRBSyncValue;
text += $"\nmapRangeRBSync = {mapRangeRBSyncValue}";
bool flag8 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag8, default(ForPrimitives));
bool flag9 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag9, default(ForPrimitives));
remoteScrapRBFlashSyncValue = flag9 || remoteScrapRBFlashSyncValue;
float num = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num, default(ForPrimitives));
if (mapRangeRBSyncValue)
{
mapRangeRBEnabledValue = flag6;
mapRangeRBMultiplierValue = num;
}
text += $"\nmapRangeRBEnabled = {mapRangeRBEnabledValue} / {mapRangeRBEnabled.Value}";
text += $"\nmapRangeRBMultiplier = {mapRangeRBMultiplierValue} / {mapRangeRBMultiplier.Value}";
float num2 = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives));
if (remoteScrapRBFlashSyncValue)
{
remoteScrapRBFlashEnabledValue = flag8;
remoteScrapRBFlashRangeValue = num2;
}
text += $"\nremoteScrapRBFlashSync = {remoteScrapRBFlashSyncValue}";
text += $"\nremoteScrapRBFlashEnabled = {remoteScrapRBFlashEnabledValue} / {remoteScrapRBFlashEnabled.Value}";
text += $"\nremoteScrapRBFlashRange = {remoteScrapRBFlashRangeValue} / {remoteScrapRBFlashRange.Value}";
isLocalConfig = false;
Plugin.MLogS.LogInfo((object)text);
}
}
public class EnhancedRadarBoosterNetworkHandler : NetworkBehaviour
{
public static EnhancedRadarBoosterNetworkHandler instance;
public override void OnNetworkSpawn()
{
if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)instance != (Object)null && (Object)(object)((Component)instance).gameObject != (Object)null)
{
NetworkObject component = ((Component)instance).gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
component.Despawn(true);
Plugin.MLogS.LogInfo((object)"EnhancedRadarBoosterNetworkHandler Despawned");
}
}
instance = this;
((NetworkBehaviour)this).OnNetworkSpawn();
Plugin.MLogS.LogInfo((object)"EnhancedRadarBoosterNetworkHandler Spawned");
}
public void TeleportRadarBoosterRpc(NetworkObjectReference item, Vector3 position, bool isEnable = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
{
instance.TeleportRadarBoosterClientRpc(item, position, isEnable);
}
}
[ServerRpc(RequireOwnership = false)]
public void TeleportRadarBoosterServerRpc(NetworkObjectReference item, Vector3 position, bool isEnable = false)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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(2627608713u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isEnable, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2627608713u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
TeleportRadarBoosterClientRpc(item, position, isEnable);
}
}
}
[ClientRpc]
public void TeleportRadarBoosterClientRpc(NetworkObjectReference item, Vector3 position, bool isEnable = false)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(729839707u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isEnable, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 729839707u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
((MonoBehaviour)this).StartCoroutine(TeleportRadarBooster(item, position, isEnable));
}
}
}
public IEnumerator TeleportRadarBooster(NetworkObjectReference item, Vector3 position, bool isEnable = false)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
NetworkObject val = null;
((NetworkObjectReference)(ref item)).TryGet(ref val, (NetworkManager)null);
RadarBoosterItem component = ((Component)val).GetComponent<RadarBoosterItem>();
Vector3 val2 = position;
((Component)component).transform.position = position;
if (isEnable)
{
((GrabbableObject)component).isInElevator = false;
((GrabbableObject)component).isInShipRoom = false;
((GrabbableObject)component).isInFactory = true;
((Component)component).transform.SetParent((Transform)null, true);
}
else
{
Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
if (((Bounds)(ref bounds)).Contains(val2))
{
((GrabbableObject)component).isInElevator = true;
((GrabbableObject)component).isInShipRoom = true;
((Component)component).transform.SetParent(StartOfRound.Instance.elevatorTransform, true);
}
else
{
bounds = StartOfRound.Instance.shipBounds.bounds;
if (((Bounds)(ref bounds)).Contains(val2))
{
((GrabbableObject)component).isInElevator = true;
((Component)component).transform.SetParent(StartOfRound.Instance.elevatorTransform, true);
}
else
{
((Component)component).transform.SetParent((Transform)null, true);
}
}
((GrabbableObject)component).isInFactory = false;
val2 += new Vector3(Random.Range(-0.5f, 0.5f), 0f, Random.Range(-0.5f, 0.5f));
}
if ((Object)(object)((Component)component).transform.parent != (Object)null)
{
val2 = ((Component)component).transform.parent.InverseTransformPoint(position);
}
((GrabbableObject)component).fallTime = 0f;
((GrabbableObject)component).hasHitGround = false;
GameNetworkManager.Instance.localPlayerController.SetItemInElevator(((GrabbableObject)component).isInElevator, ((GrabbableObject)component).isInShipRoom, (GrabbableObject)(object)component);
((GrabbableObject)component).startFallingPosition = val2 + Vector3.up * 0.07f;
((GrabbableObject)component).targetFloorPosition = val2;
((GrabbableObject)component).EnablePhysics(true);
if (((GrabbableObject)component).isBeingUsed != isEnable)
{
((GrabbableObject)component).UseItemOnClient(isEnable);
}
yield return null;
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(2627608713u, new RpcReceiveHandler(__rpc_handler_2627608713), "TeleportRadarBoosterServerRpc");
((NetworkBehaviour)this).__registerRpc(729839707u, new RpcReceiveHandler(__rpc_handler_729839707), "TeleportRadarBoosterClientRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_2627608713(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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference item = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
bool isEnable = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isEnable, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((EnhancedRadarBoosterNetworkHandler)(object)target).TeleportRadarBoosterServerRpc(item, position, isEnable);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_729839707(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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference item = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
bool isEnable = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isEnable, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((EnhancedRadarBoosterNetworkHandler)(object)target).TeleportRadarBoosterClientRpc(item, position, isEnable);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "EnhancedRadarBoosterNetworkHandler";
}
}
public class HarmonyPatches
{
private static readonly Type patchType;
private const float defaultOrthographicSize = 19.7f;
private const float defaultFarClipPlane = 7.52f;
private const float defaultNearClipPlane = -2.47f;
static HarmonyPatches()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_0118: 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_0148: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
patchType = typeof(HarmonyPatches);
Harmony val = new Harmony("LethalCompany.MrHydralisk.EnhancedRadarBooster");
val.Patch((MethodBase)AccessTools.Method(typeof(ManualCameraRenderer), "MapCameraFocusOnPosition", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(patchType, "MCR_MapCameraFocusOnPosition_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(ShipTeleporter), "beamUpPlayer", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(patchType, "ST_beamUpPlayer_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(ShipTeleporter), "beamOutPlayer", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(patchType, "ST_beamOutPlayer_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(GameNetworkManager), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(patchType, "GNM_Start_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(patchType, "SOR_Start_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(RemoteProp), "ItemActivate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(patchType, "RP_ItemActivate_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "ConnectClientToPlayerObject", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(patchType, "PCB_ConnectClientToPlayerObject_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
public static void MCR_MapCameraFocusOnPosition_Postfix(ManualCameraRenderer __instance)
{
if (Config.mapRangeRBEnabledValue)
{
if ((Object)(object)__instance.targetedPlayer == (Object)null)
{
float mapRangeRBMultiplierValue = Config.mapRangeRBMultiplierValue;
__instance.mapCamera.nearClipPlane = -2.47f / mapRangeRBMultiplierValue;
__instance.mapCamera.farClipPlane = 7.52f * mapRangeRBMultiplierValue;
StartOfRound.Instance.radarCanvas.planeDistance = -2.47f / mapRangeRBMultiplierValue + 0.05f;
__instance.mapCamera.orthographicSize = 19.7f * mapRangeRBMultiplierValue;
}
else
{
__instance.mapCamera.farClipPlane = 7.52f;
__instance.mapCamera.orthographicSize = 19.7f;
}
}
}
public static void beamUpRadarBooster(Transform teleporterPosition)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
ManualLogSource mLogS = Plugin.MLogS;
Vector3 position = teleporterPosition.position;
mLogS.LogInfo((object)("beamUpRadarBooster to " + ((object)(Vector3)(ref position)).ToString()));
ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
RadarBoosterItem component;
if ((NetworkManager.Singleton.IsServer || Config.isHostHaveERBValue) && Config.eRBNHEnabledValue && Config.tpRBEnabledValue && mapScreen.targetTransformIndex < mapScreen.radarTargets.Count && mapScreen.radarTargets[mapScreen.targetTransformIndex].isNonPlayer && (Object)(object)(component = ((Component)mapScreen.radarTargets[mapScreen.targetTransformIndex].transform).gameObject.GetComponent<RadarBoosterItem>()) != (Object)null)
{
Vector3 position2 = teleporterPosition.position;
EnhancedRadarBoosterNetworkHandler.instance.TeleportRadarBoosterRpc(NetworkObjectReference.op_Implicit(((Component)component).GetComponent<NetworkObject>()), position2);
}
}
public static IEnumerable<CodeInstruction> ST_beamUpPlayer_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
int num = -1;
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
Plugin.MLogS.LogInfo((object)string.Format(" - {0} - {1} | {2} | {3} | {4}", i, list[i], list[i].opcode, list[i].operand, CodeInstructionExtensions.Is(list[i], OpCodes.Ldstr, (object)"Targeted player is null")));
if (CodeInstructionExtensions.Is(list[i], OpCodes.Ldstr, (object)"Targeted player is null"))
{
Plugin.MLogS.LogInfo((object)$"START {i}");
num = i;
}
}
if (num > -1)
{
List<CodeInstruction> list2 = new List<CodeInstruction>();
list2.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null));
list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShipTeleporter), "teleporterPosition")));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HarmonyPatches), "beamUpRadarBooster", (Type[])null, (Type[])null)));
list.InsertRange(num + 1, list2);
}
return list.AsEnumerable();
}
public static void beamOutRadarBooster(Transform teleporterPosition, Random shipTeleporterSeed)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if ((!NetworkManager.Singleton.IsServer && !Config.isHostHaveERBValue) || !Config.eRBNHEnabledValue || !Config.itpRBEnabledValue)
{
return;
}
Collider[] array = Physics.OverlapSphere(teleporterPosition.position, 2f);
for (int i = 0; i < array.Length; i++)
{
RadarBoosterItem component = ((Component)array[i]).gameObject.GetComponent<RadarBoosterItem>();
if ((Object)(object)component != (Object)null)
{
Vector3 position = RoundManager.Instance.insideAINodes[shipTeleporterSeed.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), shipTeleporterSeed, -1, 1f);
EnhancedRadarBoosterNetworkHandler.instance.TeleportRadarBoosterRpc(NetworkObjectReference.op_Implicit(((Component)component).GetComponent<NetworkObject>()), position, isEnable: true);
}
}
}
public static Vector3 VectorToRadarBooster(Vector3 current)
{
//IL_0090: 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_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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)
ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
RadarBoosterItem component;
if (Config.itpToRBEnabledValue && mapScreen.targetTransformIndex < mapScreen.radarTargets.Count && mapScreen.radarTargets[mapScreen.targetTransformIndex].isNonPlayer && (Object)(object)(component = ((Component)mapScreen.radarTargets[mapScreen.targetTransformIndex].transform).gameObject.GetComponent<RadarBoosterItem>()) != (Object)null)
{
current = ((Component)component).transform.position;
current = RoundManager.Instance.GetNavMeshPosition(current, default(NavMeshHit), 0.5f, -1);
}
return current;
}
public static IEnumerable<CodeInstruction> ST_beamOutPlayer_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
bool flag = false;
int num = -1;
int num2 = -1;
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
if (!CodeInstructionExtensions.Calls(list[i], AccessTools.Method(typeof(RoundManager), "get_Instance", (Type[])null, (Type[])null)) || i + 5 >= list.Count || !CodeInstructionExtensions.Calls(list[i + 5], AccessTools.Method(typeof(RoundManager), "get_Instance", (Type[])null, (Type[])null)))
{
continue;
}
num = i;
for (int j = num + 1; j < list.Count; j++)
{
if (CodeInstructionExtensions.IsStloc(list[j], (LocalBuilder)null) && ((object)list[j]).ToString().Contains("UnityEngine.Vector3"))
{
flag = true;
num2 = j;
break;
}
if (list[j].opcode == OpCodes.Ret)
{
break;
}
}
if (flag)
{
break;
}
}
if (num > -1 && num2 > -1)
{
List<CodeInstruction> list2 = new List<CodeInstruction>();
list2.Add(new CodeInstruction(OpCodes.Ldloc_S, (object)8));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HarmonyPatches), "VectorToRadarBooster", (Type[])null, (Type[])null)));
list2.Add(new CodeInstruction(OpCodes.Stloc_S, (object)8));
list.InsertRange(num2 + 1, list2);
}
List<CodeInstruction> list3 = new List<CodeInstruction>();
list3.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null));
list3.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShipTeleporter), "teleporterPosition")));
list3.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null));
list3.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShipTeleporter), "shipTeleporterSeed")));
list3.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HarmonyPatches), "beamOutRadarBooster", (Type[])null, (Type[])null)));
list.InsertRange(list.Count() - 2, list3);
return list.AsEnumerable();
}
public static void GNM_Start_Postfix(GameNetworkManager __instance)
{
if (Config.eRBNHEnabledValue)
{
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.instance.enhancedRadarBoosterNetworkManager);
}
}
public static void SOR_Start_Postfix(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsHost && Config.eRBNHEnabledValue && (Config.tpRBEnabledValue || Config.itpRBEnabledValue))
{
Object.Instantiate<GameObject>(Plugin.instance.enhancedRadarBoosterNetworkManager).GetComponent<NetworkObject>().Spawn(true);
}
}
public static void RP_ItemActivate_Postfix(RemoteProp __instance)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (!Config.remoteScrapRBFlashEnabledValue)
{
return;
}
Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, Config.remoteScrapRBFlashRangeValue);
for (int i = 0; i < array.Length; i++)
{
RadarBoosterItem component = ((Component)array[i]).gameObject.GetComponent<RadarBoosterItem>();
if ((Object)(object)component != (Object)null)
{
component.FlashAndSync();
}
}
}
public static void PCB_ConnectClientToPlayerObject_Postfix()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsServer)
{
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("MrHydralisk.EnhancedRadarBooster.ConfigSync", new HandleNamedMessageDelegate(ConfigSyncRequest));
return;
}
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("MrHydralisk.EnhancedRadarBooster.ReceiveConfigSync", new HandleNamedMessageDelegate(ConfigSync));
if (NetworkManager.Singleton.IsClient)
{
Config.isHostHaveERBValue = false;
Plugin.MLogS.LogInfo((object)"Sending config sync request to Server.");
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MrHydralisk.EnhancedRadarBooster.ConfigSync", 0uL, new FastBufferWriter(16, (Allocator)2, -1), (NetworkDelivery)3);
}
else
{
Plugin.MLogS.LogWarning((object)"Error Sending config sync request to Server.");
}
}
public static void ConfigSyncRequest(ulong clientId, FastBufferReader reader)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsServer)
{
Plugin.MLogS.LogInfo((object)$"Receiving config sync request from client {clientId}. Sending config sync to Client.");
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MrHydralisk.EnhancedRadarBooster.ReceiveConfigSync", clientId, Config.WriteBuff(), (NetworkDelivery)3);
}
}
public static void ConfigSync(ulong clientId, FastBufferReader reader)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (((FastBufferReader)(ref reader)).TryBeginRead(4))
{
Plugin.MLogS.LogInfo((object)"Receiving config sync from Server.");
Config.isHostHaveERBValue = true;
Config.ReadBuff(reader);
}
else
{
Plugin.MLogS.LogWarning((object)"Error Receiving config sync from Server.");
}
}
}
[BepInPlugin("MrHydralisk.EnhancedRadarBooster", "Enhanced Radar Booster", "1.8.1")]
public class Plugin : BaseUnityPlugin
{
public const string MOD_GUID = "MrHydralisk.EnhancedRadarBooster";
private const string MOD_NAME = "Enhanced Radar Booster";
public static Plugin instance;
public static ManualLogSource MLogS;
public static ConfigFile config;
public GameObject enhancedRadarBoosterNetworkManager;
private void Awake()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
MLogS = Logger.CreateLogSource("MrHydralisk.EnhancedRadarBooster");
config = ((BaseUnityPlugin)this).Config;
Config.Bind();
instance = this;
try
{
RuntimeHelpers.RunClassConstructor(typeof(HarmonyPatches).TypeHandle);
}
catch (Exception ex)
{
MLogS.LogError((object)string.Concat("Error in static constructor of ", typeof(HarmonyPatches), ": ", ex));
}
LoadBundle();
MLogS.LogInfo((object)"Plugin is loaded!");
}
private void LoadBundle()
{
AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("EnhancedRadarBooster.Assets.enhancedradarbooster"));
enhancedRadarBoosterNetworkManager = val.LoadAsset<GameObject>("Assets/Mods/EnhancedRadarBooster/EnhancedRadarBoosterNetworkManager.prefab");
enhancedRadarBoosterNetworkManager.AddComponent<EnhancedRadarBoosterNetworkHandler>();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "EnhancedRadarBooster";
public const string PLUGIN_NAME = "EnhancedRadarBooster";
public const string PLUGIN_VERSION = "1.8.1";
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace EnhancedRadarBooster.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}