Decompiled source of LethalPhones v1.2.3

LethalPhones/LethalPhones.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalLib.Modules;
using LethalPhones.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Mirage.Domain;
using Mirage.Unity;
using Scoops.compatability;
using Scoops.customization;
using Scoops.gameobjects;
using Scoops.misc;
using Scoops.patch;
using Scoops.service;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using WeatherRegistry;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Mirage")]
[assembly: AssemblyCompany("LethalPhones")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1-alpha.0.38+49abab911808f295610f1f93164ffd388d4548f9")]
[assembly: AssemblyProduct("LethalPhones")]
[assembly: AssemblyTitle("LethalPhones")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
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 Scoops
{
	public class Config
	{
		public static ConfigEntry<float> ringtoneVolume;

		public static ConfigEntry<float> recordingStartDist;

		public static ConfigEntry<float> backgroundVoiceDist;

		public static ConfigEntry<float> eavesdropDist;

		public static ConfigEntry<float> backgroundSoundMod;

		public static ConfigEntry<float> voiceSoundMod;

		public static ConfigEntry<float> deathHangupTime;

		public static ConfigEntry<bool> hideHands;

		public static ConfigEntry<bool> disableRingtones;

		public static ConfigEntry<bool> removeBaseSkins;

		public static ConfigEntry<bool> removeBaseCharms;

		public static ConfigEntry<bool> removeBaseRingtones;

		public static ConfigEntry<string> customizationBlacklist;

		public static ConfigEntry<bool> hangupOnPutaway;

		public static ConfigEntry<bool> respawnClipboard;

		public static ConfigEntry<bool> enableStartClipboard;

		public static ConfigEntry<int> maxPhoneNumber;

		public static ConfigEntry<int> maxPhoneBugs;

		public static ConfigEntry<float> chancePhoneBug;

		public static ConfigEntry<float> minPhoneBugInterval;

		public static ConfigEntry<float> maxPhoneBugInterval;

		public static ConfigEntry<int> maxPhoneMasked;

		public static ConfigEntry<float> chancePhoneMask;

		public static ConfigEntry<float> minPhoneMaskedInterval;

		public static ConfigEntry<float> maxPhoneMaskedInterval;

		public static ConfigEntry<bool> phonePurchase;

		public static ConfigEntry<int> phonePrice;

		public static ConfigEntry<bool> clipboardPurchase;

		public static ConfigEntry<int> clipboardPrice;

		public static ConfigEntry<bool> switchboardPurchase;

		public static ConfigEntry<int> switchboardPrice;

		public static ConfigEntry<string> switchboardNumber;

		public Config(ConfigFile cfg)
		{
			ringtoneVolume = cfg.Bind<float>("General", "ringtoneVolume", 0.6f, "The volume of phone ringtones (0-1).");
			voiceSoundMod = cfg.Bind<float>("General", "voiceSoundMod", -0.2f, "All voices on calls have their volume adjusted by this value.");
			backgroundSoundMod = cfg.Bind<float>("General", "backgroundSoundMod", -0.4f, "All background noises on calls have their volume adjusted by this value.");
			recordingStartDist = cfg.Bind<float>("General", "recordingStartDist", 15f, "Disables phones while in this distance to the person you're calling.");
			backgroundVoiceDist = cfg.Bind<float>("General", "backgroundVoiceDist", 20f, "The distance at which you can hear other players in the background of a call.");
			eavesdropDist = cfg.Bind<float>("General", "eavesdropDist", 5f, "The distance at which you can listen in on someone else's call.");
			deathHangupTime = cfg.Bind<float>("General", "deathHangupTime", 0.5f, "The time it takes (in seconds) for a call to auto-hangup after death.");
			hideHands = cfg.Bind<bool>("General", "hideHands", false, "If true, the model's right hand will not be used for dialing. (useful if using a custom model with hands too big/small for the phone)");
			disableRingtones = cfg.Bind<bool>("General", "disableRingtones", false, "If true, ringtone customizations will not be used for other players and their phones will always use the default ringtone. You can still customize your own.");
			removeBaseSkins = cfg.Bind<bool>("General", "removeBaseSkins", false, "If true, only the default skin from the mod will be shown in the customization screen. Addon mods will still show.");
			removeBaseCharms = cfg.Bind<bool>("General", "removeBaseCharms", false, "If true, only the default charm from the mod will be shown in the customization screen. Addon mods will still show.");
			removeBaseRingtones = cfg.Bind<bool>("General", "removeBaseRingtones", false, "If true, only the default ringtone from the mod will be shown in the customization screen. Addon mods will still show.");
			customizationBlacklist = cfg.Bind<string>("General", "customizationBlacklist", "", "A comma-separated list of lowercase customization names that you do not want loaded. This works for base customizations and addons. Include the bundle name, eg: 'lethalphones.customizations.buggybuddy,lethalphones.customizations.rust'");
			hangupOnPutaway = cfg.Bind<bool>("Balance", "hangupOnPutaway", false, "If true, the phone will hang up any active calls when it is put away, so you cannot talk on the phone without actively holding it.");
			respawnClipboard = cfg.Bind<bool>("Balance", "respawnClipboard", false, "If true, the phonebook clipboard will respawn back on the ship if it is lost or sold.");
			enableStartClipboard = cfg.Bind<bool>("Balance", "enableStartClipboard", true, "If true, one free Phonebook Clipboard will be added to the ship at the start of new saves.");
			maxPhoneNumber = cfg.Bind<int>("Balance", "maxPhoneNumber", 10000, "This is the number of phone numbers that can be generated. The default of 10000 means numbers 0000 - 9999. You can lower this if you don't want to have to remember 4 digits, remember that the leading 0s will always be there. So putting 10 here will generate numbers from 0000 - 0009.");
			maxPhoneBugs = cfg.Bind<int>("Enemies.HoardingBugs", "maxPhoneBugs", 1, "Maximum number of Hoarding Bugs that can spawn with phones.");
			chancePhoneBug = cfg.Bind<float>("Enemies.HoardingBugs", "chancePhoneBug", 0.1f, "The chance (0 - 1) that a Hoarding Bug will be spawned with a phone.");
			minPhoneBugInterval = cfg.Bind<float>("Enemies.HoardingBugs", "minPhoneBugInterval", 15f, "The shortest time (in seconds) between calls from each Hoarding Bug.");
			maxPhoneBugInterval = cfg.Bind<float>("Enemies.HoardingBugs", "maxPhoneBugInterval", 120f, "The longest time (in seconds) between calls from each Hoarding Bug.");
			maxPhoneMasked = cfg.Bind<int>("Enemies.Masked", "maxPhoneMasked", 2, "Maximum number of Masked that can spawn with phones. NOTE: This only functions if you are using Mirage.");
			chancePhoneMask = cfg.Bind<float>("Enemies.Masked", "chancePhoneMask", 0.75f, "The chance (0 - 1) that a Masked will be spawned with a phone.");
			minPhoneMaskedInterval = cfg.Bind<float>("Enemies.Masked", "minPhoneMaskedInterval", 60f, "The shortest time (in seconds) between calls from each Masked.");
			maxPhoneMaskedInterval = cfg.Bind<float>("Enemies.Masked", "maxPhoneMaskedInterval", 180f, "The longest time (in seconds) between calls from each Masked.");
			phonePurchase = cfg.Bind<bool>("Unlockables", "phonePurchase", false, "Do phones need to be unlocked at the Shop to be used?");
			phonePrice = cfg.Bind<int>("Unlockables", "phonePrice", 200, "The cost of unlocking Phones.");
			clipboardPurchase = cfg.Bind<bool>("Unlockables", "clipboardPurchase", true, "Can additional Phonebook Clipboards be purchased?");
			clipboardPrice = cfg.Bind<int>("Unlockables", "clipboardPrice", 10, "The cost of Phonebook Clipboards.");
			switchboardPurchase = cfg.Bind<bool>("Unlockables", "switchboardPurchase", true, "Can the switchboard be purchased?");
			switchboardPrice = cfg.Bind<int>("Unlockables", "switchboardPrice", 500, "The cost of the Phone Switchboard.");
			switchboardNumber = cfg.Bind<string>("Unlockables", "switchboardNumber", "1111", "The phone number of the Switchboard. This should always be 4 digits.");
		}
	}
	public class LethalPhonesInputClass : LcInputActions
	{
		[InputAction("<Keyboard>/y", Name = "Toggle Phone", GamepadPath = "<Gamepad>/leftStickPress")]
		public InputAction TogglePhoneKey { get; set; }

		[InputAction("<Keyboard>/q", Name = "Hangup Phone", GamepadPath = "<Gamepad>/dpad/down")]
		public InputAction HangupPhoneKey { get; set; }

		[InputAction("<Mouse>/leftButton", Name = "Pickup Phone", GamepadPath = "<Gamepad>/rightTrigger")]
		public InputAction PickupPhoneKey { get; set; }

		[InputAction("<Keyboard>/z", Name = "Dial Phone", GamepadPath = "<Gamepad>/leftShoulder")]
		public InputAction DialPhoneKey { get; set; }

		[InputAction("<Keyboard>/g", Name = "Toggle Phone Volume", GamepadPath = "<Gamepad>/buttonEast")]
		public InputAction VolumePhoneKey { get; set; }
	}
	public static class PluginInformation
	{
		public const string PLUGIN_GUID = "LethalPhones";

		public const string PLUGIN_NAME = "LethalPhones";

		public const string PLUGIN_VERSION = "1.2.3";
	}
	[BepInPlugin("LethalPhones", "LethalPhones", "1.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static AssetBundle LethalPhoneAssets;

		public static AssetBundle LethalPhoneCustomization;

		public static string customizationSavePath;

		private readonly Harmony _harmony = new Harmony("LethalPhones");

		internal static LethalPhonesInputClass InputActionInstance;

		public static Plugin Instance { get; set; }

		public static Config PhoneConfig { get; internal set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public Plugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Instance = this;
		}

		private void Awake()
		{
			InputActionInstance = new LethalPhonesInputClass();
			Log.LogInfo((object)"Loading LethalPhones Version 1.2.3");
			NetcodePatcher();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "lethalphonesassets");
			LethalPhoneAssets = AssetBundle.LoadFromFile(text);
			string text2 = Path.Combine(directoryName, "lethalphonecustomizations");
			LethalPhoneCustomization = AssetBundle.LoadFromFile(text2);
			customizationSavePath = Application.persistentDataPath + "/lethalphonescustomization.txt";
			PhoneConfig = new Config(((BaseUnityPlugin)this).Config);
			PhoneAssetManager.Init();
			CustomizationManager.customizationBlacklist.AddRange(Config.customizationBlacklist.Value.Replace(" ", string.Empty).Split(','));
			Log.LogInfo((object)"Loading default phone customization...");
			CustomizationManager.LoadSkinCustomizations(LethalPhoneCustomization, "lethalphones.customizations");
			CustomizationManager.LoadCharmCustomizations(LethalPhoneCustomization, "lethalphones.customizations");
			CustomizationManager.LoadRingtoneCustomizations(LethalPhoneCustomization, "lethalphones.customizations");
			Log.LogInfo((object)"Loading user phone customization...");
			CustomizationManager.RecursiveCustomizationLoad(Paths.PluginPath);
			ReadCustomizationFromFile();
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
			if (WeatherRegistryCompat.Enabled)
			{
				Log.LogInfo((object)"Loaded Weather Registry Compatability");
			}
			if (MirageCompat.Enabled)
			{
				Log.LogInfo((object)"Loaded Mirage Compatability");
			}
		}

		private void ApplyPluginPatch()
		{
			_harmony.PatchAll(typeof(MainMenuPatch));
			_harmony.PatchAll(typeof(PlayerPhonePatch));
			_harmony.PatchAll(typeof(PlayerControllerB_SetPlayerSanityLevel_Patch));
			_harmony.PatchAll(typeof(HoardingBugPhonePatch));
			_harmony.PatchAll(typeof(MaskedPhonePatch));
			_harmony.PatchAll(typeof(StartOfRoundPhonePatch));
			_harmony.PatchAll(typeof(NetworkObjectManager));
			_harmony.PatchAll(typeof(ShipTeleporterPhonePatch));
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void ReadCustomizationFromFile()
		{
			if (!File.Exists(customizationSavePath))
			{
				return;
			}
			string[] array = File.ReadAllLines(customizationSavePath);
			if (array.Length == 3)
			{
				CustomizationManager.SelectedSkin = array[0];
				CustomizationManager.SelectedCharm = array[1];
				CustomizationManager.SelectedRingtone = array[2];
				if (!CustomizationManager.skinIds.Contains(CustomizationManager.SelectedSkin))
				{
					CustomizationManager.SelectedSkin = "lethalphones.customizations.default";
				}
				if (!CustomizationManager.charmIds.Contains(CustomizationManager.SelectedCharm))
				{
					CustomizationManager.SelectedCharm = "lethalphones.customizations.default";
				}
				if (!CustomizationManager.ringtoneIds.Contains(CustomizationManager.SelectedRingtone))
				{
					CustomizationManager.SelectedRingtone = "lethalphones.customizations.default";
				}
			}
		}

		public static void WriteCustomizationToFile()
		{
			string text = "";
			text = text + CustomizationManager.SelectedSkin + "\n";
			text = text + CustomizationManager.SelectedCharm + "\n";
			text = text + CustomizationManager.SelectedRingtone + "\n";
			File.WriteAllText(customizationSavePath, text);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPhones";

		public const string PLUGIN_NAME = "LethalPhones";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Scoops.service
{
	public class AudioSourceStorage
	{
		public AudioSource audioSource;

		private GameObject audioSourceHolder;

		private float origVolume;

		private float origPan;

		private bool hadLowPass;

		private bool hadHighPass;

		private bool hadOcclude;

		private float origLowPass;

		private float origLowPassResQ;

		private float origHighPass;

		private float origHighPassResQ;

		public AudioSourceStorage(AudioSource audioSource)
		{
			this.audioSource = audioSource;
			audioSourceHolder = ((Component)audioSource).gameObject;
			origVolume = audioSource.volume;
			origPan = audioSource.panStereo;
			hadLowPass = (Object)(object)audioSourceHolder.GetComponent<AudioLowPassFilter>() != (Object)null;
			hadHighPass = (Object)(object)audioSourceHolder.GetComponent<AudioHighPassFilter>() != (Object)null;
			hadOcclude = (Object)(object)audioSourceHolder.GetComponent<OccludeAudio>() != (Object)null;
			if (hadLowPass)
			{
				origLowPass = audioSourceHolder.GetComponent<AudioLowPassFilter>().cutoffFrequency;
				origLowPassResQ = audioSourceHolder.GetComponent<AudioLowPassFilter>().lowpassResonanceQ;
			}
			if (hadHighPass)
			{
				origHighPass = audioSourceHolder.GetComponent<AudioHighPassFilter>().cutoffFrequency;
				origHighPassResQ = audioSourceHolder.GetComponent<AudioHighPassFilter>().highpassResonanceQ;
			}
		}

		public void InitAudio()
		{
			if (!((Object)(object)audioSource != (Object)null))
			{
				return;
			}
			audioSource.spatialBlend = 0f;
			audioSource.panStereo = -0.4f;
			if ((Object)(object)audioSourceHolder != (Object)null)
			{
				if (!hadLowPass)
				{
					audioSourceHolder.AddComponent<AudioLowPassFilter>();
				}
				if (!hadHighPass)
				{
					audioSourceHolder.AddComponent<AudioHighPassFilter>();
				}
				if (hadOcclude)
				{
					((Behaviour)audioSourceHolder.GetComponent<OccludeAudio>()).enabled = false;
				}
				audioSourceHolder.GetComponent<AudioLowPassFilter>().cutoffFrequency = 2899f;
				audioSourceHolder.GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 3f;
				audioSourceHolder.GetComponent<AudioHighPassFilter>().cutoffFrequency = 1613f;
				audioSourceHolder.GetComponent<AudioHighPassFilter>().highpassResonanceQ = 1f;
			}
		}

		public void ApplyPhone(float dist, float callQuality = 1f, float listenDist = 0f, float listenAngle = 0f, bool staticMode = false)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			if (!((Object)(object)audioSourceHolder != (Object)null) || !((Object)(object)audioSource != (Object)null))
			{
				return;
			}
			float num = 0f;
			if ((int)audioSource.rolloffMode == 1)
			{
				num = Mathf.Clamp01(Mathf.InverseLerp(audioSource.maxDistance, audioSource.minDistance, dist) + Config.backgroundSoundMod.Value);
			}
			else if ((int)audioSource.rolloffMode == 2)
			{
				AnimationCurve customCurve = audioSource.GetCustomCurve((AudioSourceCurveType)0);
				if (customCurve != null)
				{
					num = Mathf.Clamp01(customCurve.Evaluate(dist / audioSource.maxDistance) + Config.backgroundSoundMod.Value);
				}
			}
			else
			{
				num = Mathf.Clamp01(audioSource.minDistance * (1f / (1f + (dist - 1f))) + Config.backgroundSoundMod.Value);
			}
			audioSource.volume = origVolume * num;
			if (staticMode)
			{
				audioSource.volume = 0f;
			}
			if (Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<AudioLowPassFilter>()))
			{
				audioSourceHolder.GetComponent<AudioLowPassFilter>().cutoffFrequency = Mathf.Lerp(2000f, 2899f, callQuality);
				audioSourceHolder.GetComponent<AudioLowPassFilter>().lowpassResonanceQ = Mathf.Lerp(5f, 3f, callQuality);
			}
			if (Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<AudioHighPassFilter>()))
			{
				audioSourceHolder.GetComponent<AudioHighPassFilter>().highpassResonanceQ = Mathf.Lerp(2f, 1f, callQuality);
			}
			if (listenDist != 0f)
			{
				float num2 = Mathf.InverseLerp(Config.eavesdropDist.Value, 0f, listenDist);
				audioSource.volume *= num2;
				if (Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<AudioLowPassFilter>()))
				{
					audioSourceHolder.GetComponent<AudioLowPassFilter>().cutoffFrequency = 750f;
				}
				audioSource.panStereo = listenAngle;
			}
		}

		public void Reset()
		{
			if (!((Object)(object)audioSourceHolder != (Object)null))
			{
				return;
			}
			if ((Object)(object)audioSource != (Object)null)
			{
				audioSource.spatialBlend = 1f;
				audioSource.panStereo = origPan;
				audioSource.volume = origVolume;
			}
			if (hadOcclude && Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<OccludeAudio>()))
			{
				((Behaviour)audioSourceHolder.GetComponent<OccludeAudio>()).enabled = true;
			}
			if (Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<AudioLowPassFilter>()))
			{
				if (hadLowPass)
				{
					audioSourceHolder.GetComponent<AudioLowPassFilter>().cutoffFrequency = origLowPass;
					audioSourceHolder.GetComponent<AudioLowPassFilter>().lowpassResonanceQ = origLowPassResQ;
				}
				else
				{
					Object.Destroy((Object)(object)audioSourceHolder.GetComponent<AudioLowPassFilter>());
				}
			}
			if (Object.op_Implicit((Object)(object)audioSourceHolder.GetComponent<AudioHighPassFilter>()))
			{
				if (hadHighPass)
				{
					audioSourceHolder.GetComponent<AudioHighPassFilter>().cutoffFrequency = origHighPass;
					audioSourceHolder.GetComponent<AudioHighPassFilter>().highpassResonanceQ = origHighPassResQ;
				}
				else
				{
					Object.Destroy((Object)(object)audioSourceHolder.GetComponent<AudioHighPassFilter>());
				}
			}
		}
	}
	public class PhoneAssetManager
	{
		public static AudioClip phoneRingCaller;

		public static AudioClip phoneRingReciever;

		public static AudioClip switchboardRing;

		public static AudioClip phonePickup;

		public static AudioClip phoneHangup;

		public static AudioClip phoneRotaryForward;

		public static AudioClip phoneRotaryBackward;

		public static AudioClip phoneRotaryStopper;

		public static AudioClip phoneRotaryFinish;

		public static AudioClip phoneFlipOpen;

		public static AudioClip phoneFlipClosed;

		public static AudioClip phoneBusy;

		public static AudioClip phoneRingVibrate;

		public static AudioClip phoneSwitch;

		public static AudioClip phoneStaticOne;

		public static AudioClip phoneStaticTwo;

		public static AudioClip phoneStaticThree;

		public static Material greenLight;

		public static Material redLight;

		public static Material offLight;

		public static GameObject customizationGUI;

		public static GameObject headphoneDisplayPrefab;

		public const string PHONE_UNLOCK_NAME = "Personal Phones";

		public static void Init()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			Plugin.Log.LogInfo((object)"Loading Assets...");
			if (Config.phonePurchase.Value)
			{
				UnlockableItem val = new UnlockableItem();
				val.unlockableName = "Personal Phones";
				val.IsPlaceable = false;
				val.spawnPrefab = false;
				val.alwaysInStock = true;
				val.canBeStored = false;
				val.unlockableType = 1;
				val.maxNumber = 1;
				TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val2).name = "PersonalPhonesInfoNode";
				val2.displayText = "Personal Phones for the whole crew! These do not take up an item slot or require battery, but tend to be difficult to work with in stressful situations.\n\n";
				val2.clearPreviousText = true;
				val2.maxCharactersToType = 25;
				Unlockables.RegisterUnlockable(val, (StoreType)1, (TerminalNode)null, (TerminalNode)null, val2, Config.phonePrice.Value);
			}
			customizationGUI = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("PhoneCustomization_GUI");
			headphoneDisplayPrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("HeadsetMicrophone");
			phoneRingCaller = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneRing_Caller");
			phoneRingReciever = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneRing_Reciever");
			switchboardRing = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("SwitchboardRing");
			phonePickup = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhonePickup");
			phoneHangup = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneHangup");
			phoneRotaryForward = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("RotaryDialForwardOptionTwo");
			phoneRotaryBackward = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("RotaryDialBackOptionOne");
			phoneRotaryStopper = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("RotaryStopperOptionOne");
			phoneRotaryFinish = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("RotaryFinishOptionOne");
			phoneFlipOpen = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneFlipOpen");
			phoneFlipClosed = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneFlipClosed");
			phoneBusy = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneBusy");
			phoneRingVibrate = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneRing_Vibrate");
			phoneSwitch = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneSwitch");
			phoneStaticOne = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneStaticOne");
			phoneStaticTwo = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneStaticTwo");
			phoneStaticThree = (AudioClip)Plugin.LethalPhoneAssets.LoadAsset("PhoneStaticThree");
			greenLight = (Material)Plugin.LethalPhoneAssets.LoadAsset("GreenLight");
			redLight = (Material)Plugin.LethalPhoneAssets.LoadAsset("RedLight");
			offLight = (Material)Plugin.LethalPhoneAssets.LoadAsset("OffLight");
		}
	}
	public class PhoneNetworkHandler : NetworkBehaviour
	{
		public static Clipboard PhonebookClipboard;

		public static NetworkVariable<bool> Locked = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private Dictionary<string, ulong> phoneNumberDict;

		private Dictionary<string, PhoneBehavior> phoneObjectDict;

		public PlayerPhone localPhone;

		public SwitchboardPhone switchboard;

		public static PhoneNetworkHandler Instance { get; private set; }

		public void Start()
		{
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && Config.enableStartClipboard.Value)
			{
				Clipboard clipboard = Object.FindAnyObjectByType<Clipboard>();
				if (!Object.op_Implicit((Object)(object)clipboard) && StartOfRound.Instance.gameStats.daysSpent == 0)
				{
					SpawnClipboard();
				}
				else if (Object.op_Implicit((Object)(object)clipboard))
				{
					PhonebookClipboard = clipboard;
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance != (Object)null)
			{
				((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
			}
			Instance = this;
			phoneNumberDict = new Dictionary<string, ulong>();
			phoneObjectDict = new Dictionary<string, PhoneBehavior>();
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				CheckPhoneUnlock();
			}
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public static void CheckPhoneUnlock()
		{
			if (!Config.phonePurchase.Value)
			{
				Locked.Value = false;
				return;
			}
			bool value = true;
			foreach (UnlockableItem unlockable in StartOfRound.Instance.unlockablesList.unlockables)
			{
				if (unlockable.unlockableName == "Personal Phones")
				{
					value = !unlockable.hasBeenUnlockedByPlayer;
				}
			}
			Locked.Value = value;
		}

		public void RegisterSwitchboard(ulong switchboardId)
		{
			//IL_0005: 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)
			RegisterSwitchboardServerRpc(switchboardId);
		}

		public void CreateNewPhone(ulong phoneId, string skinId, string charmId, string ringtoneId)
		{
			//IL_0009: 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)
			CreateNewPhoneNumberServerRpc(phoneId, skinId, charmId, ringtoneId);
		}

		public void RequestClientUpdates()
		{
			UpdateAllClientsServerRpc();
		}

		public void RequestSwitchboardUpdates()
		{
			UpdateAllClientsServerRpc();
		}

		public void SpawnClipboard()
		{
			GameObject val = Object.Instantiate<GameObject>(NetworkObjectManager.clipboardPrefab, StartOfRound.Instance.elevatorTransform);
			val.GetComponent<NetworkObject>().Spawn(false);
			PhonebookClipboard = val.GetComponent<Clipboard>();
		}

		public void CheckClipboardRespawn()
		{
			if (Config.enableStartClipboard.Value && (Object)(object)PhonebookClipboard == (Object)null)
			{
				SpawnClipboard();
				UpdateClipboardText();
			}
		}

		public void UpdateClipboardText()
		{
			List<ulong> list = new List<ulong>();
			foreach (PhoneBehavior value in phoneObjectDict.Values)
			{
				if (value is PlayerPhone)
				{
					PlayerPhone playerPhone = (PlayerPhone)value;
					list.Add(((NetworkBehaviour)playerPhone).NetworkObjectId);
				}
			}
			Clipboard[] array = Object.FindObjectsOfType<Clipboard>();
			foreach (Clipboard clipboard in array)
			{
				clipboard.UpdateTextClientRpc(list.ToArray());
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestSwitchboardUpdatesServerRpc()
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1152410923u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1152410923u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					UpdateSwitchboardPhones();
				}
			}
		}

		public void UpdateSwitchboardPhones()
		{
			List<ulong> list = new List<ulong>();
			List<PhoneBehavior> list2 = phoneObjectDict.Values.ToList();
			if (list2.Count > 1)
			{
				list2.Sort((PhoneBehavior e, PhoneBehavior f) => e.phoneNumber.CompareTo(f.phoneNumber));
			}
			foreach (PhoneBehavior item in list2)
			{
				if (!(item is MaskedPhone) && !(item is SwitchboardPhone))
				{
					list.Add(((NetworkBehaviour)item).NetworkObjectId);
				}
			}
			switchboard.UpdatePhoneListClientRpc(list.ToArray());
		}

		[ServerRpc(RequireOwnership = false)]
		public void RegisterSwitchboardServerRpc(ulong SwitchboardId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3333872520u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, SwitchboardId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3333872520u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if ((Object)(object)switchboard != (Object)null)
				{
					Plugin.Log.LogInfo((object)"Tried to register more than one switchboard.");
					return;
				}
				string value = Config.switchboardNumber.Value;
				switchboard = ((Component)((NetworkBehaviour)this).GetNetworkObject(SwitchboardId)).GetComponent<SwitchboardPhone>();
				Plugin.Log.LogInfo((object)("New switchboard for object: " + SwitchboardId));
				((Component)switchboard).GetComponent<NetworkObject>().ChangeOwnership(0uL);
				phoneNumberDict.Add(value, ((NetworkBehaviour)switchboard).NetworkObjectId);
				phoneObjectDict.Add(value, switchboard);
				switchboard.SetNewPhoneNumberClientRpc(value);
				RequestClientUpdates();
				UpdateSwitchboardPhones();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateNewPhoneNumberServerRpc(ulong phoneId, string skinId, string charmId, string ringtoneId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4149461822u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, phoneId);
				bool flag = skinId != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(skinId, false);
				}
				bool flag2 = charmId != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(charmId, false);
				}
				bool flag3 = ringtoneId != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives));
				if (flag3)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(ringtoneId, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 4149461822u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong senderClientId = serverRpcParams.Receive.SenderClientId;
			int value = Config.maxPhoneNumber.Value;
			if (phoneNumberDict.Count >= value)
			{
				Plugin.Log.LogError((object)"Cannot create a new unique phone number. Not enough numbers remaining. Please increase the maxPhoneNumber config.");
				Plugin.Log.LogError((object)("maxPhoneNumber = " + value + ", current Phone Numbers = " + phoneNumberDict.Count));
				return;
			}
			int num = Random.Range(0, value);
			string text = num.ToString("D4");
			while (phoneNumberDict.ContainsKey(num.ToString()) || num.ToString() == Config.switchboardNumber.Value)
			{
				num = Random.Range(0, value);
				text = num.ToString("D4");
			}
			PhoneBehavior component = ((Component)((NetworkBehaviour)this).GetNetworkObject(phoneId)).GetComponent<PhoneBehavior>();
			Plugin.Log.LogInfo((object)("New phone for object: " + phoneId));
			((Component)component).GetComponent<NetworkObject>().ChangeOwnership(senderClientId);
			phoneNumberDict.Add(text, ((NetworkBehaviour)component).NetworkObjectId);
			phoneObjectDict.Add(text, component);
			component.phoneSkinId = skinId;
			component.phoneCharmId = charmId;
			component.phoneRingtoneId = ringtoneId;
			component.SetNewPhoneNumberClientRpc(text);
			RequestClientUpdates();
			if ((Object)(object)switchboard != (Object)null)
			{
				UpdateSwitchboardPhones();
			}
		}

		public void DeletePlayerPhone(int playerId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			Plugin.Log.LogInfo((object)("Deleting phone for player: " + ((Object)val).name));
			PlayerPhone phone = ((Component)((Component)val).transform.Find("PhonePrefab(Clone)")).GetComponent<PlayerPhone>();
			string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == ((NetworkBehaviour)phone).NetworkObjectId).Key;
			if (!NetworkManager.Singleton.ShutdownInProgress)
			{
				((Component)phone).GetComponent<NetworkObject>().RemoveOwnership();
			}
			RemoveNumber(key);
			if ((Object)(object)switchboard != (Object)null)
			{
				UpdateSwitchboardPhones();
			}
		}

		public void DeletePhone(ulong phoneId)
		{
			Plugin.Log.LogInfo((object)("Deleting phone with ID: " + phoneId));
			PhoneBehavior phone = ((Component)((NetworkBehaviour)this).GetNetworkObject(phoneId)).GetComponent<PhoneBehavior>();
			string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == ((NetworkBehaviour)phone).NetworkObjectId).Key;
			if (!NetworkManager.Singleton.ShutdownInProgress)
			{
				((Component)phone).GetComponent<NetworkObject>().RemoveOwnership();
			}
			RemoveNumber(key);
			if ((Object)(object)switchboard != (Object)null)
			{
				UpdateSwitchboardPhones();
			}
		}

		public void DeleteSwitchboard()
		{
			Plugin.Log.LogInfo((object)"Deleting switchboard");
			string phoneNumber = switchboard.phoneNumber;
			RemoveNumber(phoneNumber);
			switchboard = null;
		}

		public void RemoveNumber(string number)
		{
			if (number != null)
			{
				Plugin.Log.LogInfo((object)("Removing number: " + number));
				phoneObjectDict.Remove(number);
				phoneNumberDict.Remove(number);
				if ((Object)(object)switchboard != (Object)null)
				{
					UpdateSwitchboardPhones();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeOutgoingCallServerRpc(string number, ulong senderId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_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_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2838937995u, serverRpcParams, (RpcDelivery)0);
				bool flag = number != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(number, false);
				}
				BytePacker.WriteValueBitPacked(val, senderId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2838937995u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong senderId2 = senderId;
			if (!Locked.Value)
			{
				string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == senderId2).Key;
				if (phoneNumberDict.ContainsKey(number))
				{
					phoneObjectDict[number].RecieveCallClientRpc(senderId2, key);
				}
				else
				{
					phoneObjectDict[key].InvalidCallClientRpc("Invalid #");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AcceptIncomingCallServerRpc(string number, ulong accepterId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_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_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3789588791u, serverRpcParams, (RpcDelivery)0);
				bool flag = number != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(number, false);
				}
				BytePacker.WriteValueBitPacked(val, accepterId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3789588791u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ulong accepterId2 = accepterId;
				string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == accepterId2).Key;
				phoneObjectDict[number].CallAcceptedClientRpc(accepterId2, key);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void HangUpCallServerRpc(string number, ulong cancellerId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_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_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(835668601u, serverRpcParams, (RpcDelivery)0);
				bool flag = number != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(number, false);
				}
				BytePacker.WriteValueBitPacked(val, cancellerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 835668601u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong cancellerId2 = cancellerId;
			if (phoneNumberDict.ContainsKey(number))
			{
				string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == cancellerId2).Key;
				phoneObjectDict[number].HangupCallClientRpc(cancellerId2, key);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TransferCallServerRpc(string number, string transferNumber, ulong transferrerId, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(760662274u, serverRpcParams, (RpcDelivery)0);
				bool flag = number != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(number, false);
				}
				bool flag2 = transferNumber != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(transferNumber, false);
				}
				BytePacker.WriteValueBitPacked(val, transferrerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 760662274u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong transferrerId2 = transferrerId;
			if (phoneNumberDict.ContainsKey(number) && phoneNumberDict.ContainsKey(transferNumber))
			{
				string key = phoneNumberDict.FirstOrDefault((KeyValuePair<string, ulong> x) => x.Value == transferrerId2).Key;
				phoneObjectDict[number].TransferCallClientRpc(transferrerId2, key, transferNumber);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void LineBusyServerRpc(string number, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_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_00ba: 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))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(16429471u, serverRpcParams, (RpcDelivery)0);
				bool flag = number != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(number, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 16429471u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				phoneObjectDict[number].InvalidCallClientRpc("Line Busy");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateAllClientsServerRpc()
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3044635500u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3044635500u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			foreach (PhoneBehavior value in phoneObjectDict.Values)
			{
				value.PropogateInformation();
			}
			UpdateClipboardText();
			if ((Object)(object)switchboard != (Object)null)
			{
				UpdateSwitchboardPhones();
			}
		}

		protected override void __initializeVariables()
		{
			if (Locked == null)
			{
				throw new Exception("PhoneNetworkHandler.Locked cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)Locked).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)Locked, "Locked");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)Locked);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PhoneNetworkHandler()
		{
			//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
			NetworkManager.__rpc_func_table.Add(1152410923u, new RpcReceiveHandler(__rpc_handler_1152410923));
			NetworkManager.__rpc_func_table.Add(3333872520u, new RpcReceiveHandler(__rpc_handler_3333872520));
			NetworkManager.__rpc_func_table.Add(4149461822u, new RpcReceiveHandler(__rpc_handler_4149461822));
			NetworkManager.__rpc_func_table.Add(2838937995u, new RpcReceiveHandler(__rpc_handler_2838937995));
			NetworkManager.__rpc_func_table.Add(3789588791u, new RpcReceiveHandler(__rpc_handler_3789588791));
			NetworkManager.__rpc_func_table.Add(835668601u, new RpcReceiveHandler(__rpc_handler_835668601));
			NetworkManager.__rpc_func_table.Add(760662274u, new RpcReceiveHandler(__rpc_handler_760662274));
			NetworkManager.__rpc_func_table.Add(16429471u, new RpcReceiveHandler(__rpc_handler_16429471));
			NetworkManager.__rpc_func_table.Add(3044635500u, new RpcReceiveHandler(__rpc_handler_3044635500));
		}

		private static void __rpc_handler_1152410923(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;
				((PhoneNetworkHandler)(object)target).RequestSwitchboardUpdatesServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3333872520(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0040: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong switchboardId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref switchboardId);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).RegisterSwitchboardServerRpc(switchboardId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4149461822(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_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_00ac: 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_00d8: 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_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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong phoneId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref phoneId);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string skinId = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref skinId, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string charmId = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref charmId, false);
				}
				bool flag3 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
				string ringtoneId = null;
				if (flag3)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref ringtoneId, false);
				}
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).CreateNewPhoneNumberServerRpc(phoneId, skinId, charmId, ringtoneId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2838937995(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_005b: 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_0069: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string number = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref number, false);
				}
				ulong senderId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref senderId);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).MakeOutgoingCallServerRpc(number, senderId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3789588791(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_005b: 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_0069: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string number = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref number, false);
				}
				ulong accepterId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref accepterId);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).AcceptIncomingCallServerRpc(number, accepterId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_835668601(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_005b: 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_0069: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string number = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref number, false);
				}
				ulong cancellerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref cancellerId);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).HangUpCallServerRpc(number, cancellerId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_760662274(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_0067: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string number = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref number, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string transferNumber = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref transferNumber, false);
				}
				ulong transferrerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref transferrerId);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).TransferCallServerRpc(number, transferNumber, transferrerId, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_16429471(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_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string number = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref number, false);
				}
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PhoneNetworkHandler)(object)target).LineBusyServerRpc(number, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3044635500(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;
				((PhoneNetworkHandler)(object)target).UpdateAllClientsServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PhoneNetworkHandler";
		}
	}
}
namespace Scoops.patch
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	public class HoardingBugPhonePatch
	{
		public static int phoneBugs;

		public static PhoneNetworkHandler PhoneManager;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CreatePhoneAssets(ref HoarderBugAI __instance)
		{
			//IL_0073: 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)
			PhoneManager = PhoneNetworkHandler.Instance;
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && phoneBugs < Config.maxPhoneBugs.Value && Random.Range(0f, 1f) <= Config.chancePhoneBug.Value)
			{
				phoneBugs++;
				GameObject val = Object.Instantiate<GameObject>(NetworkObjectManager.bugPhonePrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				val.GetComponent<NetworkObject>().TrySetParent(((Component)__instance).transform, false);
			}
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPrefix]
		private static void BugDead(ref HoarderBugAI __instance, bool destroy = false)
		{
			if (((NetworkBehaviour)__instance).IsServer && (Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).transform.Find("BugPhonePrefab(Clone)") != (Object)null)
			{
				HoardingPhone component = ((Component)((Component)__instance).transform.Find("BugPhonePrefab(Clone)")).GetComponent<HoardingPhone>();
				if ((Object)(object)component != (Object)null)
				{
					component.Death();
					((NetworkBehaviour)component).NetworkObject.Despawn(true);
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
		[HarmonyPrefix]
		private static void UnloadScene(ref RoundManager __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			HoardingPhone[] array = Object.FindObjectsOfType<HoardingPhone>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((NetworkBehaviour)array[i]).IsSpawned)
				{
					array[i].Death();
					((NetworkBehaviour)array[i]).NetworkObject.Despawn(true);
				}
			}
		}
	}
	internal class MainMenuPatch
	{
		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPostfix]
		public static void Start(MenuManager __instance)
		{
			if (!__instance.isInitScene && (CustomizationManager.skinCustomizations.Count != 1 || CustomizationManager.charmCustomizations.Count != 1 || CustomizationManager.ringtoneCustomizations.Count != 1))
			{
				((MonoBehaviour)__instance).StartCoroutine(DelayedMainMenuInjection());
			}
		}

		private static IEnumerator DelayedMainMenuInjection()
		{
			yield return (object)new WaitForSeconds(0f);
			InjectToMainMenu();
		}

		private static void InjectToMainMenu()
		{
			Plugin.Log.LogInfo((object)"Injecting phone customization menu into main menu...");
			GameObject val = GameObject.Find("MenuContainer");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Transform val2 = val.transform.Find("MainButtons");
			if (Object.op_Implicit((Object)(object)val2))
			{
				Transform val3 = val2.Find("QuitButton");
				if (Object.op_Implicit((Object)(object)val3))
				{
					CustomizationMenuUtils.InjectMenu(val2, ((Component)val3).gameObject);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	public class MaskedPhonePatch
	{
		public static int phoneMasks;

		public static PhoneNetworkHandler PhoneManager;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CreatePhoneAssets(ref MaskedPlayerEnemy __instance)
		{
			//IL_0083: 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)
			PhoneManager = PhoneNetworkHandler.Instance;
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && MirageCompat.Enabled && phoneMasks < Config.maxPhoneMasked.Value && Random.Range(0f, 1f) <= Config.chancePhoneMask.Value)
			{
				phoneMasks++;
				GameObject val = Object.Instantiate<GameObject>(NetworkObjectManager.maskPhonePrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				val.GetComponent<NetworkObject>().TrySetParent(((Component)__instance).transform, false);
			}
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPrefix]
		private static void MaskDead(ref MaskedPlayerEnemy __instance, bool destroy = false)
		{
			if (((NetworkBehaviour)__instance).IsServer && (Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).transform.Find("MaskPhonePrefab(Clone)") != (Object)null)
			{
				MaskedPhone component = ((Component)((Component)__instance).transform.Find("MaskPhonePrefab(Clone)")).GetComponent<MaskedPhone>();
				if ((Object)(object)component != (Object)null)
				{
					component.Death();
					((NetworkBehaviour)component).NetworkObject.Despawn(true);
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
		[HarmonyPrefix]
		private static void UnloadScene(ref RoundManager __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			MaskedPhone[] array = Object.FindObjectsOfType<MaskedPhone>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((NetworkBehaviour)array[i]).IsSpawned)
				{
					array[i].Death();
					((NetworkBehaviour)array[i]).NetworkObject.Despawn(true);
				}
			}
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		public static GameObject phonePrefab;

		public static GameObject bugPhonePrefab;

		public static GameObject maskPhonePrefab;

		public static GameObject clipboardPrefab;

		public static GameObject switchboardPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			if ((Object)(object)networkPrefab == (Object)null)
			{
				networkPrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("PhoneNetworkHandler");
				networkPrefab.AddComponent<PhoneNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
			if ((Object)(object)phonePrefab == (Object)null)
			{
				phonePrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("PhonePrefab");
				phonePrefab.AddComponent<PlayerPhone>();
				NetworkManager.Singleton.AddNetworkPrefab(phonePrefab);
			}
			if ((Object)(object)bugPhonePrefab == (Object)null)
			{
				bugPhonePrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("BugPhonePrefab");
				bugPhonePrefab.AddComponent<HoardingPhone>();
				NetworkManager.Singleton.AddNetworkPrefab(bugPhonePrefab);
			}
			if ((Object)(object)maskPhonePrefab == (Object)null)
			{
				maskPhonePrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("MaskPhonePrefab");
				maskPhonePrefab.AddComponent<MaskedPhone>();
				NetworkManager.Singleton.AddNetworkPrefab(maskPhonePrefab);
			}
			if ((Object)(object)clipboardPrefab == (Object)null)
			{
				clipboardPrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("ClipboardPhoneBook");
				clipboardPrefab.AddComponent<Clipboard>();
				NetworkManager.Singleton.AddNetworkPrefab(clipboardPrefab);
				if (Config.clipboardPurchase.Value)
				{
					Item itemProperties = ((GrabbableObject)clipboardPrefab.GetComponent<PhysicsProp>()).itemProperties;
					itemProperties.spawnPrefab = clipboardPrefab;
					TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val).name = "ClipboardInfoNode";
					val.displayText = "A clipboard with everyone's phone numbers written on it. Will auto update if players join or leave.\n\n";
					val.clearPreviousText = true;
					val.maxCharactersToType = 25;
					Items.RegisterShopItem(itemProperties, (TerminalNode)null, (TerminalNode)null, val, Config.clipboardPrice.Value);
				}
			}
			if ((Object)(object)switchboardPrefab == (Object)null)
			{
				switchboardPrefab = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("SwitchboardContainer");
				switchboardPrefab.AddComponent<SwitchboardPhone>();
				NetworkManager.Singleton.AddNetworkPrefab(switchboardPrefab);
				if (Config.switchboardPurchase.Value)
				{
					UnlockableItem val2 = new UnlockableItem();
					val2.prefabObject = switchboardPrefab;
					val2.unlockableName = "Switchboard";
					val2.IsPlaceable = true;
					val2.spawnPrefab = true;
					val2.alwaysInStock = true;
					val2.canBeStored = true;
					val2.unlockableType = 1;
					val2.maxNumber = 1;
					TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val3).name = "PhoneSwitchboardInfoNode";
					val3.displayText = "A Switchboard for your ship. Enjoy easy routing and management of your co-workers' Personal Phones from the safety of your ship.\n\n";
					val3.clearPreviousText = true;
					val3.maxCharactersToType = 25;
					Unlockables.RegisterUnlockable(val2, (StoreType)1, (TerminalNode)null, (TerminalNode)null, val3, Config.switchboardPrice.Value);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0024: 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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	[HarmonyPatch("SetPlayerSanityLevel")]
	public static class PlayerControllerB_SetPlayerSanityLevel_Patch
	{
		private static FieldInfo f_isPlayerAlone = AccessTools.Field(typeof(PlayerControllerB), "isPlayerAlone");

		private static MethodInfo m_UpdatePhoneSanity = AccessTools.Method(typeof(PlayerPhone), "UpdatePhoneSanity", new Type[1] { typeof(PlayerControllerB) }, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count - 3; i++)
			{
				if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 2].opcode == OpCodes.Ldc_R4 && list[i + 3].opcode == OpCodes.Bge_Un)
				{
					num = i + 1;
					break;
				}
			}
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Call, (object)m_UpdatePhoneSanity),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			};
			if (num != -1)
			{
				list.InsertRange(num, collection);
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerPhonePatch
	{
		public static PhoneNetworkHandler PhoneManager;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CreatePhoneAssets(ref PlayerControllerB __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("PhoneAudioExternal");
			Object.Instantiate<GameObject>(val, ((Component)__instance).transform.Find("Audios"));
			GameObject val2 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("LocalPhoneModel");
			GameObject val3 = Object.Instantiate<GameObject>(val2, __instance.localArmsTransform.Find("shoulder.L").Find("arm.L_upper").Find("arm.L_lower")
				.Find("hand.L"), false);
			GameObject val4 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("ServerPhoneModel");
			GameObject val5 = Object.Instantiate<GameObject>(val4, __instance.lowerSpine.Find("spine.002").Find("spine.003").Find("shoulder.L")
				.Find("arm.L_upper")
				.Find("arm.L_lower")
				.Find("hand.L"), false);
			Transform val6 = __instance.localArmsTransform.Find("RigArms");
			Transform val7 = __instance.meshContainer.Find("metarig").Find("Rig 1");
			GameObject val8 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("RightArmPhone");
			GameObject val9 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("LeftArmPhone");
			GameObject val10 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("ServerLeftArmPhone");
			GameObject val11 = (GameObject)Plugin.LethalPhoneAssets.LoadAsset("ServerPhoneTargetHolder");
			GameObject val12 = Object.Instantiate<GameObject>(val8, val6, false);
			GameObject val13 = Object.Instantiate<GameObject>(val9, val6, false);
			GameObject val14 = Object.Instantiate<GameObject>(val10, val7, false);
			GameObject val15 = Object.Instantiate<GameObject>(val11, __instance.lowerSpine.Find("spine.002").Find("spine.003"), false);
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val12.GetComponent<ChainIKConstraint>()).data)).root = __instance.localArmsTransform.Find("shoulder.R").Find("arm.R_upper");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val12.GetComponent<ChainIKConstraint>()).data)).tip = __instance.localArmsTransform.Find("shoulder.R").Find("arm.R_upper").Find("arm.R_lower")
				.Find("hand.R");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val13.GetComponent<ChainIKConstraint>()).data)).root = __instance.localArmsTransform.Find("shoulder.L").Find("arm.L_upper");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val13.GetComponent<ChainIKConstraint>()).data)).tip = __instance.localArmsTransform.Find("shoulder.L").Find("arm.L_upper").Find("arm.L_lower")
				.Find("hand.L");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val14.GetComponent<ChainIKConstraint>()).data)).root = __instance.lowerSpine.Find("spine.002").Find("spine.003").Find("shoulder.L")
				.Find("arm.L_upper");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val14.GetComponent<ChainIKConstraint>()).data)).tip = __instance.lowerSpine.Find("spine.002").Find("spine.003").Find("shoulder.L")
				.Find("arm.L_upper")
				.Find("arm.L_lower")
				.Find("hand.L");
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)val14.GetComponent<ChainIKConstraint>()).data)).target = val15.transform.Find("ServerPhoneTarget");
			((Object)val12.GetComponent<ChainIKConstraint>()).MarkDirty();
			((Object)val13.GetComponent<ChainIKConstraint>()).MarkDirty();
			((Object)val14.GetComponent<ChainIKConstraint>()).MarkDirty();
			((Component)__instance.playerBodyAnimator).GetComponent<RigBuilder>().Build();
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val16 = Object.Instantiate<GameObject>(NetworkObjectManager.phonePrefab, Vector3.zero, Quaternion.identity);
				val16.GetComponent<NetworkObject>().Spawn(false);
				val16.GetComponent<NetworkObject>().TrySetParent(((Component)__instance).transform, false);
			}
		}

		[HarmonyPatch("SpectateNextPlayer")]
		[HarmonyPostfix]
		private static void SpectatedNextPlayer(ref PlayerControllerB __instance)
		{
			PlayerPhone[] array = Object.FindObjectsByType<PlayerPhone>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				array[i].spectatorClear = true;
			}
		}

		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void InitPhone(ref PlayerControllerB __instance)
		{
			PhoneManager = PhoneNetworkHandler.Instance;
			NetworkObject component = ((Component)((Component)__instance).transform.Find("PhonePrefab(Clone)")).GetComponent<NetworkObject>();
			PhoneManager.CreateNewPhone(component.NetworkObjectId, CustomizationManager.SelectedSkin, CustomizationManager.SelectedCharm, CustomizationManager.SelectedRingtone);
			Plugin.InputActionInstance.TogglePhoneKey.performed += OnTogglePhoneKeyPressed;
			Plugin.InputActionInstance.PickupPhoneKey.performed += OnPickupPhoneKeyPressed;
			Plugin.InputActionInstance.HangupPhoneKey.performed += OnHangupPhoneKeyPressed;
			Plugin.InputActionInstance.VolumePhoneKey.performed += OnVolumePhoneKeyPressed;
		}

		[HarmonyPatch("OnDestroy")]
		[HarmonyPrefix]
		private static void CleanupPhone(ref PlayerControllerB __instance)
		{
			if ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer)
			{
				Plugin.InputActionInstance.TogglePhoneKey.performed -= OnTogglePhoneKeyPressed;
				Plugin.InputActionInstance.PickupPhoneKey.performed -= OnPickupPhoneKeyPressed;
				Plugin.InputActionInstance.HangupPhoneKey.performed -= OnHangupPhoneKeyPressed;
				Plugin.InputActionInstance.VolumePhoneKey.performed -= OnVolumePhoneKeyPressed;
			}
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPostfix]
		private static void PlayerDamaged(ref PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3))
		{
			if ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer)
			{
				float change = 0f - Mathf.Clamp01((float)damageNumber / 50f);
				PhoneManager.localPhone.InfluenceConnectionQuality(change);
			}
		}

		[HarmonyPatch("DisablePlayerModel")]
		[HarmonyPostfix]
		private static void PlayerModelDisabled(ref PlayerControllerB __instance, GameObject playerObject, bool enable = false, bool disableLocalArms = false)
		{
			PlayerPhone component = ((Component)((Component)__instance).transform.Find("PhonePrefab(Clone)")).GetComponent<PlayerPhone>();
			component.SetPhoneLocalModelActive();
			component.SetPhoneServerModelActive();
		}

		[HarmonyPatch("KillPlayerClientRpc")]
		[HarmonyPostfix]
		private static void PlayerDeath(ref PlayerControllerB __instance, int playerId, bool spawnBody, Vector3 bodyVelocity, int causeOfDeath, int deathAnimation)
		{
			PlayerPhone component = ((Component)((Component)__instance).transform.Find("PhonePrefab(Clone)")).GetComponent<PlayerPhone>();
			component.Death(causeOfDeath);
		}

		[HarmonyPatch("SpawnDeadBody")]
		[HarmonyPostfix]
		private static void PlayerSpawnBody(ref PlayerControllerB __instance, int playerId, Vector3 bodyVelocity, int causeOfDeath, PlayerControllerB deadPlayerController, int deathAnimation = 0, Transform overridePosition = null)
		{
			PlayerPhone component = ((Component)((Component)__instance).transform.Find("PhonePrefab(Clone)")).GetComponent<PlayerPhone>();
			component.ApplyCorpse();
		}

		private static void OnTogglePhoneKeyPressed(CallbackContext context)
		{
			if (!((Object)(object)PhoneManager == (Object)null) && !((Object)(object)PhoneManager.localPhone == (Object)null) && !PhoneNetworkHandler.Locked.Value)
			{
				PlayerControllerB player = PhoneManager.localPhone.player;
				if (!((Object)(object)player == (Object)null) && !player.quickMenuManager.isMenuOpen && !player.isGrabbingObjectAnimation && !player.isTypingChat && !player.inTerminalMenu && !player.throwingObject && !player.IsInspectingItem)
				{
					PhoneManager.localPhone.ToggleActive(!PhoneManager.localPhone.toggled);
				}
			}
		}

		private static void OnPickupPhoneKeyPressed(CallbackContext context)
		{
			if (!((Object)(object)PhoneManager == (Object)null) && !((Object)(object)PhoneManager.localPhone == (Object)null))
			{
				PlayerControllerB player = PhoneManager.localPhone.player;
				if (!((Object)(object)player == (Object)null) && !player.quickMenuManager.isMenuOpen && !player.isGrabbingObjectAnimation && !player.isTypingChat && !player.inTerminalMenu && !player.throwingObject && !player.IsInspectingItem)
				{
					PhoneManager.localPhone.CallButtonPressed();
				}
			}
		}

		private static void OnHangupPhoneKeyPressed(CallbackContext context)
		{
			if (!((Object)(object)PhoneManager == (Object)null) && !((Object)(object)PhoneManager.localPhone == (Object)null))
			{
				PlayerControllerB player = PhoneManager.localPhone.player;
				if (!((Object)(object)player == (Object)null) && !player.quickMenuManager.isMenuOpen && !player.isGrabbingObjectAnimation && !player.isTypingChat && !player.inTerminalMenu && !player.throwingObject && !player.IsInspectingItem)
				{
					PhoneManager.localPhone.HangupButtonPressed();
				}
			}
		}

		private static void OnVolumePhoneKeyPressed(CallbackContext context)
		{
			PlayerControllerB player = PhoneManager.localPhone.player;
			if (!((Object)(object)player == (Object)null) && !player.quickMenuManager.isMenuOpen && !player.isGrabbingObjectAnimation && !player.isTypingChat && !player.inTerminalMenu && !player.throwingObject && !player.IsInspectingItem)
			{
				PhoneManager.localPhone.VolumeButtonPressed();
			}
		}

		[HarmonyPatch("ActivateItem_performed")]
		[HarmonyPrefix]
		private static bool ActivateItem_performed(ref PlayerControllerB __instance)
		{
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return true;
			}
			if (PhoneManager.localPhone.toggled)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("InspectItem_performed")]
		[HarmonyPrefix]
		private static bool InspectItem_performed(ref PlayerControllerB __instance)
		{
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return true;
			}
			if (PhoneManager.localPhone.toggled)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("QEItemInteract_performed")]
		[HarmonyPrefix]
		private static bool QEItemInteract_performed(ref PlayerControllerB __instance)
		{
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return true;
			}
			if (PhoneManager.localPhone.toggled)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("ItemSecondaryUse_performed")]
		[HarmonyPrefix]
		private static bool ItemSecondaryUse_performed(ref PlayerControllerB __instance)
		{
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return true;
			}
			if (PhoneManager.localPhone.toggled)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("ItemTertiaryUse_performed")]
		[HarmonyPrefix]
		private static bool ItemTertiaryUse_performed(ref PlayerControllerB __instance)
		{
			if ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer)
			{
				return true;
			}
			if (PhoneManager.localPhone.toggled)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("Interact_performed")]
		[HarmonyPostfix]
		private static void Interact_performed(ref PlayerControllerB __instance)
		{
			if (((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && PhoneManager.localPhone.toggled && __instance.inTerminalMenu)
			{
				PhoneManager.localPhone.ToggleActive(active: false);
			}
		}

		[HarmonyPatch("GrabObjectClientRpc")]
		[HarmonyPostfix]
		private static void GrabObjectClientRpc(ref PlayerControllerB __instance, bool grabValidated, NetworkObjectReference grabbedObject)
		{
			if (((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && PhoneManager.localPhone.toggled)
			{
				PhoneManager.localPhone.ToggleActive(active: false);
			}
		}

		[HarmonyPatch("SwitchToItemSlot")]
		[HarmonyPostfix]
		private static void ScrollMouse_SwitchToItemSlotperformed(ref PlayerControllerB __instance)
		{
			if (((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && PhoneManager.localPhone.toggled && __instance.isHoldingObject)
			{
				PhoneManager.localPhone.ToggleActive(active: false);
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class ShipTeleporterPhonePatch
	{
		[HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")]
		[HarmonyPostfix]
		private static void InverseTeleported(ref ShipTeleporter __instance, int playerObj, Vector3 teleportPos)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj];
			if (!((Object)(object)val == (Object)null) && ((NetworkBehaviour)val).IsLocalPlayer)
			{
				PlayerPhone localPhone = PhoneNetworkHandler.Instance.localPhone;
				if ((Object)(object)localPhone != (Object)null)
				{
					localPhone.InfluenceConnectionQuality(-1f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPhonePatch
	{
		private static float updateInterval;

		private static List<AudioSource> sortedSources = new List<AudioSource>();

		[HarmonyPatch("ReviveDeadPlayers")]
		[HarmonyPostfix]
		private static void ResetPhones(ref StartOfRound __instance)
		{
			PlayerPhone[] array = Object.FindObjectsByType<PlayerPhone>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Revive();
			}
			PhoneNetworkHandler.Instance.localPhone.ToggleActive(active: false);
		}

		[HarmonyPatch("OnPlayerDC")]
		[HarmonyPrefix]
		private static void CleanupPlayerPhone(ref StartOfRound __instance, int playerObjectNumber, ulong clientId)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				PhoneNetworkHandler.Instance.DeletePlayerPhone(playerObjectNumber);
				PhoneNetworkHandler.Instance.UpdateClipboardText();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update(ref StartOfRound __instance)
		{
			if (updateInterval >= 0f)
			{
				updateInterval -= Time.deltaTime;
				return;
			}
			updateInterval = 1f;
			AudioSource[] array = Object.FindObjectsByType<AudioSource>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			sortedSources = new List<AudioSource>();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].spatialBlend != 0f)
				{
					sortedSources.Add(array[i]);
				}
			}
		}

		[HarmonyPatch("PassTimeToNextDay")]
		[HarmonyPostfix]
		private static void PassTimeToNextDay(ref StartOfRound __instance)
		{
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && Config.respawnClipboard.Value)
			{
				PhoneNetworkHandler.Instance.CheckClipboardRespawn();
			}
		}

		[HarmonyPatch("UnlockShipObject")]
		[HarmonyPostfix]
		private static void UnlockShipObject(ref StartOfRound __instance, int unlockableID)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				PhoneNetworkHandler.CheckPhoneUnlock();
			}
		}

		[HarmonyPatch("LoadUnlockables")]
		[HarmonyPostfix]
		private static void LoadUnlockables(ref StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				PhoneNetworkHandler.CheckPhoneUnlock();
			}
		}

		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		private static void ResetShip(ref StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				PhoneNetworkHandler.CheckPhoneUnlock();
			}
		}

		public static List<AudioSource> GetAllAudioSourcesInRange(Vector3 position)
		{
			//IL_006a: 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_0086: Unknown result type (might be due to invalid IL or missing references)