Decompiled source of HTFFriendList v0.0.1

HowToFishFriend.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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: AssemblyCompany("HowToFishFriend")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HowToFishFriend")]
[assembly: AssemblyTitle("HowToFishFriend")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SocialModMod
{
	public static class CodeFriendRowUI
	{
		public static GameObject Create(Transform parent, CodeFriendEntry friend, Color bg)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			GameObject val = new GameObject("CodeFriend_" + friend.CachedName);
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.preferredHeight = 52f;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = bg;
			GameObject val4 = new GameObject("StatusDot");
			val4.transform.SetParent(val.transform, false);
			Image val5 = val4.AddComponent<Image>();
			val5.sprite = UISpriteFactory.CircleSprite;
			val5.type = (Type)0;
			((Graphic)val5).color = StatusColor(friend.State);
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(16f, 0f);
			component.sizeDelta = new Vector2(14f, 14f);
			GameObject val6 = new GameObject("Info");
			val6.transform.SetParent(val.transform, false);
			Text val7 = val6.AddComponent<Text>();
			val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val7.fontSize = 14;
			((Graphic)val7).color = Color.white;
			val7.alignment = (TextAnchor)3;
			val7.text = friend.CachedName + "\n" + StatusLabel(friend.State);
			RectTransform component2 = val6.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(40f, 4f);
			component2.offsetMax = new Vector2(-260f, -4f);
			if (friend.State == FriendPlayState.PlayingThisGame && friend.LobbyId != CSteamID.Nil)
			{
				Button val8 = CreateSmallButton(val.transform, "JOIN", new Vector2(-172f, 0f), new Color(0.25f, 0.4f, 0.6f, 1f));
				((UnityEvent)val8.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					CodeFriendService.Instance.JoinFriend(friend.SteamId);
				});
			}
			if (friend.State != FriendPlayState.Offline)
			{
				Button val9 = CreateSmallButton(val.transform, "INVITE", new Vector2(-88f, 0f), new Color(0.3f, 0.55f, 0.35f, 1f));
				((UnityEvent)val9.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					CodeFriendService.Instance.InviteFriend(friend.SteamId);
				});
			}
			Button val10 = CreateSmallButton(val.transform, "REMOVE", new Vector2(-8f, 0f), new Color(0.55f, 0.25f, 0.25f, 1f));
			((UnityEvent)val10.onClick).AddListener((UnityAction)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				CodeFriendService.Instance.RemoveFriend(friend.SteamId);
			});
			return val;
		}

		private static Color StatusColor(FriendPlayState state)
		{
			//IL_0037: 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_0056: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(state switch
			{
				FriendPlayState.PlayingThisGame => new Color(0.3f, 0.85f, 0.4f), 
				FriendPlayState.OnlineElsewhere => new Color(0.4f, 0.6f, 0.95f), 
				_ => new Color(0.4f, 0.4f, 0.4f), 
			});
		}

		private static string StatusLabel(FriendPlayState state)
		{
			return state switch
			{
				FriendPlayState.PlayingThisGame => "Playing How To Fish", 
				FriendPlayState.OnlineElsewhere => "Online", 
				_ => "Offline", 
			};
		}

		private static Button CreateSmallButton(Transform parent, string label, Vector2 pos, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ef: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(76f, 30f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			Button val4 = val.AddComponent<Button>();
			((Selectable)val4).targetGraphic = (Graphic)(object)val3;
			GameObject val5 = new GameObject("Text");
			val5.transform.SetParent(val.transform, false);
			Text val6 = val5.AddComponent<Text>();
			val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val6.fontSize = 11;
			val6.fontStyle = (FontStyle)1;
			((Graphic)val6).color = Color.white;
			val6.alignment = (TextAnchor)4;
			val6.text = label;
			RectTransform component = ((Component)val6).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val4;
		}
	}
	public class CodeFriendEntry
	{
		public CSteamID SteamId;

		public string CachedName;

		public FriendPlayState State;

		public CSteamID LobbyId;
	}
	public class PendingFriendRequest
	{
		public CSteamID SteamId;

		public string FromName;

		public bool Incoming;

		public float ReceivedAt;
	}
	public class CodeFriendService : MonoBehaviour
	{
		public readonly List<CodeFriendEntry> Friends = new List<CodeFriendEntry>();

		public readonly List<PendingFriendRequest> IncomingRequests = new List<PendingFriendRequest>();

		public readonly List<PendingFriendRequest> OutgoingRequests = new List<PendingFriendRequest>();

		private string cachedMyCode;

		private const int Channel = 42;

		private const byte MsgFriendRequest = 1;

		private const byte MsgRequestAccepted = 2;

		private const byte MsgRequestDeclined = 3;

		private string savePath;

		private Callback<P2PSessionRequest_t> sessionRequestCallback;

		private Callback<PersonaStateChange_t> personaCallback;

		private float nextPlayStateRefresh;

		private const float PlayStateRefreshInterval = 2f;

		public static CodeFriendService Instance { get; private set; }

		public string MyCode
		{
			get
			{
				if (string.IsNullOrEmpty(cachedMyCode) || cachedMyCode == "unavailable")
				{
					TryGenerateMyCode();
				}
				return string.IsNullOrEmpty(cachedMyCode) ? "unavailable" : cachedMyCode;
			}
		}

		public event Action OnFriendsChanged;

		public event Action OnRequestsChanged;

		public event Action<PendingFriendRequest> OnFriendRequestReceived;

		private void TryGenerateMyCode()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CSteamID steamID = SteamUser.GetSteamID();
				if (((CSteamID)(ref steamID)).IsValid())
				{
					cachedMyCode = FriendCodeUtility.Encode(steamID);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[SocialMod] Friend code not ready yet: " + ex.Message));
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			if (!SteamReady())
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Steam client not initialized, code friends disabled.");
				((Behaviour)this).enabled = false;
				return;
			}
			string text = Path.Combine(Application.persistentDataPath, "SocialModMod");
			Directory.CreateDirectory(text);
			savePath = Path.Combine(text, "codefriends.txt");
			sessionRequestCallback = Callback<P2PSessionRequest_t>.Create((DispatchDelegate<P2PSessionRequest_t>)OnSessionRequest);
			personaCallback = Callback<PersonaStateChange_t>.Create((DispatchDelegate<PersonaStateChange_t>)delegate(PersonaStateChange_t cb)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				RefreshCachedName(new CSteamID(cb.m_ulSteamID));
			});
			LoadFriends();
		}

		private bool SteamReady()
		{
			try
			{
				return SteamAPI.IsSteamRunning();
			}
			catch
			{
				return false;
			}
		}

		private void OnSessionRequest(P2PSessionRequest_t callback)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			SteamNetworking.AcceptP2PSessionWithUser(callback.m_steamIDRemote);
		}

		private void Update()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			uint num = default(uint);
			CSteamID sender = default(CSteamID);
			while (SteamNetworking.IsP2PPacketAvailable(ref num, 42))
			{
				byte[] array = new byte[num];
				if (!SteamNetworking.ReadP2PPacket(array, num, ref num, ref sender, 42))
				{
					break;
				}
				HandlePacket(sender, array);
			}
			if (Time.unscaledTime >= nextPlayStateRefresh)
			{
				nextPlayStateRefresh = Time.unscaledTime + 2f;
				RefreshPlayStates();
			}
		}

		private void RefreshPlayStates()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0094: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			FriendGameInfo_t val2 = default(FriendGameInfo_t);
			foreach (CodeFriendEntry friend in Friends)
			{
				FriendPlayState friendPlayState = FriendPlayState.Offline;
				CSteamID val = CSteamID.Nil;
				EPersonaState friendPersonaState = SteamFriends.GetFriendPersonaState(friend.SteamId);
				if ((int)friendPersonaState > 0)
				{
					friendPlayState = FriendPlayState.OnlineElsewhere;
				}
				if (SteamFriends.GetFriendGamePlayed(friend.SteamId, ref val2) && ((CGameID)(ref val2.m_gameID)).AppID() == SteamUtils.GetAppID())
				{
					friendPlayState = FriendPlayState.PlayingThisGame;
					val = val2.m_steamIDLobby;
				}
				if (friend.State != friendPlayState || friend.LobbyId.m_SteamID != val.m_SteamID)
				{
					friend.State = friendPlayState;
					friend.LobbyId = val;
					flag = true;
				}
			}
			if (flag)
			{
				this.OnFriendsChanged?.Invoke();
			}
		}

		public void JoinFriend(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			CodeFriendEntry codeFriendEntry = Friends.Find((CodeFriendEntry f) => f.SteamId.m_SteamID == steamId.m_SteamID);
			if (codeFriendEntry == null || codeFriendEntry.LobbyId == CSteamID.Nil)
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Can't join: this friend is not currently in a lobby.");
			}
			else
			{
				SteamManager.JoinLobby(codeFriendEntry.LobbyId.m_SteamID);
			}
		}

		public void InviteFriend(CSteamID steamId)
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (SteamManager.CurrentLobbyID == CSteamID.Nil)
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Can't invite: not currently in a lobby.");
			}
			else
			{
				SteamMatchmaking.InviteUserToLobby(SteamManager.CurrentLobbyID, steamId);
			}
		}

		private void HandlePacket(CSteamID sender, byte[] data)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (data.Length == 0)
			{
				return;
			}
			byte b = data[0];
			string fromName = ((data.Length > 1) ? Encoding.UTF8.GetString(data, 1, data.Length - 1) : "");
			switch (b)
			{
			case 1:
				HandleIncomingRequest(sender, fromName);
				break;
			case 2:
				HandleRequestAccepted(sender);
				break;
			case 3:
				OutgoingRequests.RemoveAll((PendingFriendRequest r) => r.SteamId.m_SteamID == sender.m_SteamID);
				this.OnRequestsChanged?.Invoke();
				break;
			}
		}

		private void HandleIncomingRequest(CSteamID sender, string fromName)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (Friends.Exists((CodeFriendEntry f) => f.SteamId.m_SteamID == sender.m_SteamID))
			{
				SendPacket(sender, 2, "");
			}
			else if (!IncomingRequests.Exists((PendingFriendRequest r) => r.SteamId.m_SteamID == sender.m_SteamID))
			{
				PendingFriendRequest pendingFriendRequest = new PendingFriendRequest
				{
					SteamId = sender,
					FromName = (string.IsNullOrEmpty(fromName) ? sender.m_SteamID.ToString() : fromName),
					Incoming = true,
					ReceivedAt = Time.unscaledTime
				};
				IncomingRequests.Insert(0, pendingFriendRequest);
				this.OnRequestsChanged?.Invoke();
				this.OnFriendRequestReceived?.Invoke(pendingFriendRequest);
			}
		}

		private void HandleRequestAccepted(CSteamID sender)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			PendingFriendRequest pendingFriendRequest = OutgoingRequests.Find((PendingFriendRequest r) => r.SteamId.m_SteamID == sender.m_SteamID);
			if (pendingFriendRequest != null)
			{
				OutgoingRequests.Remove(pendingFriendRequest);
				AddFriendInternal(sender, pendingFriendRequest.FromName);
			}
		}

		public bool SendFriendRequestByCode(string code, out string error)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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)
			error = null;
			if (!FriendCodeUtility.TryDecode(code, out var target))
			{
				error = "Invalid friend code.";
				return false;
			}
			if (target.m_SteamID == SteamUser.GetSteamID().m_SteamID)
			{
				error = "You can't add yourself.";
				return false;
			}
			if (Friends.Exists((CodeFriendEntry f) => f.SteamId.m_SteamID == target.m_SteamID))
			{
				error = "That player is already your friend.";
				return false;
			}
			if (OutgoingRequests.Exists((PendingFriendRequest r) => r.SteamId.m_SteamID == target.m_SteamID))
			{
				error = "Friend request already sent.";
				return false;
			}
			string personaName = SteamFriends.GetPersonaName();
			SendPacket(target, 1, personaName);
			OutgoingRequests.Insert(0, new PendingFriendRequest
			{
				SteamId = target,
				FromName = personaName,
				Incoming = false,
				ReceivedAt = Time.unscaledTime
			});
			this.OnRequestsChanged?.Invoke();
			return true;
		}

		public void AcceptRequest(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			PendingFriendRequest pendingFriendRequest = IncomingRequests.Find((PendingFriendRequest r) => r.SteamId.m_SteamID == steamId.m_SteamID);
			if (pendingFriendRequest != null)
			{
				IncomingRequests.Remove(pendingFriendRequest);
				SendPacket(steamId, 2, "");
				AddFriendInternal(steamId, pendingFriendRequest.FromName);
				this.OnRequestsChanged?.Invoke();
			}
		}

		public void DeclineRequest(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			IncomingRequests.RemoveAll((PendingFriendRequest r) => r.SteamId.m_SteamID == steamId.m_SteamID);
			SendPacket(steamId, 3, "");
			this.OnRequestsChanged?.Invoke();
		}

		public void CancelOutgoingRequest(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			OutgoingRequests.RemoveAll((PendingFriendRequest r) => r.SteamId.m_SteamID == steamId.m_SteamID);
			SendPacket(steamId, 3, "");
			this.OnRequestsChanged?.Invoke();
		}

		public void RemoveFriend(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Friends.RemoveAll((CodeFriendEntry f) => f.SteamId.m_SteamID == steamId.m_SteamID);
			SaveFriends();
			this.OnFriendsChanged?.Invoke();
		}

		private void AddFriendInternal(CSteamID steamId, string name)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!Friends.Exists((CodeFriendEntry f) => f.SteamId.m_SteamID == steamId.m_SteamID))
			{
				Friends.Add(new CodeFriendEntry
				{
					SteamId = steamId,
					CachedName = name
				});
				SaveFriends();
				SteamFriends.RequestUserInformation(steamId, false);
				this.OnFriendsChanged?.Invoke();
			}
		}

		private void SendPacket(CSteamID target, byte type, string payload)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = (string.IsNullOrEmpty(payload) ? new byte[0] : Encoding.UTF8.GetBytes(payload));
			byte[] array2 = new byte[1 + array.Length];
			array2[0] = type;
			Array.Copy(array, 0, array2, 1, array.Length);
			SteamNetworking.SendP2PPacket(target, array2, (uint)array2.Length, (EP2PSend)2, 42);
		}

		private void LoadFriends()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Friends.Clear();
			if (!File.Exists(savePath))
			{
				return;
			}
			string[] array = File.ReadAllLines(savePath);
			CSteamID val = default(CSteamID);
			foreach (string text in array)
			{
				if (!string.IsNullOrWhiteSpace(text))
				{
					string[] array2 = text.Split('|');
					if (array2.Length >= 2 && ulong.TryParse(array2[0], out var result))
					{
						((CSteamID)(ref val))..ctor(result);
						Friends.Add(new CodeFriendEntry
						{
							SteamId = val,
							CachedName = array2[1]
						});
						SteamFriends.RequestUserInformation(val, false);
					}
				}
			}
		}

		private void SaveFriends()
		{
			List<string> list = new List<string>();
			foreach (CodeFriendEntry friend in Friends)
			{
				list.Add(friend.SteamId.m_SteamID + "|" + friend.CachedName.Replace("|", " "));
			}
			File.WriteAllLines(savePath, list);
		}

		public void RefreshCachedName(CSteamID steamId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			CodeFriendEntry codeFriendEntry = Friends.Find((CodeFriendEntry f) => f.SteamId.m_SteamID == steamId.m_SteamID);
			if (codeFriendEntry != null)
			{
				string friendPersonaName = SteamFriends.GetFriendPersonaName(steamId);
				if (!string.IsNullOrEmpty(friendPersonaName) && friendPersonaName != "[unknown]")
				{
					codeFriendEntry.CachedName = friendPersonaName;
					SaveFriends();
					this.OnFriendsChanged?.Invoke();
				}
			}
		}
	}
	internal static class EventTriggerHelper
	{
		public static void AddHoverJoke(GameObject target, Text label, string name, string originalStatus, string[] jokes)
		{
			//IL_002b: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			EventTrigger val = target.AddComponent<EventTrigger>();
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)0
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				string text = jokes[Random.Range(0, jokes.Length)];
				label.text = name + "\n" + text;
			});
			Entry val3 = new Entry
			{
				eventID = (EventTriggerType)1
			};
			((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				label.text = name + "\n" + originalStatus;
			});
			val.triggers.Add(val2);
			val.triggers.Add(val3);
		}
	}
	public static class FriendCodeUtility
	{
		private const string Alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";

		private const string Prefix = "nekocode-";

		public static string Encode(CSteamID steamId)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Encode(((CSteamID)(ref steamId)).GetAccountID().m_AccountID);
		}

		public static string Encode(uint accountId)
		{
			char[] array = new char[7];
			ulong num = accountId;
			for (int num2 = 6; num2 >= 0; num2--)
			{
				array[num2] = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"[(int)(num & 0x1F)];
				num >>= 5;
			}
			string text = new string(array);
			string text2 = text + "0123456789ABCDEFGHJKMNPQRSTVWXYZ"[ComputeChecksum(accountId)];
			return "nekocode-" + text2.Substring(0, 4) + "-" + text2.Substring(4, 4);
		}

		public static bool TryDecode(string code, out CSteamID steamId)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			steamId = CSteamID.Nil;
			if (string.IsNullOrEmpty(code))
			{
				return false;
			}
			string text = code.Trim();
			if (text.StartsWith("nekocode-", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring("nekocode-".Length);
			}
			text = text.Replace("-", "").Replace(" ", "").ToUpperInvariant();
			if (text.Length != 8)
			{
				return false;
			}
			string text2 = text.Substring(0, 7);
			char value = text[7];
			uint num = 0u;
			string text3 = text2;
			foreach (char value2 in text3)
			{
				int num2 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ".IndexOf(value2);
				if (num2 < 0)
				{
					return false;
				}
				num = (num << 5) | (uint)num2;
			}
			int num3 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ".IndexOf(value);
			if (num3 < 0 || num3 != ComputeChecksum(num))
			{
				return false;
			}
			steamId = new CSteamID(new AccountID_t(num), (EUniverse)1, (EAccountType)1);
			return true;
		}

		private static int ComputeChecksum(uint accountId)
		{
			ulong num = 0uL;
			ulong num2 = accountId;
			int num3 = 3;
			while (num2 != 0)
			{
				num += (ulong)((long)(num2 & 0x1F) * (long)num3);
				num2 >>= 5;
				num3 += 2;
			}
			return (int)(num % 32);
		}
	}
	public static class FriendRequestRowUI
	{
		public static GameObject Create(Transform parent, PendingFriendRequest request, Color bg)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00b4: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			GameObject val = new GameObject((request.Incoming ? "Incoming_" : "Outgoing_") + request.FromName);
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.preferredHeight = 52f;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = bg;
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform, false);
			Text val5 = val4.AddComponent<Text>();
			val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val5.fontSize = 13;
			((Graphic)val5).color = Color.white;
			val5.alignment = (TextAnchor)3;
			val5.text = (request.Incoming ? (request.FromName + "\nwants to be friends") : (request.FromName + "\nrequest pending..."));
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(12f, 4f);
			component.offsetMax = new Vector2(-160f, -4f);
			if (request.Incoming)
			{
				Button val6 = CreateSmallButton(val.transform, "ACCEPT", new Vector2(-84f, 0f), new Color(0.25f, 0.55f, 0.3f, 1f));
				((UnityEvent)val6.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					CodeFriendService.Instance.AcceptRequest(request.SteamId);
				});
				Button val7 = CreateSmallButton(val.transform, "DECLINE", new Vector2(-8f, 0f), new Color(0.55f, 0.25f, 0.25f, 1f));
				((UnityEvent)val7.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					CodeFriendService.Instance.DeclineRequest(request.SteamId);
				});
			}
			else
			{
				Button val8 = CreateSmallButton(val.transform, "CANCEL", new Vector2(-8f, 0f), new Color(0.4f, 0.4f, 0.4f, 1f));
				((UnityEvent)val8.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					CodeFriendService.Instance.CancelOutgoingRequest(request.SteamId);
				});
			}
			return val;
		}

		private static Button CreateSmallButton(Transform parent, string label, Vector2 pos, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ef: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(76f, 30f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			Button val4 = val.AddComponent<Button>();
			((Selectable)val4).targetGraphic = (Graphic)(object)val3;
			GameObject val5 = new GameObject("Text");
			val5.transform.SetParent(val.transform, false);
			Text val6 = val5.AddComponent<Text>();
			val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val6.fontSize = 11;
			val6.fontStyle = (FontStyle)1;
			((Graphic)val6).color = Color.white;
			val6.alignment = (TextAnchor)4;
			val6.text = label;
			RectTransform component = ((Component)val6).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val4;
		}
	}
	public static class FriendRowUI
	{
		private static readonly string[] HoverJokes = new string[4] { "Тащи его на борт!", "Ему тоже скучно без тебя", "Го рыбачить вместе!", "Одна удочка хорошо, а две лучше" };

		public static GameObject Create(Transform parent, FriendEntry friend, Color bg)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: 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_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Expected O, but got Unknown
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: 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_0393: Expected O, but got Unknown
			GameObject val = new GameObject("Friend_" + friend.Name);
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.preferredHeight = 52f;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = bg;
			GameObject val4 = new GameObject("Avatar");
			val4.transform.SetParent(val.transform, false);
			RawImage val5 = val4.AddComponent<RawImage>();
			val5.texture = (Texture)(object)(((Object)(object)friend.Avatar != (Object)null) ? friend.Avatar : Texture2D.grayTexture);
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(8f, 0f);
			component.sizeDelta = new Vector2(40f, 40f);
			GameObject val6 = new GameObject("StatusDot");
			val6.transform.SetParent(val4.transform, false);
			Image val7 = val6.AddComponent<Image>();
			val7.sprite = UISpriteFactory.CircleSprite;
			val7.type = (Type)0;
			((Graphic)val7).color = StatusColor(friend.State);
			RectTransform component2 = val6.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(1f, 0f);
			component2.anchorMax = new Vector2(1f, 0f);
			component2.pivot = new Vector2(1f, 0f);
			component2.anchoredPosition = new Vector2(2f, -2f);
			component2.sizeDelta = new Vector2(12f, 12f);
			GameObject val8 = new GameObject("Info");
			val8.transform.SetParent(val.transform, false);
			Text val9 = val8.AddComponent<Text>();
			val9.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val9.fontSize = 14;
			((Graphic)val9).color = Color.white;
			val9.alignment = (TextAnchor)3;
			val9.text = friend.Name + "\n" + StatusLabel(friend.State);
			val9.horizontalOverflow = (HorizontalWrapMode)1;
			RectTransform component3 = val8.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.offsetMin = new Vector2(58f, 4f);
			component3.offsetMax = new Vector2(-172f, -4f);
			bool flag = friend.State == FriendPlayState.PlayingThisGame && friend.LobbyId != CSteamID.Nil;
			if (friend.State != FriendPlayState.Offline)
			{
				if (flag)
				{
					Button val10 = CreateActionButton(val.transform, "JOIN", new Vector2(-96f, 0f), new Color(0.25f, 0.4f, 0.6f, 1f));
					((UnityEvent)val10.onClick).AddListener((UnityAction)delegate
					{
						//IL_000b: Unknown result type (might be due to invalid IL or missing references)
						SteamSocialService.Instance.JoinFriend(friend.SteamId);
					});
					EventTriggerHelper.AddHoverJoke(((Component)val10).gameObject, val9, friend.Name, StatusLabel(friend.State), HoverJokes);
				}
				Button val11 = CreateActionButton(val.transform, "INVITE", new Vector2(-8f, 0f), new Color(0.3f, 0.55f, 0.35f, 1f));
				((UnityEvent)val11.onClick).AddListener((UnityAction)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					SteamSocialService.Instance.InviteFriend(friend.SteamId);
				});
				EventTriggerHelper.AddHoverJoke(((Component)val11).gameObject, val9, friend.Name, StatusLabel(friend.State), HoverJokes);
			}
			return val;
		}

		private static Button CreateActionButton(Transform parent, string label, Vector2 pos, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00f8: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ActionButton");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(80f, 30f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			Button val4 = val.AddComponent<Button>();
			((Selectable)val4).targetGraphic = (Graphic)(object)val3;
			GameObject val5 = new GameObject("Text");
			val5.transform.SetParent(val.transform, false);
			Text val6 = val5.AddComponent<Text>();
			val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val6.fontSize = 12;
			val6.fontStyle = (FontStyle)1;
			val6.alignment = (TextAnchor)4;
			((Graphic)val6).color = Color.white;
			val6.text = label;
			RectTransform component = ((Component)val6).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val4;
		}

		private static Color StatusColor(FriendPlayState state)
		{
			//IL_0037: 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_0056: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(state switch
			{
				FriendPlayState.PlayingThisGame => new Color(0.3f, 0.85f, 0.4f), 
				FriendPlayState.OnlineElsewhere => new Color(0.4f, 0.6f, 0.95f), 
				_ => new Color(0.4f, 0.4f, 0.4f), 
			});
		}

		private static string StatusLabel(FriendPlayState state)
		{
			return state switch
			{
				FriendPlayState.PlayingThisGame => "Playing How To Fish", 
				FriendPlayState.OnlineElsewhere => "Online", 
				_ => "Offline", 
			};
		}
	}
	public static class InviteRowUI
	{
		public static GameObject Create(Transform parent, IncomingInvite invite, Color bg)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			GameObject row = new GameObject("Invite_" + invite.FromName);
			row.transform.SetParent(parent, false);
			LayoutElement val = row.AddComponent<LayoutElement>();
			val.preferredHeight = 52f;
			Image val2 = row.AddComponent<Image>();
			((Graphic)val2).color = bg;
			GameObject val3 = new GameObject("Text");
			val3.transform.SetParent(row.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val4.fontSize = 14;
			((Graphic)val4).color = Color.white;
			val4.alignment = (TextAnchor)3;
			val4.text = invite.FromName + " приглашает вас в лобби";
			RectTransform component = ((Component)val4).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(12f, 4f);
			component.offsetMax = new Vector2(-90f, -4f);
			Button val5 = CreateSmallButton(row.transform, "JOIN", new Vector2(-8f, 0f));
			((UnityEvent)val5.onClick).AddListener((UnityAction)delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				SteamSocialService.Instance.JoinLobby(invite.LobbyId);
				SteamSocialService.Instance.Invites.Remove(invite);
				Object.Destroy((Object)(object)row);
			});
			return row;
		}

		private static Button CreateSmallButton(Transform parent, string label, Vector2 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_0107: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(72f, 30f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.25f, 0.55f, 0.3f, 1f);
			Button val4 = val.AddComponent<Button>();
			((Selectable)val4).targetGraphic = (Graphic)(object)val3;
			GameObject val5 = new GameObject("Text");
			val5.transform.SetParent(val.transform, false);
			Text val6 = val5.AddComponent<Text>();
			val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val6.fontSize = 12;
			val6.fontStyle = (FontStyle)1;
			((Graphic)val6).color = Color.white;
			val6.alignment = (TextAnchor)4;
			val6.text = label;
			RectTransform component = ((Component)val6).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val4;
		}
	}
	public static class MenuVisibility
	{
		public static bool IsESPOpen;
	}
	public class NotificationToastUI : MonoBehaviour
	{
		private RectTransform stackRoot;

		private const float ToastLifetime = 5f;

		private const float FadeDuration = 0.4f;

		public static NotificationToastUI Instance { get; private set; }

		public static NotificationToastUI CreateInstance()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance;
			}
			GameObject val = new GameObject("SocialModNotifications");
			Object.DontDestroyOnLoad((Object)(object)val);
			return val.AddComponent<NotificationToastUI>();
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			BuildCanvas();
		}

		private void BuildCanvas()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0091: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Canvas val = ((Component)this).gameObject.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 5000;
			CanvasScaler val2 = ((Component)this).gameObject.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			((Component)this).gameObject.AddComponent<GraphicRaycaster>();
			GameObject val3 = new GameObject("Stack");
			val3.transform.SetParent(((Component)this).transform, false);
			stackRoot = val3.AddComponent<RectTransform>();
			stackRoot.anchorMin = new Vector2(1f, 1f);
			stackRoot.anchorMax = new Vector2(1f, 1f);
			stackRoot.pivot = new Vector2(1f, 1f);
			stackRoot.anchoredPosition = new Vector2(-24f, -24f);
			stackRoot.sizeDelta = new Vector2(320f, 0f);
			VerticalLayoutGroup val4 = val3.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val4).spacing = 8f;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = true;
			((LayoutGroup)val4).childAlignment = (TextAnchor)2;
			ContentSizeFitter val5 = val3.AddComponent<ContentSizeFitter>();
			val5.verticalFit = (FitMode)2;
		}

		public void Show(string title, string message)
		{
			((MonoBehaviour)this).StartCoroutine(ShowRoutine(title, message));
		}

		private IEnumerator ShowRoutine(string title, string message)
		{
			GameObject toast = new GameObject("Toast");
			toast.transform.SetParent((Transform)(object)stackRoot, false);
			LayoutElement layoutElement = toast.AddComponent<LayoutElement>();
			layoutElement.preferredHeight = 60f;
			CanvasGroup group = toast.AddComponent<CanvasGroup>();
			group.alpha = 0f;
			Image bg = toast.AddComponent<Image>();
			((Graphic)bg).color = new Color(0.1f, 0.13f, 0.22f, 0.95f);
			Outline outline = toast.AddComponent<Outline>();
			((Shadow)outline).effectColor = new Color(0.4f, 0.55f, 0.8f, 0.7f);
			((Shadow)outline).effectDistance = new Vector2(1f, -1f);
			GameObject titleObj = new GameObject("Title");
			titleObj.transform.SetParent(toast.transform, false);
			Text titleText = titleObj.AddComponent<Text>();
			titleText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			titleText.fontSize = 14;
			titleText.fontStyle = (FontStyle)1;
			((Graphic)titleText).color = new Color(0.55f, 0.8f, 1f);
			titleText.text = title;
			titleText.alignment = (TextAnchor)0;
			RectTransform titleRect = titleObj.GetComponent<RectTransform>();
			titleRect.anchorMin = new Vector2(0f, 1f);
			titleRect.anchorMax = new Vector2(1f, 1f);
			titleRect.pivot = new Vector2(0f, 1f);
			titleRect.anchoredPosition = new Vector2(12f, -8f);
			titleRect.sizeDelta = new Vector2(-24f, 18f);
			GameObject msgObj = new GameObject("Message");
			msgObj.transform.SetParent(toast.transform, false);
			Text msgText = msgObj.AddComponent<Text>();
			msgText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			msgText.fontSize = 13;
			((Graphic)msgText).color = Color.white;
			msgText.text = message;
			msgText.alignment = (TextAnchor)0;
			msgText.horizontalOverflow = (HorizontalWrapMode)0;
			RectTransform msgRect = msgObj.GetComponent<RectTransform>();
			msgRect.anchorMin = new Vector2(0f, 0f);
			msgRect.anchorMax = new Vector2(1f, 1f);
			msgRect.offsetMin = new Vector2(12f, 8f);
			msgRect.offsetMax = new Vector2(-12f, -28f);
			float t = 0f;
			while (t < 0.4f)
			{
				t += Time.unscaledDeltaTime;
				group.alpha = Mathf.Clamp01(t / 0.4f);
				yield return null;
			}
			group.alpha = 1f;
			yield return (object)new WaitForSecondsRealtime(5f);
			t = 0f;
			while (t < 0.4f)
			{
				t += Time.unscaledDeltaTime;
				group.alpha = 1f - Mathf.Clamp01(t / 0.4f);
				yield return null;
			}
			Object.Destroy((Object)(object)toast);
		}
	}
	[BepInPlugin("neko.howtofish.socialmod", "How To Fish Social Panel", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "neko.howtofish.socialmod";

		public const string PluginName = "How To Fish Social Panel";

		public const string PluginVersion = "1.1.0";

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			GameObject val = new GameObject("SteamSocialService");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<SteamSocialService>();
			GameObject val2 = new GameObject("CodeFriendService");
			Object.DontDestroyOnLoad((Object)(object)val2);
			val2.AddComponent<CodeFriendService>();
			NotificationToastUI.CreateInstance();
			GameObject val3 = new GameObject("SocialPanel");
			Object.DontDestroyOnLoad((Object)(object)val3);
			val3.AddComponent<SocialPanelUI>();
			new Harmony("neko.howtofish.socialmod").PatchAll();
			Log.LogInfo((object)"How To Fish Social Panel 1.1.0 loaded.");
		}
	}
	public class SocialPanelUI : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__34_0;

			internal void <BuildAddFriendTab>b__34_0()
			{
				GUIUtility.systemCopyBuffer = (((Object)(object)CodeFriendService.Instance != (Object)null) ? CodeFriendService.Instance.MyCode : "");
				NotificationToastUI.Instance?.Show("Copied", "Your friend code has been copied to the clipboard.");
			}
		}

		private static readonly Color PanelBg = new Color(0.09f, 0.12f, 0.2f, 0.92f);

		private static readonly Color TabActive = new Color(0.2f, 0.3f, 0.45f, 1f);

		private static readonly Color TabInactive = new Color(0.13f, 0.17f, 0.27f, 1f);

		private static readonly Color RowBg = new Color(0.14f, 0.18f, 0.28f, 0.9f);

		private const string PrefsPrefix = "SocialModMod_Panel";

		private GameObject canvasObject;

		private RectTransform panelRect;

		private GameObject steamFriendsScroll;

		private GameObject steamFriendsContent;

		private GameObject codeFriendsScroll;

		private GameObject codeFriendsContent;

		private GameObject addFriendRoot;

		private GameObject addFriendRequestsContent;

		private GameObject invitesScroll;

		private GameObject invitesContent;

		private Button tabSteam;

		private Button tabCode;

		private Button tabAdd;

		private Button tabInvites;

		private Text invitesBadge;

		private InputField codeInputField;

		private Text myCodeText;

		private readonly List<GameObject> steamFriendRows = new List<GameObject>();

		private readonly List<GameObject> codeFriendRows = new List<GameObject>();

		private readonly List<GameObject> requestRows = new List<GameObject>();

		private readonly List<GameObject> inviteRows = new List<GameObject>();

		private bool hiddenByUser;

		private void Awake()
		{
			BuildUI();
			ShowTab(0);
		}

		private void OnEnable()
		{
			if ((Object)(object)SteamSocialService.Instance != (Object)null)
			{
				SteamSocialService.Instance.OnFriendsRefreshed += RebuildSteamFriends;
				SteamSocialService.Instance.OnInviteReceived += OnLobbyInviteReceived;
				RebuildSteamFriends();
				RebuildInvites();
			}
			if ((Object)(object)CodeFriendService.Instance != (Object)null)
			{
				CodeFriendService.Instance.OnFriendsChanged += RebuildCodeFriends;
				CodeFriendService.Instance.OnRequestsChanged += RebuildRequests;
				CodeFriendService.Instance.OnFriendRequestReceived += OnFriendRequestReceived;
				RebuildCodeFriends();
				RebuildRequests();
				myCodeText.text = "Your code: " + CodeFriendService.Instance.MyCode;
			}
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)285))
			{
				hiddenByUser = !hiddenByUser;
			}
			ApplyVisibility();
		}

		private void ApplyVisibility()
		{
			bool flag = !hiddenByUser;
			if (canvasObject.activeSelf != flag)
			{
				canvasObject.SetActive(flag);
			}
		}

		private void OnLobbyInviteReceived(IncomingInvite invite)
		{
			RebuildInvites();
			NotificationToastUI.Instance?.Show("Lobby Invite", invite.FromName + " invited you to their lobby.");
		}

		private void OnFriendRequestReceived(PendingFriendRequest request)
		{
			NotificationToastUI.Instance?.Show("Friend Request", request.FromName + " sent you a friend request.");
		}

		private void BuildUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_005c: 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)
			//IL_00b0: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Expected O, but got Unknown
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			canvasObject = new GameObject("SocialPanelCanvas");
			Object.DontDestroyOnLoad((Object)(object)canvasObject);
			Canvas val = canvasObject.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 4500;
			CanvasScaler val2 = canvasObject.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			canvasObject.AddComponent<GraphicRaycaster>();
			GameObject val3 = CreatePanel(canvasObject.transform, new Vector2(460f, 400f));
			panelRect = val3.GetComponent<RectTransform>();
			panelRect.anchorMin = new Vector2(1f, 0f);
			panelRect.anchorMax = new Vector2(1f, 0f);
			panelRect.pivot = new Vector2(1f, 0f);
			float num = PlayerPrefs.GetFloat("SocialModMod_Panel_X", -24f);
			float num2 = PlayerPrefs.GetFloat("SocialModMod_Panel_Y", 24f);
			panelRect.anchoredPosition = new Vector2(num, num2);
			UIDragHandler uIDragHandler = val3.AddComponent<UIDragHandler>();
			uIDragHandler.Target = panelRect;
			uIDragHandler.OwnerCanvas = val;
			uIDragHandler.SavePrefsPrefix = "SocialModMod_Panel";
			Text val4 = CreateText(val3.transform, "FRIENDS  (F4 to hide)", 16, (TextAnchor)3, (FontStyle)1);
			SetTop(((Component)val4).GetComponent<RectTransform>(), new Vector2(16f, -10f), new Vector2(300f, 24f));
			float num3 = 104f;
			tabSteam = CreateTabButton(val3.transform, "Steam Friends", new Vector2(16f, -40f), num3);
			tabCode = CreateTabButton(val3.transform, "Code Friends", new Vector2(16f + (num3 + 4f), -40f), num3);
			tabAdd = CreateTabButton(val3.transform, "Add Friend", new Vector2(16f + (num3 + 4f) * 2f, -40f), num3);
			tabInvites = CreateTabButton(val3.transform, "Invites", new Vector2(16f + (num3 + 4f) * 3f, -40f), num3);
			((UnityEvent)tabSteam.onClick).AddListener((UnityAction)delegate
			{
				ShowTab(0);
			});
			((UnityEvent)tabCode.onClick).AddListener((UnityAction)delegate
			{
				ShowTab(1);
			});
			((UnityEvent)tabAdd.onClick).AddListener((UnityAction)delegate
			{
				ShowTab(2);
			});
			((UnityEvent)tabInvites.onClick).AddListener((UnityAction)delegate
			{
				ShowTab(3);
			});
			GameObject val5 = new GameObject("BadgeBg");
			val5.transform.SetParent(((Component)tabInvites).transform, false);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = new Color(0.85f, 0.25f, 0.2f, 1f);
			RectTransform component = val5.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 1f);
			component.anchoredPosition = new Vector2(-4f, -4f);
			component.sizeDelta = new Vector2(18f, 18f);
			invitesBadge = CreateText(val5.transform, "", 11, (TextAnchor)4, (FontStyle)1);
			RectTransform component2 = ((Component)invitesBadge).GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			val5.SetActive(false);
			Vector2 pos = default(Vector2);
			((Vector2)(ref pos))..ctor(16f, -76f);
			Vector2 size = default(Vector2);
			((Vector2)(ref size))..ctor(428f, 308f);
			steamFriendsScroll = CreateScrollView(val3.transform, out steamFriendsContent);
			SetTop(steamFriendsScroll.GetComponent<RectTransform>(), pos, size);
			codeFriendsScroll = CreateScrollView(val3.transform, out codeFriendsContent);
			SetTop(codeFriendsScroll.GetComponent<RectTransform>(), pos, size);
			invitesScroll = CreateScrollView(val3.transform, out invitesContent);
			SetTop(invitesScroll.GetComponent<RectTransform>(), pos, size);
			BuildAddFriendTab(val3.transform, pos, size);
			canvasObject.SetActive(false);
		}

		private void BuildAddFriendTab(Transform parent, Vector2 pos, Vector2 size)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			addFriendRoot = new GameObject("AddFriendTab");
			addFriendRoot.transform.SetParent(parent, false);
			RectTransform rect = addFriendRoot.AddComponent<RectTransform>();
			SetTop(rect, pos, size);
			myCodeText = CreateText(addFriendRoot.transform, "Your code: ...", 13, (TextAnchor)3, (FontStyle)1);
			SetTop(((Component)myCodeText).GetComponent<RectTransform>(), new Vector2(0f, 0f), new Vector2(size.x - 90f, 24f));
			Button val = CreateTabButton(addFriendRoot.transform, "Copy", new Vector2(size.x - 84f, 0f), 84f);
			ButtonClickedEvent onClick = val.onClick;
			object obj = <>c.<>9__34_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					GUIUtility.systemCopyBuffer = (((Object)(object)CodeFriendService.Instance != (Object)null) ? CodeFriendService.Instance.MyCode : "");
					NotificationToastUI.Instance?.Show("Copied", "Your friend code has been copied to the clipboard.");
				};
				<>c.<>9__34_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			codeInputField = CreateInputField(addFriendRoot.transform, "nekocode-XXXX-XXXX");
			SetTop(((Component)codeInputField).GetComponent<RectTransform>(), new Vector2(0f, -32f), new Vector2(size.x - 130f, 28f));
			Button val3 = CreateTabButton(addFriendRoot.transform, "Send Request", new Vector2(size.x - 122f, -32f), 122f);
			((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
			{
				if (!((Object)(object)CodeFriendService.Instance == (Object)null))
				{
					if (CodeFriendService.Instance.SendFriendRequestByCode(codeInputField.text, out var error))
					{
						codeInputField.text = "";
						NotificationToastUI.Instance?.Show("Friend Request Sent", "Your request has been sent.");
					}
					else
					{
						NotificationToastUI.Instance?.Show("Friend Request Failed", error);
					}
				}
			});
			Text val4 = CreateText(addFriendRoot.transform, "PENDING REQUESTS", 12, (TextAnchor)3, (FontStyle)1);
			SetTop(((Component)val4).GetComponent<RectTransform>(), new Vector2(0f, -68f), new Vector2(size.x, 20f));
			GameObject val5 = CreateScrollView(addFriendRoot.transform, out addFriendRequestsContent);
			SetTop(val5.GetComponent<RectTransform>(), new Vector2(0f, -92f), new Vector2(size.x, size.y - 92f));
		}

		private void ShowTab(int index)
		{
			//IL_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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)
			steamFriendsScroll.SetActive(index == 0);
			codeFriendsScroll.SetActive(index == 1);
			addFriendRoot.SetActive(index == 2);
			invitesScroll.SetActive(index == 3);
			((Graphic)((Component)tabSteam).GetComponent<Image>()).color = ((index == 0) ? TabActive : TabInactive);
			((Graphic)((Component)tabCode).GetComponent<Image>()).color = ((index == 1) ? TabActive : TabInactive);
			((Graphic)((Component)tabAdd).GetComponent<Image>()).color = ((index == 2) ? TabActive : TabInactive);
			((Graphic)((Component)tabInvites).GetComponent<Image>()).color = ((index == 3) ? TabActive : TabInactive);
		}

		private void RebuildSteamFriends()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject steamFriendRow in steamFriendRows)
			{
				Object.Destroy((Object)(object)steamFriendRow);
			}
			steamFriendRows.Clear();
			if ((Object)(object)SteamSocialService.Instance == (Object)null)
			{
				return;
			}
			foreach (FriendEntry friend in SteamSocialService.Instance.Friends)
			{
				steamFriendRows.Add(FriendRowUI.Create(steamFriendsContent.transform, friend, RowBg));
			}
		}

		private void RebuildCodeFriends()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject codeFriendRow in codeFriendRows)
			{
				Object.Destroy((Object)(object)codeFriendRow);
			}
			codeFriendRows.Clear();
			if ((Object)(object)CodeFriendService.Instance == (Object)null)
			{
				return;
			}
			foreach (CodeFriendEntry friend in CodeFriendService.Instance.Friends)
			{
				codeFriendRows.Add(CodeFriendRowUI.Create(codeFriendsContent.transform, friend, RowBg));
			}
		}

		private void RebuildRequests()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject requestRow in requestRows)
			{
				Object.Destroy((Object)(object)requestRow);
			}
			requestRows.Clear();
			if ((Object)(object)CodeFriendService.Instance == (Object)null)
			{
				return;
			}
			foreach (PendingFriendRequest incomingRequest in CodeFriendService.Instance.IncomingRequests)
			{
				requestRows.Add(FriendRequestRowUI.Create(addFriendRequestsContent.transform, incomingRequest, RowBg));
			}
			foreach (PendingFriendRequest outgoingRequest in CodeFriendService.Instance.OutgoingRequests)
			{
				requestRows.Add(FriendRequestRowUI.Create(addFriendRequestsContent.transform, outgoingRequest, RowBg));
			}
		}

		private void RebuildInvites()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject inviteRow in inviteRows)
			{
				Object.Destroy((Object)(object)inviteRow);
			}
			inviteRows.Clear();
			if ((Object)(object)SteamSocialService.Instance == (Object)null)
			{
				return;
			}
			int count = SteamSocialService.Instance.Invites.Count;
			((Component)((Component)invitesBadge).transform.parent).gameObject.SetActive(count > 0);
			invitesBadge.text = count.ToString();
			foreach (IncomingInvite invite in SteamSocialService.Instance.Invites)
			{
				inviteRows.Add(InviteRowUI.Create(invitesContent.transform, invite, RowBg));
			}
		}

		private GameObject CreatePanel(Transform parent, Vector2 size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0022: 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_0058: 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)
			GameObject val = new GameObject("SocialPanel");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = size;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = PanelBg;
			Outline val4 = val.AddComponent<Outline>();
			((Shadow)val4).effectColor = new Color(0.4f, 0.55f, 0.8f, 0.6f);
			((Shadow)val4).effectDistance = new Vector2(1f, -1f);
			return val;
		}

		private Button CreateTabButton(Transform parent, string label, Vector2 pos, float width)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00c9: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Tab_" + label);
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0f, 1f);
			val2.anchorMax = new Vector2(0f, 1f);
			val2.pivot = new Vector2(0f, 1f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(width, 28f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = TabInactive;
			Button val4 = val.AddComponent<Button>();
			ColorBlock colors = ((Selectable)val4).colors;
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.85f, 0.85f, 0.85f, 1f);
			((Selectable)val4).colors = colors;
			((Selectable)val4).targetGraphic = (Graphic)(object)val3;
			Text val5 = CreateText(val.transform, label, 11, (TextAnchor)4, (FontStyle)0);
			val5.horizontalOverflow = (HorizontalWrapMode)0;
			val5.verticalOverflow = (VerticalWrapMode)0;
			RectTransform component = ((Component)val5).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val4;
		}

		private GameObject CreateScrollView(Transform parent, out GameObject content)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			GameObject val = new GameObject("ScrollView");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0f, 0f, 0f, 0.15f);
			ScrollRect val4 = val.AddComponent<ScrollRect>();
			val4.horizontal = false;
			val4.vertical = true;
			val4.movementType = (MovementType)2;
			val4.scrollSensitivity = 24f;
			GameObject val5 = new GameObject("Viewport");
			val5.transform.SetParent(val.transform, false);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			((Graphic)val5.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
			val5.AddComponent<Mask>().showMaskGraphic = false;
			content = new GameObject("Content");
			content.transform.SetParent(val5.transform, false);
			RectTransform val7 = content.AddComponent<RectTransform>();
			val7.anchorMin = new Vector2(0f, 1f);
			val7.anchorMax = new Vector2(1f, 1f);
			val7.pivot = new Vector2(0.5f, 1f);
			val7.anchoredPosition = Vector2.zero;
			val7.sizeDelta = new Vector2(0f, 0f);
			VerticalLayoutGroup val8 = content.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val8).spacing = 6f;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true;
			((LayoutGroup)val8).padding = new RectOffset(4, 4, 4, 4);
			ContentSizeFitter val9 = content.AddComponent<ContentSizeFitter>();
			val9.verticalFit = (FitMode)2;
			val4.viewport = val6;
			val4.content = val7;
			return val;
		}

		private InputField CreateInputField(Transform parent, string placeholder)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_008c: 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_00b7: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0154: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("InputField");
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.08f, 0.1f, 0.16f, 1f);
			InputField val3 = val.AddComponent<InputField>();
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform, false);
			Text val5 = val4.AddComponent<Text>();
			val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val5.fontSize = 13;
			((Graphic)val5).color = Color.white;
			val5.alignment = (TextAnchor)3;
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(8f, 2f);
			component.offsetMax = new Vector2(-8f, -2f);
			GameObject val6 = new GameObject("Placeholder");
			val6.transform.SetParent(val.transform, false);
			Text val7 = val6.AddComponent<Text>();
			val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val7.fontSize = 13;
			val7.fontStyle = (FontStyle)2;
			((Graphic)val7).color = new Color(1f, 1f, 1f, 0.4f);
			val7.text = placeholder;
			val7.alignment = (TextAnchor)3;
			RectTransform component2 = val6.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(8f, 2f);
			component2.offsetMax = new Vector2(-8f, -2f);
			val3.textComponent = val5;
			val3.placeholder = (Graphic)(object)val7;
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			return val3;
		}

		private Text CreateText(Transform parent, string value, int size, TextAnchor alignment, FontStyle style)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Text");
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			Text val2 = val.AddComponent<Text>();
			val2.text = value;
			val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val2.fontSize = size;
			val2.fontStyle = style;
			val2.alignment = alignment;
			((Graphic)val2).color = Color.white;
			val2.horizontalOverflow = (HorizontalWrapMode)0;
			return val2;
		}

		private void SetTop(RectTransform rect, Vector2 pos, Vector2 size)
		{
			//IL_000c: 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_0038: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(0f, 1f);
			rect.pivot = new Vector2(0f, 1f);
			rect.anchoredPosition = pos;
			rect.sizeDelta = size;
		}
	}
	public enum FriendPlayState
	{
		Offline,
		OnlineElsewhere,
		PlayingThisGame
	}
	public class FriendEntry
	{
		public CSteamID SteamId;

		public string Name;

		public FriendPlayState State;

		public CSteamID LobbyId;

		public Texture2D Avatar;
	}
	public class IncomingInvite
	{
		public CSteamID FromSteamId;

		public string FromName;

		public CSteamID LobbyId;

		public float ReceivedAt;
	}
	public class SteamSocialService : MonoBehaviour
	{
		public readonly List<FriendEntry> Friends = new List<FriendEntry>();

		public readonly List<IncomingInvite> Invites = new List<IncomingInvite>();

		private readonly Dictionary<ulong, Texture2D> avatarCache = new Dictionary<ulong, Texture2D>();

		private Callback<PersonaStateChange_t> personaStateCallback;

		private Callback<AvatarImageLoaded_t> avatarLoadedCallback;

		private Callback<LobbyInvite_t> lobbyInviteCallback;

		private float nextRefreshTime;

		private const float RefreshInterval = 15f;

		public static SteamSocialService Instance { get; private set; }

		public event Action OnFriendsRefreshed;

		public event Action<IncomingInvite> OnInviteReceived;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			if (!SteamManagerReady())
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Steam client not initialized, service disabled.");
				((Behaviour)this).enabled = false;
				return;
			}
			personaStateCallback = Callback<PersonaStateChange_t>.Create((DispatchDelegate<PersonaStateChange_t>)OnPersonaStateChange);
			avatarLoadedCallback = Callback<AvatarImageLoaded_t>.Create((DispatchDelegate<AvatarImageLoaded_t>)OnAvatarLoaded);
			lobbyInviteCallback = Callback<LobbyInvite_t>.Create((DispatchDelegate<LobbyInvite_t>)OnLobbyInvite);
			RefreshFriends();
		}

		private bool SteamManagerReady()
		{
			try
			{
				return SteamAPI.IsSteamRunning();
			}
			catch
			{
				return false;
			}
		}

		private void Update()
		{
			if (Time.unscaledTime >= nextRefreshTime)
			{
				nextRefreshTime = Time.unscaledTime + 15f;
				RefreshFriends();
			}
		}

		public void RefreshFriends()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			Friends.Clear();
			int friendCount = SteamFriends.GetFriendCount((EFriendFlags)4);
			FriendGameInfo_t val = default(FriendGameInfo_t);
			for (int i = 0; i < friendCount; i++)
			{
				CSteamID friendByIndex = SteamFriends.GetFriendByIndex(i, (EFriendFlags)4);
				FriendEntry friendEntry = new FriendEntry
				{
					SteamId = friendByIndex,
					Name = SteamFriends.GetFriendPersonaName(friendByIndex),
					State = FriendPlayState.Offline
				};
				EPersonaState friendPersonaState = SteamFriends.GetFriendPersonaState(friendByIndex);
				if ((int)friendPersonaState > 0)
				{
					friendEntry.State = FriendPlayState.OnlineElsewhere;
				}
				if (SteamFriends.GetFriendGamePlayed(friendByIndex, ref val) && ((CGameID)(ref val.m_gameID)).AppID() == SteamUtils.GetAppID())
				{
					friendEntry.State = FriendPlayState.PlayingThisGame;
					friendEntry.LobbyId = val.m_steamIDLobby;
				}
				friendEntry.Avatar = GetOrRequestAvatar(friendByIndex);
				Friends.Add(friendEntry);
			}
			Friends.Sort(delegate(FriendEntry a, FriendEntry b)
			{
				int num = rank(a).CompareTo(rank(b));
				return (num != 0) ? num : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
			});
			this.OnFriendsRefreshed?.Invoke();
			static int rank(FriendEntry e)
			{
				return (e.State != FriendPlayState.PlayingThisGame) ? ((e.State == FriendPlayState.OnlineElsewhere) ? 1 : 2) : 0;
			}
		}

		private Texture2D GetOrRequestAvatar(CSteamID id)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (avatarCache.TryGetValue(id.m_SteamID, out var value))
			{
				return value;
			}
			int mediumFriendAvatar = SteamFriends.GetMediumFriendAvatar(id);
			if (mediumFriendAvatar == -1)
			{
				return null;
			}
			Texture2D val = ConvertAvatarHandle(mediumFriendAvatar);
			if ((Object)(object)val != (Object)null)
			{
				avatarCache[id.m_SteamID] = val;
			}
			return val;
		}

		private Texture2D ConvertAvatarHandle(int imageHandle)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			uint num = default(uint);
			uint num2 = default(uint);
			if (!SteamUtils.GetImageSize(imageHandle, ref num, ref num2) || num == 0 || num2 == 0)
			{
				return null;
			}
			byte[] array = new byte[num * num2 * 4];
			if (!SteamUtils.GetImageRGBA(imageHandle, array, array.Length))
			{
				return null;
			}
			Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false);
			byte[] array2 = new byte[array.Length];
			int num3 = (int)(num * 4);
			for (int i = 0; i < num2; i++)
			{
				Array.Copy(array, i * num3, array2, (int)(num2 - 1 - i) * num3, num3);
			}
			val.LoadRawTextureData(array2);
			val.Apply();
			return val;
		}

		private void OnAvatarLoaded(AvatarImageLoaded_t callback)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = ConvertAvatarHandle(callback.m_iImage);
			if (!((Object)(object)val == (Object)null))
			{
				avatarCache[callback.m_steamID.m_SteamID] = val;
				FriendEntry friendEntry = Friends.Find((FriendEntry f) => f.SteamId.m_SteamID == callback.m_steamID.m_SteamID);
				if (friendEntry != null)
				{
					friendEntry.Avatar = val;
					this.OnFriendsRefreshed?.Invoke();
				}
			}
		}

		private void OnPersonaStateChange(PersonaStateChange_t callback)
		{
			RefreshFriends();
		}

		private void OnLobbyInvite(LobbyInvite_t callback)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			CSteamID fromId = new CSteamID(callback.m_ulSteamIDUser);
			CSteamID lobbyId = default(CSteamID);
			((CSteamID)(ref lobbyId))..ctor(callback.m_ulSteamIDLobby);
			IncomingInvite incomingInvite = new IncomingInvite
			{
				FromSteamId = fromId,
				FromName = SteamFriends.GetFriendPersonaName(fromId),
				LobbyId = lobbyId,
				ReceivedAt = Time.unscaledTime
			};
			Invites.RemoveAll((IncomingInvite i) => i.FromSteamId.m_SteamID == fromId.m_SteamID);
			Invites.Insert(0, incomingInvite);
			this.OnInviteReceived?.Invoke(incomingInvite);
		}

		public void InviteFriend(CSteamID friendId)
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (SteamManager.CurrentLobbyID == CSteamID.Nil)
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Can't invite: not currently in a lobby.");
			}
			else
			{
				SteamMatchmaking.InviteUserToLobby(SteamManager.CurrentLobbyID, friendId);
			}
		}

		public void JoinFriend(CSteamID friendId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			FriendEntry friendEntry = Friends.Find((FriendEntry f) => f.SteamId.m_SteamID == friendId.m_SteamID);
			if (friendEntry == null || friendEntry.LobbyId == CSteamID.Nil)
			{
				Plugin.Log.LogWarning((object)"[SocialMod] Can't join: friend is not currently in a lobby (probably in the main menu).");
			}
			else
			{
				JoinLobby(friendEntry.LobbyId);
			}
		}

		public void JoinLobby(CSteamID lobbyId)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SteamManager.JoinLobby(lobbyId.m_SteamID);
		}
	}
	internal class UIDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public RectTransform Target;

		public Canvas OwnerCanvas;

		public string SavePrefsPrefix;

		public void OnBeginDrag(PointerEventData eventData)
		{
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null))
			{
				float num = (((Object)(object)OwnerCanvas != (Object)null) ? OwnerCanvas.scaleFactor : 1f);
				if (num <= 0f)
				{
					num = 1f;
				}
				RectTransform target = Target;
				target.anchoredPosition += eventData.delta / num;
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null) && !string.IsNullOrEmpty(SavePrefsPrefix))
			{
				PlayerPrefs.SetFloat(SavePrefsPrefix + "_X", Target.anchoredPosition.x);
				PlayerPrefs.SetFloat(SavePrefsPrefix + "_Y", Target.anchoredPosition.y);
				PlayerPrefs.Save();
			}
		}
	}
	internal static class UISpriteFactory
	{
		private static Sprite circleSprite;

		public static Sprite CircleSprite
		{
			get
			{
				if ((Object)(object)circleSprite == (Object)null)
				{
					circleSprite = CreateCircle(32);
				}
				return circleSprite;
			}
		}

		private static Sprite CreateCircle(int diameter)
		{
			/