Decompiled source of StanceSelector v1.4.1

StanceSelector.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Rombusz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a stance selection page to PEAK's emote wheel.")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1")]
[assembly: AssemblyProduct("StanceSelector")]
[assembly: AssemblyTitle("StanceSelector")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.0")]
[module: UnverifiableCode]
namespace StanceSelector
{
	[BepInPlugin("Rombusz.StanceSelector", "StanceSelector", "1.4.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GUIManager), "UpdateEmoteWheel")]
		private static class ShortcutPatch
		{
			private static void Prefix(GameObject ___emoteWheel)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				Character localCharacter = Character.localCharacter;
				if ((Object)(object)localCharacter == (Object)null || (Object)(object)___emoteWheel == (Object)null)
				{
					return;
				}
				if (Input.GetKey(stanceSelectorShortcutHotkey.Value))
				{
					if ((Object)(object)shortcutWheel == (Object)null)
					{
						OpenShortcutPage(___emoteWheel.GetComponent<EmoteWheel>());
					}
					localCharacter.input.emoteIsPressed = true;
				}
				else if ((Object)(object)shortcutWheel != (Object)null)
				{
					RestorePreviousPage(localCharacter.input.emoteIsPressed);
				}
				else if (localCharacter.data.usingEmoteWheel && ___emoteWheel.activeInHierarchy && Input.GetKeyDown(emoteWheelPageSwitcherHotkey.Value))
				{
					EmoteWheel component = ___emoteWheel.GetComponent<EmoteWheel>();
					WheelPage.Invoke(component) = ((WheelPage.Invoke(component) == 0) ? 1 : 0);
					component.InitWheel();
				}
			}
		}

		[HarmonyPatch(typeof(EmoteWheel), "Tab")]
		private static class ShortcutTabPatch
		{
			private static bool Prefix(EmoteWheel __instance)
			{
				return (Object)(object)__instance != (Object)(object)shortcutWheel;
			}
		}

		[HarmonyPatch(typeof(EmoteWheel), "InitWheel")]
		private static class WheelInitPatch
		{
			[HarmonyPrefix]
			[HarmonyPriority(0)]
			private static void Prefix(EmoteWheel __instance)
			{
				PrepareStancePage(__instance);
			}

			[HarmonyPostfix]
			[HarmonyPriority(0)]
			private static void Postfix(EmoteWheel __instance, int ___page)
			{
				DrawWheel(__instance, ___page);
			}
		}

		[HarmonyPatch(typeof(EmoteWheel), "Hover")]
		private static class WheelHoverPatch
		{
			private static bool Prefix(EmoteWheel __instance, EmoteWheelData emoteWheelData, ref EmoteWheelData ___chosenEmoteData)
			{
				int stance = GetStance(emoteWheelData);
				if (stance < 0)
				{
					return true;
				}
				SetHoveredStance(__instance, stance);
				((TMP_Text)__instance.selectedEmoteName).text = StanceNames[stance];
				___chosenEmoteData = emoteWheelData;
				return false;
			}
		}

		[HarmonyPatch(typeof(EmoteWheel), "Dehover")]
		private static class WheelDehoverPatch
		{
			private static void Prefix(EmoteWheel __instance, EmoteWheelData emoteWheelData)
			{
				int stance = GetStance(emoteWheelData);
				if (stance >= 0)
				{
					ClearHoveredStance(__instance, stance);
				}
			}
		}

		[HarmonyPatch(typeof(EmoteWheel), "Choose")]
		private static class WheelChoosePatch
		{
			private static bool Prefix(EmoteWheelData ___chosenEmoteData)
			{
				int stance = GetStance(___chosenEmoteData);
				if (stance < 0)
				{
					return true;
				}
				ApplyStance(stance);
				return false;
			}
		}

		[HarmonyPatch(typeof(CharacterCustomization), "Start")]
		private static class CharacterStartPatch
		{
			private static void Postfix(CharacterCustomization __instance)
			{
				//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)
				Character localCharacter = Character.localCharacter;
				if (selectedStance >= 0)
				{
					Scene activeScene = SceneManager.GetActiveScene();
					if (!IsMenuScene(((Scene)(ref activeScene)).name) && (Object)(object)localCharacter != (Object)null && (Object)(object)((Component)__instance).gameObject == (Object)(object)((Component)localCharacter).gameObject)
					{
						ApplyStance(selectedStance);
					}
				}
			}
		}

		public const string Guid = "Rombusz.StanceSelector";

		public const string Name = "StanceSelector";

		public const string Version = "1.4.1";

		private const int PageSize = 8;

		private const string LabelName = "StanceSelector Label";

		private const string PictureName = "StanceSelector Picture";

		private const string ImageFolderName = "StanceImages";

		private static readonly string[] StanceNames = new string[8] { "prideful", "ready to go", "open hands", "closed hands", "hands on hips", "normal", "shy", "snatch 'em" };

		private static readonly string[] StanceImageNames = new string[8] { "stanceprideful.png", "stancereadytogo.png", "stanceopenhands.png", "stanceclosedhands.png", "stancehandsonhips.png", "stancenormal.png", "stanceshy.png", "stancesnatchem.png" };

		private static readonly EmoteWheelData[] StanceEntries = (EmoteWheelData[])(object)new EmoteWheelData[8];

		private static readonly Sprite[] StanceSprites = (Sprite[])(object)new Sprite[8];

		private static readonly Sprite[] StanceHoveredSprites = (Sprite[])(object)new Sprite[8];

		private static readonly FieldRef<EmoteWheel, int> WheelPage = AccessTools.FieldRefAccess<EmoteWheel, int>("page");

		private static ManualLogSource log;

		private static ConfigEntry<KeyCode> stanceSelectorShortcutHotkey;

		private static ConfigEntry<KeyCode> emoteWheelPageSwitcherHotkey;

		private static ConfigEntry<bool> showStancePictures;

		private static string pluginDirectory;

		private static string stanceImageDirectory;

		private static int selectedStance = -1;

		private static int previousPage;

		private static EmoteWheel shortcutWheel;

		private static EmoteWheel hoveredWheel;

		private static int hoveredStance = -1;

		private static EmoteWheel pictureWheel;

		private static readonly List<TMP_Text> SliceTmpLabels = new List<TMP_Text>();

		private static readonly List<Text> SliceLegacyLabels = new List<Text>();

		private static readonly List<Graphic> SuppressedLabels = new List<Graphic>();

		private Harmony harmony;

		private void Awake()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			log = ((BaseUnityPlugin)this).Logger;
			pluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath;
			stanceImageDirectory = Path.Combine(pluginDirectory, "StanceImages");
			stanceSelectorShortcutHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Stance Selector Shortcut Hotkey", (KeyCode)116, "Hold to open the stance wheel directly.");
			emoteWheelPageSwitcherHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Emote Wheel Page Switcher Hotkey", (KeyCode)115, "Press while the emote wheel is open to switch between the first two vanilla emote pages, skipping the stance page.");
			showStancePictures = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Show Stance Pictures", true, "Show stance preview pictures instead of text names on the stance wheel.");
			LoadStancePictures();
			Canvas.preWillRenderCanvases += new WillRenderCanvases(BeforeCanvasRender);
			harmony = new Harmony("Rombusz.StanceSelector");
			harmony.PatchAll(typeof(Plugin).Assembly);
			SceneManager.sceneLoaded += SceneLoaded;
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Plugin StanceSelector 1.4.1 is loaded!");
		}

		private void OnDestroy()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			RestorePreviousPage(refresh: false);
			Canvas.preWillRenderCanvases -= new WillRenderCanvases(BeforeCanvasRender);
			RestoreSuppressedLabels();
			pictureWheel = null;
			SceneManager.sceneLoaded -= SceneLoaded;
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			hoveredWheel = null;
			hoveredStance = -1;
			for (int i = 0; i < 8; i++)
			{
				if ((Object)(object)StanceEntries[i] != (Object)null)
				{
					Object.Destroy((Object)(object)StanceEntries[i]);
					StanceEntries[i] = null;
				}
				DestroySprite(ref StanceSprites[i]);
				DestroySprite(ref StanceHoveredSprites[i]);
			}
		}

		private static void DestroySprite(ref Sprite sprite)
		{
			if (!((Object)(object)sprite == (Object)null))
			{
				Texture2D texture = sprite.texture;
				Object.Destroy((Object)(object)sprite);
				Object.Destroy((Object)(object)texture);
				sprite = null;
			}
		}

		private static void LoadStancePictures()
		{
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < 8; i++)
			{
				StanceSprites[i] = LoadStanceSprite(StanceImageNames[i], StanceNames[i]);
				if ((Object)(object)StanceSprites[i] != (Object)null)
				{
					num++;
				}
				StanceHoveredSprites[i] = LoadStanceSprite(Path.GetFileNameWithoutExtension(StanceImageNames[i]) + "-hovered.png", StanceNames[i] + " Hovered");
				if ((Object)(object)StanceHoveredSprites[i] != (Object)null)
				{
					num2++;
				}
			}
			if (num != 8 || num2 != 8)
			{
				log.LogWarning((object)$"Loaded {num}/{8} stance pictures and {num2}/{8} hovered pictures. Searched '{stanceImageDirectory}' and '{pluginDirectory}'. Missing hovered pictures will use their normal version.");
			}
		}

		private static Sprite LoadStanceSprite(string fileName, string displayName)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0053: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(stanceImageDirectory, fileName);
			if (!File.Exists(text))
			{
				text = Path.Combine(pluginDirectory, fileName);
				if (!File.Exists(text))
				{
					return null;
				}
			}
			Texture2D val = null;
			try
			{
				val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					name = displayName,
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1,
					hideFlags = (HideFlags)61
				};
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text), true))
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
				((Object)val2).name = displayName;
				((Object)val2).hideFlags = (HideFlags)61;
				return val2;
			}
			catch (Exception ex)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				log.LogWarning((object)("Could not load stance picture '" + text + "': " + ex.Message));
				return null;
			}
		}

		private static void PrepareStancePage(EmoteWheel wheel)
		{
			for (int i = 0; i < 8; i++)
			{
				if ((Object)(object)StanceEntries[i] == (Object)null)
				{
					StanceEntries[i] = CreateStance(i);
				}
			}
			if (GetStancePage(wheel) < 0)
			{
				int pages = wheel.pages;
				EmoteWheelData[] data = wheel.data;
				int num = Math.Max(pages, (((data != null) ? data.Length : 0) + 8 - 1) / 8);
				Array.Resize(ref wheel.data, (num + 1) * 8);
				Array.Copy(StanceEntries, 0, wheel.data, num * 8, 8);
			}
			wheel.pages = Math.Max(wheel.pages, GetStancePage(wheel) + 1);
		}

		private static int GetStancePage(EmoteWheel wheel)
		{
			if ((Object)(object)wheel == (Object)null || wheel.data == null || (Object)(object)StanceEntries[0] == (Object)null)
			{
				return -1;
			}
			for (int i = 0; i + 8 <= wheel.data.Length; i += 8)
			{
				int j;
				for (j = 0; j < 8 && (Object)(object)wheel.data[i + j] == (Object)(object)StanceEntries[j]; j++)
				{
				}
				if (j == 8)
				{
					return i / 8;
				}
			}
			return -1;
		}

		private static EmoteWheelData CreateStance(int index)
		{
			EmoteWheelData val = ScriptableObject.CreateInstance<EmoteWheelData>();
			val.emoteName = StanceNames[index];
			val.anim = string.Empty;
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private static void DrawWheel(EmoteWheel wheel, int page)
		{
			RestoreSuppressedLabels();
			bool flag = page == GetStancePage(wheel);
			pictureWheel = ((flag && showStancePictures.Value) ? wheel : null);
			if ((Object)(object)hoveredWheel == (Object)(object)wheel)
			{
				hoveredWheel = null;
				hoveredStance = -1;
			}
			bool value = showStancePictures.Value;
			for (int i = 0; i < wheel.slices.Length; i++)
			{
				EmoteWheelSlice val = wheel.slices[i];
				Transform transform = ((Component)val.image).transform;
				bool flag2 = flag && i < 8;
				if (flag2 && i >= AvailableStances())
				{
					((Selectable)((UIWheelSlice)val).button).interactable = false;
				}
				if (flag2 && value && (Object)(object)StanceSprites[i] != (Object)null)
				{
					Transform val2 = transform.Find("StanceSelector Picture");
					Image val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Image>() : CreatePicture(transform));
					val3.sprite = StanceSprites[i];
					((Component)val3).gameObject.SetActive(((Selectable)((UIWheelSlice)val).button).interactable);
					((Component)val3).transform.SetAsLastSibling();
					((Behaviour)val.image).enabled = false;
				}
				else if (flag2)
				{
					Transform val4 = transform.Find("StanceSelector Picture");
					if ((Object)(object)val4 != (Object)null)
					{
						((Component)val4).gameObject.SetActive(false);
					}
					Transform val5 = transform.Find("StanceSelector Label");
					TextMeshProUGUI val6 = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent<TextMeshProUGUI>() : CreateLabel(wheel, transform));
					((Component)val6).gameObject.SetActive(((Selectable)((UIWheelSlice)val).button).interactable);
					((Behaviour)val6).enabled = true;
					((TMP_Text)val6).text = StanceNames[i];
					((Behaviour)val.image).enabled = false;
				}
				else
				{
					Transform val7 = transform.Find("StanceSelector Label");
					if ((Object)(object)val7 != (Object)null)
					{
						((Component)val7).gameObject.SetActive(false);
					}
					Transform val8 = transform.Find("StanceSelector Picture");
					if ((Object)(object)val8 != (Object)null)
					{
						((Component)val8).gameObject.SetActive(false);
					}
				}
			}
			if (flag && value)
			{
				HideStanceLabels(wheel);
			}
			if ((Object)(object)wheel == (Object)(object)shortcutWheel)
			{
				((Component)wheel.prevButton).gameObject.SetActive(false);
				((Component)wheel.nextButton).gameObject.SetActive(false);
			}
		}

		private static void SetHoveredStance(EmoteWheel wheel, int index)
		{
			if (showStancePictures.Value && WheelPage.Invoke(wheel) == GetStancePage(wheel))
			{
				if ((Object)(object)hoveredWheel != (Object)null && hoveredStance >= 0 && ((Object)(object)hoveredWheel != (Object)(object)wheel || hoveredStance != index))
				{
					SetStancePicture(hoveredWheel, hoveredStance, hovered: false);
				}
				hoveredWheel = wheel;
				hoveredStance = index;
				SetStancePicture(wheel, index, hovered: true);
			}
		}

		private static void ClearHoveredStance(EmoteWheel wheel, int index)
		{
			if (!((Object)(object)hoveredWheel != (Object)(object)wheel) && hoveredStance == index)
			{
				SetStancePicture(wheel, index, hovered: false);
				hoveredWheel = null;
				hoveredStance = -1;
			}
		}

		private static void SetStancePicture(EmoteWheel wheel, int index, bool hovered)
		{
			if (!((Object)(object)wheel == (Object)null) && index >= 0 && index < 8 && index < wheel.slices.Length)
			{
				Transform val = ((Component)wheel.slices[index].image).transform.Find("StanceSelector Picture");
				if (!((Object)(object)val == (Object)null))
				{
					Image component = ((Component)val).GetComponent<Image>();
					component.sprite = ((hovered && (Object)(object)StanceHoveredSprites[index] != (Object)null) ? StanceHoveredSprites[index] : StanceSprites[index]);
				}
			}
		}

		private static void BeforeCanvasRender()
		{
			if ((Object)(object)pictureWheel != (Object)null && ((Component)pictureWheel).gameObject.activeInHierarchy && showStancePictures.Value && WheelPage.Invoke(pictureWheel) == GetStancePage(pictureWheel))
			{
				HideStanceLabels(pictureWheel);
			}
			else
			{
				RestoreSuppressedLabels();
			}
		}

		private static void HideStanceLabels(EmoteWheel wheel)
		{
			for (int i = 0; i < wheel.slices.Length && i < 8; i++)
			{
				if ((Object)(object)StanceSprites[i] == (Object)null)
				{
					continue;
				}
				EmoteWheelSlice val = wheel.slices[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				((Component)val).GetComponentsInChildren<TMP_Text>(true, SliceTmpLabels);
				foreach (TMP_Text sliceTmpLabel in SliceTmpLabels)
				{
					if ((Object)(object)sliceTmpLabel != (Object)(object)wheel.selectedEmoteName && IsStanceLabel(((Object)sliceTmpLabel).name, sliceTmpLabel.text))
					{
						SuppressLabel((Graphic)(object)sliceTmpLabel);
					}
				}
				((Component)val).GetComponentsInChildren<Text>(true, SliceLegacyLabels);
				foreach (Text sliceLegacyLabel in SliceLegacyLabels)
				{
					if (IsStanceLabel(((Object)sliceLegacyLabel).name, sliceLegacyLabel.text))
					{
						SuppressLabel((Graphic)(object)sliceLegacyLabel);
					}
				}
			}
			SliceTmpLabels.Clear();
			SliceLegacyLabels.Clear();
		}

		private static bool IsStanceLabel(string objectName, string text)
		{
			if (!(objectName == "StanceSelector Label") && !(objectName == "Rom Stance Label"))
			{
				return Array.IndexOf(StanceNames, text) >= 0;
			}
			return true;
		}

		private static void SuppressLabel(Graphic label)
		{
			if (((Behaviour)label).enabled)
			{
				if (!SuppressedLabels.Contains(label))
				{
					SuppressedLabels.Add(label);
				}
				((Behaviour)label).enabled = false;
			}
		}

		private static void RestoreSuppressedLabels()
		{
			foreach (Graphic suppressedLabel in SuppressedLabels)
			{
				if ((Object)(object)suppressedLabel != (Object)null)
				{
					((Behaviour)suppressedLabel).enabled = true;
				}
			}
			SuppressedLabels.Clear();
		}

		private static T CreateSliceGraphic<T>(Transform parent, string name) where T : Graphic
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0056: 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)
			//IL_0076: 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)
			GameObject val = new GameObject(name, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(T)
			});
			((Object)val).hideFlags = (HideFlags)52;
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			component.anchorMin = new Vector2(0.06f, 0.06f);
			component.anchorMax = new Vector2(0.94f, 0.94f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			T component2 = val.GetComponent<T>();
			((Graphic)component2).raycastTarget = false;
			return component2;
		}

		private static Image CreatePicture(Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Image val = CreateSliceGraphic<Image>(parent, "StanceSelector Picture");
			val.preserveAspect = true;
			((Graphic)val).color = Color.white;
			return val;
		}

		private static TextMeshProUGUI CreateLabel(EmoteWheel wheel, Transform parent)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = CreateSliceGraphic<TextMeshProUGUI>(parent, "StanceSelector Label");
			((TMP_Text)val).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val).enableAutoSizing = true;
			((TMP_Text)val).fontSizeMin = 14f;
			((TMP_Text)val).fontSizeMax = 30f;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)val).overflowMode = (TextOverflowModes)1;
			((Graphic)val).color = Color.black;
			((TMP_Text)val).font = ((TMP_Text)wheel.selectedEmoteName).font;
			((TMP_Text)val).fontSharedMaterial = ((TMP_Text)wheel.selectedEmoteName).fontSharedMaterial;
			return val;
		}

		private static int GetStance(EmoteWheelData data)
		{
			if (!((Object)(object)data != (Object)null))
			{
				return -1;
			}
			return Array.IndexOf(StanceEntries, data);
		}

		private static int AvailableStances()
		{
			Character localCharacter = Character.localCharacter;
			if (!((Object)(object)localCharacter != (Object)null) || localCharacter.refs == null || !((Object)(object)localCharacter.refs.customization != (Object)null))
			{
				return 0;
			}
			return Mathf.Clamp(localCharacter.refs.customization.maxIdles, 0, 8);
		}

		private static void OpenShortcutPage(EmoteWheel wheel)
		{
			if (!((Object)(object)shortcutWheel != (Object)null) && !((Object)(object)wheel == (Object)null))
			{
				shortcutWheel = wheel;
				previousPage = WheelPage.Invoke(wheel);
				PrepareStancePage(wheel);
				WheelPage.Invoke(wheel) = GetStancePage(wheel);
				if (((Component)wheel).gameObject.activeInHierarchy)
				{
					wheel.InitWheel();
				}
			}
		}

		private static void RestorePreviousPage(bool refresh)
		{
			EmoteWheel val = shortcutWheel;
			shortcutWheel = null;
			if (!((Object)(object)val == (Object)null))
			{
				WheelPage.Invoke(val) = previousPage;
				if (refresh && ((Component)val).gameObject.activeInHierarchy)
				{
					val.InitWheel();
				}
			}
		}

		private static void ApplyStance(int index)
		{
			Character localCharacter = Character.localCharacter;
			if (!((Object)(object)localCharacter == (Object)null) && index >= 0 && index < AvailableStances())
			{
				selectedStance = index;
				PhotonView photonView = ((MonoBehaviourPun)localCharacter).photonView;
				if (photonView.IsMine && PhotonNetwork.InRoom)
				{
					PhotonNetwork.RemoveBufferedRPCs(photonView.ViewID, "SetCharacterIdle_RPC", (int[])null);
					photonView.RPC("SetCharacterIdle_RPC", (RpcTarget)3, new object[1] { index });
				}
				else
				{
					localCharacter.refs.animations.SetIdle(index);
				}
			}
		}

		private static bool IsMenuScene(string scene)
		{
			if (!scene.Equals("Airport", StringComparison.OrdinalIgnoreCase) && !scene.Equals("Title", StringComparison.OrdinalIgnoreCase))
			{
				return scene.Equals("MainMenu", StringComparison.OrdinalIgnoreCase);
			}
			return true;
		}

		private static void SceneLoaded(Scene scene, LoadSceneMode _)
		{
			RestoreSuppressedLabels();
			pictureWheel = null;
			if (IsMenuScene(((Scene)(ref scene)).name))
			{
				selectedStance = -1;
			}
			shortcutWheel = null;
			hoveredWheel = null;
			hoveredStance = -1;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}