Decompiled source of LethalPhones v1.3.9

LethalPhones/LethalPhones.dll

Decompiled 5 days 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.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UIElements;
using WeatherRegistry;
using WeatherTweaks;

[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: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("WeatherTweaks")]
[assembly: AssemblyCompany("LethalPhones")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1-alpha.0.71+278891d293271784cc52a5ceda7da953029e03fe")]
[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<PlayerPhone.phoneVolume>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<PlayerPhone.phoneVolume>();
	}
}
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;
		}
	}
}
[HarmonyPatch]
internal class GameObjectPatches
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return new MethodInfo[5]
		{
			AccessTools.Method(typeof(Object), "Instantiate", new Type[1] { typeof(Object) }, (Type[])null),
			AccessTools.Method(typeof(Object), "Instantiate", new Type[2]
			{
				typeof(Object),
				typeof(Transform)
			}, (Type[])null),
			AccessTools.Method(typeof(Object), "Instantiate", new Type[3]
			{
				typeof(Object),
				typeof(Transform),
				typeof(bool)
			}, (Type[])null),
			AccessTools.Method(typeof(Object), "Instantiate", new Type[3]
			{
				typeof(Object),
				typeof(Vector3),
				typeof(Quaternion)
			}, (Type[])null),
			AccessTools.Method(typeof(Object), "Instantiate", new Type[4]
			{
				typeof(Object),
				typeof(Vector3),
				typeof(Quaternion),
				typeof(Transform)
			}, (Type[])null)
		};
	}

	private static void Postfix(ref Object __result)
	{
		if (__result is GameObject)
		{
			Object obj = __result;
			AudioSourceManager.CheckGameObject((GameObject)(object)((obj is GameObject) ? obj : null));
		}
	}
}
[HarmonyPatch]
internal class NetworkObjectPatches
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return new MethodInfo[1] { AccessTools.Method(typeof(NetworkSpawnManager), "CreateLocalNetworkObject", new Type[1] { typeof(SceneObject) }, (Type[])null) };
	}

	private static void Postfix(ref NetworkObject __result)
	{
		if (!((Object)(object)__result == (Object)null) && Object.op_Implicit((Object)(object)((Component)__result).gameObject))
		{
			AudioSourceManager.CheckGameObject(((Component)__result).gameObject);
		}
	}
}
[HarmonyPatch]
internal class ComponentPatches
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return new MethodInfo[1] { AccessTools.Method(typeof(GameObject), "AddComponent", new Type[1] { typeof(Type) }, (Type[])null) };
	}

	private static void Postfix(ref Component __result)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		AudioSourceHook audioSourceHook = default(AudioSourceHook);
		if (__result is AudioSource && !__result.TryGetComponent<AudioSourceHook>(ref audioSourceHook))
		{
			AudioSourceHook audioSourceHook2 = __result.gameObject.AddComponent<AudioSourceHook>();
			audioSourceHook2.SetAudioSource((AudioSource)__result);
		}
	}
}
namespace Scoops
{
	public class Config
	{
		public static ConfigEntry<float> ringtoneVolume;

		public static ConfigEntry<float> recordingDist;

		public static ConfigEntry<float> listeningDist;

		public static ConfigEntry<float> backgroundSoundAdjust;

		public static ConfigEntry<float> voiceSoundAdjust;

		public static ConfigEntry<float> staticSoundAdjust;

		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<float> switchboardBoosterRange;

		public static ConfigEntry<float> radarBoosterRange;

		public static ConfigEntry<float> apparatusRange;

		public static ConfigEntry<float> connectionHealTime;

		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).");
			voiceSoundAdjust = cfg.Bind<float>("General", "voiceSoundAdjust", 0.8f, "All voices on calls have their volume multiplied by this value.");
			backgroundSoundAdjust = cfg.Bind<float>("General", "backgroundSoundAdjust", 1f, "All background noises on calls have their volume multiplied by this value.");
			staticSoundAdjust = cfg.Bind<float>("General", "staticSoundAdjust", 0.7f, "All static noises on calls have their volume multiplied by this value.");
			recordingDist = cfg.Bind<float>("General", "recordingDist", 15f, "The distance at which phones are able to record audio.");
			listeningDist = cfg.Bind<float>("General", "listeningDist", 5f, "The distance at which you can hear audio from a phone.");
			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'");
			switchboardBoosterRange = cfg.Bind<float>("Balance", "switchboardBoosterRange", 50f, "The range in meters at which the switchboard increases phone connection quality.");
			radarBoosterRange = cfg.Bind<float>("Balance", "radarBoosterRange", 100f, "The range in meters at which the radar booster increases phone connection quality while active.");
			apparatusRange = cfg.Bind<float>("Balance", "apparatusRange", 50f, "The range in meters at which the apparatus reduces phone connection quality.");
			connectionHealTime = cfg.Bind<float>("Balance", "connectionHealTime", 45f, "How many seconds it should take for a phones connection bar to recover from full temporary connection loss (taking damage, inverse teleporting).");
			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.3.9";
	}
	[BepInPlugin("LethalPhones", "LethalPhones", "1.3.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[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.3.9");
			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");
			Log.LogInfo((object)"Setting up AudioSource Hook");
			SceneManager.sceneLoaded += AudioSourceManager.CheckAudioSourceSceneLoad;
			if (WeatherRegistryCompat.Enabled)
			{
				Log.LogInfo((object)"Loaded Weather Registry Compatability");
			}
			if (WeatherTweaksCompat.Enabled)
			{
				Log.LogInfo((object)"Loaded Weather Tweaks 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));
			_harmony.PatchAll(typeof(AudioSourceManager));
			_harmony.PatchAll(typeof(GameObjectPatches));
			_harmony.PatchAll(typeof(NetworkObjectPatches));
			_harmony.PatchAll(typeof(ComponentPatches));
			_harmony.PatchAll(typeof(ConnectionQualityManager));
		}

		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 bool modified = false;

		public bool voice = false;

		public bool staticAudio = false;

		public PlayerControllerB player = null;

		public Transform recordPos;

		public Transform playPos;

		public Transform listenerPos;

		public Transform sourcePos;

		public float recordInterference;

		public AudioSource audioSource;

		private float recordDist;

		private float origVolume;

		private float origSpatial;

		private float origPan;

		private bool hadLowPass;

		private bool hadHighPass;

		private bool hadOcclude;

		private float origLowPass;

		private float origLowPassResQ;

		private float origHighPass;

		private float origHighPassResQ;

		private AnimationCurve origSpatialCurve;

		public AudioSourceStorage(AudioSource audioSource)
		{
			this.audioSource = audioSource;
			recordPos = null;
			playPos = null;
			listenerPos = null;
			sourcePos = ((Component)audioSource).transform;
			recordInterference = 0f;
			origVolume = audioSource.volume;
			origSpatial = audioSource.spatialBlend;
			origPan = audioSource.panStereo;
			origSpatialCurve = audioSource.GetCustomCurve((AudioSourceCurveType)1);
			hadLowPass = (Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>() != (Object)null;
			hadHighPass = (Object)(object)((Component)audioSource).GetComponent<AudioHighPassFilter>() != (Object)null;
			hadOcclude = (Object)(object)((Component)audioSource).GetComponent<OccludeAudio>() != (Object)null;
			if (hadLowPass)
			{
				origLowPass = ((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency;
				origLowPassResQ = ((Component)audioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ;
			}
			else
			{
				((Behaviour)((Component)audioSource).gameObject.AddComponent<AudioLowPassFilter>()).enabled = false;
			}
			if (hadHighPass)
			{
				origHighPass = ((Component)audioSource).GetComponent<AudioHighPassFilter>().cutoffFrequency;
				origHighPassResQ = ((Component)audioSource).GetComponent<AudioHighPassFilter>().highpassResonanceQ;
			}
			else
			{
				((Behaviour)((Component)audioSource).gameObject.AddComponent<AudioHighPassFilter>()).enabled = false;
			}
		}

		public void Update()
		{
			if (!((Object)(object)AudioSourceManager.Instance != (Object)null) || !((Object)(object)audioSource != (Object)null) || (voice && (Object)(object)player == (Object)null))
			{
				return;
			}
			if ((Object)(object)recordPos != (Object)null && (Object)(object)playPos != (Object)null && (Object)(object)listenerPos != (Object)null)
			{
				if (!modified)
				{
					InitPhone();
				}
				ApplyPhoneVolume();
				ApplyPhoneEffect();
				ApplyPhoneLocation();
			}
			else if (modified)
			{
				Reset();
			}
		}

		public void InitPhone()
		{
			modified = true;
			if (staticAudio && !audioSource.isPlaying)
			{
				audioSource.Play();
			}
			audioSource.spatialBlend = 0f;
			if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
			{
				((Behaviour)((Component)audioSource).GetComponent<AudioLowPassFilter>()).enabled = true;
			}
			if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<OccludeAudio>()))
			{
				((Behaviour)((Component)audioSource).GetComponent<OccludeAudio>()).enabled = false;
			}
			if (!staticAudio && Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioHighPassFilter>()))
			{
				((Behaviour)((Component)audioSource).GetComponent<AudioHighPassFilter>()).enabled = true;
			}
		}

		public void ApplyPhoneVolume()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			float audioVolumeAtPos = GetAudioVolumeAtPos(recordPos.position);
			audioSource.volume = origVolume * audioVolumeAtPos;
			if (!staticAudio)
			{
				AudioSource obj = audioSource;
				obj.volume *= (voice ? Config.voiceSoundAdjust.Value : Config.backgroundSoundAdjust.Value);
				float num = 1f - recordInterference;
				num *= num;
				AudioSource obj2 = audioSource;
				obj2.volume *= num;
			}
		}

		public void ApplyPhoneEffect()
		{
			if (staticAudio)
			{
				if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
				{
					((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency = 3000f;
					((Component)audioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 3f;
				}
				return;
			}
			if (voice)
			{
				player.currentVoiceChatIngameSettings.set2D = true;
			}
			if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
			{
				((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency = 3000f;
				((Component)audioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = Mathf.Lerp(3f, 10f, recordInterference);
			}
			if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioHighPassFilter>()))
			{
				((Component)audioSource).GetComponent<AudioHighPassFilter>().cutoffFrequency = Mathf.Lerp(2000f, 2500f, recordInterference);
				((Component)audioSource).GetComponent<AudioHighPassFilter>().highpassResonanceQ = Mathf.Lerp(2f, 3f, recordInterference);
			}
			if (voice && player.voiceMuffledByEnemy && Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
			{
				((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency = 500f;
			}
		}

		public void ApplyPhoneLocation()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = playPos.position - listenerPos.position;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			float panStereo = Vector3.Dot(((Vector3)(ref val)).normalized, listenerPos.right);
			float value = Config.listeningDist.Value;
			value *= value;
			float num = Mathf.Clamp01(AudioSourceManager.Instance.recorderCurve.Evaluate(Mathf.Clamp01(recordDist / Config.recordingDist.Value)));
			AudioSource obj = audioSource;
			obj.volume *= num;
			if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
			{
				((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency = Mathf.Lerp(1500f, 3000f, num);
			}
			if (sqrMagnitude > 0f)
			{
				float num2 = Mathf.Clamp01(AudioSourceManager.Instance.listenerCurve.Evaluate(Mathf.Clamp01(sqrMagnitude / value)));
				AudioSource obj2 = audioSource;
				obj2.volume *= num2;
				if (Object.op_Implicit((Object)(object)((Component)audioSource).GetComponent<AudioLowPassFilter>()))
				{
					((Component)audioSource).GetComponent<AudioLowPassFilter>().cutoffFrequency = Mathf.Lerp(1000f, 750f, Mathf.Clamp01(sqrMagnitude / value));
				}
				audioSource.panStereo = panStereo;
			}
		}

		public float GetAudioVolumeAtPos(Vector3 recordPos)
		{
			//IL_0038: 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)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Invalid comparison between Unknown and I4
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Invalid comparison between Unknown and I4
			float result = 0f;
			if (!staticAudio && recordInterference == 1f)
			{
				return 0f;
			}
			recordDist = (staticAudio ? 0f : Vector3.Distance(recordPos, sourcePos.position));
			if (staticAudio)
			{
				float num = 0.3f;
				if (recordInterference > num)
				{
					float num2 = Mathf.InverseLerp(1f - num, 0f, recordInterference - num);
					num2 = 1f - num2 * num2;
					result = num2 * Config.staticSoundAdjust.Value;
				}
			}
			else if ((int)audioSource.rolloffMode == 1)
			{
				result = Mathf.Clamp01(Mathf.InverseLerp(audioSource.maxDistance, audioSource.minDistance, recordDist));
			}
			else if ((int)audioSource.rolloffMode == 2)
			{
				AnimationCurve customCurve = audioSource.GetCustomCurve((AudioSourceCurveType)0);
				if (customCurve != null)
				{
					result = Mathf.Clamp01(customCurve.Evaluate(recordDist / audioSource.maxDistance));
				}
			}
			else
			{
				result = Mathf.Clamp01(audioSource.minDistance * (1f / (1f + (recordDist - 1f))));
			}
			return result;
		}

		public void Reset()
		{
			GameObject gameObject = ((Component)audioSource).gameObject;
			if (voice)
			{
				player.currentVoiceChatIngameSettings.set2D = false;
			}
			if (staticAudio && audioSource.isPlaying)
			{
				audioSource.Stop();
			}
			audioSource.panStereo = origPan;
			audioSource.spatialBlend = origSpatial;
			audioSource.volume = origVolume;
			audioSource.SetCustomCurve((AudioSourceCurveType)1, origSpatialCurve);
			if (hadOcclude && Object.op_Implicit((Object)(object)gameObject.GetComponent<OccludeAudio>()))
			{
				((Behaviour)gameObject.GetComponent<OccludeAudio>()).enabled = true;
				if (voice)
				{
					gameObject.GetComponent<OccludeAudio>().overridingLowPass = player.voiceMuffledByEnemy;
				}
			}
			if (Object.op_Implicit((Object)(object)gameObject.GetComponent<AudioLowPassFilter>()))
			{
				if (hadLowPass)
				{
					gameObject.GetComponent<AudioLowPassFilter>().cutoffFrequency = origLowPass;
					gameObject.GetComponent<AudioLowPassFilter>().lowpassResonanceQ = origLowPassResQ;
				}
				else
				{
					((Behaviour)gameObject.GetComponent<AudioLowPassFilter>()).enabled = false;
				}
			}
			if (Object.op_Implicit((Object)(object)gameObject.GetComponent<AudioHighPassFilter>()))
			{
				if (hadHighPass)
				{
					gameObject.GetComponent<AudioHighPassFilter>().cutoffFrequency = origHighPass;
					gameObject.GetComponent<AudioHighPassFilter>().highpassResonanceQ = origHighPassResQ;
				}
				else
				{
					((Behaviour)gameObject.GetComponent<AudioHighPassFilter>()).enabled = false;
				}
			}
			modified = false;
		}
	}
	[DefaultExecutionOrder(int.MaxValue)]
	public class AudioSourceHook : MonoBehaviour
	{
		private AudioSourceStorage storage;

		private AudioSource audioSource;

		private bool staticAudio = false;

		private bool voice = false;

		private PlayerControllerB player = null;

		public void Start()
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).GetComponent<AudioSource>();
			}
			if ((Object)(object)audioSource == (Object)null || (Object)(object)AudioSourceManager.Instance == (Object)null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			storage = AudioSourceManager.RegisterAudioSource(audioSource);
			storage.staticAudio = staticAudio;
			storage.voice = voice;
			storage.player = player;
		}

		public void SetAudioSource(AudioSource source)
		{
			audioSource = source;
			if (storage != null)
			{
				storage.audioSource = source;
			}
		}

		public void SetVoice(PlayerControllerB newPlayer)
		{
			voice = true;
			player = newPlayer;
			if (storage != null)
			{
				storage.voice = true;
				storage.player = newPlayer;
			}
		}

		public void SetStaticAudio()
		{
			staticAudio = true;
			if (storage != null)
			{
				storage.staticAudio = true;
			}
		}

		public void Update()
		{
			if ((Object)(object)AudioSourceManager.Instance == (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				storage.Update();
			}
		}

		public void OnDestroy()
		{
			if (storage != null)
			{
				storage.Reset();
				AudioSourceManager.DeregisterAudioSource(storage);
			}
		}
	}
	[HarmonyPatch]
	public class AudioSourceManager : MonoBehaviour
	{
		public AnimationCurve listenerCurve;

		public AnimationCurve recorderCurve;

		private List<AudioSourceStorage> trackedAudioSources = new List<AudioSourceStorage>();

		private List<PhoneBehavior> allPhones = new List<PhoneBehavior>();

		private PlayerControllerB localPlayer;

		private Transform listenerPos;

		private PhoneBehavior listenerPhone;

		private float listenDistSqr;

		private float recordDistSqr;

		public static AudioSourceManager Instance { get; private set; }

		public void Init()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0121: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			listenDistSqr = Config.listeningDist.Value * Config.listeningDist.Value;
			recordDistSqr = Config.recordingDist.Value * Config.recordingDist.Value;
			Keyframe[] array = (Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.5f, -4f, -4f, 0.3333f, 0.3333f),
				default(Keyframe),
				default(Keyframe)
			};
			((Keyframe)(ref array[0])).tangentMode = 34;
			((Keyframe)(ref array[0])).weightedMode = (WeightedMode)0;
			array[1] = new Keyframe(0.4f, 0.1f, -0.0889f, -0.0889f, 0.3333f, 0.3333f);
			((Keyframe)(ref array[1])).tangentMode = 136;
			((Keyframe)(ref array[1])).weightedMode = (WeightedMode)0;
			array[2] = new Keyframe(1f, 0f, 0f, 0f, 0.3333f, 0.3333f);
			((Keyframe)(ref array[2])).tangentMode = 0;
			((Keyframe)(ref array[2])).weightedMode = (WeightedMode)0;
			listenerCurve = new AnimationCurve(array);
			Keyframe[] array2 = (Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0.1f, 1f, -4f, -4f, 0.3333f, 0.3333f),
				default(Keyframe),
				default(Keyframe)
			};
			((Keyframe)(ref array2[0])).tangentMode = 34;
			((Keyframe)(ref array2[0])).weightedMode = (WeightedMode)0;
			array2[1] = new Keyframe(0.5f, 0.4f, -0.0889f, -0.0889f, 0.3333f, 0.3333f);
			((Keyframe)(ref array2[1])).tangentMode = 136;
			((Keyframe)(ref array2[1])).weightedMode = (WeightedMode)0;
			array2[2] = new Keyframe(1f, 0f, 0f, 0f, 0.3333f, 0.3333f);
			((Keyframe)(ref array2[2])).tangentMode = 0;
			((Keyframe)(ref array2[2])).weightedMode = (WeightedMode)0;
			recorderCurve = new AnimationCurve(array2);
		}

		public void Update()
		{
			if ((Object)(object)localPlayer == (Object)null)
			{
				localPlayer = GameNetworkManager.Instance.localPlayerController;
			}
			if ((Object)(object)localPlayer != (Object)null)
			{
				if (localPlayer.isPlayerDead && (Object)(object)localPlayer.spectatedPlayerScript != (Object)null)
				{
					listenerPos = localPlayer.spectatedPlayerScript.playerGlobalHead;
				}
				else
				{
					listenerPos = localPlayer.playerGlobalHead;
				}
				UpdateAudioSourceStorages();
			}
		}

		private void UpdateAudioSourceStorages()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			foreach (AudioSourceStorage trackedAudioSource in trackedAudioSources)
			{
				trackedAudioSource.recordPos = null;
				trackedAudioSource.playPos = null;
				trackedAudioSource.listenerPos = null;
				trackedAudioSource.recordInterference = 0f;
				PhoneBehavior phoneBehavior = ClosestActivePhone(trackedAudioSource);
				if (!((Object)(object)phoneBehavior != (Object)null))
				{
					continue;
				}
				PhoneBehavior callerPhone = phoneBehavior.GetCallerPhone();
				float audioVolumeAtPos = trackedAudioSource.GetAudioVolumeAtPos(listenerPos.position);
				if (audioVolumeAtPos < 0.1f)
				{
					trackedAudioSource.recordPos = callerPhone.recordPos;
					trackedAudioSource.playPos = phoneBehavior.playPos;
					trackedAudioSource.listenerPos = listenerPos;
					if (localPlayer.isPlayerDead && (Object)(object)localPlayer.spectatedPlayerScript != (Object)null)
					{
						trackedAudioSource.listenerPos = phoneBehavior.playPos;
					}
					float totalInterference = phoneBehavior.GetTotalInterference();
					float totalInterference2 = callerPhone.GetTotalInterference();
					float recordInterference = ((totalInterference < totalInterference2) ? totalInterference2 : totalInterference);
					trackedAudioSource.recordInterference = recordInterference;
				}
			}
		}

		private PhoneBehavior ClosestActivePhone(AudioSourceStorage storage)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if (storage == null)
			{
				return null;
			}
			PhoneBehavior result = null;
			float num = recordDistSqr;
			float num2 = storage.audioSource.maxDistance * storage.audioSource.maxDistance;
			if (num2 < num)
			{
				num = num2;
			}
			foreach (PhoneBehavior allPhone in allPhones)
			{
				if (!((Object)(object)allPhone != (Object)null) || !allPhone.IsActive())
				{
					continue;
				}
				PhoneBehavior callerPhone = allPhone.GetCallerPhone();
				if (!((Object)(object)callerPhone != (Object)null))
				{
					continue;
				}
				Vector3 val = allPhone.playPos.position - listenerPos.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				val = callerPhone.playPos.position - listenerPos.position;
				float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude <= listenDistSqr && sqrMagnitude2 > listenDistSqr)
				{
					val = callerPhone.recordPos.position - storage.sourcePos.position;
					float sqrMagnitude3 = ((Vector3)(ref val)).sqrMagnitude;
					val = listenerPos.position - storage.sourcePos.position;
					float sqrMagnitude4 = ((Vector3)(ref val)).sqrMagnitude;
					if (sqrMagnitude3 <= num && sqrMagnitude3 < sqrMagnitude4)
					{
						result = allPhone;
					}
				}
			}
			return result;
		}

		public static AudioSourceStorage RegisterAudioSource(AudioSource source)
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return null;
			}
			AudioSourceStorage audioSourceStorage = new AudioSourceStorage(source);
			if (source.spatialBlend != 0f)
			{
				Instance.trackedAudioSources.Add(audioSourceStorage);
			}
			return audioSourceStorage;
		}

		public static void DeregisterAudioSource(AudioSourceStorage source)
		{
			if (!((Object)(object)Instance == (Object)null) && source != null)
			{
				Instance.trackedAudioSources.Remove(source);
			}
		}

		public static void RegisterPhone(PhoneBehavior phone)
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return;
			}
			Instance.allPhones.Add(phone);
			if ((Object)(object)phone.GetStaticAudioSource() != (Object)null)
			{
				AudioSourceHook audioSourceHook = default(AudioSourceHook);
				if (((Component)phone.GetStaticAudioSource()).TryGetComponent<AudioSourceHook>(ref audioSourceHook))
				{
					audioSourceHook.SetStaticAudio();
					return;
				}
				audioSourceHook = ((Component)phone.GetStaticAudioSource()).gameObject.AddComponent<AudioSourceHook>();
				audioSourceHook.SetAudioSource(phone.GetStaticAudioSource());
				audioSourceHook.SetStaticAudio();
			}
		}

		public static void DeregisterPhone(PhoneBehavior phone)
		{
			if (!((Object)(object)Instance == (Object)null))
			{
				Instance.allPhones.Remove(phone);
			}
		}

		public static void CheckGameObject(GameObject @object)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			AudioSourceHook audioSourceHook = default(AudioSourceHook);
			if (@object.TryGetComponent<AudioSourceHook>(ref audioSourceHook))
			{
				return;
			}
			AudioSource val = default(AudioSource);
			@object.TryGetComponent<AudioSource>(ref val);
			if ((Object)(object)val != (Object)null)
			{
				AudioSourceHook audioSourceHook2 = @object.AddComponent<AudioSourceHook>();
				audioSourceHook2.SetAudioSource(val);
			}
			foreach (Transform item in @object.transform)
			{
				Transform val2 = item;
				CheckGameObject(((Component)val2).gameObject);
			}
		}

		public static void CheckAudioSourceSceneLoad(Scene scene, LoadSceneMode sceneMode)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			AudioSource[] array = Object.FindObjectsByType<AudioSource>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			AudioSourceHook audioSourceHook = default(AudioSourceHook);
			foreach (AudioSource val in array)
			{
				if (!(((Component)val).gameObject.scene != scene) && !((Component)val).TryGetComponent<AudioSourceHook>(ref audioSourceHook))
				{
					AudioSourceHook audioSourceHook2 = ((Component)val).gameObject.AddComponent<AudioSourceHook>();
					audioSourceHook2.SetAudioSource(val);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "RefreshPlayerVoicePlaybackObjects")]
		private static void PlayerVoiceRefresh(ref PlayerVoiceIngameSettings __instance)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			AudioSourceHook audioSourceHook = default(AudioSourceHook);
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val.currentVoiceChatAudioSource != (Object)null)
				{
					if (((Component)val.currentVoiceChatAudioSource).TryGetComponent<AudioSourceHook>(ref audioSourceHook))
					{
						audioSourceHook.SetVoice(val);
						continue;
					}
					audioSourceHook = ((Component)val.currentVoiceChatAudioSource).gameObject.AddComponent<AudioSourceHook>();
					audioSourceHook.SetAudioSource(val.currentVoiceChatAudioSource);
					audioSourceHook.SetVoice(val);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		public static void SpawnAudioSourceManager()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				GameObject val = new GameObject("PhoneAudioSourceManager");
				Object.DontDestroyOnLoad((Object)(object)val);
				AudioSourceManager audioSourceManager = val.AddComponent<AudioSourceManager>();
				audioSourceManager.Init();
				Instance = audioSourceManager;
			}
		}
	}
	public class ConnectionModifier : MonoBehaviour
	{
		public float range = 50f;

		public float interferenceMod = 0.5f;

		private RadarBoosterItem radarBooster;

		public void Start()
		{
			ConnectionQualityManager.RegisterConnectionModifier(this);
			radarBooster = ((Component)this).GetComponent<RadarBoosterItem>();
		}

		public void Update()
		{
			if (Object.op_Implicit((Object)(object)radarBooster))
			{
				if (radarBooster.radarEnabled)
				{
					interferenceMod = -1f;
				}
				else
				{
					interferenceMod = 0f;
				}
			}
		}

		public void OnDestroy()
		{
			ConnectionQualityManager.DeregisterConnectionModifier(this);
		}
	}
	[HarmonyPatch]
	public class ConnectionQualityManager : NetworkBehaviour
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__NewRoundStart;
		}

		[CompilerGenerated]
		private sealed class <ManageAtmosphericInterference>d__22 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ConnectionQualityManager <>4__this;

			private float <interference>5__1;

			private float <variance>5__2;

			private float <delay>5__3;

			private string <currWeather>5__4;

			private string[] <>s__5;

			private int <>s__6;

			private string <weather>5__7;

			private string[] <>s__8;

			private int <>s__9;

			private string <weather>5__10;

			private string[] <>s__11;

			private int <>s__12;

			private string <weather>5__13;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ManageAtmosphericInterference>d__22(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<currWeather>5__4 = null;
				<>s__5 = null;
				<weather>5__7 = null;
				<>s__8 = null;
				<weather>5__10 = null;
				<>s__11 = null;
				<weather>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fd: Expected O, but got Unknown
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_027d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				<interference>5__1 = 0f;
				if (WeatherRegistryCompat.Enabled)
				{
					if (WeatherTweaksCompat.Enabled)
					{
						<currWeather>5__4 = WeatherTweaksCompat.CurrentWeatherName().ToLower();
					}
					else
					{
						<currWeather>5__4 = WeatherRegistryCompat.CurrentWeatherName().ToLower();
					}
					<>s__5 = registryWorstWeathers;
					for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
					{
						<weather>5__7 = <>s__5[<>s__6];
						if (<currWeather>5__4.Contains(<weather>5__7))
						{
							<interference>5__1 = 0.5f;
						}
						<weather>5__7 = null;
					}
					<>s__5 = null;
					if (<interference>5__1 == 0f)
					{
						<>s__8 = registryWorseWeathers;
						for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++)
						{
							<weather>5__10 = <>s__8[<>s__9];
							if (<currWeather>5__4.Contains(<weather>5__10))
							{
								<interference>5__1 = 0.35f;
							}
							<weather>5__10 = null;
						}
						<>s__8 = null;
					}
					if (<interference>5__1 == 0f)
					{
						<>s__11 = registryBadWeathers;
						for (<>s__12 = 0; <>s__12 < <>s__11.Length; <>s__12++)
						{
							<weather>5__13 = <>s__11[<>s__12];
							if (<currWeather>5__4.Contains(<weather>5__13))
							{
								<interference>5__1 = 0.2f;
							}
							<weather>5__13 = null;
						}
						<>s__11 = null;
					}
					<currWeather>5__4 = null;
				}
				else if ((Object)(object)TimeOfDay.Instance != (Object)null)
				{
					if (badWeathers.Contains(TimeOfDay.Instance.currentLevelWeather))
					{
						<interference>5__1 = 0.2f;
					}
					if (worseWeathers.Contains(TimeOfDay.Instance.currentLevelWeather))
					{
						<interference>5__1 = 0.35f;
					}
					if (worstWeathers.Contains(TimeOfDay.Instance.currentLevelWeather))
					{
						<interference>5__1 = 0.5f;
					}
				}
				<variance>5__2 = Random.Range(0f, <interference>5__1) - <interference>5__1 / 2f;
				<>4__this.UpdateAtmosphericInterferenceClientRpc(<interference>5__1 + <variance>5__2);
				<delay>5__3 = Random.Range(1.5f, 6f);
				<>2__current = (object)new WaitForSeconds(<delay>5__3);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static float AtmosphericInterference = 0f;

		public const float STATIC_START_INTERFERENCE = 0.3f;

		private const float MAX_ENTRANCE_DIST = 40000f;

		private EntranceTeleport[] entranceArray = (EntranceTeleport[])(object)new EntranceTeleport[0];

		private List<ConnectionModifier> connectionModifiers = new List<ConnectionModifier>();

		private static LevelWeatherType[] badWeathers;

		private static LevelWeatherType[] worseWeathers;

		private static LevelWeatherType[] worstWeathers;

		private static string[] registryBadWeathers;

		private static string[] registryWorseWeathers;

		private static string[] registryWorstWeathers;

		private Coroutine atmosphericInterferenceCoroutine;

		public static ConnectionQualityManager Instance { get; private set; }

		public void Start()
		{
			//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_003c: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			SimpleEvent startNewRoundEvent = StartOfRound.Instance.StartNewRoundEvent;
			object obj = <>O.<0>__NewRoundStart;
			if (obj == null)
			{
				UnityAction val = NewRoundStart;
				<>O.<0>__NewRoundStart = val;
				obj = (object)val;
			}
			((UnityEvent)startNewRoundEvent).AddListener((UnityAction)obj);
			LungProp[] array = Resources.FindObjectsOfTypeAll<LungProp>();
			LungProp[] array2 = array;
			foreach (LungProp val2 in array2)
			{
				if ((Object)(object)((Component)val2).GetComponent<ConnectionModifier>() == (Object)null)
				{
					ConnectionModifier connectionModifier = ((Component)val2).gameObject.AddComponent<ConnectionModifier>();
					connectionModifier.interferenceMod = 0.5f;
					connectionModifier.range = Config.apparatusRange.Value;
				}
			}
			RadarBoosterItem[] array3 = Resources.FindObjectsOfTypeAll<RadarBoosterItem>();
			RadarBoosterItem[] array4 = array3;
			foreach (RadarBoosterItem val3 in array4)
			{
				if ((Object)(object)((Component)val3).GetComponent<ConnectionModifier>() == (Object)null)
				{
					ConnectionModifier connectionModifier2 = ((Component)val3).gameObject.AddComponent<ConnectionModifier>();
					connectionModifier2.interferenceMod = -1f;
					connectionModifier2.range = Config.radarBoosterRange.Value;
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				atmosphericInterferenceCoroutine = ((MonoBehaviour)this).StartCoroutine(ManageAtmosphericInterference());
			}
		}

		public override void OnNetworkDespawn()
		{
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && atmosphericInterferenceCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(atmosphericInterferenceCoroutine);
			}
		}

		public static void RegisterConnectionModifier(ConnectionModifier modifier)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				if (Instance.connectionModifiers == null)
				{
					Instance.connectionModifiers = new List<ConnectionModifier>();
				}
				Instance.connectionModifiers.Add(modifier);
			}
		}

		public static void DeregisterConnectionModifier(ConnectionModifier modifier)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				if (Instance.connectionModifiers == null)
				{
					Instance.connectionModifiers = new List<ConnectionModifier>();
				}
				Instance.connectionModifiers.Remove(modifier);
			}
		}

		public static float GetLocalInterference(PhoneBehavior phone)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			if ((Object)(object)Instance != (Object)null)
			{
				Vector3 val2;
				if (phone.PhoneInsideFactory() && Instance.entranceArray.Length != 0)
				{
					float num2 = 40000f;
					EntranceTeleport[] array = Instance.entranceArray;
					foreach (EntranceTeleport val in array)
					{
						if ((Object)(object)val != (Object)null && !val.isEntranceToBuilding)
						{
							val2 = ((Component)val).transform.position - phone.recordPos.position;
							float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
							if (sqrMagnitude < num2)
							{
								num2 = sqrMagnitude;
							}
						}
					}
					num += Mathf.Lerp(0f, 0.4f, Mathf.InverseLerp(0f, 40000f, num2));
				}
				float num3 = 0f;
				foreach (ConnectionModifier connectionModifier in Instance.connectionModifiers)
				{
					float num4 = connectionModifier.range * connectionModifier.range;
					val2 = ((Component)connectionModifier).transform.position - phone.recordPos.position;
					float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude2 <= num4)
					{
						num3 += connectionModifier.interferenceMod * (1f - sqrMagnitude2 / num4);
					}
				}
				num += num3;
			}
			return num;
		}

		[IteratorStateMachine(typeof(<ManageAtmosphericInterference>d__22))]
		public IEnumerator ManageAtmosphericInterference()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ManageAtmosphericInterference>d__22(0)
			{
				<>4__this = this
			};
		}

		[ClientRpc]
		public void UpdateAtmosphericInterferenceClientRpc(float interference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2016322979u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref interference, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2016322979u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					AtmosphericInterference = interference;
				}
			}
		}

		public static void NewRoundStart()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Instance.entranceArray = Object.FindObjectsByType<EntranceTeleport>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnConnectionQualityManager(ref StartOfRound __instance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance == (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(NetworkObjectManager.connectionManagerPrefab, Vector3.zero, Quaternion.identity);
				ConnectionQualityManager component = val.GetComponent<ConnectionQualityManager>();
				val.GetComponent<NetworkObject>().Spawn(false);
				Instance = component;
			}
		}

		static ConnectionQualityManager()
		{
			LevelWeatherType[] array = new LevelWeatherType[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			badWeathers = (LevelWeatherType[])(object)array;
			worseWeathers = (LevelWeatherType[])(object)new LevelWeatherType[1] { (LevelWeatherType)1 };
			worstWeathers = (LevelWeatherType[])(object)new LevelWeatherType[1] { (LevelWeatherType)2 };
			registryBadWeathers = new string[5] { "flooded", "foggy", "dust clouds", "heatwave", "eclipsed" };
			registryWorseWeathers = new string[3] { "rainy", "snowfall", "toxic smog" };
			registryWorstWeathers = new string[3] { "stormy", "blizzard", "solar flare" };
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ConnectionQualityManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2016322979u, new RpcReceiveHandler(__rpc_handler_2016322979));
		}

		private static void __rpc_handler_2016322979(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float interference = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref interference, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ConnectionQualityManager)(object)target).UpdateAtmosphericInterferenceClientRpc(interference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ConnectionQualityManager";
		}
	}
	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 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_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");
			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);

		public static List<PhoneBehavior> allPhoneBehaviors = new List<PhoneBehavior>();

		private Dictionary<short, ulong> phoneNumberDict;

		private Dictionary<short, PhoneBehavior> phoneObjectDict;

		public PlayerPhone localPhone;

		public SwitchboardPhone switchboard;

		public static UnityEvent phoneListUpdateEvent = new UnityEvent();

		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<short, ulong>();
			phoneObjectDict = new Dictionary<short, 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();
			UpdateAllPhonesListServerRpc();
		}

		public void RequestPhoneListUpdates()
		{
			UpdateAllPhonesListServerRpc();
		}

		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();
				UpdateAllPhonesList();
			}
		}

		public void UpdateAllPhonesList()
		{
			List<ulong> list = new List<ulong>();
			foreach (PhoneBehavior value in phoneObjectDict.Values)
			{
				list.Add(((NetworkBehaviour)value).NetworkObjectId);
			}
			UpdateAllPhonesListClientRpc(list.ToArray());
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateAllPhonesListServerRpc()
		{
			//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(2624363442u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2624363442u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					UpdateAllPhonesList();
				}
			}
		}

		[ClientRpc]
		public void UpdateAllPhonesListClientRpc(ulong[] phoneIds)
		{
			//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_00c7: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1230094269u, val, (RpcDelivery)0);
				bool flag = phoneIds != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(phoneIds, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1230094269u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (allPhoneBehaviors == null)
				{
					allPhoneBehaviors = new List<PhoneBehavior>();
				}
				allPhoneBehaviors.Clear();
				foreach (ulong num in phoneIds)
				{
					PhoneBehavior component = ((Component)((NetworkBehaviour)this).GetNetworkObject(num)).GetComponent<PhoneBehavior>();
					allPhoneBehaviors.Add(component);
				}
				phoneListUpdateEvent.Invoke();
			}
		}

		[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();
			}
		}

		[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;
				}
				short num = short.Parse(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(num, ((NetworkBehaviour)switchboard).NetworkObjectId);
				phoneObjectDict.Add(num, switchboard);
				switchboard.SetNewPhoneNumberClientRpc(num);
				RequestClientUpdates();
			}
		}

		[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;
			}
			short num = (short)Random.Range(0, value);
			string text = num.ToString("D4");
			while (phoneNumberDict.ContainsKey(num) || text == Config.switchboardNumber.Value)
			{
				num = (short)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(num, ((NetworkBehaviour)component).NetworkObjectId);
			phoneObjectDict.Add(num, component);
			component.phoneSkinId = skinId;
			component.phoneCharmId = charmId;
			component.phoneRingtoneId = ringtoneId;
			component.SetNewPhoneNumberClientRpc(num);
			RequestClientUpdates();
		}

		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>();
			short key = phoneNumberDict.FirstOrDefault((KeyValuePair<short, ulong> x) => x.Value == ((NetworkBehaviour)phone).NetworkObjectId).Key;
			if (!NetworkManager.Singleton.ShutdownInProgress)
			{
				((Component)phone).GetComponent<NetworkObject>().RemoveOwnership();
			}
			RemoveNumber(key);
		}

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

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

		public void RemoveNumber(short number)
		{
			if (number != -1)
			{
				Plugin.Log.LogInfo((object)("Removing number: " + number));
				phoneObjectDict.Remove(number);
				phoneNumberDict.Remove(number);
				UpdateAllPhonesList();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeOutgoingCallServerRpc(short 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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(3645932923u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, number);
				BytePacker.WriteValueBitPacked(val, senderId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3645932923u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong senderId2 = senderId;
			if (!Locked.Value)
			{
				short key = phoneNumberDict.FirstOrDefault((KeyValuePair<short, 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(short 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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(2826581995u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, number);
				BytePacker.WriteValueBitPacked(val, accepterId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2826581995u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ulong accepterId2 = accepterId;
				short key = phoneNumberDict.FirstOrDefault((KeyValuePair<short, ulong> x) => x.Value == accepterId2).Key;
				phoneObjectDict[number].CallAcceptedClientRpc(accepterId2, key);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void HangUpCallServerRpc(short 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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(3553008736u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, number);
				BytePacker.WriteValueBitPacked(val, cancellerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3553008736u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ulong cancellerId2 = cancellerId;
			if (phoneNumberDict.ContainsKey(number))
			{
				short key = phoneNumberDict.FirstOrDefault((KeyValuePair<short, ulong> x) => x.Value == cancellerId2).Key;
				phoneObjectDict[number].HangupCallClientRpc(cancellerId2, key);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TransferCallServerRpc(short number, short 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_007e: 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_00a3: 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(2279494917u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, number);
				BytePacker.WriteValueBitPacked(val, transferNumber);
				BytePacker.WriteValueBitPacked(val, transferrerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2279494917u, 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))
			{
				short key = phoneNumberDict.FirstOrDefault((KeyValuePair<short, ulong> x) => x.Value == transferrerId2).Key;
				phoneObjectDict[number].TransferCallClientRpc(transferrerId2, key, transferNumber);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void LineBusyServerRpc(short 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1774882772u, serverRpcParams, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, number);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1774882772u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					phoneObjectDict[number].InvalidCallClientRpc("Line Busy");
				}
			}
		}

		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
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2624363442u, new RpcReceiveHandler(__rpc_handler_2624363442));
			NetworkManager.__rpc_func_table.Add(1230094269u, new RpcReceiveHandler(__rpc_handler_1230094269));
			NetworkManager.__rpc_func_table.Add(3044635500u, new RpcReceiveHandler(__rpc_handler_3044635500));
			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(3645932923u, new RpcReceiveHandler(__rpc_handler_3645932923));
			NetworkManager.__rpc_func_table.Add(2826581995u, new RpcReceiveHandler(__rpc_handler_2826581995));
			NetworkManager.__rpc_func_table.Add(3553008736u, new RpcReceiveHandler(__rpc_handler_3553008736));
			NetworkManager.__rpc_func_table.Add(2279494917u, new RpcReceiveHandler(__rpc_handler_2279494917));
			NetworkManager.__rpc_func_table.Add(1774882772u, new RpcReceiveHandler(__rpc_handler_1774882772));
		}

		private static void __rpc_handler_2624363442(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).UpdateAllPhonesListServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1230094269(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_006e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ulong[] phoneIds = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref phoneIds, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PhoneNetworkHandler)(object)target).UpdateAllPhonesListClientRpc(phoneIds);
				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;
			}
		}

		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_3645932923(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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			/