Decompiled source of FrequencyWalkie v1.3.2

FrequencyWalkie/FrequencyWalkie.dll

Decompiled 11 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FrequencyWalkie")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FrequencyWalkie")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("35C861E5-B445-4C78-8068-886EDD23D8E3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FrequencyWalkie;

public static class Assets
{
	private static Dictionary<string, Object> _assets = new Dictionary<string, Object>();

	public static T GetResource<T>(string objName) where T : Object
	{
		if (_assets.TryGetValue(objName, out var value))
		{
			return (T)(object)value;
		}
		T[] array = Resources.FindObjectsOfTypeAll<T>();
		foreach (T val in array)
		{
			if (((Object)val).name == objName)
			{
				_assets.Add(objName, (Object)(object)val);
				return val;
			}
		}
		return default(T);
	}
}
internal enum RpcExecStage
{
	None,
	Server,
	Client
}
[BepInPlugin("larko.frequencywalkie", "FrequencyWalkie", "1.3.1")]
public class FrequencyWalkie : BaseUnityPlugin
{
	public static Dictionary<int, int> walkieTalkieFrequencies = new Dictionary<int, int>();

	public static List<string> frequencies = new List<string>
	{
		"BR.d", "18.3", "19.5", "21.7", "23.3", "25.0", "27.9", "29.3", "31.3", "33.6",
		"35.4", "36.8", "37.7", "38.6", "39.4", "40.2", "42.3", "43.8", "44.5", "45.1",
		"46.9", "47.2", "47.8", "48.1", "48.5"
	};

	public static string tooltip = "[R] Increase frequency\n[F] Decrease frequency";

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		Patches.ApplyPatches(new Harmony("larko.frequencywalkie"));
	}

	public static T GetResource<T>(string objName) where T : Object
	{
		T[] array = Resources.FindObjectsOfTypeAll<T>();
		foreach (T val in array)
		{
			if (((Object)val).name == objName)
			{
				return val;
			}
		}
		return default(T);
	}

	public static IEnumerator OnFrequencyChanged(WalkieTalkie walkie, bool increased)
	{
		Canvas canvas = ((Component)walkie).gameObject.GetComponent<Canvas>();
		((Component)canvas).GetComponentInChildren<Text>().text = "<b><size=40>" + frequencies[walkieTalkieFrequencies[((Object)walkie).GetInstanceID()]] + "</size><i><size=30>MHz</size></i></b>";
		AccessTools.Method(typeof(WalkieTalkie), "SendWalkieTalkieStartTransmissionSFX", (Type[])null, (Type[])null).Invoke(walkie, new object[1] { (int)((GrabbableObject)walkie).playerHeldBy.playerClientId });
		if (walkieTalkieFrequencies[((Object)walkie).GetInstanceID()] == 0)
		{
			((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 4)).gameObject.SetActive(true);
		}
		else
		{
			((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 4)).gameObject.SetActive(false);
		}
		if (increased)
		{
			((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 2)).gameObject.SetActive(false);
		}
		else
		{
			((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 1)).gameObject.SetActive(false);
		}
		yield return (object)new WaitForSeconds(0.5f);
		((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 1)).gameObject.SetActive(true);
		((Component)((Component)canvas).transform.GetChild(((Component)canvas).transform.childCount - 2)).gameObject.SetActive(true);
	}

	public static void SetPlayerSpeakingOnWalkieTalkieServerRpc(WalkieTalkie instance, int playerId, int frequency)
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)instance).NetworkManager;
		if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
		{
			return;
		}
		int num = (int)AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").GetValue(instance);
		MethodInfo methodInfo = AccessTools.Method(typeof(WalkieTalkie), "__beginSendServerRpc", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(WalkieTalkie), "__endSendServerRpc", (Type[])null, (Type[])null);
		if (num != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)instance).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = (FastBufferWriter)methodInfo.Invoke(instance, new object[3]
			{
				64994802u,
				val,
				(object)(RpcDelivery)0
			});
			BytePacker.WriteValueBitPacked(val2, playerId);
			BytePacker.WriteValueBitPacked(val2, frequency);
			methodInfo2.Invoke(instance, new object[4]
			{
				val2,
				64994802u,
				val,
				(object)(RpcDelivery)0
			});
		}
		if (num == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SetPlayerSpeakingOnWalkieTalkieClientRpc(instance, playerId, frequency);
		}
	}

	public static void SetPlayerSpeakingOnWalkieTalkieClientRpc(WalkieTalkie instance, int playerId, int frequency)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)instance).NetworkManager;
		if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
		{
			return;
		}
		int num = (int)AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").GetValue(instance);
		MethodInfo methodInfo = AccessTools.Method(typeof(WalkieTalkie), "__beginSendClientRpc", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(WalkieTalkie), "__endSendClientRpc", (Type[])null, (Type[])null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(WalkieTalkie), "SendWalkieTalkieStartTransmissionSFX", (Type[])null, (Type[])null);
		if (num != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = (FastBufferWriter)methodInfo.Invoke(instance, new object[3]
			{
				2961867446u,
				val,
				(object)(RpcDelivery)0
			});
			BytePacker.WriteValueBitPacked(val2, playerId);
			BytePacker.WriteValueBitPacked(val2, frequency);
			methodInfo2.Invoke(instance, new object[4]
			{
				val2,
				2961867446u,
				val,
				(object)(RpcDelivery)0
			});
		}
		if (num != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++)
		{
			if ((int)((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).playerHeldBy.playerClientId == playerId)
			{
				walkieTalkieFrequencies[((Object)WalkieTalkie.allWalkieTalkies[i]).GetInstanceID()] = frequency;
				((MonoBehaviour)instance).StartCoroutine(OnFrequencyChanged(WalkieTalkie.allWalkieTalkies[i], increased: false));
				break;
			}
		}
		if (walkieTalkieFrequencies[((Object)instance).GetInstanceID()] == frequency || frequency == 0)
		{
			StartOfRound.Instance.allPlayerScripts[playerId].speakingToWalkieTalkie = true;
			instance.clientIsHoldingAndSpeakingIntoThis = true;
			methodInfo3.Invoke(instance, new object[1] { playerId });
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
		}
	}
}
public static class Patches
{
	public static void ApplyPatches(Harmony harmony)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Expected O, but got Unknown
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Expected O, but got Unknown
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Expected O, but got Unknown
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Expected O, but got Unknown
		MethodInfo methodInfo = AccessTools.Method(typeof(WalkieTalkie), "SetLocalClientSpeaking", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), "WalkieTalkie_SetLocalClientSpeaking", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(WalkieTalkie), "__rpc_handler_64994802", (Type[])null, (Type[])null);
		MethodInfo methodInfo4 = AccessTools.Method(typeof(Patches), "WalkieTalkie_HandlePlayerSpeakingServerRPC", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo5 = AccessTools.Method(typeof(WalkieTalkie), "__rpc_handler_2961867446", (Type[])null, (Type[])null);
		MethodInfo methodInfo6 = AccessTools.Method(typeof(Patches), "WalkieTalkie_HandlePlayerSpeakingClientRPC", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo7 = AccessTools.Method(typeof(WalkieTalkie), "Update", (Type[])null, (Type[])null);
		MethodInfo methodInfo8 = AccessTools.Method(typeof(Patches), "WalkieTalkie_Update", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo9 = AccessTools.Method(typeof(WalkieTalkie), "Start", (Type[])null, (Type[])null);
		MethodInfo methodInfo10 = AccessTools.Method(typeof(Patches), "WalkieTalkie_Start", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo9, (HarmonyMethod)null, new HarmonyMethod(methodInfo10), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo11 = AccessTools.Method(typeof(WalkieTalkie), "SwitchWalkieTalkieOn", (Type[])null, (Type[])null);
		MethodInfo methodInfo12 = AccessTools.Method(typeof(Patches), "WalkieTalkie_SwitchWalkieTalkieOn", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo11, (HarmonyMethod)null, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo13 = AccessTools.Method(typeof(WalkieTalkie), "EquipItem", (Type[])null, (Type[])null);
		MethodInfo methodInfo14 = AccessTools.Method(typeof(Patches), "WalkieTalkie_EquipItem", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo13, (HarmonyMethod)null, new HarmonyMethod(methodInfo14), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo15 = AccessTools.Method(typeof(WalkieTalkie), "PocketItem", (Type[])null, (Type[])null);
		MethodInfo methodInfo16 = AccessTools.Method(typeof(Patches), "WalkieTalkie_PocketItem", (Type[])null, (Type[])null);
		harmony.Patch((MethodBase)methodInfo15, (HarmonyMethod)null, new HarmonyMethod(methodInfo16), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static void WalkieTalkie_EquipItem(WalkieTalkie __instance)
	{
		if (((GrabbableObject)__instance).isBeingUsed)
		{
			((Behaviour)((Component)__instance).gameObject.GetComponent<Canvas>()).enabled = true;
		}
	}

	private static void WalkieTalkie_PocketItem(WalkieTalkie __instance)
	{
		((Behaviour)((Component)__instance).gameObject.GetComponent<Canvas>()).enabled = false;
	}

	private static void WalkieTalkie_Start(WalkieTalkie __instance)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: 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_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		FrequencyWalkie.walkieTalkieFrequencies.Add(((Object)__instance).GetInstanceID(), 0);
		((GrabbableObject)__instance).itemProperties.toolTips = CollectionExtensions.AddToArray<string>(((GrabbableObject)__instance).itemProperties.toolTips, FrequencyWalkie.tooltip);
		RenderTexture val = new RenderTexture(__instance.onMaterial.mainTexture.width, __instance.onMaterial.mainTexture.width, 32);
		Graphics.Blit(__instance.onMaterial.mainTexture, val);
		RenderTexture.active = val;
		Texture2D val2 = new Texture2D(__instance.onMaterial.mainTexture.width, __instance.onMaterial.mainTexture.height);
		val2.ReadPixels(new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), 0, 0);
		Color[] array = (Color[])(object)new Color[((Texture)val2).width * ((Texture)val2).height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = new Color(122f, 150f, 121f);
		}
		val2.SetPixels(420, 64, 135, 76, array);
		val2.Apply();
		RenderTexture.active = null;
		__instance.onMaterial.mainTexture = (Texture)(object)val2;
		Canvas val3 = ((Component)__instance).gameObject.AddComponent<Canvas>();
		val3.renderMode = (RenderMode)2;
		val3.worldCamera = Camera.main;
		((Component)val3).GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 40f);
		GameObject val4 = new GameObject("Text");
		val4.transform.parent = ((Component)val3).transform;
		val4.transform.localPosition = new Vector3(2.7f, -0.9f, -0.23f);
		val4.transform.localRotation = Quaternion.Euler(-90f, -90f, 0f);
		GameObject val5 = new GameObject("Circle");
		val5.transform.parent = ((Component)val3).transform;
		val5.transform.localPosition = new Vector3(3.25f, -0.9f, -0.45f);
		val5.transform.localRotation = Quaternion.Euler(-90f, -90f, 0f);
		val5.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
		Image obj = val5.AddComponent<Image>();
		obj.sprite = Assets.GetResource<Sprite>("scanCircle2");
		((Graphic)obj).color = Color.black;
		GameObject val6 = new GameObject("Speaking");
		val6.transform.parent = ((Component)val3).transform;
		val6.transform.localPosition = new Vector3(3.25f, -0.9f, 0.2f);
		val6.transform.localRotation = Quaternion.Euler(-90f, -90f, 0f);
		Image obj2 = val6.AddComponent<Image>();
		obj2.sprite = Assets.GetResource<Sprite>("SpeakingSymbol");
		((Graphic)obj2).color = Color.black;
		val6.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
		GameObject val7 = new GameObject("ArrowUp");
		val7.transform.parent = ((Component)val3).transform;
		val7.transform.localPosition = new Vector3(3.25f, -0.9f, -0.2f);
		val7.transform.localRotation = Quaternion.Euler(-90f, -90f, 0f);
		val7.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
		Image val8 = val7.AddComponent<Image>();
		val8.sprite = Assets.GetResource<Sprite>("arrow2");
		((Graphic)val8).color = Color.black;
		GameObject val9 = new GameObject("ArrowDown");
		val9.transform.parent = ((Component)val3).transform;
		val9.transform.localPosition = new Vector3(3.25f, -0.9f, -0.1f);
		val9.transform.localRotation = Quaternion.Euler(-90f, -90f, 0f);
		val9.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
		Image obj3 = val9.AddComponent<Image>();
		obj3.sprite = Assets.GetResource<Sprite>("arrow2");
		((Component)val8).transform.Rotate(0f, 0f, 180f);
		((Graphic)obj3).color = Color.black;
		Text obj4 = val4.AddComponent<Text>();
		obj4.text = "<b><size=40>" + FrequencyWalkie.frequencies[FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()]] + "</size><i><size=30>MHz</size></i></b>";
		obj4.font = Assets.GetResource<Font>("3270-Regular");
		((Graphic)obj4).color = Color.black;
		obj4.fontSize = 40;
		obj4.lineSpacing = 0.5f;
		val4.transform.localScale = new Vector3(0.015f, 0.01f, 0.01f);
		((Behaviour)val3).enabled = false;
		Light walkieTalkieLight = __instance.walkieTalkieLight;
		walkieTalkieLight.intensity /= 3f;
	}

	private static void WalkieTalkie_SwitchWalkieTalkieOn(WalkieTalkie __instance)
	{
		((Behaviour)((Component)__instance).gameObject.GetComponent<Canvas>()).enabled = ((GrabbableObject)__instance).isBeingUsed;
		if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && ((GrabbableObject)__instance).isBeingUsed)
		{
			HUDManager.Instance.DisplayTip("FrequencyWalkie", "Press [R] or [F] to cycle between frequencies. BR.d will broadcast to all walkie talkies.", false, true, "FW_UseTip");
		}
	}

	private static void WalkieTalkie_Update(WalkieTalkie __instance)
	{
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		bool flag = (Object)(object)localPlayerController.ItemSlots[localPlayerController.currentItemSlot] == (Object)(object)__instance;
		if (localPlayerController.isGrabbingObjectAnimation || localPlayerController.isTypingChat || localPlayerController.inTerminalMenu || localPlayerController.inSpecialInteractAnimation || !((GrabbableObject)__instance).isBeingUsed || !flag)
		{
			return;
		}
		if (UnityInput.Current.GetKeyUp((KeyCode)102))
		{
			FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()]--;
			if (FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()] < 0)
			{
				FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()] = FrequencyWalkie.frequencies.Count - 1;
			}
			((MonoBehaviour)__instance).StartCoroutine(FrequencyWalkie.OnFrequencyChanged(__instance, increased: false));
		}
		else if (UnityInput.Current.GetKeyUp((KeyCode)114))
		{
			FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()] = (FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()] + 1) % FrequencyWalkie.frequencies.Count;
			((MonoBehaviour)__instance).StartCoroutine(FrequencyWalkie.OnFrequencyChanged(__instance, increased: true));
		}
	}

	private static bool WalkieTalkie_SetLocalClientSpeaking(WalkieTalkie __instance, PlayerControllerB ___previousPlayerHeldBy, bool speaking)
	{
		if (___previousPlayerHeldBy.speakingToWalkieTalkie != speaking)
		{
			___previousPlayerHeldBy.speakingToWalkieTalkie = speaking;
			if (speaking)
			{
				FrequencyWalkie.SetPlayerSpeakingOnWalkieTalkieServerRpc(__instance, (int)___previousPlayerHeldBy.playerClientId, FrequencyWalkie.walkieTalkieFrequencies[((Object)__instance).GetInstanceID()]);
				return false;
			}
			__instance.UnsetPlayerSpeakingOnWalkieTalkieServerRpc((int)___previousPlayerHeldBy.playerClientId);
		}
		return false;
	}

	private static bool WalkieTalkie_HandlePlayerSpeakingServerRPC(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
		{
			return false;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel > 1)
			{
				return false;
			}
			Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
		}
		else
		{
			int playerId = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
			int frequency = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref frequency);
			AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").SetValue(target, 1);
			FrequencyWalkie.SetPlayerSpeakingOnWalkieTalkieServerRpc((WalkieTalkie)target, playerId, frequency);
			AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").SetValue(target, 0);
		}
		return false;
	}

	private static bool WalkieTalkie_HandlePlayerSpeakingClientRPC(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		NetworkManager networkManager = target.NetworkManager;
		if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
		{
			return false;
		}
		int playerId = default(int);
		ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
		int frequency = default(int);
		ByteUnpacker.ReadValueBitPacked(reader, ref frequency);
		AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").SetValue(target, 2);
		FrequencyWalkie.SetPlayerSpeakingOnWalkieTalkieClientRpc((WalkieTalkie)target, playerId, frequency);
		AccessTools.Field(typeof(WalkieTalkie), "__rpc_exec_stage").SetValue(target, 0);
		return false;
	}
}