Decompiled source of RPNames v1.6.0

RPNames.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeTalker;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Marioalexsan.Multitool.SaveUtils;
using Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using Newtonsoft.Json;
using RPNames.Packets;
using Steamworks;
using TMPro;
using UnityEngine;
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("s0apy.RPNames.sftwre")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.6.0+363211c905fcfc51d9a04bfa05adc93bcc565188")]
[assembly: AssemblyProduct("RPNames")]
[assembly: AssemblyTitle("RPNames")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 RPNames
{
	public class CharacterTitleProfile
	{
		[JsonIgnore]
		public uint TargetNetID { get; set; }

		public string Title { get; set; } = "";

		public BracketType BracketStyle { get; set; } = BracketType.Parentheses;

		public TextAnimationType TextAnimation { get; set; } = TextAnimationType.Static;

		public ColoringType Coloring { get; set; } = ColoringType.None;

		public float AnimationSpeed { get; set; } = 0.25f;

		public int MarqueeWidth { get; set; } = 16;

		public string SingleHexColor { get; set; } = "FFFFFF";

		public string GradientStartColor { get; set; } = "FF0000";

		public string GradientEndColor { get; set; } = "0000FF";

		public bool AnimateGradient { get; set; } = false;

		public float GradientSpread { get; set; } = 10f;

		public float RainbowWaveSpread { get; set; } = 15f;

		public float ColorAnimationSpeed { get; set; } = 1f;

		public string Pronouns { get; set; } = "";

		public bool ShowPronouns { get; set; } = false;

		public BracketType PronounBracketStyle { get; set; } = BracketType.Parentheses;

		public bool ShareTitleColoring { get; set; } = true;

		public ColoringType PronounColoring { get; set; } = ColoringType.None;

		public string PronounSingleHexColor { get; set; } = "FFFFFF";

		public string PronounGradientStartColor { get; set; } = "FF0000";

		public string PronounGradientEndColor { get; set; } = "0000FF";

		public bool PronounAnimateGradient { get; set; } = false;

		public float PronounGradientSpread { get; set; } = 10f;

		public float PronounRainbowWaveSpread { get; set; } = 15f;

		public float PronounColorAnimationSpeed { get; set; } = 1f;

		public bool TitleOnNewLine { get; set; } = true;

		public bool AddGapAboveTitle { get; set; } = true;
	}
	public class SteamNameState
	{
		public string Original = "";

		public bool HasOriginal;

		public string Applied = "";

		public List<string> AutoNames = new List<string>();

		public ulong SteamId;

		public long Stamp;
	}
	public class CharacterSaveData
	{
		public CharacterTitleProfile? Title;

		public SteamNameState? Steam;
	}
	public enum TextAnimationType
	{
		Static,
		Scroll,
		Marquee,
		Typewriter
	}
	public enum ColoringType
	{
		None,
		SingleColor,
		Rainbow,
		Gradient,
		Wave,
		StaticRainbow
	}
	public enum BracketType
	{
		None,
		Parentheses,
		SquareBrackets,
		Tilde,
		Dash,
		Plus,
		Equals,
		Asterisk,
		Dollar,
		Hash,
		Exclamation,
		Pipe
	}
	internal class PlayerTitleAnimator
	{
		public uint NetId;

		public float AnimationTimer = 0f;

		public int AnimationIndex = 0;

		public bool IsAnimatingForward = true;

		public float RainbowHue = 0f;

		public Main.TypewriterState TypewriterState = Main.TypewriterState.Typing;

		public float TypewriterPauseTimer = 0f;

		public bool TypewriterCursorVisible = true;

		public float TypewriterBlinkTimer = 0f;

		public PlayerTitleAnimator(uint netId)
		{
			NetId = netId;
		}
	}
	[BepInPlugin("s0apy.RPNames.sftwre", "RPNames", "1.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		internal enum TypewriterState
		{
			Typing,
			Blinking,
			Backspacing
		}

		private enum MenuState
		{
			Closed,
			Opening,
			Open,
			Closing
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static BinaryPacketListener <0>__OnProfileUpdate;

			public static BinaryPacketListener <1>__OnFullSync;

			public static PacketListener <2>__OnSyncRequest;
		}

		public static Main instance;

		internal static ManualLogSource Log;

		internal static bool IsReady = false;

		private static ConfigEntry<string> _characterProfilesJson;

		private static ConfigEntry<string> _customPresetsJson;

		private ConfigEntry<bool> _autoSetGlobalNameFromSteam = null;

		private SteamNameState _steamState = new SteamNameState();

		private Dictionary<int, CharacterTitleProfile> _legacyProfiles = new Dictionary<int, CharacterTitleProfile>();

		internal static bool UsingMultitool;

		private readonly Dictionary<Player, string> _originalGlobalNicknames = new Dictionary<Player, string>();

		private readonly Dictionary<Player, string> _appliedSteamPlayerNicknames = new Dictionary<Player, string>();

		private readonly HashSet<ulong> _requestedSteamUsers = new HashSet<ulong>();

		private float _globalNameRefreshTimer;

		private bool _steamNameUnavailableWarningLogged;

		internal Dictionary<int, CharacterTitleProfile> AllCharacterProfiles = new Dictionary<int, CharacterTitleProfile>();

		internal static int CurrentCharacterSlot = -1;

		private ConfigEntry<KeyCode> _menuKey;

		private Rect _windowRect = new Rect(20f, 20f, 360f, 850f);

		private CharacterTitleProfile _uiEditingProfile = new CharacterTitleProfile();

		private bool _showTextAnimPicker;

		private bool _showColoringPicker;

		private bool _showBracketPicker;

		private bool _showPronounBracketPicker;

		private bool _showPresetPicker;

		private bool _showPronounColoringPicker;

		private Vector2 _scrollPosition = Vector2.zero;

		private Vector2 _presetScrollPosition = Vector2.zero;

		private bool _showClearConfirmation = false;

		private string _newPresetName = "My New Style";

		internal static bool _isCodeTalkerLoaded = false;

		private static CharacterTitleProfile _copiedProfileBuffer = null;

		internal static Dictionary<uint, PlayerTitleAnimator> AllPlayerAnimators = new Dictionary<uint, PlayerTitleAnimator>();

		private Color _gradientStartColorCache;

		private Color _gradientEndColorCache;

		private static readonly List<string> _presetTitles = new List<string>();

		private static Dictionary<string, CharacterTitleProfile> _customPresets = new Dictionary<string, CharacterTitleProfile>();

		private bool _showSingleColorPicker;

		private bool _showGradientStartPicker;

		private bool _showGradientEndPicker;

		private bool _showPronounSingleColorPicker;

		private bool _showPronounGradientStartPicker;

		private bool _showPronounGradientEndPicker;

		private MenuState _menuState = MenuState.Closed;

		private float _animationProgress = 0f;

		private const float AnimationDuration = 0.25f;

		private bool _stylesInitialized = false;

		private GUISkin _modSkin;

		public static GUISkin OriginalSkin;

		private static bool _networkSendWarningLogged = false;

		private bool _pollWasInGame = false;

		private static string SteamStatePath => Path.Combine(Application.persistentDataPath, "RPNames_steam_state.json");

		private void Awake()
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_menuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1. General", "Menu Key", (KeyCode)289, "The key to press to show/hide the settings menu.");
			_autoSetGlobalNameFromSteam = ((BaseUnityPlugin)this).Config.Bind<bool>("Steamworks", "AutoSetGlobalNameFromSteam", true, "Use Steam persona names for the local global nickname and player name labels. Disabling may affect related functionality, but RPNames will continue to work; the choice is yours.");
			_characterProfilesJson = ((BaseUnityPlugin)this).Config.Bind<string>("2. Data", "CharacterProfiles", "{}", "Legacy storage. With Multitool installed, titles are saved with each character instead and this is only kept so old titles can be imported.");
			_customPresetsJson = ((BaseUnityPlugin)this).Config.Bind<string>("2. Data", "CustomPresetsFull", "{}", "Stores user-defined full title profiles (style presets).");
			UsingMultitool = TryRegisterMultitool();
			if (UsingMultitool)
			{
				LoadLegacyProfiles();
			}
			else
			{
				LoadProfiles();
			}
			LoadSteamState();
			LoadCustomPresets();
			PopulatePresetTitles();
			if (Type.GetType("CodeTalker.Networking.CodeTalkerNetwork, CodeTalker") != null)
			{
				_isCodeTalkerLoaded = true;
				object obj = <>O.<0>__OnProfileUpdate;
				if (obj == null)
				{
					BinaryPacketListener val = OnProfileUpdate;
					<>O.<0>__OnProfileUpdate = val;
					obj = (object)val;
				}
				CodeTalkerNetwork.RegisterBinaryListener<UpdateTitleProfilePacket>((BinaryPacketListener)obj);
				object obj2 = <>O.<1>__OnFullSync;
				if (obj2 == null)
				{
					BinaryPacketListener val2 = OnFullSync;
					<>O.<1>__OnFullSync = val2;
					obj2 = (object)val2;
				}
				CodeTalkerNetwork.RegisterBinaryListener<FullSyncPacket>((BinaryPacketListener)obj2);
				object obj3 = <>O.<2>__OnSyncRequest;
				if (obj3 == null)
				{
					PacketListener val3 = OnSyncRequest;
					<>O.<2>__OnSyncRequest = val3;
					obj3 = (object)val3;
				}
				CodeTalkerNetwork.RegisterListener<RequestAllTitlesPacket>((PacketListener)obj3);
			}
			try
			{
				InitEasySettings();
			}
			catch (Exception ex)
			{
				Log.LogInfo((object)("[RPNames] EasySettings not available, skipping the settings page (" + ex.GetType().Name + ")"));
			}
			Harmony.CreateAndPatchAll(typeof(HarmonyPatches), (string)null);
			Log.LogInfo((object)"[RPNames v1.6.0] has loaded.");
		}

		internal void QueueApplySteamGlobalName(CharacterSelectManager? characterSelect)
		{
			if (_autoSetGlobalNameFromSteam.Value || _steamState.HasOriginal)
			{
				((MonoBehaviour)this).StartCoroutine(ApplySteamGlobalNameAfterMenuUpdate(characterSelect));
			}
		}

		private IEnumerator ApplySteamGlobalNameAfterMenuUpdate(CharacterSelectManager? characterSelect)
		{
			yield return null;
			yield return (object)new WaitForSeconds(0.25f);
			if (IsGameUiInGame())
			{
				yield break;
			}
			if ((Object)(object)characterSelect == (Object)null)
			{
				characterSelect = Object.FindObjectOfType<CharacterSelectManager>();
				if ((Object)(object)characterSelect == (Object)null)
				{
					Log.LogWarning((object)"[RPNames] CharacterSelectManager not found while applying Steam global name.");
					yield break;
				}
			}
			InputField input = characterSelect._globalNickanmeInput;
			if ((Object)(object)input == (Object)null)
			{
				Log.LogWarning((object)"[RPNames] Character select global nickname input is not available.");
				yield break;
			}
			Log.LogInfo((object)("[RPNames] Nickname check: field='" + input.text + "', applied='" + _steamState.Applied + "', steam='" + GetLocalSteamName() + "'"));
			if (IsPreservingLocalNicknameInput(input))
			{
				yield break;
			}
			if (!_autoSetGlobalNameFromSteam.Value)
			{
				if (_steamState.HasOriginal)
				{
					if (input.text == _steamState.Applied)
					{
						SetGlobalNicknameInput(input, _steamState.Original);
					}
					ResetSteamState();
				}
				yield break;
			}
			string steamName = GetLocalSteamName();
			if (string.IsNullOrWhiteSpace(steamName))
			{
				LogSteamNameUnavailableOnce("Steam persona name is unavailable; the global nickname was not changed.");
				yield break;
			}
			_steamNameUnavailableWarningLogged = false;
			ulong steamId = GetLocalSteamId();
			if (!string.IsNullOrWhiteSpace(input.text))
			{
				if (input.text != steamName)
				{
					if (_steamState.SteamId != 0L && _steamState.SteamId != steamId)
					{
						Log.LogInfo((object)"[RPNames] Steam account changed, updating the global nickname.");
					}
					RememberAutoName(steamName, steamId);
					yield return ApplyNicknameWithRetry(input, steamName);
				}
				else if (_steamState.Applied != steamName || _steamState.SteamId != steamId)
				{
					RememberAutoName(steamName, steamId);
				}
			}
			else
			{
				_steamState.Original = input.text;
				_steamState.HasOriginal = true;
				RememberAutoName(steamName, steamId);
				yield return ApplyNicknameWithRetry(input, steamName);
			}
		}

		private void LoadSteamState()
		{
			try
			{
				if (File.Exists(SteamStatePath))
				{
					_steamState = JsonConvert.DeserializeObject<SteamNameState>(File.ReadAllText(SteamStatePath)) ?? new SteamNameState();
				}
			}
			catch
			{
				_steamState = new SteamNameState();
			}
		}

		private void SaveSteamState()
		{
			_steamState.Stamp = DateTime.UtcNow.Ticks;
			WriteSteamStateFile();
		}

		private void WriteSteamStateFile()
		{
			try
			{
				File.WriteAllText(SteamStatePath, JsonConvert.SerializeObject((object)_steamState));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[RPNames] Couldn't save Steam nickname state: " + ex.Message));
			}
		}

		private void ResetSteamState()
		{
			_steamState = new SteamNameState();
			SaveSteamState();
		}

		private static Type? FindType(string fullName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = assembly.GetType(fullName, throwOnError: false);
					if (type != null)
					{
						return type;
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private static bool TryRegisterMultitool()
		{
			if (FindType("Marioalexsan.Multitool.SaveUtils.SaveUtilsAPI") == null)
			{
				Log.LogWarning((object)"[RPNames] Multitool not found - titles fall back to the old cfg storage. Install Multitool to keep titles with each character.");
				return false;
			}
			try
			{
				MultitoolHook.Register();
				return true;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[RPNames] Multitool hook failed, using cfg storage: " + ex.Message));
				return false;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void InitEasySettings()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Settings.OnInitialized.AddListener(new UnityAction(AddSettings));
			Settings.OnApplySettings.AddListener(new UnityAction(OnSettingsApplied));
		}

		private void AddSettings()
		{
			SettingsTab modTab = Settings.ModTab;
			modTab.AddHeader("RPNames (Global)");
			modTab.AddToggle("Use Steam name as global nickname", _autoSetGlobalNameFromSteam);
			modTab.AddKeyButton("Menu Key", _menuKey);
		}

		internal void OnSettingsApplied()
		{
			((BaseUnityPlugin)this).Config.Save();
			QueueApplySteamGlobalName(null);
		}

		internal void OnCharacterLoaded(int slot, CharacterSaveData? data)
		{
			if (data?.Title == null)
			{
				AllCharacterProfiles.Remove(slot);
			}
			else
			{
				AllCharacterProfiles[slot] = data.Title;
			}
			if (data?.Steam != null && data.Steam.Stamp > _steamState.Stamp)
			{
				_steamState = data.Steam;
				WriteSteamStateFile();
			}
		}

		internal CharacterSaveData? OnCharacterSaving(int slot)
		{
			AllCharacterProfiles.TryGetValue(slot, out CharacterTitleProfile value);
			SteamNameState steamNameState = null;
			if (_steamState.Stamp > 0)
			{
				steamNameState = new SteamNameState
				{
					Original = _steamState.Original,
					HasOriginal = _steamState.HasOriginal,
					Applied = _steamState.Applied,
					AutoNames = new List<string>(_steamState.AutoNames),
					SteamId = _steamState.SteamId,
					Stamp = _steamState.Stamp
				};
			}
			if (value == null && steamNameState == null)
			{
				return null;
			}
			return new CharacterSaveData
			{
				Title = value,
				Steam = steamNameState
			};
		}

		internal void OnCharacterDeleted(int slot)
		{
			AllCharacterProfiles.Remove(slot);
		}

		private void LoadLegacyProfiles()
		{
			try
			{
				Dictionary<int, CharacterTitleProfile> dictionary = JsonConvert.DeserializeObject<Dictionary<int, CharacterTitleProfile>>(_characterProfilesJson.Value);
				if (dictionary != null)
				{
					_legacyProfiles = dictionary;
				}
			}
			catch
			{
				_legacyProfiles = new Dictionary<int, CharacterTitleProfile>();
			}
		}

		private void SaveLegacyProfiles()
		{
			_characterProfilesJson.Value = JsonConvert.SerializeObject((object)_legacyProfiles);
			((BaseUnityPlugin)this).Config.Save();
		}

		private static void SetGlobalNicknameInput(InputField input, string text)
		{
			if (!(input.text == text))
			{
				input.text = text;
				((UnityEvent<string>)(object)input.onEndEdit).Invoke(text);
			}
		}

		private void RefreshSteamGlobalNames()
		{
			if (IsGameUiInGame())
			{
				return;
			}
			if (!_autoSetGlobalNameFromSteam.Value)
			{
				foreach (KeyValuePair<Player, string> originalGlobalNickname in _originalGlobalNicknames)
				{
					if ((Object)(object)originalGlobalNickname.Key != (Object)null && _appliedSteamPlayerNicknames.TryGetValue(originalGlobalNickname.Key, out string value) && originalGlobalNickname.Key._globalNickname == value)
					{
						originalGlobalNickname.Key._globalNickname = originalGlobalNickname.Value;
					}
				}
				_originalGlobalNicknames.Clear();
				_appliedSteamPlayerNicknames.Clear();
				return;
			}
			Player[] array = Object.FindObjectsOfType<Player>();
			foreach (Player val in array)
			{
				if ((Object)(object)val == (Object)null || !ulong.TryParse(val._steamID, out var result) || (((NetworkBehaviour)val).isLocalPlayer && IsPreservingLocalNicknameInput()))
				{
					continue;
				}
				string text = (((NetworkBehaviour)val).isLocalPlayer ? GetLocalSteamName() : GetSteamName(result));
				if (string.IsNullOrWhiteSpace(text))
				{
					continue;
				}
				bool flag = _originalGlobalNicknames.ContainsKey(val);
				if (flag && (!_appliedSteamPlayerNicknames.TryGetValue(val, out string value2) || val._globalNickname != value2))
				{
					_originalGlobalNicknames.Remove(val);
					_appliedSteamPlayerNicknames.Remove(val);
					flag = false;
					if (!string.IsNullOrWhiteSpace(val._globalNickname))
					{
						continue;
					}
				}
				if (!flag)
				{
					if (!string.IsNullOrWhiteSpace(val._globalNickname))
					{
						continue;
					}
					_originalGlobalNicknames[val] = val._globalNickname;
				}
				if (val._globalNickname != text)
				{
					val._globalNickname = text;
				}
				_appliedSteamPlayerNicknames[val] = text;
			}
			foreach (Player item in _originalGlobalNicknames.Keys.Where((Player player) => (Object)(object)player == (Object)null).ToList())
			{
				_originalGlobalNicknames.Remove(item);
				_appliedSteamPlayerNicknames.Remove(item);
			}
		}

		private bool IsPreservingLocalNicknameInput(InputField? input = null)
		{
			if (input == null)
			{
				input = Object.FindObjectOfType<CharacterSelectManager>()?._globalNickanmeInput;
			}
			if ((Object)(object)input == (Object)null)
			{
				return false;
			}
			return input.isFocused || (!string.IsNullOrWhiteSpace(input.text) && !IsAutoName(input.text));
		}

		private bool IsAutoName(string text)
		{
			return text == _steamState.Applied || _steamState.AutoNames.Contains(text) || text == GetLocalSteamName();
		}

		private void RememberAutoName(string name, ulong steamId)
		{
			_steamState.Applied = name;
			_steamState.SteamId = steamId;
			if (!_steamState.AutoNames.Contains(name))
			{
				_steamState.AutoNames.Add(name);
			}
			if (_steamState.AutoNames.Count > 8)
			{
				_steamState.AutoNames.RemoveAt(0);
			}
			SaveSteamState();
		}

		private IEnumerator ApplyNicknameWithRetry(InputField input, string name)
		{
			for (int attempt = 1; attempt <= 3; attempt++)
			{
				if ((Object)(object)input == (Object)null)
				{
					break;
				}
				SetGlobalNicknameInput(input, name);
				yield return (object)new WaitForSeconds(0.5f);
				if ((Object)(object)input == (Object)null)
				{
					break;
				}
				if (input.text == name)
				{
					Log.LogInfo((object)("[RPNames] Global nickname set to '" + name + "'."));
					break;
				}
				if (input.isFocused)
				{
					break;
				}
				Log.LogInfo((object)$"[RPNames] Nickname field went back to '{input.text}', retrying ({attempt}/3).");
			}
		}

		private static ulong GetLocalSteamId()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!SteamManager.Initialized)
			{
				return 0uL;
			}
			return SteamUser.GetSteamID().m_SteamID;
		}

		private static string? GetLocalSteamName()
		{
			if (!SteamManager.Initialized)
			{
				return null;
			}
			return SteamFriends.GetPersonaName();
		}

		private string? GetSteamName(ulong steamId)
		{
			//IL_0019: 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)
			if (!SteamAPI.IsSteamRunning())
			{
				return null;
			}
			CSteamID val = default(CSteamID);
			((CSteamID)(ref val))..ctor(steamId);
			string friendPersonaName = SteamFriends.GetFriendPersonaName(val);
			if (string.IsNullOrWhiteSpace(friendPersonaName) || friendPersonaName == "[unknown]")
			{
				if (_requestedSteamUsers.Add(steamId))
				{
					SteamFriends.RequestUserInformation(val, true);
				}
				return null;
			}
			return friendPersonaName;
		}

		private void LogSteamNameUnavailableOnce(string message)
		{
			if (!_steamNameUnavailableWarningLogged)
			{
				Log.LogWarning((object)("[RPNames] " + message));
				_steamNameUnavailableWarningLogged = true;
			}
		}

		private static bool IsGameUiInGame()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			return (Object)(object)Player._mainPlayer != (Object)null && (int)Player._mainPlayer._currentGameCondition == 1;
		}

		private void InitializeGUIStyles()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00b4: 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_00d4: 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_00e7: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0116: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: 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_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Expected O, but got Unknown
			//IL_02ce: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Expected O, but got Unknown
			//IL_02fb: Expected O, but got Unknown
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Expected O, but got Unknown
			//IL_03cd: Expected O, but got Unknown
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_0429: Expected O, but got Unknown
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: 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_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: 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)
			//IL_04cb: Expected O, but got Unknown
			if ((Object)(object)OriginalSkin == (Object)null)
			{
				OriginalSkin = GUI.skin;
			}
			_modSkin = Object.Instantiate<GUISkin>(GUI.skin);
			GUISkin modSkin = _modSkin;
			GUIStyle val = new GUIStyle(GUI.skin.window);
			val.normal.background = MakeTex(new Color(0.1f, 0.12f, 0.15f, 0.97f));
			val.normal.textColor = new Color(0.9f, 0.9f, 0.9f);
			val.onNormal.background = MakeTex(new Color(0.1f, 0.12f, 0.15f, 0.97f));
			val.onNormal.textColor = new Color(0.9f, 0.9f, 0.9f);
			val.padding = new RectOffset(15, 15, 30, 15);
			val.border = new RectOffset(2, 2, 2, 2);
			val.alignment = (TextAnchor)1;
			val.fontSize = 16;
			val.fontStyle = (FontStyle)1;
			modSkin.window = val;
			GUISkin modSkin2 = _modSkin;
			GUIStyle val2 = new GUIStyle(GUI.skin.box);
			val2.normal.background = MakeTex(new Color(0.2f, 0.22f, 0.25f, 0.5f));
			modSkin2.box = val2;
			_modSkin.label.normal.textColor = new Color(0.85f, 0.85f, 0.85f);
			GUISkin modSkin3 = _modSkin;
			GUIStyle val3 = new GUIStyle(GUI.skin.button);
			val3.normal.background = MakeTex(new Color(0.3f, 0.35f, 0.4f));
			val3.normal.textColor = Color.white;
			val3.hover.background = MakeTex(new Color(0.4f, 0.45f, 0.5f));
			val3.hover.textColor = Color.white;
			val3.active.background = MakeTex(new Color(0.2f, 0.25f, 0.3f));
			val3.active.textColor = Color.white;
			val3.onNormal.background = MakeTex(new Color(0.5f, 0.55f, 0.6f));
			val3.onNormal.textColor = Color.white;
			val3.onHover.background = MakeTex(new Color(0.55f, 0.6f, 0.65f));
			val3.onHover.textColor = Color.white;
			val3.border = new RectOffset(4, 4, 4, 4);
			val3.padding = new RectOffset(8, 8, 8, 8);
			modSkin3.button = val3;
			_modSkin.toggle = new GUIStyle(_modSkin.toggle)
			{
				padding = new RectOffset(25, 0, 3, 3)
			};
			_modSkin.toggle.normal.background = MakeToggleTex(on: false);
			_modSkin.toggle.onNormal.background = MakeToggleTex(on: true);
			_modSkin.toggle.hover.background = MakeToggleTex(on: false);
			_modSkin.toggle.onHover.background = MakeToggleTex(on: true);
			GUISkin modSkin4 = _modSkin;
			GUIStyle val4 = new GUIStyle(GUI.skin.textField);
			val4.normal.background = MakeTex(new Color(0.05f, 0.05f, 0.05f));
			val4.normal.textColor = Color.white;
			val4.padding = new RectOffset(5, 5, 5, 5);
			modSkin4.textField = val4;
			GUISkin modSkin5 = _modSkin;
			GUIStyle val5 = new GUIStyle(GUI.skin.horizontalSlider);
			val5.normal.background = MakeTex(new Color(0.15f, 0.17f, 0.2f));
			val5.fixedHeight = 10f;
			val5.border = new RectOffset(2, 2, 2, 2);
			modSkin5.horizontalSlider = val5;
			GUISkin modSkin6 = _modSkin;
			GUIStyle val6 = new GUIStyle(GUI.skin.horizontalSliderThumb);
			val6.normal.background = MakeTex(new Color(0.6f, 0.65f, 0.7f));
			val6.hover.background = MakeTex(new Color(0.7f, 0.75f, 0.8f));
			val6.active.background = MakeTex(new Color(0.5f, 0.55f, 0.6f));
			val6.fixedHeight = 18f;
			val6.fixedWidth = 10f;
			modSkin6.horizontalSliderThumb = val6;
			_stylesInitialized = true;
			static Texture2D MakeTex(Color col)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val7 = new Texture2D(1, 1);
				val7.SetPixel(0, 0, col);
				val7.Apply();
				((Object)val7).hideFlags = (HideFlags)61;
				return val7;
			}
			static Texture2D MakeToggleTex(bool on)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val7 = new Texture2D(16, 16);
				Color val8 = default(Color);
				((Color)(ref val8))..ctor(0.2f, 0.22f, 0.25f);
				Color val9 = default(Color);
				((Color)(ref val9))..ctor(0.4f, 0.45f, 0.5f);
				Color val10 = default(Color);
				((Color)(ref val10))..ctor(0.8f, 0.85f, 0.9f);
				for (int i = 0; i < 16; i++)
				{
					for (int j = 0; j < 16; j++)
					{
						if (j < 1 || j > 14 || i < 1 || i > 14)
						{
							val7.SetPixel(j, i, val9);
						}
						else
						{
							val7.SetPixel(j, i, val8);
						}
					}
				}
				if (on)
				{
					for (int k = 4; k < 12; k++)
					{
						for (int l = 4; l < 12; l++)
						{
							val7.SetPixel(l, k, val10);
						}
					}
				}
				val7.Apply();
				((Object)val7).hideFlags = (HideFlags)61;
				return val7;
			}
		}

		private void LoadProfiles()
		{
			try
			{
				Dictionary<int, CharacterTitleProfile> dictionary = JsonConvert.DeserializeObject<Dictionary<int, CharacterTitleProfile>>(_characterProfilesJson.Value);
				if (dictionary != null)
				{
					AllCharacterProfiles = dictionary;
				}
			}
			catch
			{
				AllCharacterProfiles = new Dictionary<int, CharacterTitleProfile>();
			}
		}

		private void SaveProfiles()
		{
			if (!UsingMultitool)
			{
				_characterProfilesJson.Value = JsonConvert.SerializeObject((object)AllCharacterProfiles, (Formatting)1);
				((BaseUnityPlugin)this).Config.Save();
			}
		}

		private void LoadCustomPresets()
		{
			try
			{
				Dictionary<string, CharacterTitleProfile> dictionary = JsonConvert.DeserializeObject<Dictionary<string, CharacterTitleProfile>>(_customPresetsJson.Value);
				if (dictionary != null)
				{
					_customPresets = dictionary;
				}
			}
			catch
			{
				_customPresets = new Dictionary<string, CharacterTitleProfile>();
			}
		}

		private void SaveCustomPresets()
		{
			_customPresetsJson.Value = JsonConvert.SerializeObject((object)_customPresets, (Formatting)1);
			((BaseUnityPlugin)this).Config.Save();
		}

		private void PopulatePresetTitles()
		{
			_presetTitles.Clear();
			_presetTitles.AddRange(new string[14]
			{
				"The Explorer", "The Patient", "Dragonslayer", "Scarab Lord", "The Undying", "The Insane", "Grand Marshal", "High Warlord", "Arena Master", "Salty",
				"Chef", "Guardian of Cenarius", "Hand of A'dal", "Master Angler"
			});
		}

		public static void OnProfileUpdate(PacketHeader header, BinaryPacketBase packet)
		{
			if (packet is UpdateTitleProfilePacket updateTitleProfilePacket)
			{
				Player val = ((IEnumerable<Player>)Object.FindObjectsOfType<Player>()).FirstOrDefault((Func<Player, bool>)((Player x) => x._steamID == header.SenderID.ToString()));
				if ((Object)(object)val != (Object)null)
				{
					ApplyProfileUpdate(((NetworkBehaviour)val).netId, updateTitleProfilePacket.Profile);
				}
			}
		}

		public static void OnFullSync(PacketHeader header, BinaryPacketBase packet)
		{
			if (!(packet is FullSyncPacket fullSyncPacket))
			{
				return;
			}
			Log.LogInfo((object)$"[RPNames] Received full-sync with {fullSyncPacket.AllProfiles?.Count ?? 0} profile(s).");
			List<uint> list = HarmonyPatches.PlayerProfiles.Keys.ToList();
			foreach (uint item in list)
			{
				if (!fullSyncPacket.AllProfiles.ContainsKey(item))
				{
					ApplyProfileUpdate(item, null);
				}
			}
			foreach (KeyValuePair<uint, CharacterTitleProfile> allProfile in fullSyncPacket.AllProfiles)
			{
				ApplyProfileUpdate(allProfile.Key, allProfile.Value);
			}
		}

		private static void ApplyProfileUpdate(uint netId, CharacterTitleProfile profile)
		{
			if (profile == null || (string.IsNullOrEmpty(profile.Title) && (!profile.ShowPronouns || string.IsNullOrEmpty(profile.Pronouns))))
			{
				if (HarmonyPatches.PlayerProfiles.ContainsKey(netId))
				{
					HarmonyPatches.PlayerProfiles.Remove(netId);
				}
				if (HarmonyPatches.CurrentPlayerTitles.ContainsKey(netId))
				{
					HarmonyPatches.CurrentPlayerTitles.Remove(netId);
				}
				if (AllPlayerAnimators.ContainsKey(netId))
				{
					AllPlayerAnimators.Remove(netId);
				}
				return;
			}
			profile.TargetNetID = netId;
			if (HarmonyPatches.PlayerProfiles.ContainsKey(netId))
			{
				HarmonyPatches.PlayerProfiles[netId] = profile;
			}
			else
			{
				HarmonyPatches.PlayerProfiles.Add(netId, profile);
			}
			if (AllPlayerAnimators.ContainsKey(netId))
			{
				AllPlayerAnimators.Remove(netId);
			}
			if (instance.ShouldAnimate(profile))
			{
				PlayerTitleAnimator playerTitleAnimator = new PlayerTitleAnimator(netId);
				AllPlayerAnimators.Add(netId, playerTitleAnimator);
				string animatedText = instance.GetAnimatedText(profile, playerTitleAnimator);
				if (HarmonyPatches.CurrentPlayerTitles.ContainsKey(netId))
				{
					HarmonyPatches.CurrentPlayerTitles[netId] = animatedText;
				}
				else
				{
					HarmonyPatches.CurrentPlayerTitles.Add(netId, animatedText);
				}
			}
			else if (HarmonyPatches.CurrentPlayerTitles.ContainsKey(netId))
			{
				HarmonyPatches.CurrentPlayerTitles[netId] = profile.Title;
			}
			else
			{
				HarmonyPatches.CurrentPlayerTitles.Add(netId, profile.Title);
			}
		}

		private static bool TrySend(Action send)
		{
			try
			{
				send();
				return true;
			}
			catch (Exception ex)
			{
				if (!_networkSendWarningLogged)
				{
					Log.LogWarning((object)("[RPNames] Couldn't send a network packet (Steamworks may not be initialized) — networked titles will be disabled until this resolves. " + ex.GetType().Name + ": " + ex.Message));
					_networkSendWarningLogged = true;
				}
				return false;
			}
		}

		public static void OnSyncRequest(PacketHeader header, PacketBase packet)
		{
			if (NetworkServer.active && packet is RequestAllTitlesPacket)
			{
				FullSyncPacket syncPacket = new FullSyncPacket(HarmonyPatches.PlayerProfiles);
				Log.LogInfo((object)$"[RPNames] Replying to full-sync request from {header.SenderID} with {HarmonyPatches.PlayerProfiles.Count} profile(s).");
				TrySend(delegate
				{
					CodeTalkerNetwork.SendNetworkPacket(header.SenderID, (BinaryPacketBase)(object)syncPacket, (CompressionType)4, CompressionLevel.Fastest);
				});
			}
		}

		public static void SendTitleUpdate(CharacterTitleProfile profile)
		{
			if (!((Object)(object)Player._mainPlayer == (Object)null))
			{
				UpdateTitleProfilePacket packet = new UpdateTitleProfilePacket(profile);
				if (TrySend(delegate
				{
					CodeTalkerNetwork.SendNetworkPacket((BinaryPacketBase)(object)packet);
				}))
				{
					ApplyProfileUpdate(((NetworkBehaviour)Player._mainPlayer).netId, profile);
				}
			}
		}

		public static void RequestFullTitleSync()
		{
			if (_isCodeTalkerLoaded && !_networkSendWarningLogged)
			{
				Log.LogInfo((object)"[RPNames] Sending full-sync request to server.");
				TrySend(delegate
				{
					CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new RequestAllTitlesPacket());
				});
			}
		}

		private void Update()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			_globalNameRefreshTimer += Time.unscaledDeltaTime;
			if (_globalNameRefreshTimer >= 1f)
			{
				_globalNameRefreshTimer = 0f;
				RefreshSteamGlobalNames();
			}
			bool flag = (Object)(object)Player._mainPlayer != (Object)null && (int)Player._mainPlayer._currentGameCondition == 1;
			if (flag && !_pollWasInGame)
			{
				Log.LogInfo((object)"[RPNames] Detected IN_GAME via poll fallback.");
				RequestFullTitleSync();
			}
			_pollWasInGame = flag;
			switch (_menuState)
			{
			case MenuState.Opening:
				_animationProgress = Mathf.Clamp01(_animationProgress + Time.unscaledDeltaTime / 0.25f);
				if (_animationProgress >= 1f)
				{
					_menuState = MenuState.Open;
				}
				break;
			case MenuState.Closing:
				_animationProgress = Mathf.Clamp01(_animationProgress - Time.unscaledDeltaTime / 0.25f);
				if (_animationProgress <= 0f)
				{
					_menuState = MenuState.Closed;
				}
				break;
			}
			if (Input.GetKeyDown(_menuKey.Value))
			{
				if (_menuState == MenuState.Open || _menuState == MenuState.Opening)
				{
					_menuState = MenuState.Closing;
					_showTextAnimPicker = (_showColoringPicker = (_showBracketPicker = (_showPresetPicker = (_showPronounBracketPicker = (_showPronounColoringPicker = false)))));
				}
				else
				{
					_menuState = MenuState.Opening;
					LoadUIFromProfile((CurrentCharacterSlot >= 0) ? CurrentCharacterSlot : 0);
				}
			}
			foreach (PlayerTitleAnimator item in AllPlayerAnimators.Values.ToList())
			{
				if (!HarmonyPatches.PlayerProfiles.TryGetValue(item.NetId, out CharacterTitleProfile value) || value == null)
				{
					AllPlayerAnimators.Remove(item.NetId);
					continue;
				}
				bool flag2 = false;
				item.AnimationTimer += Time.deltaTime;
				if (item.AnimationTimer >= value.AnimationSpeed)
				{
					item.AnimationTimer = 0f;
					flag2 = true;
				}
				bool flag3 = false;
				if (ShouldAnimateColor(value) || ShouldAnimatePronounColor(value))
				{
					item.RainbowHue = (item.RainbowHue + Time.deltaTime * value.ColorAnimationSpeed * 0.1f) % 1f;
					flag3 = true;
				}
				if (value.TextAnimation == TextAnimationType.Typewriter && item.TypewriterState == TypewriterState.Blinking)
				{
					item.TypewriterPauseTimer += Time.deltaTime;
					item.TypewriterBlinkTimer += Time.deltaTime;
					if (item.TypewriterBlinkTimer >= 0.5f)
					{
						item.TypewriterBlinkTimer = 0f;
						item.TypewriterCursorVisible = !item.TypewriterCursorVisible;
						flag2 = true;
					}
					if (item.TypewriterPauseTimer >= 5f)
					{
						item.TypewriterPauseTimer = 0f;
						item.TypewriterState = TypewriterState.Backspacing;
					}
				}
				if (flag2)
				{
					switch (value.TextAnimation)
					{
					case TextAnimationType.Scroll:
						if (item.IsAnimatingForward)
						{
							item.AnimationIndex++;
							if (item.AnimationIndex >= value.Title.Length)
							{
								item.AnimationIndex = value.Title.Length;
								item.IsAnimatingForward = false;
							}
						}
						else
						{
							item.AnimationIndex--;
							if (item.AnimationIndex <= 1)
							{
								item.AnimationIndex = 1;
								item.IsAnimatingForward = true;
							}
						}
						break;
					case TextAnimationType.Marquee:
					{
						string text = new string(' ', value.MarqueeWidth);
						string text2 = text + value.Title + text;
						item.AnimationIndex = (item.AnimationIndex + 1) % (text2.Length - value.MarqueeWidth);
						break;
					}
					case TextAnimationType.Typewriter:
						switch (item.TypewriterState)
						{
						case TypewriterState.Typing:
							if (item.AnimationIndex < value.Title.Length)
							{
								item.AnimationIndex++;
								break;
							}
							item.TypewriterState = TypewriterState.Blinking;
							item.TypewriterPauseTimer = (item.TypewriterBlinkTimer = 0f);
							item.TypewriterCursorVisible = true;
							break;
						case TypewriterState.Backspacing:
							if (item.AnimationIndex > 0)
							{
								item.AnimationIndex--;
							}
							else
							{
								item.TypewriterState = TypewriterState.Typing;
							}
							break;
						}
						break;
					}
				}
				if (flag2 || flag3)
				{
					string animatedText = GetAnimatedText(value, item);
					if (HarmonyPatches.CurrentPlayerTitles.ContainsKey(item.NetId))
					{
						HarmonyPatches.CurrentPlayerTitles[item.NetId] = animatedText;
					}
					else
					{
						HarmonyPatches.CurrentPlayerTitles.Add(item.NetId, animatedText);
					}
				}
			}
		}

		internal string GetAnimatedText(CharacterTitleProfile profile, PlayerTitleAnimator animator)
		{
			if (string.IsNullOrEmpty(profile.Title))
			{
				return "";
			}
			switch (profile.TextAnimation)
			{
			case TextAnimationType.Scroll:
				return profile.Title.Substring(0, animator.AnimationIndex);
			case TextAnimationType.Marquee:
			{
				string text2 = new string(' ', profile.MarqueeWidth);
				string text3 = text2 + profile.Title + text2;
				return text3.Substring(animator.AnimationIndex, profile.MarqueeWidth);
			}
			case TextAnimationType.Typewriter:
			{
				if (animator.AnimationIndex > profile.Title.Length)
				{
					animator.AnimationIndex = profile.Title.Length;
				}
				string text = profile.Title.Substring(0, animator.AnimationIndex);
				if (animator.TypewriterState == TypewriterState.Blinking)
				{
					return profile.Title + (animator.TypewriterCursorVisible ? "|" : "");
				}
				return text + "|";
			}
			default:
				return profile.Title;
			}
		}

		internal string ApplyColoring(string text, CharacterTitleProfile p, PlayerTitleAnimator a, bool isForPronoun)
		{
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return "";
			}
			if (isForPronoun && p.ShareTitleColoring)
			{
				isForPronoun = false;
			}
			float num = a?.RainbowHue ?? 0f;
			ColoringType coloringType = (isForPronoun ? p.PronounColoring : p.Coloring);
			string text2 = (isForPronoun ? p.PronounSingleHexColor : p.SingleHexColor);
			string text3 = (isForPronoun ? p.PronounGradientStartColor : p.GradientStartColor);
			string text4 = (isForPronoun ? p.PronounGradientEndColor : p.GradientEndColor);
			bool flag = (isForPronoun ? p.PronounAnimateGradient : p.AnimateGradient);
			float num2 = (isForPronoun ? p.PronounGradientSpread : p.GradientSpread);
			float num3 = (isForPronoun ? p.PronounRainbowWaveSpread : p.RainbowWaveSpread);
			switch (coloringType)
			{
			case ColoringType.SingleColor:
				return "<color=#" + text2.Replace("#", "") + ">" + text + "</color>";
			case ColoringType.Rainbow:
				return "<color=#" + ColorUtility.ToHtmlStringRGB(Color.HSVToRGB(num, 1f, 1f)) + ">" + text + "</color>";
			case ColoringType.Gradient:
			{
				Color val = default(Color);
				ColorUtility.TryParseHtmlString("#" + text3, ref val);
				Color val2 = default(Color);
				ColorUtility.TryParseHtmlString("#" + text4, ref val2);
				StringBuilder stringBuilder2 = new StringBuilder();
				if (flag)
				{
					for (int j = 0; j < text.Length; j++)
					{
						float num5 = num + (float)j / num2;
						float num6 = 1f - Mathf.Abs(num5 * 2f % 2f - 1f);
						Color val3 = Color.Lerp(val, val2, num6);
						stringBuilder2.Append($"<color=#{ColorUtility.ToHtmlStringRGB(val3)}>{text[j]}</color>");
					}
				}
				else
				{
					for (int k = 0; k < text.Length; k++)
					{
						float num7 = ((text.Length <= 1) ? 0f : ((float)k / (float)(text.Length - 1)));
						Color val4 = Color.Lerp(val, val2, num7);
						stringBuilder2.Append($"<color=#{ColorUtility.ToHtmlStringRGB(val4)}>{text[k]}</color>");
					}
				}
				return stringBuilder2.ToString();
			}
			case ColoringType.Wave:
			{
				StringBuilder stringBuilder3 = new StringBuilder();
				for (int l = 0; l < text.Length; l++)
				{
					float num8 = (num + (float)l / num3) % 1f;
					stringBuilder3.Append($"<color=#{ColorUtility.ToHtmlStringRGB(Color.HSVToRGB(num8, 1f, 1f))}>{text[l]}</color>");
				}
				return stringBuilder3.ToString();
			}
			case ColoringType.StaticRainbow:
			{
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < text.Length; i++)
				{
					float num4 = (float)i / num3 % 1f;
					stringBuilder.Append($"<color=#{ColorUtility.ToHtmlStringRGB(Color.HSVToRGB(num4, 1f, 1f))}>{text[i]}</color>");
				}
				return stringBuilder.ToString();
			}
			default:
				return text;
			}
		}

		internal void UpdateGradientCache(CharacterTitleProfile profile)
		{
			ColorUtility.TryParseHtmlString("#" + profile.GradientStartColor, ref _gradientStartColorCache);
			ColorUtility.TryParseHtmlString("#" + profile.GradientEndColor, ref _gradientEndColorCache);
		}

		internal bool ShouldAnimate(CharacterTitleProfile p)
		{
			return p != null && !string.IsNullOrEmpty(p.Title) && (p.TextAnimation != TextAnimationType.Static || ShouldAnimateColor(p) || ShouldAnimatePronounColor(p));
		}

		internal bool ShouldAnimateColor(CharacterTitleProfile p)
		{
			return p.Coloring == ColoringType.Rainbow || p.Coloring == ColoringType.Wave || (p.Coloring == ColoringType.Gradient && p.AnimateGradient);
		}

		internal bool ShouldAnimatePronounColor(CharacterTitleProfile p)
		{
			return p.ShowPronouns && (p.ShareTitleColoring ? ShouldAnimateColor(p) : (p.PronounColoring == ColoringType.Rainbow || p.PronounColoring == ColoringType.Wave || (p.PronounColoring == ColoringType.Gradient && p.PronounAnimateGradient)));
		}

		private void OnGUI()
		{
			//IL_0071: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (_menuState == MenuState.Closed)
			{
				return;
			}
			if (!_stylesInitialized)
			{
				try
				{
					InitializeGUIStyles();
				}
				catch (Exception)
				{
				}
			}
			GUI.skin = _modSkin;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			float num = easeOut(_animationProgress);
			float num2 = 0f - ((Rect)(ref _windowRect)).width;
			float num3 = 20f;
			Rect windowRect = _windowRect;
			((Rect)(ref windowRect)).x = Mathf.Lerp(num2, num3, num);
			_windowRect = GUILayout.Window(1863, windowRect, new WindowFunction(DrawSettingsWindow), "RPNames Settings", Array.Empty<GUILayoutOption>());
			GUI.skin = OriginalSkin;
			static float easeOut(float t)
			{
				return 1f - Mathf.Pow(1f - t, 3f);
			}
		}

		private void LoadUIFromProfile(int slot)
		{
			if (slot == -1)
			{
				_uiEditingProfile = new CharacterTitleProfile();
				return;
			}
			if (!AllCharacterProfiles.TryGetValue(slot, out CharacterTitleProfile value))
			{
				value = new CharacterTitleProfile();
			}
			_uiEditingProfile = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)value));
		}

		private void DrawSettingsWindow(int windowID)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Expected O, but got Unknown
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Expected O, but got Unknown
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0897: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a9: Expected O, but got Unknown
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Expected O, but got Unknown
			//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b14: Expected O, but got Unknown
			if (CurrentCharacterSlot == -1)
			{
				GUILayout.FlexibleSpace();
				GUILayout.Label("Please load a character to edit their profile.", Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				GUI.DragWindow();
				return;
			}
			GUILayout.Label($"Editing Profile for Slot: {CurrentCharacterSlot + 1}", Array.Empty<GUILayoutOption>());
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Title", new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			_uiEditingProfile.Title = GUILayout.TextField(_uiEditingProfile.Title, 50, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Name:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) });
			_newPresetName = GUILayout.TextField(_newPresetName, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Save Preset", Array.Empty<GUILayoutOption>()) && !string.IsNullOrEmpty(_newPresetName))
			{
				CharacterTitleProfile value = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)_uiEditingProfile));
				if (_customPresets.ContainsKey(_newPresetName))
				{
					_customPresets[_newPresetName] = value;
				}
				else
				{
					_customPresets.Add(_newPresetName, value);
				}
				SaveCustomPresets();
			}
			GUILayout.EndHorizontal();
			if (GUILayout.Button("Select a Preset", Array.Empty<GUILayoutOption>()))
			{
				_showPresetPicker = !_showPresetPicker;
			}
			if (_showPresetPicker)
			{
				_presetScrollPosition = GUILayout.BeginScrollView(_presetScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) });
				GUILayout.Label("- Default Presets (Text Only) -", Array.Empty<GUILayoutOption>());
				foreach (string presetTitle in _presetTitles)
				{
					if (GUILayout.Button(presetTitle, Array.Empty<GUILayoutOption>()))
					{
						_uiEditingProfile.Title = presetTitle;
						_showPresetPicker = false;
					}
				}
				if (_customPresets.Count > 0)
				{
					GUILayout.Label("- Custom Presets (Full Style) -", Array.Empty<GUILayoutOption>());
					List<string> list = new List<string>();
					foreach (KeyValuePair<string, CharacterTitleProfile> customPreset in _customPresets)
					{
						GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
						if (GUILayout.Button(customPreset.Key, Array.Empty<GUILayoutOption>()))
						{
							_uiEditingProfile = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)customPreset.Value));
							_showPresetPicker = false;
						}
						if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) }))
						{
							list.Add(customPreset.Key);
						}
						GUILayout.EndHorizontal();
					}
					if (list.Count > 0)
					{
						foreach (string item in list)
						{
							_customPresets.Remove(item);
						}
						SaveCustomPresets();
					}
				}
				GUILayout.EndScrollView();
			}
			GUILayout.Space(10f);
			GUILayout.Label("--- Pronouns ---", new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			_uiEditingProfile.ShowPronouns = GUILayout.Toggle(_uiEditingProfile.ShowPronouns, " Show Pronouns", Array.Empty<GUILayoutOption>());
			if (_uiEditingProfile.ShowPronouns)
			{
				_uiEditingProfile.Pronouns = GUILayout.TextField(_uiEditingProfile.Pronouns, 50, Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label("Pronoun Brackets:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
				if (GUILayout.Button(_uiEditingProfile.PronounBracketStyle.ToString(), Array.Empty<GUILayoutOption>()))
				{
					_showPronounBracketPicker = !_showPronounBracketPicker;
				}
				GUILayout.EndHorizontal();
				if (_showPronounBracketPicker)
				{
					string[] names = Enum.GetNames(typeof(BracketType));
					int num = GUILayout.SelectionGrid((int)_uiEditingProfile.PronounBracketStyle, names, 3, Array.Empty<GUILayoutOption>());
					if (num != (int)_uiEditingProfile.PronounBracketStyle)
					{
						_uiEditingProfile.PronounBracketStyle = (BracketType)num;
						_showPronounBracketPicker = false;
					}
				}
			}
			GUILayout.Space(10f);
			GUILayout.Label("--- Display Options ---", new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			_uiEditingProfile.TitleOnNewLine = GUILayout.Toggle(_uiEditingProfile.TitleOnNewLine, " Display on New Line", Array.Empty<GUILayoutOption>());
			if (_uiEditingProfile.TitleOnNewLine)
			{
				_uiEditingProfile.AddGapAboveTitle = GUILayout.Toggle(_uiEditingProfile.AddGapAboveTitle, " Add Gap Above", Array.Empty<GUILayoutOption>());
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Title Brackets:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			if (GUILayout.Button(_uiEditingProfile.BracketStyle.ToString(), Array.Empty<GUILayoutOption>()))
			{
				_showBracketPicker = !_showBracketPicker;
			}
			GUILayout.EndHorizontal();
			if (_showBracketPicker)
			{
				string[] names2 = Enum.GetNames(typeof(BracketType));
				int num2 = GUILayout.SelectionGrid((int)_uiEditingProfile.BracketStyle, names2, 3, Array.Empty<GUILayoutOption>());
				if (num2 != (int)_uiEditingProfile.BracketStyle)
				{
					_uiEditingProfile.BracketStyle = (BracketType)num2;
					_showBracketPicker = false;
				}
			}
			GUILayout.Space(10f);
			GUILayout.Label("--- Title Animation ---", new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Animation:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			if (GUILayout.Button(_uiEditingProfile.TextAnimation.ToString(), Array.Empty<GUILayoutOption>()))
			{
				_showTextAnimPicker = !_showTextAnimPicker;
			}
			GUILayout.EndHorizontal();
			if (_showTextAnimPicker)
			{
				string[] names3 = Enum.GetNames(typeof(TextAnimationType));
				int num3 = GUILayout.SelectionGrid((int)_uiEditingProfile.TextAnimation, names3, 3, Array.Empty<GUILayoutOption>());
				if (num3 != (int)_uiEditingProfile.TextAnimation)
				{
					_uiEditingProfile.TextAnimation = (TextAnimationType)num3;
					_showTextAnimPicker = false;
				}
			}
			if (_uiEditingProfile.TextAnimation != TextAnimationType.Static)
			{
				float num4 = Mathf.Lerp(10f, 1f, Mathf.InverseLerp(0.05f, 0.5f, _uiEditingProfile.AnimationSpeed));
				GUILayout.Label($"Animation Speed: {num4:F1}", Array.Empty<GUILayoutOption>());
				num4 = GUILayout.HorizontalSlider(num4, 1f, 10f, Array.Empty<GUILayoutOption>());
				_uiEditingProfile.AnimationSpeed = Mathf.Lerp(0.5f, 0.05f, Mathf.InverseLerp(1f, 10f, num4));
			}
			if (_uiEditingProfile.TextAnimation == TextAnimationType.Marquee)
			{
				GUILayout.Label($"Marquee Width: {_uiEditingProfile.MarqueeWidth}", Array.Empty<GUILayoutOption>());
				_uiEditingProfile.MarqueeWidth = (int)GUILayout.HorizontalSlider((float)_uiEditingProfile.MarqueeWidth, 5f, 40f, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(10f);
			GUILayout.Label("--- Title Coloring ---", new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			DrawColorCustomization(isForPronoun: false);
			if (_uiEditingProfile.ShowPronouns)
			{
				GUILayout.Space(10f);
				GUILayout.Label("--- Pronoun Coloring ---", new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				}, Array.Empty<GUILayoutOption>());
				_uiEditingProfile.ShareTitleColoring = GUILayout.Toggle(_uiEditingProfile.ShareTitleColoring, " Share Title Coloring", Array.Empty<GUILayoutOption>());
				if (!_uiEditingProfile.ShareTitleColoring)
				{
					DrawColorCustomization(isForPronoun: true);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Copy", Array.Empty<GUILayoutOption>()))
			{
				_copiedProfileBuffer = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)_uiEditingProfile));
			}
			GUI.enabled = _copiedProfileBuffer != null;
			if (GUILayout.Button("Paste", Array.Empty<GUILayoutOption>()) && _copiedProfileBuffer != null)
			{
				_uiEditingProfile = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)_copiedProfileBuffer));
			}
			GUI.enabled = true;
			GUILayout.EndHorizontal();
			if (UsingMultitool && !AllCharacterProfiles.ContainsKey(CurrentCharacterSlot) && _legacyProfiles.TryGetValue(CurrentCharacterSlot, out CharacterTitleProfile value2) && value2 != null && GUILayout.Button("Import old title from config (this slot)", Array.Empty<GUILayoutOption>()))
			{
				_uiEditingProfile = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)value2));
			}
			if (GUILayout.Button("Set & Save", Array.Empty<GUILayoutOption>()))
			{
				AllCharacterProfiles[CurrentCharacterSlot] = JsonConvert.DeserializeObject<CharacterTitleProfile>(JsonConvert.SerializeObject((object)_uiEditingProfile));
				SaveProfiles();
				if (UsingMultitool && _legacyProfiles.Remove(CurrentCharacterSlot))
				{
					SaveLegacyProfiles();
				}
				CharacterTitleProfile profile = AllCharacterProfiles[CurrentCharacterSlot];
				UpdateGradientCache(profile);
				SendTitleUpdate(profile);
				_menuState = MenuState.Closing;
			}
			if (_showClearConfirmation)
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4
				};
				val.normal.textColor = Color.yellow;
				GUILayout.Label("Are you sure?", val, Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("YES, CLEAR", Array.Empty<GUILayoutOption>()))
				{
					if (AllCharacterProfiles.ContainsKey(CurrentCharacterSlot))
					{
						AllCharacterProfiles.Remove(CurrentCharacterSlot);
					}
					SaveProfiles();
					SendTitleUpdate(null);
					LoadUIFromProfile(CurrentCharacterSlot);
					_showClearConfirmation = false;
				}
				if (GUILayout.Button("CANCEL", Array.Empty<GUILayoutOption>()))
				{
					_showClearConfirmation = false;
				}
				GUILayout.EndHorizontal();
			}
			else if (GUILayout.Button("Clear All", Array.Empty<GUILayoutOption>()))
			{
				_showClearConfirmation = true;
			}
			GUI.DragWindow();
			void DrawColorCustomization(bool isForPronoun)
			{
				//IL_061a: Unknown result type (might be due to invalid IL or missing references)
				//IL_061f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0627: Unknown result type (might be due to invalid IL or missing references)
				//IL_062d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0642: Expected O, but got Unknown
				CharacterTitleProfile p = _uiEditingProfile;
				Action<ColoringType> action = delegate(ColoringType coloringType2)
				{
					if (isForPronoun)
					{
						p.PronounColoring = coloringType2;
					}
					else
					{
						p.Coloring = coloringType2;
					}
				};
				Action<string> action2 = delegate(string text4)
				{
					if (isForPronoun)
					{
						p.PronounSingleHexColor = text4;
					}
					else
					{
						p.SingleHexColor = text4;
					}
				};
				Action<string> action3 = delegate(string text4)
				{
					if (isForPronoun)
					{
						p.PronounGradientStartColor = text4;
					}
					else
					{
						p.GradientStartColor = text4;
					}
				};
				Action<string> action4 = delegate(string text4)
				{
					if (isForPronoun)
					{
						p.PronounGradientEndColor = text4;
					}
					else
					{
						p.GradientEndColor = text4;
					}
				};
				Action<bool> action5 = delegate(bool flag2)
				{
					if (isForPronoun)
					{
						p.PronounAnimateGradient = flag2;
					}
					else
					{
						p.AnimateGradient = flag2;
					}
				};
				Action<float> action6 = delegate(float num10)
				{
					if (isForPronoun)
					{
						p.PronounGradientSpread = num10;
					}
					else
					{
						p.GradientSpread = num10;
					}
				};
				Action<float> action7 = delegate(float num10)
				{
					if (isForPronoun)
					{
						p.PronounRainbowWaveSpread = num10;
					}
					else
					{
						p.RainbowWaveSpread = num10;
					}
				};
				Action<float> action8 = delegate(float num10)
				{
					if (isForPronoun)
					{
						p.PronounColorAnimationSpeed = num10;
					}
					else
					{
						p.ColorAnimationSpeed = num10;
					}
				};
				ref bool reference = ref isForPronoun ? ref _showPronounColoringPicker : ref _showColoringPicker;
				ref bool reference2 = ref isForPronoun ? ref _showPronounSingleColorPicker : ref _showSingleColorPicker;
				ref bool reference3 = ref isForPronoun ? ref _showPronounGradientStartPicker : ref _showGradientStartPicker;
				ref bool reference4 = ref isForPronoun ? ref _showPronounGradientEndPicker : ref _showGradientEndPicker;
				ColoringType coloringType = (isForPronoun ? p.PronounColoring : p.Coloring);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label("Effect:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
				if (GUILayout.Button(coloringType.ToString(), Array.Empty<GUILayoutOption>()))
				{
					reference = !reference;
				}
				GUILayout.EndHorizontal();
				if (reference)
				{
					string[] names4 = Enum.GetNames(typeof(ColoringType));
					int num5 = GUILayout.SelectionGrid((int)coloringType, names4, 3, Array.Empty<GUILayoutOption>());
					if (num5 != (int)coloringType)
					{
						action((ColoringType)num5);
						reference = false;
						reference2 = (reference3 = (reference4 = false));
					}
				}
				Action<string, Action<string>> action9 = delegate(string currentHex, Action<string> setter)
				{
					//IL_0058: 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_008e: Unknown result type (might be due to invalid IL or missing references)
					//IL_00af: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fd: Expected O, but got Unknown
					//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
					//IL_010d: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					//IL_0116: Unknown result type (might be due to invalid IL or missing references)
					//IL_011f: Unknown result type (might be due to invalid IL or missing references)
					//IL_014d: Unknown result type (might be due to invalid IL or missing references)
					Color white = default(Color);
					if (!ColorUtility.TryParseHtmlString("#" + currentHex, ref white))
					{
						white = Color.white;
					}
					GUILayout.BeginVertical(_modSkin.box, Array.Empty<GUILayoutOption>());
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					float num10 = GUILayout.HorizontalSlider(white.r, 0f, 1f, Array.Empty<GUILayoutOption>());
					float num11 = GUILayout.HorizontalSlider(white.g, 0f, 1f, Array.Empty<GUILayoutOption>());
					float num12 = GUILayout.HorizontalSlider(white.b, 0f, 1f, Array.Empty<GUILayoutOption>());
					GUILayout.EndVertical();
					Color backgroundColor = GUI.backgroundColor;
					GUI.backgroundColor = white;
					GUIStyle val3 = new GUIStyle();
					val3.normal.background = Texture2D.whiteTexture;
					GUILayout.Box("", val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(40f),
						GUILayout.Height(40f)
					});
					GUI.backgroundColor = backgroundColor;
					GUILayout.EndHorizontal();
					if (num10 != white.r || num11 != white.g || num12 != white.b)
					{
						white.r = num10;
						white.g = num11;
						white.b = num12;
						setter(ColorUtility.ToHtmlStringRGB(white));
					}
					GUILayout.EndVertical();
				};
				if (coloringType == ColoringType.SingleColor)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("Hex Color", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
					string text = (isForPronoun ? p.PronounSingleHexColor : p.SingleHexColor);
					action2(GUILayout.TextField(text, 7, Array.Empty<GUILayoutOption>()));
					if (GUILayout.Button("Pick", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
					{
						reference2 = !reference2;
						reference3 = (reference4 = false);
					}
					GUILayout.EndHorizontal();
					if (reference2)
					{
						action9(text, action2);
					}
				}
				if (coloringType == ColoringType.Gradient)
				{
					bool flag = (isForPronoun ? p.PronounAnimateGradient : p.AnimateGradient);
					action5(GUILayout.Toggle(flag, "Animate Gradient", Array.Empty<GUILayoutOption>()));
					if (flag)
					{
						float num6 = (isForPronoun ? p.PronounColorAnimationSpeed : p.ColorAnimationSpeed);
						GUILayout.Label($"Color Speed: {num6:F1}", Array.Empty<GUILayoutOption>());
						action8(GUILayout.HorizontalSlider(num6, 0.1f, 5f, Array.Empty<GUILayoutOption>()));
					}
					float num7 = (isForPronoun ? p.PronounGradientSpread : p.GradientSpread);
					GUILayout.Label($"Gradient Spread: {num7:F1}", Array.Empty<GUILayoutOption>());
					action6(GUILayout.HorizontalSlider(num7, 1f, 50f, Array.Empty<GUILayoutOption>()));
					GUI.enabled = !flag;
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("Start", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
					string text2 = (isForPronoun ? p.PronounGradientStartColor : p.GradientStartColor);
					action3(GUILayout.TextField(text2, 7, Array.Empty<GUILayoutOption>()));
					if (GUILayout.Button("Pick", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
					{
						reference3 = !reference3;
						reference2 = (reference4 = false);
					}
					GUILayout.EndHorizontal();
					if (reference3)
					{
						action9(text2, action3);
					}
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("End", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
					string text3 = (isForPronoun ? p.PronounGradientEndColor : p.GradientEndColor);
					action4(GUILayout.TextField(text3, 7, Array.Empty<GUILayoutOption>()));
					if (GUILayout.Button("Pick", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
					{
						reference4 = !reference4;
						reference2 = (reference3 = false);
					}
					GUILayout.EndHorizontal();
					if (reference4)
					{
						action9(text3, action4);
					}
					GUI.enabled = true;
				}
				if (coloringType == ColoringType.Wave || coloringType == ColoringType.Rainbow)
				{
					float num8 = (isForPronoun ? p.PronounColorAnimationSpeed : p.ColorAnimationSpeed);
					GUILayout.Label($"Color Speed: {num8:F1}", Array.Empty<GUILayoutOption>());
					action8(GUILayout.HorizontalSlider(num8, 0.1f, 5f, Array.Empty<GUILayoutOption>()));
				}
				if (coloringType == ColoringType.Wave || coloringType == ColoringType.StaticRainbow)
				{
					float num9 = (isForPronoun ? p.PronounRainbowWaveSpread : p.RainbowWaveSpread);
					GUILayout.Label($"Wave Spread: {num9:F1}", Array.Empty<GUILayoutOption>());
					action7(GUILayout.HorizontalSlider(num9, 5f, 50f, Array.Empty<GUILayoutOption>()));
				}
				if (coloringType == ColoringType.Gradient || coloringType == ColoringType.SingleColor)
				{
					GUIStyle val2 = new GUIStyle(_modSkin.label)
					{
						fontStyle = (FontStyle)2
					};
					val2.normal.textColor = Color.gray;
					GUILayout.Label("(RRGGBB format, no #)", val2, Array.Empty<GUILayoutOption>());
				}
			}
		}
	}
	internal static class MultitoolHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static SaveProfileData<CharacterSaveData> <0>__Save;

			public static LoadProfileData<CharacterSaveData> <1>__Load;

			public static DeleteProfileData <2>__Delete;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Register()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			SaveProfileData<CharacterSaveData> obj = Save;
			LoadProfileData<CharacterSaveData> obj2 = Load;
			object obj3 = <>O.<2>__Delete;
			if (obj3 == null)
			{
				DeleteProfileData val = Delete;
				<>O.<2>__Delete = val;
				obj3 = (object)val;
			}
			SaveUtilsAPI.RegisterProfileData<CharacterSaveData>("s0apy.RPNames.sftwre", obj, obj2, (DeleteProfileData)obj3);
		}

		private static void Save(CharacterFile file, int slotIndex, out CharacterSaveData? data)
		{
			data = Main.instance.OnCharacterSaving(slotIndex);
		}

		private static void Load(CharacterFile file, int slotIndex, CharacterSaveData? data)
		{
			Main.instance.OnCharacterLoaded(slotIndex, data);
		}

		private static void Delete(CharacterFile file, int slotIndex)
		{
			Main.instance.OnCharacterDeleted(slotIndex);
		}
	}
	[HarmonyPatch]
	internal static class HarmonyPatches
	{
		private class PlayerCleanupMarker : MonoBehaviour
		{
			public uint NetId;

			private void OnDestroy()
			{
				PlayerProfiles.Remove(NetId);
				CurrentPlayerTitles.Remove(NetId);
				Main.AllPlayerAnimators.Remove(NetId);
			}
		}

		internal static readonly Dictionary<uint, CharacterTitleProfile> PlayerProfiles = new Dictionary<uint, CharacterTitleProfile>();

		internal static readonly Dictionary<uint, string> CurrentPlayerTitles = new Dictionary<uint, string>();

		private static readonly FieldInfo _globalNicknameTextMeshField = AccessTools.Field(typeof(Player), "_globalNicknameTextMesh");

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MainMenuManager), "Set_MenuCondition")]
		private static void OnSetMenuCondition_Postfix(MainMenuManager __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)__instance._mainMenuCondition == 1)
			{
				Main.instance.QueueApplySteamGlobalName(__instance._characterSelectManager);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MainMenuManager), "Load_HostSettings")]
		private static void OnLoadHostSettings_Postfix(MainMenuManager __instance)
		{
			Main.instance.QueueApplySteamGlobalName(__instance._characterSelectManager);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ProfileDataSender), "OnSend_CharacterFileData")]
		private static void OnSendCharacterFileData_Postfix()
		{
			Main.instance.QueueApplySteamGlobalName(Object.FindObjectOfType<CharacterSelectManager>());
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "OnGameConditionChange")]
		private static void OnGameConditionChange_Postfix(Player __instance, GameCondition _newCondition)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if ((Object)(object)__instance != (Object)(object)Player._mainPlayer)
			{
				return;
			}
			Main.IsReady = (int)_newCondition == 1;
			if (Main.IsReady)
			{
				Main.CurrentCharacterSlot = ProfileDataManager._current.SelectedFileIndex;
				if (Main.instance.AllCharacterProfiles.TryGetValue(Main.CurrentCharacterSlot, out CharacterTitleProfile value))
				{
					Main.instance.UpdateGradientCache(value);
					Main.SendTitleUpdate(value);
				}
				Main.RequestFullTitleSync();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AtlyssNetworkManager), "OnStopClient")]
		private static void OnStopClient_Postfix()
		{
			Main.IsReady = false;
			Main.CurrentCharacterSlot = -1;
			PlayerProfiles.Clear();
			CurrentPlayerTitles.Clear();
			Main.AllPlayerAnimators.Clear();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "OnStartAuthority")]
		private static void OnPlayerStart_Postfix(Player __instance)
		{
			if (((NetworkBehaviour)__instance).isLocalPlayer && Main._isCodeTalkerLoaded)
			{
				Main.RequestFullTitleSync();
			}
		}

		private static string GetFormattedStringWithBrackets(string content, BracketType bracketType)
		{
			if (string.IsNullOrEmpty(content))
			{
				return "";
			}
			return bracketType switch
			{
				BracketType.Parentheses => "(" + content + ")", 
				BracketType.SquareBrackets => "[" + content + "]", 
				BracketType.Tilde => "~" + content + "~", 
				BracketType.Dash => "-" + content + "-", 
				BracketType.Plus => "+" + content + "+", 
				BracketType.Equals => "=" + content + "=", 
				BracketType.Asterisk => "*" + content + "*", 
				BracketType.Dollar => "$" + content + "$", 
				BracketType.Hash => "#" + content + "#", 
				BracketType.Exclamation => "!" + content + "!", 
				BracketType.Pipe => "|" + content + "|", 
				_ => content, 
			};
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "Handle_ClientParameters")]
		private static void Handle_ClientParameters_Postfix(Player __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<PlayerCleanupMarker>() == (Object)null)
			{
				PlayerCleanupMarker playerCleanupMarker = ((Component)__instance).gameObject.AddComponent<PlayerCleanupMarker>();
				playerCleanupMarker.NetId = ((NetworkBehaviour)__instance).netId;
			}
			object? value = _globalNicknameTextMeshField.GetValue(__instance);
			TextMeshPro val = (TextMeshPro)((value is TextMeshPro) ? value : null);
			if (val == null)
			{
				return;
			}
			if (!((TMP_Text)val).richText)
			{
				((TMP_Text)val).richText = true;
			}
			CurrentPlayerTitles.TryGetValue(((NetworkBehaviour)__instance).netId, out string value2);
			PlayerProfiles.TryGetValue(((NetworkBehaviour)__instance).netId, out CharacterTitleProfile value3);
			if (value3 == null)
			{
				value3 = new CharacterTitleProfile();
			}
			Main.AllPlayerAnimators.TryGetValue(((NetworkBehaviour)__instance).netId, out PlayerTitleAnimator value4);
			bool flag = !string.IsNullOrEmpty(value2);
			bool flag2 = value3.ShowPronouns && !string.IsNullOrEmpty(value3.Pronouns);
			string text5;
			if (!string.IsNullOrEmpty(__instance._globalNickname) || flag || flag2)
			{
				string content = Main.instance.ApplyColoring(value2, value3, value4, isForPronoun: false);
				string content2 = Main.instance.ApplyColoring(value3.Pronouns, value3, value4, isForPronoun: true);
				string formattedStringWithBrackets = GetFormattedStringWithBrackets(content, value3.BracketStyle);
				string text = (flag2 ? GetFormattedStringWithBrackets(content2, value3.PronounBracketStyle) : "");
				string text2 = "";
				if (flag && flag2)
				{
					text2 = formattedStringWithBrackets + " " + text;
				}
				else if (flag)
				{
					text2 = formattedStringWithBrackets;
				}
				else if (flag2)
				{
					text2 = text;
				}
				string text3 = ((!string.IsNullOrEmpty(__instance._globalNickname)) ? ("@" + __instance._globalNickname) : ((flag || flag2) ? "@." : ""));
				string text4 = ((value3.AddGapAboveTitle && value3.TitleOnNewLine) ? "\n" : "");
				string separator = (value3.TitleOnNewLine ? "\n" : " ");
				List<string> list = new List<string>();
				if (!string.IsNullOrEmpty(text3))
				{
					list.Add(text3);
				}
				if (!string.IsNullOrEmpty(text2))
				{
					list.Add(text2);
				}
				text5 = text4 + string.Join(separator, list);
			}
			else
			{
				text5 = "";
			}
			if (((TMP_Text)val).text != text5)
			{
				((TMP_Text)val).text = text5;
			}
		}
	}
	internal static class ModInfo
	{
		public const string GUID = "s0apy.RPNames.sftwre";

		public const string NAME = "RPNames";

		public const string VERSION = "1.6.0";
	}
}
namespace RPNames.Packets
{
	internal static class ProfileSerializer
	{
		public static void WriteProfile(BinaryWriter writer, CharacterTitleProfile profile)
		{
			if (profile == null)
			{
				writer.Write(value: false);
				return;
			}
			writer.Write(value: true);
			writer.Write(profile.Title ?? "");
			writer.Write((byte)profile.BracketStyle);
			writer.Write((byte)profile.TextAnimation);
			writer.Write((byte)profile.Coloring);
			writer.Write(profile.AnimationSpeed);
			writer.Write(profile.MarqueeWidth);
			writer.Write(profile.SingleHexColor ?? "FFFFFF");
			writer.Write(profile.GradientStartColor ?? "FF0000");
			writer.Write(profile.GradientEndColor ?? "0000FF");
			writer.Write(profile.AnimateGradient);
			writer.Write(profile.GradientSpread);
			writer.Write(profile.RainbowWaveSpread);
			writer.Write(profile.ColorAnimationSpeed);
			writer.Write(profile.Pronouns ?? "");
			writer.Write(profile.ShowPronouns);
			writer.Write((byte)profile.PronounBracketStyle);
			writer.Write(profile.ShareTitleColoring);
			writer.Write((byte)profile.PronounColoring);
			writer.Write(profile.PronounSingleHexColor ?? "FFFFFF");
			writer.Write(profile.PronounGradientStartColor ?? "FF0000");
			writer.Write(profile.PronounGradientEndColor ?? "0000FF");
			writer.Write(profile.PronounAnimateGradient);
			writer.Write(profile.PronounGradientSpread);
			writer.Write(profile.PronounRainbowWaveSpread);
			writer.Write(profile.PronounColorAnimationSpeed);
			writer.Write(profile.TitleOnNewLine);
			writer.Write(profile.AddGapAboveTitle);
		}

		public static CharacterTitleProfile ReadProfile(BinaryReader reader)
		{
			if (!reader.ReadBoolean())
			{
				return null;
			}
			return new CharacterTitleProfile
			{
				Title = reader.ReadString(),
				BracketStyle = (BracketType)reader.ReadByte(),
				TextAnimation = (TextAnimationType)reader.ReadByte(),
				Coloring = (ColoringType)reader.ReadByte(),
				AnimationSpeed = reader.ReadSingle(),
				MarqueeWidth = reader.ReadInt32(),
				SingleHexColor = reader.ReadString(),
				GradientStartColor = reader.ReadString(),
				GradientEndColor = reader.ReadString(),
				AnimateGradient = reader.ReadBoolean(),
				GradientSpread = reader.ReadSingle(),
				RainbowWaveSpread = reader.ReadSingle(),
				ColorAnimationSpeed = reader.ReadSingle(),
				Pronouns = reader.ReadString(),
				ShowPronouns = reader.ReadBoolean(),
				PronounBracketStyle = (BracketType)reader.ReadByte(),
				ShareTitleColoring = reader.ReadBoolean(),
				PronounColoring = (ColoringType)reader.ReadByte(),
				PronounSingleHexColor = reader.ReadString(),
				PronounGradientStartColor = reader.ReadString(),
				PronounGradientEndColor = reader.ReadString(),
				PronounAnimateGradient = reader.ReadBoolean(),
				PronounGradientSpread = reader.ReadSingle(),
				PronounRainbowWaveSpread = reader.ReadSingle(),
				PronounColorAnimationSpeed = reader.ReadSingle(),
				TitleOnNewLine = reader.ReadBoolean(),
				AddGapAboveTitle = reader.ReadBoolean()
			};
		}
	}
	public class UpdateTitleProfilePacket : BinaryPacketBase
	{
		public override string PacketSignature => "s0apy.RPNames.sftwre_UpdateProfile";

		public CharacterTitleProfile Profile { get; set; }

		public UpdateTitleProfilePacket()
		{
		}

		public UpdateTitleProfilePacket(CharacterTitleProfile profile)
		{
			Profile = profile;
		}

		public override byte[] Serialize()
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (BinaryWriter writer = new BinaryWriter(memoryStream))
			{
				ProfileSerializer.WriteProfile(writer, Profile);
			}
			return memoryStream.ToArray();
		}

		public override void Deserialize(byte[] data)
		{
			using MemoryStream input = new MemoryStream(data);
			using BinaryReader reader = new BinaryReader(input);
			Profile = ProfileSerializer.ReadProfile(reader);
		}
	}
	public class FullSyncPacket : BinaryPacketBase
	{
		public override string PacketSignature => "s0apy.RPNames.sftwre_FullSync";

		public Dictionary<uint, CharacterTitleProfile> AllProfiles { get; set; }

		public FullSyncPacket()
		{
		}

		public FullSyncPacket(Dictionary<uint, CharacterTitleProfile> profiles)
		{
			AllProfiles = profiles;
		}

		public override byte[] Serialize()
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
			{
				binaryWriter.Write(AllProfiles.Count);
				foreach (KeyValuePair<uint, CharacterTitleProfile> allProfile in AllProfiles)
				{
					binaryWriter.Write(allProfile.Key);
					ProfileSerializer.WriteProfile(binaryWriter, allProfile.Value);
				}
			}
			return memoryStream.ToArray();
		}

		public override void Deserialize(byte[] data)
		{
			using MemoryStream input = new MemoryStream(data);
			using BinaryReader binaryReader = new BinaryReader(input);
			int num = binaryReader.ReadInt32();
			AllProfiles = new Dictionary<uint, CharacterTitleProfile>(num);
			for (int i = 0; i < num; i++)
			{
				AllProfiles.Add(binaryReader.ReadUInt32(), ProfileSerializer.ReadProfile(binaryReader));
			}
		}
	}
	public class RequestAllTitlesPacket : PacketBase
	{
		public override string PacketSourceGUID => "s0apy.RPNames.sftwre";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}