Decompiled source of WalkieTalkieItemBundle v1.1.3

Radio.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using KeybindLib.Classes;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[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: AssemblyCompany("Lnx0id")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+5612d01251f4122f31dc8ef1803032cc9a5a5c07")]
[assembly: AssemblyProduct("Radio")]
[assembly: AssemblyTitle("Radio")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Radio
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Lnx0id.Radio", "Radio", "1.1.3")]
	public class Radio : BaseUnityPlugin
	{
		internal static Radio Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? _Harmony { get; set; }

		internal WalkieTalkieLn? scriptInstance { get; private set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			BindConfig.switchWalkieChannel = Keybinds.Bind("SwitchChannel", "<Keyboard>/v");
			scriptInstance = ((Component)this).gameObject.AddComponent<WalkieTalkieLn>();
			Patch();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "WalkieTalkieItemBundle");
			BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				ItemContent val = assetBundle.LoadAsset<ItemContent>("WalkieTalkieItemRepoLibItem");
				Items.RegisterItem(val);
			}, false);
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (_Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				_Harmony = val;
			}
			_Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = _Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class BindConfig
	{
		public static Keybind switchWalkieChannel;
	}
	public class WalkieTalkieLn : MonoBehaviour
	{
		private static int firstChannel;

		private static Dictionary<int, GameObject> _allRadios = new Dictionary<int, GameObject>();

		[SerializeField]
		private Sound? messageIncomeSound;

		[SerializeField]
		private Sound? changeOrEndChannelSound;

		[SerializeField]
		private Sound? noiseLoopSound;

		private bool findWalkieTalkieOutOfListComplete = false;

		private PhysGrabObject? physGrabObject;

		public Light? lightMain;

		private TextMeshProUGUI? warningTextMeshGUI;

		private GameObject? destintionGameObject;

		private bool autoSetupDone = false;

		[SerializeField]
		private TextMeshPro? textSource;

		[SerializeField]
		private TextMeshPro? textDestination;

		[SerializeField]
		private TextMeshPro? textBroadcastFromSource;

		private WalkieTalkieLn? destinationGameObjectScript;

		public ItemEquippable? itemEquipableScript;

		public bool isReceiving = false;

		public int fromChannelReceiving = 1;

		private PhotonView? photonView;

		private bool isEquipedLately = true;

		private int latestChannelDestination = 1;

		private bool isCurrentlyBroadcastingTo;

		private GameObject? latestOwnersWalkieGameObject;

		private PlayerAvatar? latestOwnerAvatar;

		private bool isReceivedLately;

		private Vector3 globalPositionInInventory = new Vector3(0f, 3000f, 0f);

		public bool isThisEquiped { get; private set; } = false;


		public int currentChannelSource { get; private set; } = 1;


		public int toChannelDestination { get; private set; } = 1;


		private void Awake()
		{
			RegisterWalkeiTalkieInstance();
			if (!((Object)((Component)this).gameObject).name.Equals("0InstanceWalkie"))
			{
				DisplayChannel();
				physGrabObject = ((Component)this).gameObject.GetComponent<PhysGrabObject>();
				lightMain = ((Component)((Component)this).gameObject.transform.GetChild(0)).gameObject.GetComponent<Light>();
				itemEquipableScript = ((Component)this).gameObject.GetComponent<ItemEquippable>();
			}
		}

		private void FixedUpdate()
		{
			//IL_0091: 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)
			//IL_00a7: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)physGrabObject == (Object)null)
			{
				return;
			}
			List<PhysGrabber> playerGrabbing = physGrabObject.playerGrabbing;
			bool flag = false;
			foreach (PhysGrabber item in playerGrabbing)
			{
				if (item.isRotating)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				Quaternion val = Quaternion.Euler(0f, -180f, 0f);
				Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
				Quaternion identity = Quaternion.identity;
				physGrabObject.TurnXYZ(val, val2, identity);
				physGrabObject.OverrideTorqueStrength(2f + physGrabObject.massOriginal, 0.1f);
			}
		}

		private void Update()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Invalid comparison between Unknown and I4
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Invalid comparison between Unknown and I4
			if (((Object)((Component)this).gameObject).name.Equals("0InstanceWalkie") || (Object)(object)physGrabObject == (Object)null || (Object)(object)lightMain == (Object)null || (Object)(object)itemEquipableScript == (Object)null)
			{
				return;
			}
			isThisEquiped = (int)itemEquipableScript.currentState == 2 || (int)itemEquipableScript.currentState == 1;
			UpdateEquiping();
			if (physGrabObject.grabbed)
			{
				AutoSetup();
				if (SemiFunc.InputDown(BindConfig.switchWalkieChannel.inputKey))
				{
					photonView.RPC("SwitchChannel", (RpcTarget)0, Array.Empty<object>());
					photonView.RPC("PlayOutSound", (RpcTarget)0, Array.Empty<object>());
				}
				BroadCast();
			}
			else if ((Object)(object)destinationGameObjectScript != (Object)null && destinationGameObjectScript.fromChannelReceiving == currentChannelSource && (Object)(object)destinationGameObjectScript.warningTextMeshGUI != (Object)null && !string.IsNullOrEmpty(((TMP_Text)destinationGameObjectScript.warningTextMeshGUI).text) && destinationGameObjectScript.isReceiving)
			{
				destinationGameObjectScript.isReceiving = false;
				destinationGameObjectScript.photonView.RPC("SetIsReceiving", (RpcTarget)1, new object[1] { false });
				destinationGameObjectScript.photonView.RPC("HudDeactivate", (RpcTarget)0, Array.Empty<object>());
			}
			if ((Object)(object)itemEquipableScript != (Object)null && (int)itemEquipableScript.currentState == 2 && (Object)(object)destinationGameObjectScript != (Object)null && destinationGameObjectScript.fromChannelReceiving == currentChannelSource && destinationGameObjectScript.isReceiving)
			{
				destinationGameObjectScript.lightMain.intensity = 0f;
				destinationGameObjectScript.isReceiving = false;
				destinationGameObjectScript.photonView.RPC("SetIsReceiving", (RpcTarget)1, new object[1] { false });
				destinationGameObjectScript.photonView.RPC("PlayOutSound", (RpcTarget)0, Array.Empty<object>());
				destinationGameObjectScript.photonView.RPC("HudDeactivate", (RpcTarget)0, Array.Empty<object>());
			}
			if (fromChannelReceiving == 0)
			{
				isReceiving = false;
				photonView.RPC("SetIsReceiving", (RpcTarget)1, new object[1] { false });
			}
			if (isReceiving == isReceivedLately)
			{
				return;
			}
			photonView.RPC("PlayLoopBackgroundSound", (RpcTarget)0, new object[1] { isReceiving });
			isReceivedLately = isReceiving;
			if (isReceiving)
			{
				if ((int)itemEquipableScript.currentState == 2 && !((Object)(object)latestOwnerAvatar == (Object)null) && latestOwnerAvatar.playerName.Equals(PlayerAvatar.instance.playerName))
				{
					if ((Object)(object)warningTextMeshGUI == (Object)null)
					{
						HudGenerate();
					}
					else if (!((UIBehaviour)warningTextMeshGUI).IsActive())
					{
						HudActivate();
					}
				}
			}
			else if ((Object)(object)warningTextMeshGUI != (Object)null && !string.IsNullOrEmpty(((TMP_Text)warningTextMeshGUI).text))
			{
				HudDeactivate();
			}
		}

		private void AutoSetup()
		{
			if (!autoSetupDone)
			{
				if (firstChannel != currentChannelSource)
				{
					photonView.RPC("SetChannel", (RpcTarget)0, new object[1] { firstChannel });
				}
				else
				{
					photonView.RPC("SwitchChannel", (RpcTarget)0, Array.Empty<object>());
				}
				DisplayChannel();
				autoSetupDone = true;
			}
		}

		private void UpdateEquiping()
		{
			if (isEquipedLately == isThisEquiped)
			{
				return;
			}
			if (isThisEquiped)
			{
				if (fromChannelReceiving < 1)
				{
					return;
				}
				latestOwnerAvatar = getOwnerAvatar(fromChannelReceiving);
			}
			else
			{
				latestOwnerAvatar = null;
			}
			isEquipedLately = isThisEquiped;
		}

		private PlayerAvatar? getOwnerAvatar(int channelId)
		{
			if (channelId == currentChannelSource)
			{
				return PlayerAvatar.instance;
			}
			if (!_allRadios.TryGetValue(channelId, out GameObject value))
			{
				return null;
			}
			if ((Object)(object)value.GetComponent<WalkieTalkieLn>() == (Object)null)
			{
				return null;
			}
			value.GetComponent<WalkieTalkieLn>().latestOwnersWalkieGameObject = ((Component)this).gameObject;
			PhotonView val = PhotonView.Find(itemEquipableScript.ownerPlayerId);
			if ((Object)(object)val != (Object)null)
			{
				latestOwnerAvatar = ((Component)val).gameObject.GetComponent<PlayerAvatar>();
				if ((Object)(object)latestOwnerAvatar == (Object)null)
				{
					return null;
				}
				return latestOwnerAvatar;
			}
			return null;
		}

		[PunRPC]
		private void HudActivate()
		{
			if ((Object)(object)warningTextMeshGUI == (Object)null)
			{
				HudGenerate();
			}
			((Component)warningTextMeshGUI).gameObject.SetActive(true);
			((TMP_Text)warningTextMeshGUI).SetText("INCOMING MESSAGE", true);
		}

		[PunRPC]
		private void HudDeactivate()
		{
			if (!((Object)(object)warningTextMeshGUI == (Object)null))
			{
				((Component)warningTextMeshGUI).gameObject.SetActive(false);
				((TMP_Text)warningTextMeshGUI).SetText("", true);
			}
		}

		[PunRPC]
		private void HudGenerate()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_004d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			GameObject val = new GameObject("RadioMessage", new Type[1] { typeof(RectTransform) });
			warningTextMeshGUI = val.AddComponent<TextMeshProUGUI>();
			TextMeshProUGUI component = ((Component)HealthUI.instance).GetComponent<TextMeshProUGUI>();
			RectTransform rectTransform = ((TMP_Text)warningTextMeshGUI).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 0f);
			rectTransform.anchorMax = new Vector2(0.5f, 0f);
			rectTransform.pivot = new Vector2(0f, 1f);
			((TMP_Text)warningTextMeshGUI).transform.SetParent(((TMP_Text)component).transform.parent, false);
			((TMP_Text)warningTextMeshGUI).font = ((TMP_Text)component).font;
			((Graphic)warningTextMeshGUI).material = ((TMP_Text)component).fontMaterial;
			((Graphic)warningTextMeshGUI).color = Color.red;
			((TMP_Text)warningTextMeshGUI).fontSize = ((TMP_Text)component).fontSize - 12.5f;
			((TMP_Text)warningTextMeshGUI).rectTransform.anchoredPosition = new Vector2(-60f, 115f);
			((TMP_Text)warningTextMeshGUI).SetText("INCOMING MESSAGE", true);
			((Behaviour)warningTextMeshGUI).enabled = true;
		}

		private void BroadCast()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			isCurrentlyBroadcastingTo = false;
			Vector3 destinationObjectPosition = Vector3.zero;
			if (toChannelDestination == 0)
			{
				return;
			}
			if (toChannelDestination == currentChannelSource)
			{
				photonView.RPC("SwitchChannel", (RpcTarget)0, Array.Empty<object>());
				return;
			}
			if ((Object)(object)destintionGameObject == (Object)null)
			{
				destintionGameObject = tryGetDestinationWalkieGameObject();
			}
			if ((Object)(object)destintionGameObject == (Object)null)
			{
				return;
			}
			if ((Object)(object)destinationGameObjectScript == (Object)null)
			{
				destinationGameObjectScript = destintionGameObject.GetComponent<WalkieTalkieLn>();
			}
			if ((Object)(object)destinationGameObjectScript == (Object)null)
			{
				return;
			}
			if (destinationGameObjectScript.fromChannelReceiving != currentChannelSource)
			{
				destinationGameObjectScript.fromChannelReceiving = currentChannelSource;
				destinationGameObjectScript.photonView.RPC("SetFromChannelReceiving", (RpcTarget)1, new object[1] { currentChannelSource });
			}
			float num = 0f;
			if ((Object)(object)physGrabObject == (Object)null)
			{
				return;
			}
			foreach (PhysGrabber item in physGrabObject.playerGrabbing)
			{
				PlayerVoiceChat voiceChat = item.playerAvatar.voiceChat;
				if (item.playerAvatar.voiceChatFetched)
				{
					if (!getDestinationPosition(ref destinationObjectPosition))
					{
						return;
					}
					voiceChat.OverridePosition(destinationObjectPosition, 0.2f);
					voiceChat.OverridePitch(0.85f, 0.1f, 0.1f, 0.2f, 0.05f, 100f);
					item.playerAvatar.voiceChat.OverrideNoTalkAnimation(0.2f);
					isCurrentlyBroadcastingTo = true;
					if (voiceChat.clipLoudness > 0.005f)
					{
						num += voiceChat.clipLoudness * 8f;
					}
				}
			}
			if (!((Object)(object)destinationGameObjectScript == (Object)null))
			{
				if (isCurrentlyBroadcastingTo && !destinationGameObjectScript.isReceiving)
				{
					destinationGameObjectScript.photonView.RPC("SetIsReceiving", (RpcTarget)0, new object[1] { true });
					destinationGameObjectScript.photonView.RPC("PlayIncomeSound", (RpcTarget)0, Array.Empty<object>());
				}
				if (!isCurrentlyBroadcastingTo && destinationGameObjectScript.isReceiving)
				{
					destinationGameObjectScript.photonView.RPC("SetIsReceiving", (RpcTarget)0, new object[1] { false });
					destinationGameObjectScript.photonView.RPC("PlayOutSound", (RpcTarget)0, Array.Empty<object>());
				}
				destinationGameObjectScript.lightMain.intensity = num;
			}
		}

		private bool getDestinationPosition(ref Vector3 destinationObjectPosition)
		{
			//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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destintionGameObject == (Object)null)
			{
				return false;
			}
			if (destinationObjectPosition == Vector3.zero)
			{
				PhysGrabObject component = destintionGameObject.GetComponent<PhysGrabObject>();
				if ((Object)(object)component != (Object)null && Object.op_Implicit((Object)(object)component))
				{
					destinationObjectPosition = component.centerPoint;
				}
				else
				{
					if (!Object.op_Implicit((Object)(object)destintionGameObject))
					{
						return false;
					}
					destinationObjectPosition = destintionGameObject.transform.position;
				}
			}
			if (destinationObjectPosition == globalPositionInInventory && (Object)(object)latestOwnersWalkieGameObject == (Object)null)
			{
				return false;
			}
			return true;
		}

		private GameObject? tryGetDestinationWalkieGameObject()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			GameObject value = null;
			if (_allRadios.Count <= 1)
			{
				return null;
			}
			if (_allRadios.TryGetValue(toChannelDestination, out value) && (Object)(object)value != (Object)null)
			{
				photonView.RPC("SetChannel", (RpcTarget)1, new object[1] { toChannelDestination });
				return value;
			}
			List<int> list = _allRadios.Keys.OrderBy((int x) => x).ToList();
			if (!findWalkieTalkieOutOfListComplete)
			{
				foreach (int item in list)
				{
					if (item != toChannelDestination)
					{
						_allRadios.TryGetValue(item, out GameObject value2);
						if (!((Object)(object)value2 == (Object)null))
						{
							toChannelDestination = item;
							return value2;
						}
					}
				}
				findWalkieTalkieOutOfListComplete = true;
				return null;
			}
			return destintionGameObject;
		}

		private void GiveUp()
		{
			toChannelDestination = 0;
			photonView.RPC("SetChannel", (RpcTarget)1, new object[1] { toChannelDestination });
		}

		[PunRPC]
		private void SwitchChannel()
		{
			List<int> list = _allRadios.Keys.OrderBy((int x) => x).ToList();
			if (list.Count >= 2)
			{
				int num = list.IndexOf(toChannelDestination);
				toChannelDestination = list[(num + 1) % list.Count];
				if ((Object)(object)destintionGameObject != (Object)null && (Object)(object)destinationGameObjectScript != (Object)null)
				{
					destinationGameObjectScript.photonView.RPC("SetFromChannelReceiving", (RpcTarget)0, new object[1] { 0 });
				}
				destintionGameObject = null;
				destinationGameObjectScript = null;
				DisplayChannel();
			}
		}

		[PunRPC]
		private void DisplayNet()
		{
			DisplayChannel();
		}

		[PunRPC]
		private void SetChannel(int newChannelId)
		{
			toChannelDestination = newChannelId;
			DisplayChannel();
		}

		[PunRPC]
		private void SetFirstChannel(int newChannelId)
		{
			firstChannel = newChannelId;
			DisplayChannel();
		}

		[PunRPC]
		private void SetFromChannelReceiving(int fromBroadcastId)
		{
			fromChannelReceiving = fromBroadcastId;
			DisplayChannel();
		}

		[PunRPC]
		private void SetIsReceiving(bool currentlyBroadcasting)
		{
			isReceiving = currentlyBroadcasting;
			DisplayChannel();
		}

		[PunRPC]
		private void SetEquiped(bool newEquiped)
		{
			isThisEquiped = newEquiped;
		}

		[PunRPC]
		private void PlayIncomeSound()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayInInventory(ref messageIncomeSound))
			{
				messageIncomeSound.Play(((Component)this).gameObject.transform.position, 1f, 1f, 1f, 1f);
			}
		}

		[PunRPC]
		private void PlayOutSound()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayInInventory(ref changeOrEndChannelSound))
			{
				changeOrEndChannelSound.Play(((Component)this).gameObject.transform.position, 1f, 1f, 1f, 1f);
			}
		}

		[PunRPC]
		private void PlayLoopBackgroundSound(bool toPlay)
		{
			noiseLoopSound.PlayLoop(toPlay, 10f, 10f, 1f);
		}

		private bool PlayInInventory(ref Sound targetSoundInstance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemEquipableScript != (Object)null)
			{
				if ((int)itemEquipableScript.currentState == 2)
				{
					PlayerAvatar ownerAvatar = getOwnerAvatar(currentChannelSource);
					if ((Object)(object)ownerAvatar == (Object)null)
					{
						return false;
					}
					AudioSource val = ((Component)ownerAvatar).gameObject.GetComponent<AudioSource>();
					if ((Object)(object)val == (Object)null)
					{
						val = ((Component)ownerAvatar).gameObject.AddComponent<AudioSource>();
						((Component)ownerAvatar).gameObject.AddComponent<AudioLowPassFilter>();
						((Component)ownerAvatar).gameObject.AddComponent<AudioLowPassLogic>();
					}
					AudioSource source = targetSoundInstance.Source;
					targetSoundInstance.Source = val;
					targetSoundInstance.Play(ownerAvatar.clientPositionCurrent, 1f, 1f, 1f, 1f);
					targetSoundInstance.Source = source;
					return true;
				}
				return false;
			}
			return false;
		}

		private void DisplayChannel()
		{
			if ((Object)(object)textSource == (Object)null)
			{
				textSource = ((Component)((Component)this).gameObject.transform.GetChild(1)).gameObject.GetComponent<TextMeshPro>();
			}
			if ((Object)(object)textDestination == (Object)null)
			{
				textDestination = ((Component)((Component)this).gameObject.transform.GetChild(2)).gameObject.GetComponent<TextMeshPro>();
			}
			if ((Object)(object)textBroadcastFromSource == (Object)null)
			{
				textBroadcastFromSource = ((Component)((Component)this).gameObject.transform.GetChild(4)).gameObject.GetComponent<TextMeshPro>();
			}
			((TMP_Text)textBroadcastFromSource).SetText((fromChannelReceiving == 0) ? "" : ("from " + fromChannelReceiving % 100), true);
			((TMP_Text)textSource).SetText((currentChannelSource % 100).ToString(), true);
			((TMP_Text)textDestination).SetText((toChannelDestination % 100).ToString(), true);
		}

		private void RegisterWalkeiTalkieInstance()
		{
			try
			{
				lightMain = ((Component)((Component)this).gameObject.transform.GetChild(0)).GetComponent<Light>();
				if ((Object)(object)lightMain == (Object)null)
				{
					((Object)((Component)this).gameObject).name = "0InstanceWalkie";
					return;
				}
			}
			catch
			{
				((Object)((Component)this).gameObject).name = "0InstanceWalkie";
				return;
			}
			photonView = ((Component)this).GetComponent<PhotonView>();
			currentChannelSource = photonView.ViewID;
			((Object)((Component)this).gameObject).name = "WalkieTalkie" + currentChannelSource;
			_allRadios.Add(currentChannelSource, ((Component)this).gameObject);
			if (_allRadios.Count == 1)
			{
				firstChannel = currentChannelSource;
				photonView.RPC("SetFirstChannel", (RpcTarget)1, new object[1] { currentChannelSource });
			}
		}

		private void Start()
		{
			if (_allRadios.Count >= 2)
			{
				if (firstChannel != currentChannelSource)
				{
					photonView.RPC("SetChannel", (RpcTarget)0, new object[1] { firstChannel });
					return;
				}
				photonView.RPC("SetChannel", (RpcTarget)0, new object[1] { currentChannelSource });
				photonView.RPC("SwitchChannel", (RpcTarget)0, Array.Empty<object>());
				photonView.RPC("DisplayNet", (RpcTarget)0, Array.Empty<object>());
			}
		}

		private void OnDestroy()
		{
			_allRadios.Remove(currentChannelSource);
		}
	}
}