Decompiled source of ImmersiveCompany v0.3.4

plugins/ImmersiveCompany/ImmersiveCompany_patched.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using ImmersiveCompany.ICItems;
using ImmersiveCompany.ImmersiveCompanyItems;
using ImmersiveCompany.NetcodePatcher;
using ImmersiveCompany.Patches;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;

[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 = "")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("ImmersiveCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Immersion focused gameplay mod.")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("ImmersiveCompany")]
[assembly: AssemblyTitle("ImmersiveCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace ImmersiveCompany
{
	public class ICUtilityHandler : MonoBehaviour
	{
		public static ICUtilityHandler instance;

		public Camera localPlayerCamera;

		public GameObject localPlayer;

		public GameObject networkHandlerPrefab;

		public void Awake()
		{
			instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}
	}
	public class ImmersiveCompanyNetManager : NetworkBehaviour
	{
		public static ImmersiveCompanyNetManager instance;

		private void Awake()
		{
			instance = this;
			Debug.Log((object)"///////////////////////////////////////////////////////");
			Debug.Log((object)"//      Immersive Company Network Initialized.       //");
			Debug.Log((object)"///////////////////////////////////////////////////////");
		}

		[ServerRpc(RequireOwnership = false)]
		public void LockDoorServerRpc(ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: 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)
			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(3532575946u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3532575946u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					GameObject val3 = FindObjectById(networkId);
					DoorLock componentInChildren = val3.GetComponentInChildren<DoorLock>();
					componentInChildren.LockDoor(30f);
					LockDoorClientRpc(networkId);
				}
			}
		}

		[ClientRpc]
		public void LockDoorClientRpc(ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: 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)
			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(1651559856u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, networkId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1651559856u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				GameObject val3 = FindObjectById(networkId);
				if ((Object)(object)val3 != (Object)null)
				{
					DoorLock componentInChildren = val3.GetComponentInChildren<DoorLock>();
					componentInChildren.LockDoor(30f);
				}
			}
		}

		public void LockDoorSyncWithServer(ulong networkId)
		{
			LockDoorServerRpc(networkId);
		}

		public void Scanner_SetStateAndSync(bool powerState, ulong networkId)
		{
			Scanner_SetStateServerRpc(powerState, networkId);
		}

		[ClientRpc]
		public void Scanner_SetStateClientRpc(bool powerState, ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008c: 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)
			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(3463519805u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref powerState, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, networkId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3463519805u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				GameObject val3 = FindObjectById(networkId);
				if ((Object)(object)val3 != (Object)null)
				{
					val3.GetComponent<ICPersonalRadar>().SetState(powerState);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void Scanner_SetStateServerRpc(bool powerState, ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1837023028u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref powerState, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, networkId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1837023028u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				GameObject val3 = FindObjectById(networkId);
				if ((Object)(object)val3 != (Object)null)
				{
					val3.GetComponent<ICPersonalRadar>().SetState(powerState);
				}
				Scanner_SetStateClientRpc(powerState, networkId);
			}
		}

		private static GameObject FindObjectById(ulong networkId)
		{
			return (networkId == 0L) ? null : ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId]).gameObject;
		}

		public void Glowstick_ActivateAndSync(ulong networkId)
		{
			GlowStick_ActivateServerRpc(networkId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void GlowStick_ActivateServerRpc(ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: 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)
			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(1768428293u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1768428293u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					GlowStick_ActivateClientRpc(networkId);
					ICGlowStick component = FindObjectById(networkId).GetComponent<ICGlowStick>();
					component.Activate();
				}
			}
		}

		[ClientRpc]
		public void GlowStick_ActivateClientRpc(ulong networkId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: 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)
			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(4098792217u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4098792217u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ICGlowStick component = FindObjectById(networkId).GetComponent<ICGlowStick>();
					component.Activate();
				}
			}
		}

		public void TeleportRadarBoosterAndSync(ulong networkId, SVector3 position, ulong teleporterId)
		{
			TeleportRadarBoosterServerRpc(networkId, position, teleporterId);
		}

		[ServerRpc(RequireOwnership = false)]
		public void TeleportRadarBoosterServerRpc(ulong networkId, SVector3 position, ulong teleporterId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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(1310342417u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<SVector3>(ref position, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, teleporterId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1310342417u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					TeleportRadarBoosterClientRpc(networkId, position, teleporterId);
				}
			}
		}

		[ClientRpc]
		public void TeleportRadarBoosterClientRpc(ulong networkId, SVector3 position, ulong teleporterId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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(1443374522u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<SVector3>(ref position, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, teleporterId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1443374522u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					GameObject item = FindObjectById(networkId);
					ShipTeleporter component = FindObjectById(teleporterId).gameObject.GetComponent<ShipTeleporter>();
					typeof(ShipTeleporter).GetMethod("PressButtonEffects", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(component, null);
					component.shipTeleporterAudio.PlayOneShot(component.teleporterSpinSFX);
					((MonoBehaviour)this).StartCoroutine(TeleportRadarBoosterEnum(item, SVector3.ToVector3(position), component));
				}
			}
		}

		public IEnumerator TeleportRadarBoosterEnum(GameObject item, Vector3 position, ShipTeleporter teleporter)
		{
			//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)
			yield return (object)new WaitForSeconds(3f);
			teleporter.shipTeleporterAudio.PlayOneShot(teleporter.teleporterBeamUpSFX);
			RadarBoosterItem radarBooster = item.GetComponent<RadarBoosterItem>();
			((GrabbableObject)radarBooster).startFallingPosition = position;
			((Component)radarBooster).transform.position = position;
			((GrabbableObject)radarBooster).targetFloorPosition = position;
			((GrabbableObject)radarBooster).FallToGround(false);
			yield return null;
		}

		public void SetLanternStateAndSync(ulong networkId, bool state)
		{
			SetLanternStateServerRpc(networkId, state);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetLanternStateServerRpc(ulong networkId, bool state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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)
			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(2896780308u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2896780308u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetLanternStateClientRpc(networkId, state);
				}
			}
		}

		[ClientRpc]
		public void SetLanternStateClientRpc(ulong networkId, bool state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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)
			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(3536438799u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, networkId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3536438799u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					GameObject val3 = FindObjectById(networkId);
					val3.GetComponent<ICLantern>().SetState(state);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ImmersiveCompanyNetManager()
		{
			//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
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3532575946u, new RpcReceiveHandler(__rpc_handler_3532575946));
			NetworkManager.__rpc_func_table.Add(1651559856u, new RpcReceiveHandler(__rpc_handler_1651559856));
			NetworkManager.__rpc_func_table.Add(3463519805u, new RpcReceiveHandler(__rpc_handler_3463519805));
			NetworkManager.__rpc_func_table.Add(1837023028u, new RpcReceiveHandler(__rpc_handler_1837023028));
			NetworkManager.__rpc_func_table.Add(1768428293u, new RpcReceiveHandler(__rpc_handler_1768428293));
			NetworkManager.__rpc_func_table.Add(4098792217u, new RpcReceiveHandler(__rpc_handler_4098792217));
			NetworkManager.__rpc_func_table.Add(1310342417u, new RpcReceiveHandler(__rpc_handler_1310342417));
			NetworkManager.__rpc_func_table.Add(1443374522u, new RpcReceiveHandler(__rpc_handler_1443374522));
			NetworkManager.__rpc_func_table.Add(2896780308u, new RpcReceiveHandler(__rpc_handler_2896780308));
			NetworkManager.__rpc_func_table.Add(3536438799u, new RpcReceiveHandler(__rpc_handler_3536438799));
		}

		private static void __rpc_handler_3532575946(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ImmersiveCompanyNetManager)(object)target).LockDoorServerRpc(networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1651559856(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ImmersiveCompanyNetManager)(object)target).LockDoorClientRpc(networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3463519805(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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool powerState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref powerState, default(ForPrimitives));
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ImmersiveCompanyNetManager)(object)target).Scanner_SetStateClientRpc(powerState, networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1837023028(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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool powerState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref powerState, default(ForPrimitives));
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ImmersiveCompanyNetManager)(object)target).Scanner_SetStateServerRpc(powerState, networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1768428293(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ImmersiveCompanyNetManager)(object)target).GlowStick_ActivateServerRpc(networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4098792217(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ImmersiveCompanyNetManager)(object)target).GlowStick_ActivateClientRpc(networkId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1310342417(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				SVector3 position = default(SVector3);
				((FastBufferReader)(ref reader)).ReadValueSafe<SVector3>(ref position, default(ForNetworkSerializable));
				ulong teleporterId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref teleporterId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ImmersiveCompanyNetManager)(object)target).TeleportRadarBoosterServerRpc(networkId, position, teleporterId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1443374522(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				SVector3 position = default(SVector3);
				((FastBufferReader)(ref reader)).ReadValueSafe<SVector3>(ref position, default(ForNetworkSerializable));
				ulong teleporterId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref teleporterId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ImmersiveCompanyNetManager)(object)target).TeleportRadarBoosterClientRpc(networkId, position, teleporterId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2896780308(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				bool state = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref state, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ImmersiveCompanyNetManager)(object)target).SetLanternStateServerRpc(networkId, state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3536438799(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkId);
				bool state = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref state, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ImmersiveCompanyNetManager)(object)target).SetLanternStateClientRpc(networkId, state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ImmersiveCompanyNetManager";
		}
	}
	[BepInPlugin("ImmersiveCompany", "ImmersiveCompany", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ImmersiveCompany");

		public static AssetBundle ICAssets;

		public static ImmersiveCompanyNetManager netManager;

		public string path_Audio = "Assets/ImmersiveCompanyAssets/Audio/";

		public string path_ItemData = "Assets/ImmersiveCompanyAssets/ItemData/";

		public string path_ItemPrefab = "Assets/ImmersiveCompanyAssets/ItemPrefab/";

		public string path_Enemies = "Assets/ImmersiveCompanyAssets/Enemies/";

		public string path_CustomData = "Assets/ImmersiveCompanyAssets/CustomData/";

		public static ICConfig Config;

		public GameObject netManagerGO;

		private void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Config = new ICConfig(((BaseUnityPlugin)this).Config);
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("ICNetManager");
			val.AddComponent<ImmersiveCompanyNetManager>();
			GameObject val2 = new GameObject("ICNetUtiltiy");
			val2.AddComponent<ICUtilityHandler>();
			val2.GetComponent<ICUtilityHandler>().networkHandlerPrefab = val;
			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);
					}
				}
			}
			LogAscii();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			ICAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "immersivecompanyassets"));
			if ((Object)(object)ICAssets == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Immersive Company failed to load it's assets...");
				return;
			}
			if (Config.customScrapEnabled.Value)
			{
				AddScrap("IC_Screwdriver", 40, (LevelTypes)(-1));
				AddScrap("IC_Gemstone", 4, (LevelTypes)(-1));
				SetupClock();
				SetupStrangeCanister();
			}
			if (Config.personalRadarEnabled.Value)
			{
				SetupScannerGun(Config.personalRadarPrice.Value);
			}
			if (Config.glowStickEnabled.Value)
			{
				SetupGlowStick(Config.glowStickPrice.Value);
			}
			if (Config.lanternEnabled.Value)
			{
				SetupLantern(Config.lanternPrice.Value);
			}
			if (Config.permanentLadderEnabled.Value)
			{
				harmony.PatchAll(typeof(ICLadderPatch));
			}
			if (Config.keysLockDoorsEnabled.Value)
			{
				harmony.PatchAll(typeof(ICKeyItemPatch));
				harmony.PatchAll(typeof(DoorLockPatch));
			}
			if (Config.radarBoosterOverhaulEnabled.Value)
			{
				harmony.PatchAll(typeof(ManualCameraRendererPatch));
				harmony.PatchAll(typeof(ShipTeleporterPatch));
				harmony.PatchAll(typeof(ICRadarBoosterPatch));
			}
			harmony.PatchAll(typeof(ICStartOfRoundPatch));
		}

		public void AddScrap(string itemAssetName, int rarity, LevelTypes levelType)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Item val = LoadItem(itemAssetName);
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, levelType);
		}

		public void SetupScannerGun(int price)
		{
			//IL_0052: 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)
			string itemAssetName = "IC_ScannerGun";
			string itemName = "Personal Radar";
			string displayText = "Scans for scrap in your vicinity. \n";
			int itemId = 6767;
			float screenEdgeDistance = 0.125f;
			float batteryUsage = 250f;
			Item val = LoadItem(itemAssetName);
			val.itemId = itemId;
			val.batteryUsage = batteryUsage;
			val.restingRotation = new Vector3(0f, 0f, 90f);
			val.itemName = itemName;
			val.itemSpawnsOnGround = true;
			GameObject lootNodePrefab = ICAssets.LoadAsset<GameObject>(path_ItemPrefab + "ItemScannerItemNode.prefab");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			ICPersonalRadar iCPersonalRadar = val.spawnPrefab.AddComponent<ICPersonalRadar>();
			iCPersonalRadar.lootNodePrefab = lootNodePrefab;
			iCPersonalRadar.scannerScreenBase = ((Component)((Component)iCPersonalRadar).gameObject.transform.GetChild(0)).gameObject;
			iCPersonalRadar.scannerScreen = ((Component)iCPersonalRadar).gameObject.transform.GetChild(0).GetChild(0);
			iCPersonalRadar.screenLight = ((Component)((Component)iCPersonalRadar).gameObject.transform.GetChild(0).GetChild(1)).gameObject;
			iCPersonalRadar.blackOutScreen = ((Component)((Component)iCPersonalRadar).gameObject.transform.GetChild(0).GetChild(2)).gameObject;
			((GrabbableObject)iCPersonalRadar).itemProperties = val;
			((GrabbableObject)iCPersonalRadar).grabbable = true;
			((GrabbableObject)iCPersonalRadar).grabbableToEnemies = true;
			iCPersonalRadar.screenEdgeDistance = screenEdgeDistance;
			TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
			val2.displayText = displayText;
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, price);
		}

		public void SetupGlowStick(int price)
		{
			string itemAssetName = "IC_GlowStick";
			string itemName = "Glow stick";
			string displayText = "Lights the way. \n";
			Item val = LoadItem(itemAssetName);
			val.itemName = itemName;
			val.itemSpawnsOnGround = true;
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			ICGlowStick iCGlowStick = val.spawnPrefab.AddComponent<ICGlowStick>();
			iCGlowStick.snapSFX = LoadAudioClip("glowstickSnap");
			iCGlowStick.light = ((Component)((Component)iCGlowStick).gameObject.transform.GetChild(0)).gameObject;
			((GrabbableObject)iCGlowStick).itemProperties = val;
			((GrabbableObject)iCGlowStick).grabbable = true;
			((GrabbableObject)iCGlowStick).grabbableToEnemies = true;
			TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
			val2.displayText = displayText;
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, price);
		}

		public void SetupStrangeCanister()
		{
			Item val = LoadItem("IC_StrangeCanister");
			ICStrangeCanister iCStrangeCanister = val.spawnPrefab.AddComponent<ICStrangeCanister>();
			((GrabbableObject)iCStrangeCanister).itemProperties = val;
			((GrabbableObject)iCStrangeCanister).grabbable = true;
			((GrabbableObject)iCStrangeCanister).grabbableToEnemies = true;
			val.itemName = "Strange Canister";
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 5, (LevelTypes)(-1));
		}

		public void SetupHandGrenade()
		{
			Item val = LoadItem("IC_HandGrenade");
			ICHandGrenade iCHandGrenade = val.spawnPrefab.AddComponent<ICHandGrenade>();
			((GrabbableObject)iCHandGrenade).itemProperties = val;
			iCHandGrenade.itemAnimator = val.spawnPrefab.GetComponent<Animator>();
			iCHandGrenade.itemAudio = val.spawnPrefab.GetComponent<AudioSource>();
			iCHandGrenade.grenadeFallCurve = ImmersiveUtilities.GetLinearCurve();
			iCHandGrenade.grenadeVerticalFallCurve = ImmersiveUtilities.GetGrenadeVerticalCurve();
			iCHandGrenade.grenadeVerticalFallCurveNoBounce = ImmersiveUtilities.GetGrenadeVerticalCurve();
			iCHandGrenade.explodeSFX = ICAssets.LoadAsset<AudioClip>(path_Audio + "ICGrenadeExplosion.ogg");
			iCHandGrenade.pullPinSFX = ICAssets.LoadAsset<AudioClip>(path_Audio + "FlashbangPullPin.ogg");
			((GrabbableObject)iCHandGrenade).grabbable = true;
			((GrabbableObject)iCHandGrenade).grabbableToEnemies = true;
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 3, (LevelTypes)(-1));
		}

		public void SetupLantern(int price)
		{
			Item val = LoadItem("IC_Lantern");
			string itemName = "Lantern";
			string displayText = "A powerful light source with a long lasting battery. \n";
			int num = 650;
			val.itemName = itemName;
			ICLantern iCLantern = val.spawnPrefab.AddComponent<ICLantern>();
			((GrabbableObject)iCLantern).grabbable = true;
			val.batteryUsage = num;
			((GrabbableObject)iCLantern).grabbableToEnemies = true;
			((GrabbableObject)iCLantern).itemProperties = val;
			iCLantern.toggleClip = LoadAudioClip("FlashlightClick");
			iCLantern.light = ((Component)((Component)iCLantern).gameObject.transform.GetChild(0).GetChild(0).GetChild(0)
				.GetChild(0)).gameObject;
			iCLantern.lightMast = ((Component)((Component)iCLantern).gameObject.transform.GetChild(0).GetChild(0).GetChild(0)
				.GetChild(2)).gameObject;
			iCLantern.body = ((Component)iCLantern).gameObject.transform.GetChild(0).GetChild(0).GetChild(0);
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
			val2.displayText = displayText;
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, price);
		}

		public void SetupClock()
		{
			Item val = LoadItem("IC_Clock");
			ICClock iCClock = val.spawnPrefab.AddComponent<ICClock>();
			((GrabbableObject)iCClock).grabbable = true;
			iCClock.alarmClip = LoadAudioClip("AlarmClock");
			((GrabbableObject)iCClock).grabbableToEnemies = true;
			((GrabbableObject)iCClock).itemProperties = val;
			iCClock.hourHand = ((Component)iCClock).gameObject.transform.GetChild(0).GetChild(2);
			iCClock.minuteHand = ((Component)iCClock).gameObject.transform.GetChild(0).GetChild(3);
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 5, (LevelTypes)(-1));
		}

		public void LogAscii()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"\n  _____  __  __  __  __  ______  _____    _____  _____ __      __ ______ \n |_   _||  \\/  ||  \\/  ||  ____||  __ \\  / ____||_   _|\\ \\    / /|  ____|\n   | |  | \\  / || \\  / || |__   | |__) || (___    | |   \\ \\  / / | |__   \n   | |  | |\\/| || |\\/| ||  __|  |  _  /  \\___ \\   | |    \\ \\/ /  |  __|  \n  _| |_ | |  | || |  | || |____ | | \\ \\  ____) | _| |_    \\  /   | |____ \n |_____||_|  |_||_|  |_||______||_|  \\_\\|_____/ |_____|    \\/    |______|\n          _____  ____   __  __  _____          _   _ __     __           \n         / ____|/ __ \\ |  \\/  ||  __ \\  /\\    | \\ | |\\ \\   / /           \n        | |    | |  | || \\  / || |__) |/  \\   |  \\| | \\ \\_/ /            \n        | |    | |  | || |\\/| ||  ___// /\\ \\  | . ` |  \\   /             \n        | |____| |__| || |  | || |   / ____ \\ | |\\  |   | |              \n         \\_____|\\____/ |_|  |_||_|  /_/    \\_\\|_| \\_|   |_|              \n");
		}

		public Item LoadItem(string itemAssetName)
		{
			Item val = ICAssets.LoadAsset<Item>(path_ItemData + itemAssetName + ".asset");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Failed to load item: " + itemAssetName));
			return null;
		}

		public AudioClip LoadAudioClip(string clipAssetName)
		{
			AudioClip val = ICAssets.LoadAsset<AudioClip>(path_Audio + clipAssetName + ".ogg");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Failed to load audio clip: " + clipAssetName));
			return null;
		}

		public AudioClip LoadAudioClip(string clipAssetName, string format)
		{
			AudioClip val = ICAssets.LoadAsset<AudioClip>(path_Audio + clipAssetName + "." + format);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Failed to load audio clip: " + clipAssetName));
			return null;
		}
	}
	public class ICConfig : SyncedConfig2<ICConfig>
	{
		public SyncedEntry<bool> keysLockDoorsEnabled;

		public SyncedEntry<bool> permanentLadderEnabled;

		public SyncedEntry<bool> radarBoosterOverhaulEnabled;

		public SyncedEntry<bool> personalRadarEnabled;

		public SyncedEntry<int> personalRadarPrice;

		public SyncedEntry<bool> glowStickEnabled;

		public SyncedEntry<int> glowStickPrice;

		public SyncedEntry<bool> lanternEnabled;

		public SyncedEntry<int> lanternPrice;

		public SyncedEntry<bool> customScrapEnabled;

		public ICConfig(ConfigFile cfg)
			: base("ImmersiveCompany")
		{
			ConfigManager.Register<ICConfig>((SyncedConfig2<ICConfig>)this);
			keysLockDoorsEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Keys Lock Doors", "Enabled", true, "Enabled");
			permanentLadderEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Permanent Ladder", "Enabled", true, "Enabled");
			radarBoosterOverhaulEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Radar Booster Overhaul", "Enabled", true, "Enabled");
			customScrapEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Custom Scrap", "Enabled", true, "Enabled");
			personalRadarEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Personal Radar", "Enabled", true, "Enabled");
			personalRadarPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Personal Radar", "Price", 400, "Price");
			glowStickEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Glow Stick", "Enabled", true, "Enabled");
			glowStickPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Glow Stick", "Price", 10, "Price");
			lanternEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Lantern", "Enabled", true, "Enabled");
			lanternPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Lantern", "Price", 125, "Price");
		}
	}
	public static class ImmersiveUtilities
	{
		public static AnimationCurve GetLinearCurve()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			Keyframe[] keys = (Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0f),
				new Keyframe(1f, 1f)
			};
			AnimationCurve val = new AnimationCurve();
			val.keys = keys;
			return val;
		}

		public static AnimationCurve GetGrenadeVerticalCurve()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			Keyframe[] keys = (Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0f, 0f, 0f),
				new Keyframe(1f, 1f, 2f, 2f)
			};
			AnimationCurve val = new AnimationCurve();
			val.keys = keys;
			return val;
		}
	}
	public struct SVector3 : INetworkSerializable
	{
		public float x;

		public float y;

		public float z;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref x, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref y, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref z, default(ForPrimitives));
		}

		public SVector3(float X, float Y, float Z)
		{
			x = X;
			y = Y;
			z = Z;
		}

		public static Vector3 ToVector3(SVector3 vector)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(vector.x, vector.y, vector.z);
		}

		public static SVector3 FromVector3(Vector3 vector)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return new SVector3(vector.x, vector.y, vector.z);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ImmersiveCompany";

		public const string PLUGIN_NAME = "ImmersiveCompany";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}
namespace ImmersiveCompany.Patches
{
	[HarmonyPatch(typeof(KeyItem))]
	internal class ICKeyItemPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		private static bool KeyItemLockPatch(ref KeyItem __instance, bool used, bool buttonDown = true)
		{
			//IL_002b: 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)
			PlayerControllerB playerHeldBy = ((Component)__instance).GetComponent<GrabbableObject>().playerHeldBy;
			RaycastHit val = default(RaycastHit);
			if ((Object)(object)playerHeldBy != (Object)null && ((NetworkBehaviour)__instance).IsOwner && Physics.Raycast(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward, ref val, 3f, 2816))
			{
				DoorLock component = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<DoorLock>();
				if ((Object)(object)component != (Object)null && !component.isPickingLock)
				{
					if (!component.isLocked)
					{
						if ((Object)(object)ImmersiveCompanyNetManager.instance == (Object)null)
						{
							Debug.LogError((object)"ImmersiveCompanyNetManager has not been initialized..");
							return false;
						}
						ImmersiveCompanyNetManager.instance.LockDoorSyncWithServer(((NetworkBehaviour)component).NetworkObjectId);
						playerHeldBy.DespawnHeldObject();
					}
					else
					{
						component.UnlockDoorSyncWithServer();
						playerHeldBy.DespawnHeldObject();
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(DoorLock))]
	internal class DoorLockPatch
	{
		[HarmonyPatch("LockDoor")]
		[HarmonyPrefix]
		private static void LockDoorPatch(ref DoorLock __instance)
		{
			__instance.doorLockSFX.Stop();
			__instance.doorLockSFX.PlayOneShot(__instance.unlockSFX);
		}
	}
	[HarmonyPatch(typeof(ExtensionLadderItem))]
	internal class ICLadderPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void LadderTimePatch(ref float ___ladderTimer)
		{
			___ladderTimer = 1f;
		}
	}
	[HarmonyPatch(typeof(RadarBoosterItem))]
	internal class ICRadarBoosterPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		public static void RadarBoosterActivatePatch(RadarBoosterItem __instance)
		{
		}
	}
	[HarmonyPatch(typeof(ManualCameraRenderer))]
	internal class ManualCameraRendererPatch
	{
		[HarmonyPatch("MapCameraFocusOnPosition")]
		[HarmonyPostfix]
		public static void MapCameraFocusPatch(ManualCameraRenderer __instance)
		{
			float orthographicSize = 19.7f;
			float orthographicSize2 = 32.7f;
			float nearClipPlane = -2.47f;
			float nearClipPlane2 = -0.25f;
			float planeDistance = -2.4f;
			float planeDistance2 = -0.2f;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				if (__instance.radarTargets[__instance.targetTransformIndex].isNonPlayer)
				{
					__instance.mapCamera.orthographicSize = orthographicSize2;
					__instance.mapCamera.nearClipPlane = nearClipPlane2;
					StartOfRound.Instance.radarCanvas.planeDistance = planeDistance2;
				}
				else
				{
					__instance.mapCamera.orthographicSize = orthographicSize;
					__instance.mapCamera.nearClipPlane = nearClipPlane;
					StartOfRound.Instance.radarCanvas.planeDistance = planeDistance;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporterPatch
	{
		[HarmonyPatch("PressTeleportButtonOnLocalClient")]
		[HarmonyPrefix]
		public static bool PressTeleportButtonLocalClientPatch(ShipTeleporter __instance)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
			TransformAndName val = mapScreen.radarTargets[mapScreen.targetTransformIndex];
			if (val.isNonPlayer && !__instance.isInverseTeleporter && !StartOfRound.Instance.inShipPhase && SceneManager.sceneCount > 1)
			{
				ImmersiveCompanyNetManager.instance.TeleportRadarBoosterAndSync(((Component)val.transform).gameObject.GetComponent<NetworkObject>().NetworkObjectId, SVector3.FromVector3(__instance.teleporterPosition.position), ((NetworkBehaviour)__instance).NetworkObjectId);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class ICStartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(ICUtilityHandler.instance.networkHandlerPrefab);
				NetworkObject component = val.GetComponent<NetworkObject>();
				component.SpawnWithObservers = true;
				component.Spawn(false);
			}
			Debug.Log((object)GameObject.Find("ICNetManager"));
		}
	}
}
namespace ImmersiveCompany.ImmersiveCompanyItems
{
	public class ICGlowStick : GrabbableObject
	{
		public bool activated = false;

		public GameObject light;

		public AudioClip snapSFX;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (!activated)
			{
				ImmersiveCompanyNetManager.instance.Glowstick_ActivateAndSync(((NetworkBehaviour)this).NetworkObjectId);
			}
		}

		public void Activate()
		{
			if (!activated)
			{
				light.SetActive(true);
				SetMaterialIntensity(5f);
				AudioSource component = ((Component)this).GetComponent<AudioSource>();
				component.PlayOneShot(snapSFX);
				activated = true;
			}
		}

		public void SetMaterialIntensity(float intensity)
		{
			//IL_0011: 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)
			((Renderer)((Component)this).GetComponent<MeshRenderer>()).material.SetColor("_EmissionColor", Color.green * intensity);
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			light.SetActive(false);
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if (activated)
			{
				light.SetActive(true);
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ICGlowStick";
		}
	}
	public class ICPersonalRadar : GrabbableObject
	{
		public GameObject lootNodePrefab;

		public Transform scannerScreen;

		public GameObject scannerScreenBase;

		public GameObject screenLight;

		public GameObject blackOutScreen;

		public float screenEdgeDistance;

		private List<Vector3> targets = new List<Vector3>();

		private List<GameObject> nodes = new List<GameObject>();

		private ImmersiveCompanyNetManager netMan = ImmersiveCompanyNetManager.instance;

		private bool state;

		private float scanRange = 25f;

		private LayerMask scanMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "ScanNode" }));

		private bool isScanning = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			base.insertedBattery.charge = 1f;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (base.insertedBattery.charge > 0f)
			{
				if ((Object)(object)netMan == (Object)null)
				{
					netMan = ImmersiveCompanyNetManager.instance;
				}
				netMan.Scanner_SetStateAndSync(!state, ((NetworkBehaviour)this).NetworkObjectId);
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			scannerScreenBase.SetActive(true);
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			netMan.Scanner_SetStateAndSync(powerState: false, ((NetworkBehaviour)this).NetworkObjectId);
			scannerScreenBase.SetActive(false);
		}

		public override void UseUpBatteries()
		{
			((GrabbableObject)this).UseUpBatteries();
			netMan.Scanner_SetStateAndSync(powerState: false, ((NetworkBehaviour)this).NetworkObjectId);
		}

		public void SetState(bool powerState)
		{
			state = powerState;
			if (state)
			{
				base.isBeingUsed = true;
				screenLight.SetActive(true);
				blackOutScreen.SetActive(false);
				if (!isScanning)
				{
					((MonoBehaviour)this).StartCoroutine(ScannerEnum());
				}
			}
			else
			{
				ClearScannerScreen();
				screenLight.SetActive(false);
				blackOutScreen.SetActive(true);
				base.isBeingUsed = false;
			}
		}

		public void Scan()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, scanRange, LayerMask.op_Implicit(scanMask));
			targets.Clear();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)((Component)((Component)val).transform.parent).gameObject.GetComponent<GrabbableObject>() != (Object)null && Mathf.Abs(((Component)val).transform.position.y - ((Component)this).transform.position.y) < 3f)
				{
					Vector3 item = ((Component)val).transform.position - ((Component)this).transform.position;
					item.x *= -1f;
					targets.Add(item);
				}
			}
		}

		public void Render()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			ClearScannerScreen();
			foreach (Vector3 target in targets)
			{
				GameObject val = Object.Instantiate<GameObject>(lootNodePrefab, scannerScreen);
				val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				Vector3 relativePos = target;
				Quaternion rotation = ((Component)this).transform.rotation;
				float y = ((Quaternion)(ref rotation)).eulerAngles.y;
				if ((Object)(object)base.playerHeldBy != (Object)null)
				{
					rotation = ((Component)base.playerHeldBy).transform.rotation;
					y = ((Quaternion)(ref rotation)).eulerAngles.y;
				}
				else
				{
					rotation = ((Component)this).transform.rotation;
					y = ((Quaternion)(ref rotation)).eulerAngles.y;
				}
				relativePos = RotateAroundPoint(relativePos, new Vector3(0f, 1f, 0f), y);
				relativePos.y = 0f;
				val.transform.localPosition = new Vector3(relativePos.x, relativePos.z, 0f);
				nodes.Add(val);
			}
		}

		public void ClearScannerScreen()
		{
			for (int i = 0; i < nodes.Count; i++)
			{
				Object.Destroy((Object)(object)nodes[i]);
			}
			nodes.Clear();
		}

		public IEnumerator ScannerEnum()
		{
			while (state)
			{
				isScanning = true;
				Scan();
				Render();
				yield return (object)new WaitForSeconds(0.35f);
			}
			isScanning = false;
		}

		public Vector3 RotateAroundPoint(Vector3 relativePos, Vector3 axis, float angle)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//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_0011: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.AngleAxis(angle, axis);
			return val * relativePos;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ICPersonalRadar";
		}
	}
}
namespace ImmersiveCompany.ICItems
{
	public class ICClock : GrabbableObject
	{
		public Transform hourHand;

		public Transform minuteHand;

		public AudioClip alarmClip;

		public bool alarmTriggered = true;

		private float timer;

		private float refreshRate = 1f;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			timer += Time.deltaTime;
			if (timer > refreshRate)
			{
				SetClock();
				timer = 0f;
			}
		}

		public void SetClock()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			float normalizedTimeOfDay = TimeOfDay.Instance.normalizedTimeOfDay;
			float num = TimeOfDay.Instance.numberOfHours;
			int num2 = (int)(normalizedTimeOfDay * (60f * num)) + 360;
			int num3 = (int)Mathf.Floor((float)(num2 / 60));
			int num4 = num2 % 60;
			if (num3 == 12)
			{
				alarmTriggered = false;
			}
			if (num3 >= 12)
			{
				num3 -= 12;
			}
			if (num3 == 8 && !alarmTriggered)
			{
				alarmTriggered = true;
				((Component)this).GetComponent<AudioSource>().PlayOneShot(alarmClip);
			}
			float num5 = 30 * num3 * -1;
			float num6 = 6 * num4 * -1;
			hourHand.localRotation = Quaternion.Euler(num5, 0f, 0f);
			minuteHand.localRotation = Quaternion.Euler(num6, 0f, 0f);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ICClock";
		}
	}
	public class ICHandGrenade : GrabbableObject
	{
		public float TimeToExplode = 4f;

		public bool DestroyGrenade = true;

		public string playerAnimation = "PullGrenadePin";

		[Space(5f)]
		public bool explodeOnCollision = false;

		public bool dontRequirePullingPin = false;

		public float chanceToExplode = 100f;

		public bool spawnDamagingShockwave = true;

		private bool explodeOnThrow;

		private bool gotExplodeOnThrowRPC;

		private bool hasCollided;

		[Space(3f)]
		public bool pinPulled;

		public bool inPullingPinAnimation;

		public string throwString = "Throw grenade: [RMB]";

		private Coroutine pullPinCoroutine;

		public Animator itemAnimator;

		public AudioSource itemAudio;

		public AudioClip pullPinSFX;

		public AudioClip explodeSFX;

		public AnimationCurve grenadeFallCurve;

		public AnimationCurve grenadeVerticalFallCurve;

		public AnimationCurve grenadeVerticalFallCurveNoBounce;

		public RaycastHit grenadeHit;

		public Ray grenadeThrowRay;

		private int stunGrenadeMask = 268437761;

		public float explodeTimer;

		public bool hasExploded;

		public GameObject stunGrenadeExplosion;

		private PlayerControllerB playerThrownBy;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (inPullingPinAnimation)
			{
				return;
			}
			if (!pinPulled)
			{
				if (pullPinCoroutine == null)
				{
					base.playerHeldBy.activatingItem = true;
					pullPinCoroutine = ((MonoBehaviour)this).StartCoroutine(pullPinAnimation());
				}
			}
			else if (((NetworkBehaviour)this).IsOwner)
			{
				base.playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetGrenadeThrowDestination(), true);
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null && !explodeOnCollision)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void EquipItem()
		{
			if (explodeOnCollision)
			{
				playerThrownBy = base.playerHeldBy;
			}
			gotExplodeOnThrowRPC = false;
			hasCollided = false;
			SetControlTipForGrenade();
			((GrabbableObject)this).EnableItemMeshes(true);
			base.isPocketed = false;
			if (chanceToExplode < 100f)
			{
				SetExplodeOnThrowServerRpc();
			}
			if (!base.hasBeenHeld)
			{
				base.hasBeenHeld = true;
				if (!base.isInShipRoom && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
				{
					RoundManager instance = RoundManager.Instance;
					instance.valueOfFoundScrapItems += base.scrapValue;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetExplodeOnThrowServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(99902746u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 99902746u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetExplodeOnThrowClientRpc(explode: true);
				}
			}
		}

		[ClientRpc]
		public void SetExplodeOnThrowClientRpc(bool explode)
		{
			//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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(494497829u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref explode, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 494497829u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					gotExplodeOnThrowRPC = true;
					explodeOnThrow = explode;
				}
			}
		}

		private void SetControlTipForGrenade()
		{
			string[] array = ((!pinPulled) ? new string[1] { throwString } : new string[1] { "Pull pin: [RMB]" });
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.ChangeControlTipMultiple(array, true, base.itemProperties);
			}
		}

		public override void FallWithCurve()
		{
			//IL_0002: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = base.startFallingPosition - base.targetFloorPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)this).transform.localPosition = Vector3.Lerp(base.startFallingPosition, base.targetFloorPosition, grenadeFallCurve.Evaluate(base.fallTime));
			if (magnitude > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurveNoBounce.Evaluate(base.fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurve.Evaluate(base.fallTime));
			}
			base.fallTime += Mathf.Abs(Time.deltaTime * 12f / magnitude);
		}

		private IEnumerator pullPinAnimation()
		{
			inPullingPinAnimation = true;
			base.playerHeldBy.activatingItem = true;
			base.playerHeldBy.doingUpperBodyEmote = 1.16f;
			base.playerHeldBy.playerBodyAnimator.SetTrigger(playerAnimation);
			itemAnimator.SetTrigger("pullPin");
			itemAudio.PlayOneShot(pullPinSFX);
			WalkieTalkie.TransmitOneShotAudio(itemAudio, pullPinSFX, 0.8f);
			yield return (object)new WaitForSeconds(1f);
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				if (!DestroyGrenade)
				{
					base.playerHeldBy.activatingItem = false;
				}
				playerThrownBy = base.playerHeldBy;
			}
			inPullingPinAnimation = false;
			pinPulled = true;
			base.itemUsedUp = true;
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.playerHeldBy != (Object)null)
			{
				SetControlTipForGrenade();
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (hasCollided)
			{
				if (gotExplodeOnThrowRPC)
				{
					gotExplodeOnThrowRPC = false;
					ExplodeStunGrenade(DestroyGrenade);
				}
			}
			else if (!dontRequirePullingPin && pinPulled && !hasExploded)
			{
				explodeTimer += Time.deltaTime;
				if (explodeTimer > TimeToExplode)
				{
					ExplodeStunGrenade(DestroyGrenade);
				}
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			if (dontRequirePullingPin)
			{
				pinPulled = true;
			}
		}

		public override void OnHitGround()
		{
			((GrabbableObject)this).OnHitGround();
			if ((Object)(object)playerThrownBy != (Object)null && explodeOnCollision && pinPulled)
			{
				hasCollided = true;
			}
		}

		private void ExplodeStunGrenade(bool destroy = false)
		{
			if (hasExploded)
			{
				return;
			}
			if ((chanceToExplode < 100f && !explodeOnThrow) || (explodeOnCollision && !StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && (Object)(object)base.parentObject == (Object)(object)Object.FindObjectOfType<DepositItemsDesk>().deskObjectsContainer))
			{
				if ((Object)(object)playerThrownBy != (Object)null)
				{
					playerThrownBy.activatingItem = false;
				}
				return;
			}
			hasExploded = true;
			Transform val = (base.isInElevator ? RoundManager.Instance.mapPropsContainer.transform : StartOfRound.Instance.elevatorTransform);
			itemAudio.PlayOneShot(explodeSFX);
			WalkieTalkie.TransmitOneShotAudio(itemAudio, explodeSFX, 1f);
			if (DestroyGrenade)
			{
				((GrabbableObject)this).DestroyObjectInHand(playerThrownBy);
			}
		}

		public Vector3 GetGrenadeThrowDestination()
		{
			//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)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0091: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00d8: 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_00e2: 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)
			Vector3 position = ((Component)this).transform.position;
			grenadeThrowRay = new Ray(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward);
			position = ((!Physics.Raycast(grenadeThrowRay, ref grenadeHit, 12f, stunGrenadeMask, (QueryTriggerInteraction)1)) ? ((Ray)(ref grenadeThrowRay)).GetPoint(10f) : ((Ray)(ref grenadeThrowRay)).GetPoint(((RaycastHit)(ref grenadeHit)).distance - 0.05f));
			grenadeThrowRay = new Ray(position, Vector3.down);
			if (Physics.Raycast(grenadeThrowRay, ref grenadeHit, 30f, stunGrenadeMask, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref grenadeHit)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref grenadeThrowRay)).GetPoint(30f);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ICHandGrenade()
		{
			//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
			NetworkManager.__rpc_func_table.Add(99902746u, new RpcReceiveHandler(__rpc_handler_99902746));
			NetworkManager.__rpc_func_table.Add(494497829u, new RpcReceiveHandler(__rpc_handler_494497829));
		}

		private static void __rpc_handler_99902746(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ICHandGrenade)(object)target).SetExplodeOnThrowServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_494497829(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 explodeOnThrowClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref explodeOnThrowClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ICHandGrenade)(object)target).SetExplodeOnThrowClientRpc(explodeOnThrowClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ICHandGrenade";
		}
	}
	public class ICLantern : GrabbableObject
	{
		public bool activated;

		public GameObject light;

		public AudioClip toggleClip;

		public GameObject lightMast;

		public Transform body;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			base.insertedBattery.charge = 1f;
			light.SetActive(false);
			SetMaterialIntensity(0f);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			ImmersiveCompanyNetManager.instance.SetLanternStateAndSync(((NetworkBehaviour)this).NetworkObjectId, !activated);
		}

		public override void UseUpBatteries()
		{
			((GrabbableObject)this).UseUpBatteries();
			ImmersiveCompanyNetManager.instance.SetLanternStateAndSync(((NetworkBehaviour)this).NetworkObjectId, state: false);
		}

		public void SetState(bool state)
		{
			if (state != activated && base.insertedBattery.charge > 0f)
			{
				if (state)
				{
					light.SetActive(true);
					SetMaterialIntensity(12f);
					AudioSource component = ((Component)this).GetComponent<AudioSource>();
					component.PlayOneShot(toggleClip);
					activated = true;
					base.isBeingUsed = true;
				}
				else
				{
					light.SetActive(false);
					SetMaterialIntensity(0f);
					AudioSource component2 = ((Component)this).GetComponent<AudioSource>();
					component2.PlayOneShot(toggleClip);
					activated = false;
					base.isBeingUsed = false;
				}
			}
		}

		public void SetMaterialIntensity(float intensity)
		{
			((Renderer)lightMast.GetComponent<MeshRenderer>()).material.SetFloat("_Emission_Strength", intensity);
		}

		public override void PocketItem()
		{
			if (activated)
			{
				ImmersiveCompanyNetManager.instance.SetLanternStateAndSync(((NetworkBehaviour)this).NetworkObjectId, state: false);
			}
			((GrabbableObject)this).PocketItem();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ICLantern";
		}
	}
	internal class ICStrangeCanister : GrabbableObject
	{
		public GameObject light;

		private Transform gooPlane;

		private Transform cameraTransform;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			gooPlane = ((Component)this).transform.GetChild(0).GetChild(2);
			light = ((Component)((Component)this).transform.GetChild(0).GetChild(3)).gameObject;
			light.SetActive(true);
		}

		public override void Update()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if ((Object)(object)cameraTransform == (Object)null)
			{
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					cameraTransform = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform;
				}
			}
			else
			{
				Vector3 localEulerAngles = gooPlane.localEulerAngles;
				gooPlane.LookAt(cameraTransform.position);
				Vector3 localEulerAngles2 = default(Vector3);
				((Vector3)(ref localEulerAngles2))..ctor(localEulerAngles.x, gooPlane.localEulerAngles.y + 180f, localEulerAngles.z);
				gooPlane.localEulerAngles = localEulerAngles2;
			}
		}

		public override void PocketItem()
		{
			light.SetActive(false);
			((GrabbableObject)this).PocketItem();
		}

		public override void EquipItem()
		{
			light.SetActive(true);
			((GrabbableObject)this).EquipItem();
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "ICStrangeCanister";
		}
	}
}
namespace ImmersiveCompany.ICCustomDataHandlers
{
	[CreateAssetMenu]
	public class ICHandGrenadeData : ScriptableObject
	{
		public float TimeToExplode = 4f;

		public bool DestroyGrenade = true;

		public string playerAnimation = "PullGrenadePin";

		[Space(5f)]
		public bool explodeOnCollision = false;

		public bool dontRequirePullingPin = false;

		public float chanceToExplode = 100f;

		public bool spawnDamagingShockwave = true;

		public string throwString = "Throw grenade: [RMB]";

		public AudioClip pullPinSFX;

		public AudioClip explodeSFX;

		public AnimationCurve grenadeFallCurve;

		public AnimationCurve grenadeVerticalFallCurve;

		public AnimationCurve grenadeVerticalFallCurveNoBounce;

		public Ray grenadeThrowRay;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace ImmersiveCompany.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}