Decompiled source of LethalEmotesAPI v1.15.8

LethalEmotesApi/LethalEmotesAPI.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using AdvancedCompany.Game;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterEmote.AssetScripts;
using BetterEmote.Patches;
using BetterEmote.Utils;
using EmotesAPI;
using GameNetcodeStuff;
using HarmonyLib;
using JetBrains.Annotations;
using LethalCompanyInputUtils.Api;
using LethalEmotesAPI;
using LethalEmotesAPI.Core;
using LethalEmotesAPI.Data;
using LethalEmotesAPI.ImportV2;
using LethalEmotesAPI.NetcodePatcher;
using LethalEmotesAPI.Patches;
using LethalEmotesAPI.Patches.ModCompat;
using LethalEmotesAPI.Utils;
using LethalEmotesApi.Ui;
using LethalEmotesApi.Ui.Data;
using LethalEmotesApi.Ui.Db;
using LethalEmotesApi.Ui.Dmca;
using LethalInternship.AI;
using LethalVRM;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using MonoMod.RuntimeDetour;
using MoreCompany.Cosmetics;
using Newtonsoft.Json;
using TMPro;
using TooManyEmotes;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("BetterEmotes")]
[assembly: IgnoresAccessChecksTo("LethalInternship")]
[assembly: IgnoresAccessChecksTo("LethalVRM")]
[assembly: IgnoresAccessChecksTo("MToon")]
[assembly: IgnoresAccessChecksTo("UniGLTF")]
[assembly: IgnoresAccessChecksTo("UniGLTF.Utils")]
[assembly: IgnoresAccessChecksTo("UniHumanoid")]
[assembly: IgnoresAccessChecksTo("VRM10")]
[assembly: IgnoresAccessChecksTo("VrmLib")]
[assembly: IgnoresAccessChecksTo("VRMShaders.GLTF.IO.Runtime")]
[assembly: IgnoresAccessChecksTo("VRMShaders.VRM.IO.Runtime")]
[assembly: IgnoresAccessChecksTo("VRMShaders.VRM10.Format.Runtime")]
[assembly: IgnoresAccessChecksTo("VRMShaders.VRM10.MToon10.Runtime")]
[assembly: AssemblyCompany("LethalEmotesAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+15eb38b312ea9fbf6ce336edf9651f91374b8535")]
[assembly: AssemblyProduct("LethalEmotesAPI")]
[assembly: AssemblyTitle("LethalEmotesAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class AnimationReplacements
{
	internal static GameObject g;

	internal static bool setup;

	internal static void RunAll()
	{
		ChangeAnims();
	}

	internal static BoneMapper Import(GameObject prefab, string skeleton, int[] pos, bool hidemesh = true)
	{
		GameObject val = Object.Instantiate<GameObject>(Assets.Load<GameObject>("@CustomEmotesAPI_customemotespackage:assets/animationreplacements/commando.prefab"));
		GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>(skeleton));
		val2.GetComponent<Animator>().runtimeAnimatorController = val.GetComponent<Animator>().runtimeAnimatorController;
		BoneMapper result = ApplyAnimationStuff(prefab, val2, pos, hidemesh, jank: false, revertBonePositions: true);
		val.transform.SetParent(val2.transform);
		return result;
	}

	public static void DebugBones(GameObject fab)
	{
		SkinnedMeshRenderer[] componentsInChildren = fab.GetComponentsInChildren<SkinnedMeshRenderer>();
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append($"rendererererer: {componentsInChildren[0]}\n");
		stringBuilder.Append($"bone count: {componentsInChildren[0].bones.Length}\n");
		stringBuilder.Append($"mesh count: {componentsInChildren.Length}\n");
		stringBuilder.Append("root bone: " + ((Object)componentsInChildren[0].rootBone).name + "\n");
		stringBuilder.Append(((object)fab).ToString() + ":\n");
		SkinnedMeshRenderer[] array = componentsInChildren;
		foreach (SkinnedMeshRenderer val in array)
		{
			if (val.bones.Length == 0)
			{
				stringBuilder.Append("No bones");
			}
			else
			{
				stringBuilder.Append("[");
				Transform[] bones = val.bones;
				foreach (Transform val2 in bones)
				{
					stringBuilder.Append("'" + ((Object)val2).name + "', ");
				}
				stringBuilder.Remove(stringBuilder.Length - 2, 2);
				stringBuilder.Append("]");
			}
			stringBuilder.Append("\n\n");
			DebugClass.Log(stringBuilder.ToString());
		}
	}

	internal static void ChangeAnims()
	{
	}

	internal static void ApplyAnimationStuff(GameObject bodyPrefab, string resource, int[] pos)
	{
		GameObject animcontroller = Assets.Load<GameObject>(resource);
		ApplyAnimationStuff(bodyPrefab, animcontroller, pos);
	}

	internal static BoneMapper ApplyAnimationStuff(GameObject bodyPrefab, GameObject animcontroller, int[] pos, bool hidemeshes = true, bool jank = false, bool revertBonePositions = false)
	{
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: 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)
		try
		{
			if (!animcontroller.GetComponentInChildren<Animator>().avatar.isHuman)
			{
				DebugClass.Log($"{animcontroller}'s avatar isn't humanoid, please fix it in unity!");
				return null;
			}
		}
		catch (Exception arg)
		{
			DebugClass.Log($"Had issue checking if avatar was humanoid: {arg}");
			throw;
		}
		try
		{
			if (hidemeshes)
			{
				SkinnedMeshRenderer[] componentsInChildren = animcontroller.GetComponentsInChildren<SkinnedMeshRenderer>();
				foreach (SkinnedMeshRenderer val in componentsInChildren)
				{
					val.sharedMesh = null;
				}
				MeshFilter[] componentsInChildren2 = animcontroller.GetComponentsInChildren<MeshFilter>();
				foreach (MeshFilter val2 in componentsInChildren2)
				{
					val2.sharedMesh = null;
				}
			}
		}
		catch (Exception arg2)
		{
			DebugClass.Log($"Had trouble while hiding meshes: {arg2}");
			throw;
		}
		Transform transform = ((Component)bodyPrefab.GetComponentInChildren<Animator>()).transform;
		SkinnedMeshRenderer[] array = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[pos.Length];
		SkinnedMeshRenderer emoteSkeletonSMR;
		try
		{
			emoteSkeletonSMR = animcontroller.GetComponentsInChildren<SkinnedMeshRenderer>()[0];
		}
		catch (Exception arg3)
		{
			DebugClass.Log($"Had trouble setting emote skeletons SkinnedMeshRenderer: {arg3}");
			throw;
		}
		try
		{
			for (int k = 0; k < pos.Length; k++)
			{
				array[k] = bodyPrefab.GetComponentsInChildren<SkinnedMeshRenderer>()[pos[k]];
			}
		}
		catch (Exception arg4)
		{
			DebugClass.Log($"Had trouble setting the original skeleton's skinned mesh renderer: {arg4}");
			throw;
		}
		BoneMapper boneMapper = animcontroller.AddComponent<BoneMapper>();
		try
		{
			boneMapper.jank = jank;
			boneMapper.emoteSkeletonSMR = emoteSkeletonSMR;
			boneMapper.basePlayerModelSMR = array;
			boneMapper.bodyPrefab = bodyPrefab;
			boneMapper.basePlayerModelAnimator = ((Component)transform).GetComponentInChildren<Animator>();
			boneMapper.emoteSkeletonAnimator = animcontroller.GetComponentInChildren<Animator>();
		}
		catch (Exception arg5)
		{
			DebugClass.Log($"Had issue when setting up BoneMapper settings 1: {arg5}");
			throw;
		}
		try
		{
			GameObject val3 = Assets.Load<GameObject>("assets/customstuff/scavEmoteSkeleton.prefab");
			val3.transform.localScale = new Vector3(1.1216f, 1.1216f, 1.1216f);
			float num = Vector3.Distance(val3.GetComponentInChildren<Animator>().GetBoneTransform((HumanBodyBones)10).position, val3.GetComponentInChildren<Animator>().GetBoneTransform((HumanBodyBones)5).position);
			float num2 = Vector3.Distance(animcontroller.GetComponentInChildren<Animator>().GetBoneTransform((HumanBodyBones)10).position, animcontroller.GetComponentInChildren<Animator>().GetBoneTransform((HumanBodyBones)5).position);
			boneMapper.scale = num2 / num;
			boneMapper.model = ((Component)transform).gameObject;
		}
		catch (Exception arg6)
		{
			DebugClass.Log($"Had issue when setting up BoneMapper settings 2: {arg6}");
			throw;
		}
		try
		{
			animcontroller.transform.parent = transform;
			animcontroller.transform.localPosition = Vector3.zero;
			animcontroller.transform.eulerAngles = bodyPrefab.transform.eulerAngles;
			animcontroller.transform.localScale = Vector3.one;
		}
		catch (Exception arg7)
		{
			DebugClass.Log($"Had trouble setting emote skeletons parent: {arg7}");
			throw;
		}
		boneMapper.revertTransform = revertBonePositions;
		return boneMapper;
	}
}
public struct WorldProp
{
	internal GameObject prop;

	internal JoinSpot[] joinSpots;

	public WorldProp(GameObject _prop, JoinSpot[] _joinSpots)
	{
		prop = _prop;
		joinSpots = _joinSpots;
	}
}
public enum TempThirdPerson
{
	none,
	on,
	off
}
public class BoneMapper : MonoBehaviour
{
	public static List<AudioClip[]> primaryAudioClips = new List<AudioClip[]>();

	public static List<AudioClip[]> secondaryAudioClips = new List<AudioClip[]>();

	public static List<AudioClip[]> primaryDMCAFreeAudioClips = new List<AudioClip[]>();

	public static List<AudioClip[]> secondaryDMCAFreeAudioClips = new List<AudioClip[]>();

	public GameObject audioObject;

	public SkinnedMeshRenderer emoteSkeletonSMR;

	public SkinnedMeshRenderer[] basePlayerModelSMR;

	public Animator basePlayerModelAnimator;

	public Animator emoteSkeletonAnimator;

	public int h;

	public List<BonePair> pairs = new List<BonePair>();

	public float timer = 0f;

	public GameObject model;

	private bool twopart = false;

	public static Dictionary<string, CustomAnimationClip> animClips = new Dictionary<string, CustomAnimationClip>();

	public CustomAnimationClip currentClip = null;

	public string currentClipName = "none";

	public string prevClipName = "none";

	public CustomAnimationClip prevClip = null;

	internal static float Current_MSX = 69f;

	internal static List<BoneMapper> allMappers = new List<BoneMapper>();

	internal static List<WorldProp> allWorldProps = new List<WorldProp>();

	public bool local = false;

	internal static bool moving = false;

	internal static bool attacking = false;

	public bool jank = false;

	public List<GameObject> props = new List<GameObject>();

	public float scale = 1f;

	internal int desiredEvent = 0;

	public int currEvent = 0;

	public float autoWalkSpeed = 0f;

	public bool overrideMoveSpeed = false;

	public bool autoWalk = false;

	public GameObject currentEmoteSpot = null;

	public GameObject reservedEmoteSpot = null;

	public bool worldProp = false;

	public bool ragdolling = false;

	public GameObject bodyPrefab;

	public int uniqueSpot = -1;

	public bool preserveProps = false;

	public bool preserveParent = false;

	internal bool useSafePositionReset = false;

	public List<EmoteLocation> emoteLocations = new List<EmoteLocation>();

	private List<string> dontAnimateUs = new List<string>();

	public bool enableAnimatorOnDeath = true;

	public bool revertTransform = false;

	public bool oneFrameAnimatorLeeWay = false;

	public GameObject mapperBody;

	public PlayerControllerB playerController;

	public EnemyAI enemyController;

	public Transform mapperBodyTransform;

	public static bool firstMapperSpawn = true;

	public static List<List<AudioSource>> listOfCurrentEmoteAudio = new List<List<AudioSource>>();

	public List<EmoteConstraint> cameraConstraints = new List<EmoteConstraint>();

	public List<EmoteConstraint> itemHolderConstraints = new List<EmoteConstraint>();

	public Transform itemHolderPosition;

	public List<EmoteConstraint> additionalConstraints = new List<EmoteConstraint>();

	public EmoteConstraint thirdPersonConstraint;

	public static Dictionary<string, string> customNamePairs = new Dictionary<string, string>();

	public Vector3 positionBeforeRootMotion = new Vector3(69f, 69f, 69f);

	public Quaternion rotationBeforeRootMotion = Quaternion.identity;

	public float currentAudioLevel = 0f;

	public TempThirdPerson temporarilyThirdPerson = TempThirdPerson.none;

	internal int originalCullingMask;

	internal bool needToTurnOffRenderingThing = false;

	public BoneMapper currentlyLockedBoneMapper;

	public static Dictionary<GameObject, BoneMapper> playersToMappers = new Dictionary<GameObject, BoneMapper>();

	public AudioSource personalAudioSource;

	public InteractTrigger personalTrigger;

	public string currentJoinButton;

	public bool isServer = false;

	public int networkId;

	public bool joined = false;

	public bool canThirdPerson = true;

	internal bool canEmote = false;

	public bool isValidPlayer = false;

	internal bool canStop = true;

	internal List<EmoteConstraint> cosmeticConstraints = new List<EmoteConstraint>();

	internal GameObject originalCosmeticPosition;

	public GameObject parentGameObject;

	public bool positionLock;

	public bool rotationLock;

	public bool scaleLock;

	private Vector3 ogScale = new Vector3(-69f, -69f, -69f);

	private Vector3 ogVisorScale = Vector3.zeroVector;

	private Vector3 scaleDiff = Vector3.one;

	public GameObject rotationPoint;

	public GameObject desiredCameraPos;

	public GameObject realCameraPos;

	private bool ranSinceLastAnim = false;

	public Vector3 deltaPos = new Vector3(0f, 0f, 0f);

	public Quaternion deltaRot = Quaternion.identity;

	public Vector3 prevPosition = Vector3.zero;

	public Quaternion prevRotation = Quaternion.identity;

	public Vector3 prevMapperPos = new Vector3(69f, 69f, 69f);

	public Vector3 prevMapperRot = default(Vector3);

	public bool justSwitched = false;

	public bool isEnemy = false;

	public bool isInThirdPerson = false;

	public int originalLayer = -1;

	internal bool needToTurnOffShadows = true;

	internal bool needToTurnOffCosmetics = true;

	private Renderer helmetRenderer = null;

	public static string GetRealAnimationName(string animationName)
	{
		if (customNamePairs.ContainsKey(animationName))
		{
			return customNamePairs[animationName];
		}
		return animationName;
	}

	private IEnumerator lockBonesAfterAFrame()
	{
		yield return (object)new WaitForEndOfFrame();
		LockBones();
	}

	public void PlayAnim(string s, int pos, int eventNum)
	{
		desiredEvent = eventNum;
		s = GetRealAnimationName(s);
		PlayAnim(s, pos);
	}

	public void PlayAnim(string s, int pos)
	{
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0593: Expected O, but got Unknown
		ranSinceLastAnim = false;
		s = GetRealAnimationName(s);
		prevClipName = currentClipName;
		if (s != "none")
		{
			if (!animClips.ContainsKey(s))
			{
				DebugClass.Log("No emote bound to the name [" + s + "]");
				return;
			}
			if (animClips[s] == null || !animClips[s].animates)
			{
				CustomEmotesAPI.Changed(s, this);
				return;
			}
		}
		((Behaviour)emoteSkeletonAnimator).enabled = true;
		dontAnimateUs.Clear();
		if (currentClip != null)
		{
			try
			{
				if (currentClip.syncronizeAnimation || currentClip.syncronizeAudio)
				{
					CustomAnimationClip.syncPlayerCount[currentClip.syncPos]--;
				}
				audioObject.GetComponent<AudioManager>().Stop();
			}
			catch (Exception arg)
			{
				DebugClass.Log($"had issue turning off audio before new audio played step 1: {arg}");
			}
			try
			{
				if ((Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null && currentClip.syncronizeAudio)
				{
					try
					{
						listOfCurrentEmoteAudio[currentClip.syncPos].Remove(audioObject.GetComponent<AudioSource>());
					}
					catch (Exception arg2)
					{
						DebugClass.Log($"had issue turning off audio before new audio played step 2: {arg2}");
						try
						{
							DebugClass.Log($"{prevClip.syncPos}");
							DebugClass.Log($"{currentClip.syncPos}");
							DebugClass.Log(listOfCurrentEmoteAudio[currentClip.syncPos]);
						}
						catch (Exception)
						{
						}
						try
						{
							DebugClass.Log("going to try a brute force method to avoid audio desync issues");
							foreach (List<AudioSource> item in listOfCurrentEmoteAudio)
							{
								if (item.Contains(audioObject.GetComponent<AudioSource>()))
								{
									item.Remove(audioObject.GetComponent<AudioSource>());
								}
							}
						}
						catch (Exception arg3)
						{
							DebugClass.Log($"wow {arg3}");
						}
					}
				}
			}
			catch (Exception ex2)
			{
				DebugClass.Log($"had issue turning off audio before new audio played step 3: {primaryAudioClips[currentClip.syncPos]} {currentClip.syncPos} {currEvent} {ex2}");
			}
			try
			{
				if (uniqueSpot != -1 && CustomAnimationClip.uniqueAnimations[currentClip.syncPos][uniqueSpot])
				{
					CustomAnimationClip.uniqueAnimations[currentClip.syncPos][uniqueSpot] = false;
					uniqueSpot = -1;
				}
			}
			catch (Exception arg4)
			{
				DebugClass.Log($"had issue turning off audio before new audio played step 4: {arg4}");
			}
		}
		currEvent = 0;
		currentClipName = s;
		if (s == "none")
		{
			UnlockBones();
			emoteSkeletonAnimator.Play("none", -1, 0f);
			twopart = false;
			prevClip = currentClip;
			currentClip = null;
			NewAnimation(null);
			CustomEmotesAPI.Changed(s, this);
		}
		else
		{
			if (BlacklistSettings.emotesDisabled.Contains(s))
			{
				return;
			}
			if (s != "none")
			{
				prevClip = currentClip;
				currentClip = animClips[s];
				if (currentClip == null)
				{
					return;
				}
				if (pos == -2)
				{
					pos = ((CustomAnimationClip.syncPlayerCount[animClips[s].syncPos] != 0) ? animClips[s].joinPref : animClips[s].startPref);
				}
				if (pos == -2)
				{
					for (int i = 0; i < CustomAnimationClip.uniqueAnimations[currentClip.syncPos].Count; i++)
					{
						if (!CustomAnimationClip.uniqueAnimations[currentClip.syncPos][i])
						{
							pos = i;
							uniqueSpot = pos;
							CustomAnimationClip.uniqueAnimations[currentClip.syncPos][uniqueSpot] = true;
							break;
						}
					}
					if (uniqueSpot == -1)
					{
						pos = -1;
					}
				}
				if (pos == -1)
				{
					pos = Random.Range(0, currentClip.clip.Length);
				}
				((MonoBehaviour)this).StartCoroutine(lockBonesAfterAFrame());
			}
			AnimatorOverrideController animController = new AnimatorOverrideController(emoteSkeletonAnimator.runtimeAnimatorController);
			if (currentClip.syncronizeAnimation || currentClip.syncronizeAudio)
			{
				CustomAnimationClip.syncPlayerCount[currentClip.syncPos]++;
				if (CustomAnimationClip.syncPlayerCount[currentClip.syncPos] == 1)
				{
					CustomAnimationClip.syncTimer[currentClip.syncPos] = 0f;
				}
			}
			if ((Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null)
			{
				if (CustomAnimationClip.syncPlayerCount[currentClip.syncPos] == 1 && currentClip.syncronizeAudio)
				{
					if (desiredEvent != -1)
					{
						currEvent = desiredEvent;
					}
					else
					{
						currEvent = Random.Range(0, primaryAudioClips[currentClip.syncPos].Length);
					}
					foreach (BoneMapper allMapper in allMappers)
					{
						allMapper.currEvent = currEvent;
					}
					if (currentClip.customPostEventCodeSync != null)
					{
						currentClip.customPostEventCodeSync(this);
					}
				}
				else if (!currentClip.syncronizeAudio)
				{
					currEvent = Random.Range(0, primaryAudioClips[currentClip.syncPos].Length);
					if (currentClip.customPostEventCodeNoSync != null)
					{
						currentClip.customPostEventCodeNoSync(this);
					}
				}
				currentAudioLevel = currentClip.audioLevel;
				audioObject.GetComponent<AudioManager>().Play(currentClip.syncPos, currEvent, currentClip.looping, currentClip.syncronizeAudio, currentClip.willGetClaimed);
				if (currentClip.syncronizeAudio && (Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null)
				{
					listOfCurrentEmoteAudio[currentClip.syncPos].Add(audioObject.GetComponent<AudioSource>());
				}
			}
			SetAnimationSpeed(1f);
			StartAnimations(animController, pos, emoteSkeletonAnimator);
			if (local && CustomEmotesAPI.hudObject != null)
			{
				if (currentClip.displayName != "")
				{
					((TMP_Text)CustomEmotesAPI.currentEmoteText).text = currentClip.displayName;
				}
				else if (currentClip.customInternalName != "")
				{
					((TMP_Text)CustomEmotesAPI.currentEmoteText).text = currentClip.customInternalName;
				}
				else if (!currentClip.visibility)
				{
					((TMP_Text)CustomEmotesAPI.currentEmoteText).text = "";
				}
				else
				{
					((TMP_Text)CustomEmotesAPI.currentEmoteText).text = currentClipName;
				}
			}
			twopart = false;
			NewAnimation(currentClip.joinSpots);
			if (currentClip.usesNewImportSystem)
			{
				CustomEmotesAPI.Changed(currentClip.customInternalName, this);
			}
			else
			{
				CustomEmotesAPI.Changed(s, this);
			}
		}
	}

	public void StartAnimations(AnimatorOverrideController animController, int pos, Animator animator)
	{
		if (currentClip.secondaryClip != null && currentClip.secondaryClip.Length != 0)
		{
			bool flag = true;
			if (CustomAnimationClip.syncTimer[currentClip.syncPos] > currentClip.clip[pos].length)
			{
				animController["Floss"] = currentClip.secondaryClip[pos];
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)animController;
				animator.Play("Loop", -1, (CustomAnimationClip.syncTimer[currentClip.syncPos] - currentClip.clip[pos].length) % currentClip.secondaryClip[pos].length / currentClip.secondaryClip[pos].length);
			}
			else
			{
				animController["Dab"] = currentClip.clip[pos];
				animController["nobones"] = currentClip.secondaryClip[pos];
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)animController;
				animator.Play("PoopToLoop", -1, CustomAnimationClip.syncTimer[currentClip.syncPos] % currentClip.clip[pos].length / currentClip.clip[pos].length);
			}
		}
		else if (((Motion)currentClip.clip[0]).isLooping)
		{
			animController["Floss"] = currentClip.clip[pos];
			animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)animController;
			if (currentClip.clip[pos].length != 0f)
			{
				animator.Play("Loop", -1, CustomAnimationClip.syncTimer[currentClip.syncPos] % currentClip.clip[pos].length / currentClip.clip[pos].length);
			}
			else
			{
				animator.Play("Loop", -1, 0f);
			}
		}
		else
		{
			animController["Default Dance"] = currentClip.clip[pos];
			animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)animController;
			animator.Play("Poop", -1, CustomAnimationClip.syncTimer[currentClip.syncPos] % currentClip.clip[pos].length / currentClip.clip[pos].length);
		}
	}

	public static void PreviewAnimations(Animator animator, string animation)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		AnimatorOverrideController val = new AnimatorOverrideController(animator.runtimeAnimatorController);
		animation = GetRealAnimationName(animation);
		if (!animClips.ContainsKey(animation))
		{
			return;
		}
		CustomAnimationClip customAnimationClip = animClips[animation];
		if (customAnimationClip != null && customAnimationClip.clip != null && customAnimationClip.clip[0] != null)
		{
			int num = 0;
			if (customAnimationClip.secondaryClip != null && customAnimationClip.secondaryClip.Length != 0)
			{
				val["Dab"] = customAnimationClip.clip[num];
				val["nobones"] = customAnimationClip.secondaryClip[num];
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)val;
				animator.Play("PoopToLoop", -1, 0f);
			}
			else if (((Motion)customAnimationClip.clip[0]).isLooping)
			{
				val["Floss"] = customAnimationClip.clip[num];
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)val;
				animator.Play("Loop", -1, 0f);
			}
			else
			{
				val["Default Dance"] = customAnimationClip.clip[num];
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)val;
				animator.Play("Poop", -1, 0f);
			}
		}
	}

	public void SetAnimationSpeed(float speed)
	{
		emoteSkeletonAnimator.speed = speed;
	}

	internal void NewAnimation(JoinSpot[] locations)
	{
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			try
			{
				if (local)
				{
					((Component)itemHolderPosition).gameObject.GetComponent<EmoteConstraint>().DeactivateConstraints();
				}
			}
			catch (Exception)
			{
			}
			try
			{
				emoteLocations.Clear();
				autoWalkSpeed = 0f;
				autoWalk = false;
				overrideMoveSpeed = false;
				if (Object.op_Implicit((Object)(object)parentGameObject) && !preserveParent)
				{
					parentGameObject = null;
				}
			}
			catch (Exception)
			{
			}
			try
			{
				useSafePositionReset = currentClip.useSafePositionReset;
			}
			catch (Exception)
			{
				useSafePositionReset = true;
			}
			try
			{
				if (preserveParent)
				{
					preserveParent = false;
				}
				else
				{
					mapperBody.gameObject.transform.localEulerAngles = new Vector3(0f, mapperBody.gameObject.transform.localEulerAngles.y, 0f);
					if (ogScale != new Vector3(-69f, -69f, -69f))
					{
						mapperBody.transform.localScale = ogScale;
						if (local)
						{
							playerController.localVisor.localScale = ogVisorScale;
						}
						ogScale = new Vector3(-69f, -69f, -69f);
					}
					Collider[] componentsInChildren = mapperBody.GetComponentsInChildren<Collider>();
					foreach (Collider val in componentsInChildren)
					{
						val.enabled = true;
					}
					if (Object.op_Implicit((Object)(object)mapperBody.GetComponent<CharacterController>()))
					{
						((Collider)mapperBody.GetComponent<CharacterController>()).enabled = true;
					}
				}
			}
			catch (Exception)
			{
			}
			if (preserveProps)
			{
				preserveProps = false;
			}
			else
			{
				foreach (GameObject prop in props)
				{
					if (Object.op_Implicit((Object)(object)prop))
					{
						Object.Destroy((Object)(object)prop);
					}
				}
				props.Clear();
			}
			if (locations != null)
			{
				for (int j = 0; j < locations.Length; j++)
				{
					SpawnJoinSpot(locations[j]);
				}
			}
		}
		catch (Exception arg)
		{
			DebugClass.Log($"error during new animation: {arg}");
		}
	}

	public void ScaleProps()
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		foreach (GameObject prop in props)
		{
			if (Object.op_Implicit((Object)(object)prop))
			{
				Transform parent = prop.transform.parent;
				prop.transform.SetParent((Transform)null);
				prop.transform.localScale = new Vector3(scale * 1.15f, scale * 1.15f, scale * 1.15f);
				prop.transform.SetParent(parent);
			}
		}
	}

	public void UpdateHoverTip(string emoteName)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (personalTrigger != null)
		{
			InputBinding val = EmotesInputSettings.Instance.JoinEmote.bindings[0];
			currentJoinButton = InputControlPath.ToHumanReadableString(((InputBinding)(ref val)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
			personalTrigger.hoverTip = "Press [" + currentJoinButton + "] to join " + emoteName;
		}
	}

	internal IEnumerator preventEmotesInSpawnAnimation()
	{
		yield return (object)new WaitForSeconds(3f);
		foreach (EmoteConstraint item in cosmeticConstraints)
		{
			item.ActivateConstraints();
		}
		canEmote = true;
	}

	private void Start()
	{
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Expected O, but got Unknown
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0607: 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 (worldProp)
		{
			return;
		}
		PlayerControllerB componentInParent = ((Component)((Component)this).transform).GetComponentInParent<PlayerControllerB>();
		if (Object.op_Implicit((Object)(object)((Component)((Component)this).transform).GetComponentInParent<EnemyAI>()) || (componentInParent != null && Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponentInChildren<EnemyAI>())))
		{
			EnemyAI val = ((Component)((Component)this).transform).GetComponentInParent<EnemyAI>();
			if (val == null)
			{
				val = ((Component)componentInParent).GetComponentInChildren<EnemyAI>();
			}
			mapperBody = ((Component)val).gameObject;
			networkId = -1;
			isEnemy = CustomEmotesAPI.localMapper.isServer;
			enemyController = val;
		}
		else if (Object.op_Implicit((Object)(object)componentInParent))
		{
			mapperBody = ((Component)componentInParent).gameObject;
			networkId = (int)((NetworkBehaviour)mapperBody.GetComponent<PlayerControllerB>()).NetworkObjectId;
		}
		else
		{
			networkId = -1;
			mapperBody = ((Component)this).gameObject;
		}
		if (enemyController == null)
		{
			playerController = mapperBody.GetComponent<PlayerControllerB>();
		}
		isValidPlayer = playerController != null;
		if (playersToMappers.ContainsKey(mapperBody))
		{
			playersToMappers[mapperBody] = this;
		}
		else
		{
			playersToMappers.Add(mapperBody, this);
		}
		mapperBodyTransform = mapperBody.transform;
		allMappers.Add(this);
		if (playerController != null)
		{
			GameObject gameObject = ((Component)mapperBody.gameObject.transform.Find("PlayerPhysicsBox")).gameObject;
			gameObject.tag = "InteractTrigger";
			personalTrigger = gameObject.AddComponent<InteractTrigger>();
			personalTrigger.interactable = false;
			personalTrigger.hoverIcon = Object.Instantiate<Sprite>(Assets.Load<Sprite>("assets/fineilldoitmyself/nothing.png"));
			personalTrigger.disabledHoverIcon = Object.Instantiate<Sprite>(Assets.Load<Sprite>("assets/fineilldoitmyself/nothing.png"));
			personalTrigger.disabledHoverTip = "";
			UpdateHoverTip("none");
		}
		GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>("assets/source1.prefab"));
		((Object)val2).name = ((Object)this).name + "_AudioObject";
		val2.transform.SetParent(mapperBody.transform);
		val2.transform.localPosition = Vector3.zero;
		SphereCollider val3 = val2.AddComponent<SphereCollider>();
		val3.radius = 0.01f;
		((Collider)val3).isTrigger = true;
		val2.layer = 6;
		personalAudioSource = val2.GetComponent<AudioSource>();
		val2.AddComponent<AudioManager>().Setup(personalAudioSource, this);
		personalAudioSource.playOnAwake = false;
		personalAudioSource.volume = Settings.EmotesVolume.Value / 100f;
		audioObject = val2;
		int num = 0;
		if (true)
		{
			SkinnedMeshRenderer[] array = basePlayerModelSMR;
			foreach (SkinnedMeshRenderer val4 in array)
			{
				int num2 = 0;
				for (int j = 0; j < emoteSkeletonSMR.bones.Length; j++)
				{
					for (int k = num2; k < val4.bones.Length; k++)
					{
						if (emoteSkeletonSMR.bones[j] != null && ((Object)emoteSkeletonSMR.bones[j]).name == ((Object)val4.bones[k]).name && !Object.op_Implicit((Object)(object)((Component)val4.bones[k]).gameObject.GetComponent<EmoteConstraint>()))
						{
							num2 = k;
							EmoteConstraint emoteConstraint = ((Component)val4.bones[k]).gameObject.GetComponent<EmoteConstraint>();
							if (emoteConstraint == null)
							{
								emoteConstraint = ((Component)val4.bones[k]).gameObject.AddComponent<EmoteConstraint>();
							}
							else
							{
								emoteConstraint.Reset();
							}
							emoteConstraint.AddSource(ref val4.bones[k], ref emoteSkeletonSMR.bones[j]);
							emoteConstraint.revertTransform = revertTransform;
							break;
						}
						if (k == num2 - 1)
						{
							break;
						}
						if (num2 > 0 && k == val4.bones.Length - 1)
						{
							k = -1;
						}
					}
				}
			}
		}
		if (jank)
		{
			SkinnedMeshRenderer[] array2 = basePlayerModelSMR;
			foreach (SkinnedMeshRenderer val5 in array2)
			{
				for (int m = 0; m < val5.bones.Length; m++)
				{
					try
					{
						if (Object.op_Implicit((Object)(object)((Component)val5.bones[m]).gameObject.GetComponent<EmoteConstraint>()))
						{
							((Component)val5.bones[m]).gameObject.GetComponent<EmoteConstraint>().ActivateConstraints();
						}
					}
					catch (Exception arg)
					{
						DebugClass.Log($"{arg}");
					}
				}
			}
		}
		((Component)this).transform.localPosition = Vector3.zero;
		CustomEmotesAPI.MapperCreated(this);
		if (playerController != null)
		{
			((MonoBehaviour)this).StartCoroutine(SetupHandConstraint());
		}
		((MonoBehaviour)this).StartCoroutine(preventEmotesInSpawnAnimation());
		((MonoBehaviour)this).StartCoroutine(GetLocal());
		GameObject val6 = new GameObject();
		((Object)val6).name = "BoneMapperHolder";
		val6.transform.SetParent(mapperBody.transform);
		val6.transform.localEulerAngles = ((Component)this).transform.localEulerAngles;
		val6.transform.position = ((Component)this).transform.position;
		((Component)this).transform.SetParent(val6.transform);
		val6.transform.localPosition = Vector3.zero;
	}

	public IEnumerator SetupHandConstraint()
	{
		while (!Object.op_Implicit((Object)(object)CustomEmotesAPI.localMapper))
		{
			yield return (object)new WaitForEndOfFrame();
		}
		itemHolderPosition = ((Component)this).GetComponentInChildren<Animator>().GetBoneTransform((HumanBodyBones)18).Find("ServerItemHolder");
		itemHolderConstraints.Add(EmoteConstraint.AddConstraint(((Component)playerController.serverItemHolder).gameObject, this, itemHolderPosition, needToFix: true));
		itemHolderConstraints.Add(EmoteConstraint.AddConstraint(((Component)playerController.localItemHolder).gameObject, this, itemHolderPosition, needToFix: true));
		((Component)itemHolderPosition).gameObject.AddComponent<EmoteConstraint>();
	}

	public void AssignParentGameObject(GameObject youAreTheFather, bool lockPosition, bool lockRotation, bool lockScale, bool scaleAsScavenger = true, bool disableCollider = true)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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)
		if (Object.op_Implicit((Object)(object)parentGameObject))
		{
			NewAnimation(null);
		}
		ogScale = mapperBody.transform.localScale;
		if (local)
		{
			ogVisorScale = playerController.localVisor.localScale;
		}
		if (scaleAsScavenger)
		{
			scaleDiff = ogScale / scale;
		}
		else
		{
			scaleDiff = ogScale;
		}
		parentGameObject = youAreTheFather;
		positionLock = lockPosition;
		rotationLock = lockRotation;
		scaleLock = lockScale;
		Collider[] componentsInChildren = mapperBody.GetComponentsInChildren<Collider>();
		foreach (Collider val in componentsInChildren)
		{
			val.enabled = !disableCollider;
		}
		if (Object.op_Implicit((Object)(object)mapperBody.GetComponent<CharacterController>()))
		{
			((Collider)mapperBody.GetComponent<CharacterController>()).enabled = !disableCollider;
		}
		if (disableCollider && Object.op_Implicit((Object)(object)currentEmoteSpot))
		{
			if (currentEmoteSpot.GetComponent<EmoteLocation>().validPlayers != 0)
			{
				currentEmoteSpot.GetComponent<EmoteLocation>().validPlayers--;
			}
			currentEmoteSpot.GetComponent<EmoteLocation>().SetColor();
			currentEmoteSpot = null;
		}
	}

	private void LocalFunctions()
	{
		if (!((Behaviour)emoteSkeletonAnimator).enabled)
		{
			return;
		}
		try
		{
			if (moving && currentClip != null && currentClip.stopOnMove)
			{
				CustomEmotesAPI.PlayAnimation("none");
			}
		}
		catch (Exception)
		{
		}
	}

	private IEnumerator GetLocal()
	{
		yield return (object)new WaitForEndOfFrame();
		try
		{
			if (!Object.op_Implicit((Object)(object)CustomEmotesAPI.localMapper) && (Object)(object)playerController == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				CustomEmotesAPI.localMapper = this;
				local = true;
				originalCosmeticPosition = new GameObject();
				originalCosmeticPosition.transform.parent = playerController.headCostumeContainerLocal.parent;
				originalCosmeticPosition.transform.position = playerController.headCostumeContainerLocal.position;
				originalCosmeticPosition.transform.localEulerAngles = playerController.headCostumeContainerLocal.localEulerAngles;
				EmoteConstraint e2 = ((Component)playerController.headCostumeContainerLocal).gameObject.AddComponent<EmoteConstraint>();
				e2.AddSource(playerController.headCostumeContainerLocal, emoteSkeletonAnimator.GetBoneTransform((HumanBodyBones)10));
				cosmeticConstraints.Add(e2);
				foreach (EmoteConstraint item in cosmeticConstraints)
				{
					item.emoteBone = originalCosmeticPosition.transform;
				}
				((Component)this).gameObject.AddComponent<NearestEmoterChecker>().self = this;
				isServer = ((NetworkBehaviour)playerController).IsServer && ((NetworkBehaviour)playerController).IsOwner;
				HealthbarAnimator.Setup(this);
				FixLocalArms();
				Camera c = playerController.gameplayCamera;
				if (c != null)
				{
					rotationPoint = new GameObject();
					rotationPoint.transform.SetParent(((Component)c).transform.parent.parent.parent.parent);
					rotationPoint.transform.localPosition = new Vector3(0f, 0.8f, 0f);
					rotationPoint.transform.localEulerAngles = Vector3.zero;
					desiredCameraPos = new GameObject();
					desiredCameraPos.transform.SetParent(rotationPoint.transform);
					desiredCameraPos.transform.localPosition = new Vector3(0.3f, 1f, -3f);
					desiredCameraPos.transform.localEulerAngles = Vector3.zero;
					realCameraPos = new GameObject();
					realCameraPos.transform.SetParent(desiredCameraPos.transform);
					realCameraPos.transform.localPosition = Vector3.zero;
					realCameraPos.transform.localEulerAngles = Vector3.zero;
					thirdPersonConstraint = EmoteConstraint.AddConstraint(((Component)((Component)c).transform.parent).gameObject, this, realCameraPos.transform, needToFix: false);
					thirdPersonConstraint.debug = true;
					if (((Object)basePlayerModelSMR[0].bones[32]).name == "spine.004")
					{
						GameObject camHolder = new GameObject();
						((Object)camHolder).name = "EmotesAPICameraHolderThing";
						camHolder.transform.parent = basePlayerModelSMR[0].bones[32];
						camHolder.transform.localEulerAngles = Vector3.zero;
						camHolder.transform.position = ((Component)c).transform.parent.position;
						Transform transform = camHolder.transform;
						transform.localPosition += new Vector3(0f, 0.045f, 0f);
						cameraConstraints.Add(EmoteConstraint.AddConstraint(((Component)((Component)c).transform.parent).gameObject, this, camHolder.transform, needToFix: false));
					}
					else
					{
						cameraConstraints.Add(EmoteConstraint.AddConstraint(((Component)((Component)c).transform.parent).gameObject, this, emoteSkeletonAnimator.GetBoneTransform((HumanBodyBones)10), needToFix: false));
					}
					GameObject cameraRotationObjectLmao = new GameObject();
					cameraRotationObjectLmao.transform.SetParent(((Component)c).transform);
					cameraRotationObjectLmao.transform.localPosition = new Vector3(0.01f, -0.048f, -0.053f);
					cameraRotationObjectLmao.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
					cameraConstraints.Add(EmoteConstraint.AddConstraint(((Component)StartOfRound.Instance.localPlayerController.localVisor).gameObject, this, cameraRotationObjectLmao.transform, needToFix: false));
				}
			}
		}
		catch (Exception e)
		{
			DebugClass.Log(e);
		}
		if (!Object.op_Implicit((Object)(object)CustomEmotesAPI.localMapper))
		{
			((MonoBehaviour)this).StartCoroutine(GetLocal());
		}
	}

	internal void FixLocalArms()
	{
		int i = 0;
		for (int j = 0; j < basePlayerModelSMR[1].bones.Length; j++)
		{
			EmoteConstraint component = ((Component)basePlayerModelSMR[1].bones[j]).GetComponent<EmoteConstraint>();
			if (component == null)
			{
				continue;
			}
			int num = i;
			for (; i < basePlayerModelSMR[0].bones.Length; i++)
			{
				if (((Object)basePlayerModelSMR[1].bones[j]).name == ((Object)basePlayerModelSMR[0].bones[i]).name)
				{
					component.AddSource(basePlayerModelSMR[1].bones[j], basePlayerModelSMR[0].bones[i]);
					component.forceGlobalTransforms = true;
					break;
				}
				if (i == num - 1)
				{
					break;
				}
				if (num > 0 && i == basePlayerModelSMR[0].bones.Length - 1)
				{
					i = -1;
				}
			}
		}
	}

	private void TwoPartThing()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		if (ranSinceLastAnim)
		{
			return;
		}
		AnimatorStateInfo currentAnimatorStateInfo = emoteSkeletonAnimator.GetCurrentAnimatorStateInfo(0);
		if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("none"))
		{
			if (twopart)
			{
				ranSinceLastAnim = true;
				if (((Behaviour)emoteSkeletonAnimator).enabled && !jank)
				{
					UnlockBones();
				}
				if (!ragdolling)
				{
					oneFrameAnimatorLeeWay = true;
				}
				((Behaviour)emoteSkeletonAnimator).enabled = false;
				try
				{
					if (currentClip == null)
					{
						return;
					}
					CustomEmotesAPI.Changed("none", this);
					NewAnimation(null);
					if (currentClip.syncronizeAnimation || currentClip.syncronizeAudio)
					{
						CustomAnimationClip.syncPlayerCount[currentClip.syncPos]--;
					}
					if ((Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null)
					{
						audioObject.GetComponent<AudioManager>().Stop();
						if ((Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null && currentClip.syncronizeAudio)
						{
							listOfCurrentEmoteAudio[currentClip.syncPos].Remove(audioObject.GetComponent<AudioSource>());
						}
					}
					prevClip = currentClip;
					currentClip = null;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			twopart = true;
		}
		else
		{
			twopart = false;
		}
	}

	private void Health()
	{
		if (!isValidPlayer || !playerController.isPlayerDead || !local || currentClip == null)
		{
			return;
		}
		UnlockBones();
		CustomEmotesAPI.PlayAnimation("none");
		foreach (GameObject prop in props)
		{
			if (Object.op_Implicit((Object)(object)prop))
			{
				Object.Destroy((Object)(object)prop);
			}
		}
		props.Clear();
	}

	private void WorldPropAndParent()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)parentGameObject))
		{
			return;
		}
		if (positionLock)
		{
			mapperBody.gameObject.transform.position = parentGameObject.transform.position + new Vector3(0f, 1f, 0f);
			mapperBody.transform.position = parentGameObject.transform.position;
			PlayerControllerB obj = playerController;
			if (obj != null)
			{
				obj.ResetFallGravity();
			}
		}
		if (rotationLock)
		{
			mapperBody.transform.rotation = parentGameObject.transform.rotation;
		}
		if (scaleLock)
		{
			mapperBody.transform.localScale = new Vector3(parentGameObject.transform.localScale.x * scaleDiff.x, parentGameObject.transform.localScale.y * scaleDiff.y, parentGameObject.transform.localScale.z * scaleDiff.z);
			if (local)
			{
				playerController.localVisor.localScale = ogVisorScale * (mapperBody.transform.localScale.x / ogScale.x);
			}
		}
	}

	private void Update()
	{
		if (!worldProp)
		{
			WorldPropAndParent();
			if (local)
			{
				LocalFunctions();
			}
			TwoPartThing();
			Health();
			SetDeltaPosition();
			RootMotion();
			CameraControls();
		}
	}

	internal bool ThirdPersonCheck()
	{
		return !CustomEmotesAPI.LCThirdPersonPresent && currentClip != null && (((currentClip.thirdPerson || Settings.thirdPersonType.Value == ThirdPersonType.All) && Settings.thirdPersonType.Value != ThirdPersonType.None) || temporarilyThirdPerson == TempThirdPerson.on) && canThirdPerson && temporarilyThirdPerson != TempThirdPerson.off;
	}

	public void CameraControls()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		if (local && isInThirdPerson)
		{
			Vector3 val = mapperBodyTransform.position + new Vector3(0f, 1.75f * scale, 0f);
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(val, desiredCameraPos.transform.position - val);
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, 10f, 268437761, (QueryTriggerInteraction)1))
			{
				realCameraPos.transform.position = ((Ray)(ref val2)).GetPoint(((RaycastHit)(ref val3)).distance - 0.25f);
			}
			else
			{
				realCameraPos.transform.position = ((Ray)(ref val2)).GetPoint(10f);
			}
			if (Vector3.Distance(realCameraPos.transform.position, val) > Vector3.Distance(desiredCameraPos.transform.position, val))
			{
				realCameraPos.transform.position = desiredCameraPos.transform.position;
			}
		}
	}

	private void SetDeltaPosition()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		deltaPos = ((Component)this).transform.position - prevPosition;
		deltaRot = ((Component)this).transform.rotation * Quaternion.Inverse(prevRotation);
		prevPosition = ((Component)this).transform.position;
		prevRotation = ((Component)this).transform.rotation;
	}

	public void RootMotion()
	{
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: 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_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Behaviour)emoteSkeletonAnimator).enabled)
			{
				return;
			}
			if (justSwitched)
			{
				justSwitched = false;
			}
			else
			{
				if (currentClip == null || currentClip.lockType != AnimationClipParams.LockType.rootMotion)
				{
					return;
				}
				if (local || isEnemy)
				{
					if (Settings.rootMotionType.Value != RootMotionType.None || isEnemy)
					{
						Vector3 position = ((Component)this).transform.position;
						Quaternion rotation = ((Component)this).transform.rotation;
						mapperBody.transform.position = new Vector3(emoteSkeletonAnimator.GetBoneTransform((HumanBodyBones)7).position.x, mapperBody.transform.position.y, emoteSkeletonAnimator.GetBoneTransform((HumanBodyBones)7).position.z);
						if (isEnemy || !isInThirdPerson)
						{
							mapperBody.transform.eulerAngles = new Vector3(mapperBody.transform.eulerAngles.x, emoteSkeletonAnimator.GetBoneTransform((HumanBodyBones)10).eulerAngles.y, mapperBody.transform.eulerAngles.z);
						}
						((Component)this).transform.position = position;
						((Component)this).transform.rotation = rotation;
						if (positionBeforeRootMotion != new Vector3(69f, 69f, 69f))
						{
							mapperBody.transform.position = positionBeforeRootMotion;
							mapperBody.transform.rotation = rotationBeforeRootMotion;
							positionBeforeRootMotion = new Vector3(69f, 69f, 69f);
						}
					}
					if (deltaPos != Vector3.zero || deltaRot != Quaternion.identity)
					{
						if (isEnemy)
						{
							EmoteNetworker.instance.SyncBoneMapperPos(((NetworkBehaviour)enemyController).NetworkObjectId, ((Component)this).transform.position, ((Component)this).transform.eulerAngles);
						}
						else
						{
							EmoteNetworker.instance.SyncBoneMapperPos(((NetworkBehaviour)playerController).NetworkObjectId, ((Component)this).transform.position, ((Component)this).transform.eulerAngles);
						}
					}
				}
				else
				{
					((Component)this).transform.position = prevMapperPos;
					((Component)this).transform.eulerAngles = prevMapperRot;
				}
			}
		}
		catch (Exception)
		{
		}
	}

	public int SpawnJoinSpot(JoinSpot joinSpot)
	{
		props.Add(Object.Instantiate<GameObject>(Assets.Load<GameObject>("@CustomEmotesAPI_customemotespackage:assets/emotejoiner/JoinVisual.prefab")));
		props[props.Count - 1].transform.SetParent(((Component)this).transform);
		((Object)props[props.Count - 1]).name = joinSpot.name;
		EmoteLocation emoteLocation = props[props.Count - 1].AddComponent<EmoteLocation>();
		emoteLocation.joinSpot = joinSpot;
		emoteLocation.owner = this;
		emoteLocations.Add(emoteLocation);
		return props.Count - 1;
	}

	public void JoinEmoteSpot()
	{
		//IL_0111: 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_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)reservedEmoteSpot))
		{
			if (Object.op_Implicit((Object)(object)currentEmoteSpot))
			{
				if (currentEmoteSpot.GetComponent<EmoteLocation>().validPlayers != 0)
				{
					currentEmoteSpot.GetComponent<EmoteLocation>().validPlayers--;
				}
				currentEmoteSpot.GetComponent<EmoteLocation>().SetColor();
			}
			currentEmoteSpot = reservedEmoteSpot;
			reservedEmoteSpot = null;
		}
		int i;
		for (i = 0; i < ((Component)currentEmoteSpot.transform.parent).GetComponentsInChildren<EmoteLocation>().Length && !((Object)(object)((Component)currentEmoteSpot.transform.parent).GetComponentsInChildren<EmoteLocation>()[i] == (Object)(object)currentEmoteSpot.GetComponent<EmoteLocation>()); i++)
		{
		}
		if (!currentEmoteSpot.GetComponent<EmoteLocation>().owner.worldProp && currentEmoteSpot.GetComponent<EmoteLocation>().joinSpot.requireRaycastToJoin)
		{
			Vector3 val = mapperBodyTransform.position + new Vector3(0f, 1.75f * scale, 0f);
			BoneMapper owner = currentEmoteSpot.GetComponent<EmoteLocation>().owner;
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(val, owner.mapperBodyTransform.position - val);
			float num = Vector3.Distance(owner.mapperBodyTransform.position, mapperBodyTransform.position) + 2f;
			RaycastHit[] array = Physics.RaycastAll(val2, num, 8);
			RaycastHit[] array2 = array;
			RaycastHit val4 = default(RaycastHit);
			for (int j = 0; j < array2.Length; j++)
			{
				RaycastHit val3 = array2[j];
				if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val3)).collider).gameObject.GetComponent<PlayerControllerB>()) && (Object)(object)playersToMappers[((Component)((RaycastHit)(ref val3)).collider).gameObject] == (Object)(object)owner)
				{
					if (Physics.Raycast(val2, ref val4, num, StartOfRound.Instance.allPlayersCollideWithMask, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val4)).distance < ((RaycastHit)(ref val3)).distance)
					{
						return;
					}
					break;
				}
			}
		}
		EmoteNetworker.instance.SyncJoinSpot(mapperBody.GetComponent<NetworkObject>().NetworkObjectId, currentEmoteSpot.GetComponentInParent<NetworkObject>().NetworkObjectId, currentEmoteSpot.GetComponent<EmoteLocation>().owner.worldProp, i);
	}

	public void RemoveProp(int propPos)
	{
		Object.Destroy((Object)(object)props[propPos]);
	}

	public void SetAutoWalk(float speed, bool overrideBaseMovement, bool autoWalk)
	{
		autoWalkSpeed = speed;
		overrideMoveSpeed = overrideBaseMovement;
		this.autoWalk = autoWalk;
	}

	public void SetAutoWalk(float speed, bool overrideBaseMovement)
	{
		autoWalkSpeed = speed;
		overrideMoveSpeed = overrideBaseMovement;
		autoWalk = true;
	}

	internal IEnumerator waitForTwoFramesThenDisableA1()
	{
		yield return (object)new WaitForEndOfFrame();
	}

	private void OnDestroy()
	{
		if (playerController == null)
		{
			return;
		}
		playersToMappers.Remove(((Component)playerController).gameObject);
		if (worldProp)
		{
			return;
		}
		playersToMappers.Remove(mapperBody);
		PlayAnim("none", -1);
		try
		{
			if (currentClip != null)
			{
				((object)currentClip.clip[0]).ToString();
				NewAnimation(null);
				if ((currentClip.syncronizeAnimation || currentClip.syncronizeAudio) && CustomAnimationClip.syncPlayerCount[currentClip.syncPos] > 0)
				{
					CustomAnimationClip.syncPlayerCount[currentClip.syncPos]--;
				}
				if ((Object)(object)primaryAudioClips[currentClip.syncPos][currEvent] != (Object)null)
				{
					audioObject.GetComponent<AudioManager>().Stop();
					if (currentClip.syncronizeAudio)
					{
						listOfCurrentEmoteAudio[currentClip.syncPos].Remove(audioObject.GetComponent<AudioSource>());
					}
				}
				if (uniqueSpot != -1 && CustomAnimationClip.uniqueAnimations[currentClip.syncPos][uniqueSpot])
				{
					CustomAnimationClip.uniqueAnimations[currentClip.syncPos][uniqueSpot] = false;
					uniqueSpot = -1;
				}
				prevClip = currentClip;
				currentClip = null;
			}
		}
		catch (Exception)
		{
		}
		allMappers.Remove(this);
	}

	public void UnlockBones(bool animatorEnabled = true)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.localPosition = Vector3.zero;
		((Component)this).transform.eulerAngles = bodyPrefab.transform.eulerAngles;
		SkinnedMeshRenderer[] array = basePlayerModelSMR;
		foreach (SkinnedMeshRenderer val in array)
		{
			for (int j = 0; j < val.bones.Length; j++)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)((Component)val.bones[j]).gameObject.GetComponent<EmoteConstraint>()))
					{
						((Component)val.bones[j]).gameObject.GetComponent<EmoteConstraint>().DeactivateConstraints();
					}
				}
				catch (Exception)
				{
					break;
				}
			}
		}
		foreach (EmoteConstraint cameraConstraint in cameraConstraints)
		{
			cameraConstraint.DeactivateConstraints();
		}
		foreach (EmoteConstraint itemHolderConstraint in itemHolderConstraints)
		{
			itemHolderConstraint.DeactivateConstraints();
		}
		foreach (EmoteConstraint additionalConstraint in additionalConstraints)
		{
			additionalConstraint.DeactivateConstraints();
		}
		if (thirdPersonConstraint != null)
		{
			thirdPersonConstraint.DeactivateConstraints();
		}
		DeThirdPerson();
	}

	public void LockBones()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		UnlockBones();
		((Component)this).transform.localPosition = Vector3.zero;
		bool flag = true;
		if (currentClip != null)
		{
			foreach (HumanBodyBones soloIgnoredBone in currentClip.soloIgnoredBones)
			{
				if (Object.op_Implicit((Object)(object)emoteSkeletonAnimator.GetBoneTransform(soloIgnoredBone)))
				{
					dontAnimateUs.Add(((Object)emoteSkeletonAnimator.GetBoneTransform(soloIgnoredBone)).name);
				}
			}
			foreach (HumanBodyBones rootIgnoredBone in currentClip.rootIgnoredBones)
			{
				if (Object.op_Implicit((Object)(object)emoteSkeletonAnimator.GetBoneTransform(rootIgnoredBone)))
				{
					dontAnimateUs.Add(((Object)emoteSkeletonAnimator.GetBoneTransform(rootIgnoredBone)).name);
				}
				Transform[] componentsInChildren = ((Component)emoteSkeletonAnimator.GetBoneTransform(rootIgnoredBone)).GetComponentsInChildren<Transform>();
				foreach (Transform val in componentsInChildren)
				{
					dontAnimateUs.Add(((Object)val).name);
				}
			}
			flag = !currentClip.forceCameraMode || (currentClip.forceCameraMode && currentClip.thirdPerson);
		}
		if (!jank)
		{
			((Renderer)emoteSkeletonSMR).enabled = true;
			SkinnedMeshRenderer[] array = basePlayerModelSMR;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				for (int k = 0; k < val2.bones.Length; k++)
				{
					try
					{
						if (Object.op_Implicit((Object)(object)((Component)val2.bones[k]).gameObject.GetComponent<EmoteConstraint>()) && !dontAnimateUs.Contains(((Object)val2.bones[k]).name))
						{
							EmoteConstraint component = ((Component)val2.bones[k]).gameObject.GetComponent<EmoteConstraint>();
							component.ActivateConstraints();
							if ((Object)(object)val2 == (Object)(object)basePlayerModelSMR.First() && currentClip != null)
							{
								component.SetLocalTransforms(currentClip.localTransforms);
							}
						}
						else if (dontAnimateUs.Contains(((Object)val2.bones[k]).name))
						{
							((Component)val2.bones[k]).gameObject.GetComponent<EmoteConstraint>().DeactivateConstraints();
						}
					}
					catch (Exception arg)
					{
						DebugClass.Log($"{arg}");
					}
				}
			}
			foreach (EmoteConstraint itemHolderConstraint in itemHolderConstraints)
			{
				itemHolderConstraint.ActivateConstraints();
			}
			foreach (EmoteConstraint additionalConstraint in additionalConstraints)
			{
				additionalConstraint.ActivateConstraints();
			}
			LockCameraStuff(local && ThirdPersonCheck() && flag);
		}
		else
		{
			((MonoBehaviour)this).StartCoroutine(waitForTwoFramesThenDisableA1());
		}
	}

	public void LockCameraStuff(bool thirdPersonLock)
	{
		bool flag = false;
		if (currentClip != null)
		{
			flag = currentClip.allowThirdPerson && !currentClip.customInternalName.Contains("TooManyEmotes__");
		}
		if (thirdPersonLock && flag)
		{
			TurnOnThirdPerson();
		}
		else if (currentClip != null)
		{
			if (Settings.rootMotionType.Value != RootMotionType.None && (currentClip.lockType == AnimationClipParams.LockType.rootMotion || Settings.rootMotionType.Value == RootMotionType.All || currentClip.lockType == AnimationClipParams.LockType.lockHead))
			{
				((MonoBehaviour)this).StartCoroutine(ActivateCameraConstraintsAfterFrame(onlyY: false));
			}
			else if (currentClip.lockType == AnimationClipParams.LockType.headBobbing && Settings.rootMotionType.Value != RootMotionType.None)
			{
				((MonoBehaviour)this).StartCoroutine(ActivateCameraConstraintsAfterFrame(onlyY: true));
			}
		}
	}

	private IEnumerator ActivateCameraConstraintsAfterFrame(bool onlyY)
	{
		yield return (object)new WaitForEndOfFrame();
		foreach (EmoteConstraint item2 in cameraConstraints)
		{
			((Behaviour)item2).enabled = true;
			item2.ActivateConstraints();
			if (onlyY && (Object)(object)item2 != (Object)(object)cameraConstraints[cameraConstraints.Count - 1])
			{
				item2.onlyY = true;
			}
		}
		yield return (object)new WaitForEndOfFrame();
		foreach (EmoteConstraint item in cameraConstraints)
		{
			if (!((Behaviour)item).enabled)
			{
				((Behaviour)item).enabled = true;
				item.ActivateConstraints();
				if (onlyY && (Object)(object)item != (Object)(object)cameraConstraints[cameraConstraints.Count - 1])
				{
					item.onlyY = true;
				}
			}
		}
	}

	public void UnlockCameraStuff()
	{
		foreach (EmoteConstraint cameraConstraint in cameraConstraints)
		{
			cameraConstraint.DeactivateConstraints();
		}
		thirdPersonConstraint.DeactivateConstraints();
		DeThirdPerson();
	}

	public void TurnOnThirdPerson()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Invalid comparison between Unknown and I4
		if (helmetRenderer == null)
		{
			helmetRenderer = ((Component)((Component)playerController.localVisor).transform.GetChild(0)).GetComponent<Renderer>();
		}
		helmetRenderer.enabled = false;
		if ((int)((Renderer)playerController.thisPlayerModel).shadowCastingMode == 1)
		{
			needToTurnOffShadows = false;
		}
		((Renderer)playerController.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
		((Renderer)playerController.thisPlayerModelArms).shadowCastingMode = (ShadowCastingMode)3;
		((Component)playerController.thisPlayerModelLOD1).gameObject.SetActive(false);
		((Component)playerController.thisPlayerModelLOD2).gameObject.SetActive(false);
		if (originalLayer == -1)
		{
			originalLayer = ((Component)playerController.thisPlayerModel).gameObject.layer;
			originalCullingMask = playerController.gameplayCamera.cullingMask;
		}
		((Component)playerController.thisPlayerModel).gameObject.layer = 1;
		playerController.grabDistance = 5.65f;
		playerController.gameplayCamera.cullingMask = StartOfRound.Instance.spectateCamera.cullingMask;
		thirdPersonConstraint.ActivateConstraints();
		isInThirdPerson = true;
		foreach (EmoteConstraint cosmeticConstraint in cosmeticConstraints)
		{
			cosmeticConstraint.emoteBone = playerController.playerGlobalHead;
		}
		if (CustomEmotesAPI.MoreCompanyPresent)
		{
			try
			{
				needToTurnOffCosmetics = true;
				MoreCompanyCompat.TurnOnCosmetics(this);
			}
			catch (Exception arg)
			{
				DebugClass.Log($"couldn't turn on cosmetics: {arg}");
			}
		}
		if (CustomEmotesAPI.BetterEmotesPresent)
		{
			Transform val = ((Component)playerController).transform.Find("ScavengerModel/LEGS");
			if (val != null)
			{
				((Component)val).gameObject.layer = 31;
			}
		}
	}

	public void DeThirdPerson()
	{
		if (!isInThirdPerson)
		{
			return;
		}
		playerController.gameplayCamera.cullingMask = originalCullingMask;
		if (needToTurnOffShadows)
		{
			((Renderer)playerController.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)3;
		}
		needToTurnOffShadows = true;
		((Renderer)playerController.thisPlayerModelArms).shadowCastingMode = (ShadowCastingMode)0;
		((Component)playerController.thisPlayerModelLOD1).gameObject.SetActive(true);
		((Component)playerController.thisPlayerModelLOD2).gameObject.SetActive(true);
		helmetRenderer.enabled = true;
		((Component)playerController.thisPlayerModel).gameObject.layer = originalLayer;
		playerController.grabDistance = 3f;
		isInThirdPerson = false;
		foreach (EmoteConstraint cosmeticConstraint in cosmeticConstraints)
		{
			cosmeticConstraint.emoteBone = originalCosmeticPosition.transform;
		}
		if (CustomEmotesAPI.MoreCompanyPresent && needToTurnOffCosmetics)
		{
			try
			{
				MoreCompanyCompat.TurnOffCosmetics(this);
			}
			catch (Exception arg)
			{
				DebugClass.Log($"couldn't clear cosmetics: {arg}");
			}
		}
		if (CustomEmotesAPI.BetterEmotesPresent)
		{
			Transform val = ((Component)playerController).transform.Find("ScavengerModel/LEGS");
			if (val != null)
			{
				((Component)val).gameObject.layer = 0;
			}
		}
	}

	public void AttachItemHolderToTransform(Transform target)
	{
		((Component)itemHolderPosition).gameObject.GetComponent<EmoteConstraint>().AddSource(itemHolderPosition, target);
		((Component)itemHolderPosition).gameObject.GetComponent<EmoteConstraint>().ActivateConstraints();
	}
}
public class CustomAnimationClip : MonoBehaviour
{
	public AnimationClip[] clip;

	public AnimationClip[] secondaryClip;

	public bool looping;

	public string wwiseEvent;

	public bool syncronizeAudio;

	public List<HumanBodyBones> soloIgnoredBones;

	public List<HumanBodyBones> rootIgnoredBones;

	public bool dimAudioWhenClose;

	public bool stopOnAttack;

	public bool stopOnMove;

	public bool visibility;

	public int startPref;

	public int joinPref;

	public JoinSpot[] joinSpots;

	public bool useSafePositionReset;

	public string customInternalName;

	public Action<BoneMapper> customPostEventCodeSync;

	public Action<BoneMapper> customPostEventCodeNoSync;

	public bool syncronizeAnimation;

	public int syncPos;

	public static List<float> syncTimer = new List<float>();

	public static List<int> syncPlayerCount = new List<int>();

	public static List<List<bool>> uniqueAnimations = new List<List<bool>>();

	public bool vulnerableEmote = false;

	public AnimationClipParams.LockType lockType = AnimationClipParams.LockType.none;

	public bool willGetClaimed = false;

	public float audioLevel = 0.5f;

	public bool thirdPerson = false;

	public string displayName = "";

	public bool localTransforms = false;

	public BepInPlugin ownerPlugin;

	public bool usesNewImportSystem = false;

	public bool animates = true;

	public bool preventsMovement = false;

	public bool allowJoining = true;

	public string joinEmote = "";

	public bool forceCameraMode = false;

	public bool allowThirdPerson = true;

	public bool animateHealthbar = true;

	internal CustomAnimationClip(AnimationClip[] _clip, bool _loop, AudioClip[] primaryAudioClips = null, AudioClip[] secondaryAudioClips = null, HumanBodyBones[] rootBonesToIgnore = null, HumanBodyBones[] soloBonesToIgnore = null, AnimationClip[] _secondaryClip = null, bool dimWhenClose = false, bool stopWhenMove = false, bool stopWhenAttack = false, bool visible = true, bool syncAnim = false, bool syncAudio = false, int startPreference = -1, int joinPreference = -1, JoinSpot[] _joinSpots = null, bool safePositionReset = false, string customName = "", Action<BoneMapper> _customPostEventCodeSync = null, Action<BoneMapper> _customPostEventCodeNoSync = null, AnimationClipParams.LockType lockType = AnimationClipParams.LockType.none, AudioClip[] primaryDMCAFreeAudioClips = null, AudioClip[] secondaryDMCAFreeAudioClips = null, bool willGetClaimed = false, float audioLevel = 0.5f, bool thirdPerson = false, string displayName = "", BepInPlugin ownerPlugin = null, bool localTransforms = false, bool usesNewImportSystem = false, bool animates = true, bool preventsMovement = false, bool allowJoining = true, string joinEmote = "", bool forceCameraMode = false, bool allowThirdPerson = true, bool animateHealthbar = true)
	{
		if (rootBonesToIgnore == null)
		{
			rootBonesToIgnore = (HumanBodyBones[])(object)new HumanBodyBones[0];
		}
		if (soloBonesToIgnore == null)
		{
			soloBonesToIgnore = (HumanBodyBones[])(object)new HumanBodyBones[0];
		}
		clip = _clip;
		secondaryClip = _secondaryClip;
		looping = _loop;
		dimAudioWhenClose = dimWhenClose;
		stopOnAttack = stopWhenAttack;
		stopOnMove = stopWhenMove;
		visibility = visible;
		joinPref = joinPreference;
		startPref = startPreference;
		customPostEventCodeSync = _customPostEventCodeSync;
		customPostEventCodeNoSync = _customPostEventCodeNoSync;
		if (primaryAudioClips == null)
		{
			BoneMapper.primaryAudioClips.Add((AudioClip[])(object)new AudioClip[1]);
		}
		else
		{
			BoneMapper.primaryAudioClips.Add(primaryAudioClips);
		}
		if (secondaryAudioClips == null)
		{
			BoneMapper.secondaryAudioClips.Add((AudioClip[])(object)new AudioClip[1]);
		}
		else
		{
			BoneMapper.secondaryAudioClips.Add(secondaryAudioClips);
		}
		if (primaryDMCAFreeAudioClips == null)
		{
			BoneMapper.primaryDMCAFreeAudioClips.Add((AudioClip[])(object)new AudioClip[1]);
		}
		else
		{
			BoneMapper.primaryDMCAFreeAudioClips.Add(primaryDMCAFreeAudioClips);
		}
		if (secondaryDMCAFreeAudioClips == null)
		{
			BoneMapper.secondaryDMCAFreeAudioClips.Add((AudioClip[])(object)new AudioClip[1]);
		}
		else
		{
			BoneMapper.secondaryDMCAFreeAudioClips.Add(secondaryDMCAFreeAudioClips);
		}
		if (soloBonesToIgnore.Length != 0)
		{
			soloIgnoredBones = new List<HumanBodyBones>(soloBonesToIgnore);
		}
		else
		{
			soloIgnoredBones = new List<HumanBodyBones>();
		}
		if (rootBonesToIgnore.Length != 0)
		{
			rootIgnoredBones = new List<HumanBodyBones>(rootBonesToIgnore);
		}
		else
		{
			rootIgnoredBones = new List<HumanBodyBones>();
		}
		syncronizeAnimation = syncAnim;
		syncronizeAudio = syncAudio;
		syncPos = syncTimer.Count;
		syncTimer.Add(0f);
		syncPlayerCount.Add(0);
		if (_clip != null)
		{
			List<bool> list = new List<bool>();
			for (int i = 0; i < _clip.Length; i++)
			{
				list.Add(item: false);
			}
			uniqueAnimations.Add(list);
		}
		if (_joinSpots == null)
		{
			_joinSpots = new JoinSpot[0];
		}
		joinSpots = _joinSpots;
		useSafePositionReset = safePositionReset;
		customInternalName = customName;
		this.usesNewImportSystem = usesNewImportSystem;
		if (!usesNewImportSystem && customName != "")
		{
			BoneMapper.customNamePairs.Add(customName, ((Object)_clip[0]).name);
		}
		BoneMapper.listOfCurrentEmoteAudio.Add(new List<AudioSource>());
		this.lockType = lockType;
		this.willGetClaimed = willGetClaimed;
		this.audioLevel = audioLevel;
		this.thirdPerson = thirdPerson;
		this.displayName = displayName;
		if (displayName == "")
		{
			DebugClass.Log("display name wasn't set, using " + customInternalName);
			this.displayName = customInternalName;
		}
		this.ownerPlugin = ownerPlugin;
		this.localTransforms = localTransforms;
		this.animates = animates;
		this.preventsMovement = preventsMovement;
		this.allowJoining = allowJoining;
		if (string.IsNullOrEmpty(customInternalName))
		{
			return;
		}
		Keybinds.DisableKeybinds();
		if (usesNewImportSystem)
		{
			InputActionReference orCreateInputRef = Keybinds.GetOrCreateInputRef(customInternalName);
			orCreateInputRef.action.Enable();
			orCreateInputRef.action.started += EmoteAction_started;
			if (Keybinds.keyBindOverrideStorage.TryGetValue(customInternalName, out var value))
			{
				InputActionRebindingExtensions.ApplyBindingOverride(orCreateInputRef.action, value, (string)null, (string)null);
			}
		}
		else
		{
			InputActionReference orCreateInputRef2 = Keybinds.GetOrCreateInputRef(((Object)clip[0]).name);
			orCreateInputRef2.action.Enable();
			orCreateInputRef2.action.started += EmoteAction_started;
			if (Keybinds.keyBindOverrideStorage.TryGetValue(((Object)clip[0]).name, out var value2))
			{
				InputActionRebindingExtensions.ApplyBindingOverride(orCreateInputRef2.action, value2, (string)null, (string)null);
			}
		}
		Keybinds.EnableKeybinds();
		if (joinEmote == "")
		{
			joinEmote = customInternalName;
		}
		this.joinEmote = joinEmote;
		if (EmoteDmcaVerificationStatusDb.IsNonDmcaCompliant(ownerPlugin.GUID))
		{
			this.willGetClaimed = true;
		}
		this.forceCameraMode = forceCameraMode;
		this.allowThirdPerson = allowThirdPerson;
		this.animateHealthbar = animateHealthbar;
	}

	private static void EmoteAction_started(CallbackContext obj)
	{
		if (EmoteUiManager.CanOpenEmoteWheels() && CustomEmotesAPI.localMapper != null)
		{
			CustomEmotesAPI.PlayAnimation(((CallbackContext)(ref obj)).action.name);
		}
	}
}
[DefaultExecutionOrder(-2)]
public class EmoteConstraint : MonoBehaviour
{
	public Transform originalBone;

	public Transform emoteBone;

	private Vector3 originalPosition;

	private Quaternion originalRotation;

	public bool constraintActive = false;

	public bool revertTransform;

	private bool firstTime = true;

	private bool firstTime2 = true;

	private bool hasEverActivatedConstraints = false;

	public bool onlyY = false;

	public bool debug = false;

	public bool forceGlobalTransforms = false;

	internal bool needToFix = true;

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


	public bool SetLocalTransforms(bool input)
	{
		localTransforms = !forceGlobalTransforms && input;
		return localTransforms;
	}

	private void LateUpdate()
	{
		ActUponConstraints();
	}

	public void ActUponConstraints()
	{
		//IL_00ff: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!constraintActive)
		{
			return;
		}
		if (localTransforms)
		{
			if (onlyY)
			{
				originalBone.localPosition = new Vector3(originalBone.localPosition.x, emoteBone.localPosition.y, originalBone.localPosition.z);
				return;
			}
			originalBone.localPosition = emoteBone.localPosition;
			originalBone.localRotation = emoteBone.localRotation;
		}
		else if (onlyY)
		{
			originalBone.position = new Vector3(originalBone.position.x, emoteBone.position.y, originalBone.position.z);
		}
		else
		{
			originalBone.position = emoteBone.position;
			originalBone.rotation = emoteBone.rotation;
		}
	}

	public void ActivateConstraints()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if (!constraintActive && emoteBone != null)
		{
			if (firstTime2)
			{
				firstTime2 = false;
				((Component)this).gameObject.GetComponent<MonoBehaviour>().StartCoroutine(FirstTimeActiveFix(this));
				return;
			}
			originalPosition = originalBone.localPosition;
			originalRotation = originalBone.localRotation;
			hasEverActivatedConstraints = true;
			constraintActive = true;
			onlyY = false;
		}
	}

	internal IEnumerator FirstTimeActiveFix(EmoteConstraint e)
	{
		((Behaviour)e).enabled = false;
		yield return (object)new WaitForEndOfFrame();
		((Behaviour)e).enabled = true;
		if (e.onlyY)
		{
			e.ActivateConstraints();
			e.onlyY = true;
		}
		else
		{
			e.ActivateConstraints();
		}
	}

	public void DeactivateConstraints()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		constraintActive = false;
		if (firstTime || !revertTransform || !hasEverActivatedConstraints)
		{
			firstTime = false;
			return;
		}
		originalBone.localPosition = originalPosition;
		originalBone.localRotation = originalRotation;
	}

	internal void AddSource(ref Transform originalBone, ref Transform emoteBone)
	{
		this.originalBone = originalBone;
		this.emoteBone = emoteBone;
		if (((Component)emoteBone).GetComponent<BoneRef>() != null)
		{
			((Component)emoteBone).GetComponent<BoneRef>().target = originalBone;
		}
		else
		{
			((Component)emoteBone).gameObject.AddComponent<BoneRef>().target = originalBone;
		}
	}

	internal void AddSource(Transform originalBone, Transform emoteBone)
	{
		this.originalBone = originalBone;
		this.emoteBone = emoteBone;
		if (((Component)emoteBone).GetComponent<BoneRef>() != null)
		{
			((Component)emoteBone).GetComponent<BoneRef>().target = originalBone;
		}
		else
		{
			((Component)emoteBone).gameObject.AddComponent<BoneRef>().target = originalBone;
		}
	}

	internal static EmoteConstraint AddConstraint(GameObject gameObject, BoneMapper mapper, Transform target, bool needToFix)
	{
		EmoteConstraint emoteConstraint = gameObject.AddComponent<EmoteConstraint>();
		emoteConstraint.AddSource(gameObject.transform, target);
		emoteConstraint.revertTransform = mapper.revertTransform;
		emoteConstraint.needToFix = needToFix;
		return emoteConstraint;
	}

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(FixConstraints());
	}

	private IEnumerator FixConstraints()
	{
		yield return (object)new WaitForEndOfFrame();
		if (needToFix)
		{
			ActivateConstraints();
			yield return (object)new WaitForEndOfFrame();
			DeactivateConstraints();
		}
	}

	internal void Reset()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		originalBone = null;
		emoteBone = null;
		originalPosition = Vector3.zero;
		originalRotation = Quaternion.identity;
		constraintActive = false;
		revertTransform = false;
		firstTime = true;
		firstTime2 = true;
		hasEverActivatedConstraints = false;
		onlyY = false;
		debug = false;
		localTransforms = false;
		forceGlobalTransforms = false;
		needToFix = true;
	}
}
public struct JoinSpot
{
	public string name;

	public Vector3 position;

	public Vector3 rotation;

	public Vector3 scale;

	public bool requireRaycastToJoin;

	public JoinSpot(string _name, Vector3 _position, Vector3 _rotation, Vector3 _scale, bool _requireRaycastToJoin)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		name = _name;
		position = _position;
		rotation = _rotation;
		scale = _scale;
		requireRaycastToJoin = _requireRaycastToJoin;
	}

	public JoinSpot(string _name, Vector3 _position, Vector3 _rotation, Vector3 _scale)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		name = _name;
		position = _position;
		rotation = _rotation;
		scale = _scale;
		requireRaycastToJoin = false;
	}

	public JoinSpot(string _name, Vector3 _position)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		name = _name;
		position = _position;
		rotation = Vector3.zero;
		scale = Vector3.one;
		requireRaycastToJoin = false;
	}
}
public class EmoteLocation : MonoBehaviour
{
	public static List<EmoteLocation> emoteLocations = new List<EmoteLocation>();

	public static bool visibile = true;

	public int spot;

	public int validPlayers = 0;

	public BoneMapper owner;

	public BoneMapper emoter;

	public JoinSpot joinSpot;

	private InteractTrigger personalTrigger;

	public static void HideAllSpots()
	{
		visibile = false;
		foreach (EmoteLocation emoteLocation in emoteLocations)
		{
			try
			{
				Renderer[] componentsInChildren = ((Component)emoteLocation).GetComponentsInChildren<Renderer>();
				foreach (Renderer val in componentsInChildren)
				{
					val.enabled = false;
				}
				ParticleSystemRenderer[] componentsInChildren2 = ((Component)emoteLocation).GetComponentsInChildren<ParticleSystemRenderer>();
				foreach (ParticleSystemRenderer val2 in componentsInChildren2)
				{
					((Renderer)val2).enabled = false;
				}
			}
			catch (Exception)
			{
			}
		}
	}

	public static void ShowAllSpots()
	{
		visibile = true;
		foreach (EmoteLocation emoteLocation in emoteLocations)
		{
			try
			{
				Renderer[] componentsInChildren = ((Component)emoteLocation).GetComponentsInChildren<Renderer>();
				foreach (Renderer val in componentsInChildren)
				{
					val.enabled = true;
				}
				ParticleSystemRenderer[] componentsInChildren2 = ((Component)emoteLocation).GetComponentsInChildren<ParticleSystemRenderer>();
				foreach (ParticleSystemRenderer val2 in componentsInChildren2)
				{
					((Renderer)val2).enabled = true;
				}
			}
			catch (Exception)
			{
			}
		}
	}

	private void Start()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		SetColor();
		emoteLocations.Add(this);
		((MonoBehaviour)this).StartCoroutine(setScale());
		if (!visibile)
		{
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				val.enabled = false;
			}
			ParticleSystemRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val2 in componentsInChildren2)
			{
				((Renderer)val2).enabled = false;
			}
		}
		personalTrigger = ((Component)this).gameObject.AddComponent<InteractTrigger>();
		((Component)this).gameObject.tag = "InteractTrigger";
		((Component)this).gameObject.layer = LayerMask.NameToLayer("InteractableObject");
		personalTrigger.interactable = true;
		personalTrigger.hoverIcon = Object.Instantiate<Sprite>(Assets.Load<Sprite>("assets/fineilldoitmyself/nothing.png"));
		personalTrigger.disabledHoverIcon = Object.Instantiate<Sprite>(Assets.Load<Sprite>("assets/fineilldoitmyself/nothing.png"));
		personalTrigger.disabledHoverTip = "";
		InputBinding val3 = EmotesInputSettings.Instance.JoinEmote.bindings[0];
		string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref val3)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
		personalTrigger.hoverTip = "Press [" + text + "] to join";
	}

	private void OnDestroy()
	{
		emoteLocations.Remove(this);
	}

	public void SetEmoterAndHideLocation(BoneMapper boneMapper)
	{
		if (!Object.op_Implicit((Object)(object)emoter))
		{
			emoter = boneMapper;
			SetVisible(visibility: false);
		}
	}

	public IEnumerator setScale()
	{
		yield return (object)new WaitForSeconds(0.1f);
		_ = Vector3.one;
		Vector3 scal = ((!Object.op_Implicit((Object)(object)owner.emoteSkeletonSMR)) ? ((Component)owner).transform.lossyScale : ((Component)owner).transform.parent.lossyScale);
		((Component)this).transform.localPosition = new Vector3(joinSpot.position.x / scal.x, joinSpot.position.y / scal.y, joinSpot.position.z / scal.z);
		((Component)this).transform.localEulerAngles = joinSpot.rotation;
		((Component)this).transform.localScale = new Vector3(joinSpot.scale.x / scal.x, joinSpot.scale.y / scal.y, joinSpot.scale.z / scal.z);
	}

	internal void SetVisible(bool visibility)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (visibility)
		{
			Transform transform = ((Component)this).gameObject.transform;
			transform.localPosition += new Vector3(5000f, 5000f, 5000f);
		}
		else
		{
			Transform transform2 = ((Component)this).gameObject.transform;
			transform2.localPosition -= new Vector3(5000f, 5000f, 5000f);
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (!Object.op_Implicit((Object)(object)((Component)other).GetComponentInChildren<BoneMapper>()) || !((Object)(object)((Component)other).GetComponentInChildren<BoneMapper>() != (Object)(object)owner))
		{
			return;
		}
		BoneMapper componentInChildren = ((Component)other).GetComponentInChildren<BoneMapper>();
		if (Object.op_Implicit((Object)(object)componentInChildren))
		{
			validPlayers++;
			SetColor();
			if (componentInChildren.local)
			{
				personalTrigger.interactable = true;
			}
			componentInChildren.currentEmoteSpot = ((Component)this).gameObject;
			CustomEmotesAPI.JoinSpotEntered(componentInChildren, owner);
		}
	}

	private void OnTriggerExit(Collider other)
	{
		if (!Object.op_Implicit((Object)(object)((Component)other).GetComponentInChildren<BoneMapper>()) || !((Object)(object)((Component)other).GetComponentInChildren<BoneMapper>() != (Object)(object)owner))
		{
			return;
		}
		BoneMapper componentInChildren = ((Component)other).GetComponentInChildren<BoneMapper>();
		if (Object.op_Implicit((Object)(object)componentInChildren))
		{
			if (validPlayers != 0)
			{
				validPlayers--;
			}
			if (componentInChildren.local)
			{
				personalTrigger.interactable = false;
			}
			SetColor();
			if ((Object)(object)componentInChildren.currentEmoteSpot == (Object)(object)((Component)this).gameObject)
			{
				componentInChildren.currentEmoteSpot = null;
			}
		}
	}

	internal void SetColor()
	{
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: 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)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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)
		if (validPlayers > 0)
		{
			((Component)this).GetComponentsInChildren<Renderer>()[((Component)this).GetComponentsInChildren<Renderer>().Length - 1].material.color = Color.green;
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				val.material.SetColor("_EmissionColor", Color.green);
			}
			ParticleSystemRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val2 in componentsInChildren2)
			{
				((Renderer)val2).material.SetColor("_EmissionColor", Color.green);
			}
			ParticleSystem[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val3 in componentsInChildren3)
			{
				TrailModule trails = val3.trails;
				((TrailModule)(ref trails)).colorOverTrail = MinMaxGradient.op_Implicit(Color.green);
			}
		}
		else
		{
			((Component)this).GetComponentsInChildren<Renderer>()[((Component)this).GetComponentsInChildren<Renderer>().Length - 1].material.color = new Color(0.003921569f, 52f / 85f, 38f / 51f);
			Renderer[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren4)
			{
				val4.material.SetColor("_EmissionColor", new Color(0.003921569f, 52f / 85f, 38f / 51f));
			}
			ParticleSystemRenderer[] componentsInChildren5 = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val5 in componentsInChildren5)
			{
				((Renderer)val5).material.SetColor("_EmissionColor", new Color(0.003921569f, 52f / 85f, 38f / 51f));
			}
			ParticleSystem[] componentsInChildren6 = ((Component)this).GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val6 in componentsInChildren6)
			{
				TrailModule trails2 = val6.trails;
				((TrailModule)(ref trails2)).colorOverTrail = MinMaxGradient.op_Implicit(new Color(0.003921569f, 52f / 85f, 38f / 51f));
			}
		}
	}
}
public class AudioContainer : MonoBehaviour
{
	internal List<GameObject> playingObjects = new List<GameObject>();
}
public class AudioObject : MonoBehaviour
{
	internal int spot;

	internal int playerCount;

	internal GameObject audioObject;

	internal int activeObjectsSpot;
}
public class BonePair
{
	public Transform original;

	public Transform newiginal;

	public BonePair(Transform n, Transform o)
	{
		newiginal = n;
		original = o;
	}

	public void test()
	{
	}
}
public static class DebugClass
{
	private static ManualLogSource Logger;

	public static void SetLogger(ManualLogSource logSource)
	{
		Logger = logSource;
	}

	public static void Log(object message)
	{
		Logger.Log((LogLevel)16, (object)$"{message}");
	}
}
public class EmoteNetworker : NetworkBehaviour
{
	public static EmoteNetworker instance;

	private void Awake()
	{
		((Object)this).name = "Bigma Lalls";
		instance = this;
	}

	public void SyncEmote(ulong playerId, string animation, int pos)
	{
		if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).IsServer)
		{
			SyncEmoteToClients(playerId, animation, pos);
		}
		else
		{
			SyncEmoteToServerRpc(playerId, animation, pos);
		}
	}

	public void SyncEmoteToClients(ulong playerId, string animation, int pos)
	{
		GameObject gameObject = ((Component)((NetworkBehaviour)this).GetNetworkObject(playerId)).gameObject;
		if (!Object.op_Implicit((Object)(object)gameObject))
		{
			DebugClass.Log("Body is null!!!");
		}
		int eventNum = -1;
		CustomAnimationClip customAnimationClip = BoneMapper.animClips[animation];
		try
		{
			if (customAnimationClip != null)
			{
				eventNum = Random.Range(0, BoneMapper.primaryAudioClips[customAnimationClip.syncPos].Length);
			}
		}
		catch (Exception)
		{
		}
		SyncEmoteToClientRpc(playerId, animation, pos, eventNum);
	}

	[ClientRpc]
	public void SyncEmoteToClientRpc(ulong playerId, string animation, int pos, int eventNum)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1218916340u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, playerId);
			bool flag = animation != null;
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
			if (flag)
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe(animation, false);
			}
			BytePacker.WriteValueBitPacked(val2, pos);
			BytePacker.WriteValueBitPacked(val2, eventNum);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1218916340u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		GameObject gameObject = ((Component)((NetworkBehaviour)this).GetNetworkObject(playerId)).gameObject;
		if (!Object.op_Implicit((Object)(object)gameObject))
		{
			DebugClass.Log("Body is null!!!");
		}
		BoneMapper componentInChildren = gameObject.GetComponentInChildren<BoneMapper>();
		if (componentInChildren.playerController != null && componentInChildren.playerController.performingEmote && !animation.Contains("BetterEmotes__") && !animation.Contains("TooManyEmotes__"))
		{
			componentInChildren.playerController.performingEmote = false;
			if (((NetworkBehaviour)componentInChildren.playerController).IsOwner)
			{
				componentInChildren.playerController.StopPerformingEmoteServerRpc();
			}
		}
		DebugClass.Log($"Recieved message to play {animation} on client. Playing on {gameObject}");
		componentInChildren.PlayAnim(animation, pos, eventNum);
	}

	[ServerRpc(RequireOwnership 

LethalEmotesApi/LethalEmotesApi.Ui.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using LethalEmotesApi.Ui.Animation;
using LethalEmotesApi.Ui.Customize;
using LethalEmotesApi.Ui.Customize.DragDrop;
using LethalEmotesApi.Ui.Customize.Preview;
using LethalEmotesApi.Ui.Customize.RebindConflict;
using LethalEmotesApi.Ui.Customize.Wheel;
using LethalEmotesApi.Ui.Data;
using LethalEmotesApi.Ui.Db;
using LethalEmotesApi.Ui.Elements;
using LethalEmotesApi.Ui.Elements.Recycle;
using LethalEmotesApi.Ui.NetcodePatcher;
using LethalEmotesApi.Ui.Utils;
using LethalEmotesApi.Ui.Wheel;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
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("LethalEmotesApi.Ui")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+15eb38b312ea9fbf6ce336edf9651f91374b8535")]
[assembly: AssemblyProduct("LethalEmotesApi.Ui")]
[assembly: AssemblyTitle("LethalEmotesApi.Ui")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalEmotesApi.Ui
{
	internal static class DebugUtils
	{
		public static string ToPrettyString<T>(this IEnumerable<T> enumerable)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			stringBuilder.AppendLine("{");
			num++;
			int num2 = 0;
			foreach (T item in enumerable)
			{
				if (item != null)
				{
					for (int i = 0; i < num; i++)
					{
						stringBuilder.Append("    ");
					}
					stringBuilder.AppendLine($"[{num2}]: {item.ToString()}");
					num2++;
				}
			}
			stringBuilder.AppendLine("}");
			return stringBuilder.ToString();
		}
	}
	public static class EmoteUiManager
	{
		private static IEmoteUiStateController? _stateController;

		internal static EmoteUiPanel? emoteUiInstance;

		private static bool _hasShownDmcaPrompt;

		private static EmoteWheelSetDisplayData? _emoteDisplayData;

		internal static IEmoteDb EmoteDb => _stateController.EmoteDb;

		internal static IReadOnlyCollection<string> EmoteKeys => _stateController.EmoteDb.EmoteKeys;

		internal static IReadOnlyCollection<string> RandomPoolBlacklist => _stateController.RandomPoolBlacklist;

		internal static IReadOnlyCollection<string> EmotePoolBlacklist => _stateController.EmotePoolBlacklist;

		public static float EmoteVolume
		{
			get
			{
				return _stateController.EmoteVolume;
			}
			set
			{
				_stateController.EmoteVolume = value;
			}
		}

		public static bool HideJoinSpots
		{
			get
			{
				return _stateController.HideJoinSpots;
			}
			set
			{
				_stateController.HideJoinSpots = value;
			}
		}

		public static int RootMotionType
		{
			get
			{
				return _stateController.RootMotionType;
			}
			set
			{
				_stateController.RootMotionType = value;
			}
		}

		public static bool EmotesAlertEnemies
		{
			get
			{
				return _stateController.EmotesAlertEnemies;
			}
			set
			{
				_stateController.EmotesAlertEnemies = value;
			}
		}

		public static int DmcaFree
		{
			get
			{
				return _stateController.DmcaFree;
			}
			set
			{
				_stateController.DmcaFree = value;
			}
		}

		public static int ThirdPerson
		{
			get
			{
				return _stateController.ThirdPerson;
			}
			set
			{
				_stateController.ThirdPerson = value;
			}
		}

		public static bool UseGlobalSettings
		{
			get
			{
				return _stateController.UseGlobalSettings;
			}
			set
			{
				_stateController.UseGlobalSettings = value;
			}
		}

		public static bool DontShowDmcaPrompt
		{
			get
			{
				return _stateController.DontShowDmcaPrompt;
			}
			set
			{
				_stateController.DontShowDmcaPrompt = value;
			}
		}

		public static bool PermanentEmotingHealthbar
		{
			get
			{
				return _stateController.PermanentEmotingHealthbar;
			}
			set
			{
				_stateController.PermanentEmotingHealthbar = value;
			}
		}

		public static bool ImportTME
		{
			get
			{
				return _stateController.ImportTME;
			}
			set
			{
				_stateController.ImportTME = value;
			}
		}

		public static bool ImportBetterEmotes
		{
			get
			{
				return _stateController.ImportBetterEmotes;
			}
			set
			{
				_stateController.ImportBetterEmotes = value;
			}
		}

		public static bool NearestEmoteText
		{
			get
			{
				return _stateController.NearestEmoteText;
			}
			set
			{
				_stateController.NearestEmoteText = value;
			}
		}

		public static bool NearestEmoteTutorial
		{
			get
			{
				return _stateController.NearestEmoteTextTutorial;
			}
			set
			{
				_stateController.NearestEmoteTextTutorial = value;
			}
		}

		public static void RegisterStateController(IEmoteUiStateController stateController)
		{
			_stateController = stateController;
		}

		public static IEmoteUiStateController? GetStateController()
		{
			return _stateController;
		}

		internal static void PlayEmote(string emoteKey)
		{
			try
			{
				_stateController?.PlayEmote(emoteKey);
			}
			catch
			{
				Debug.Log((object)"Emote selected might not exist");
			}
		}

		internal static void LockMouseInput()
		{
			_stateController?.LockMouseInput();
		}

		internal static void UnlockMouseInput()
		{
			_stateController?.UnlockMouseInput();
		}

		internal static void LockPlayerInput()
		{
			_stateController?.LockPlayerInput();
		}

		internal static void UnlockPlayerInput()
		{
			_stateController?.UnlockPlayerInput();
		}

		internal static void EnableKeybinds()
		{
			_stateController?.EnableKeybinds();
		}

		internal static void DisableKeybinds()
		{
			_stateController?.DisableKeybinds();
		}

		internal static void PlayAnimationOn(Animator animator, string emoteKey)
		{
			_stateController?.PlayAnimationOn(animator, emoteKey);
		}

		internal static string GetEmoteName(string emoteKey)
		{
			IEmoteDb emoteDb = _stateController.EmoteDb;
			if (emoteDb.EmoteExists(emoteKey))
			{
				return emoteDb.GetEmoteName(emoteKey);
			}
			if (_emoteDisplayData == null)
			{
				return emoteKey;
			}
			return _emoteDisplayData.EmoteKeyEmoteNameLut.GetValueOrDefault(emoteKey, emoteKey);
		}

		internal static string GetEmoteModName(string emoteKey)
		{
			IEmoteDb emoteDb = _stateController.EmoteDb;
			if (emoteDb.EmoteExists(emoteKey))
			{
				return emoteDb.GetModName(emoteKey);
			}
			if (_emoteDisplayData == null)
			{
				return "Unknown";
			}
			return _emoteDisplayData.EmoteKeyModNameLut.GetValueOrDefault(emoteKey, "Unknown");
		}

		internal static bool GetEmoteVisibility(string emoteKey)
		{
			return _stateController.EmoteDb.GetEmoteVisibility(emoteKey);
		}

		internal static void AddToRandomPoolBlacklist(string emoteKey)
		{
			_stateController?.AddToRandomPoolBlacklist(emoteKey);
		}

		internal static void RemoveFromRandomPoolBlacklist(string emoteKey)
		{
			_stateController?.RemoveFromRandomPoolBlacklist(emoteKey);
		}

		internal static void AddToEmoteBlacklist(string emoteKey)
		{
			_stateController?.AddToEmoteBlacklist(emoteKey);
		}

		internal static void RemoveFromEmoteBlacklist(string emoteKey)
		{
			_stateController?.RemoveFromEmoteBlacklist(emoteKey);
		}

		internal static void RefreshBothLists()
		{
			_stateController?.RefreshBothLists();
		}

		internal static InputActionReference? GetEmoteKeybind(string? emoteKey)
		{
			if (emoteKey == null)
			{
				return null;
			}
			return _stateController?.GetEmoteKeybind(emoteKey);
		}

		internal static string[] GetEmoteKeysForBindPath(string bindPath)
		{
			return _stateController.GetEmoteKeysForBindPath(bindPath);
		}

		internal static EmoteWheelSetData LoadEmoteWheelSetData()
		{
			_emoteDisplayData = _stateController.LoadEmoteWheelSetDisplayData();
			EmoteWheelSetData emoteWheelSetData = _stateController.LoadEmoteWheelSetData();
			_stateController.SaveEmoteWheelSetDisplayData(_emoteDisplayData.LoadFromWheelSetData(emoteWheelSetData));
			return emoteWheelSetData;
		}

		internal static void SaveEmoteWheelSetData(EmoteWheelSetData dataToSave)
		{
			_stateController.SaveEmoteWheelSetData(dataToSave);
			_emoteDisplayData = _emoteDisplayData.LoadFromWheelSetData(dataToSave);
			_stateController.SaveEmoteWheelSetDisplayData(_emoteDisplayData);
			if (emoteUiInstance != null)
			{
				emoteUiInstance.ReloadData();
			}
		}

		internal static void SaveKeybinds()
		{
			_stateController?.SaveKeybinds();
		}

		internal static void LoadKeybinds()
		{
			_stateController?.LoadKeybinds();
		}

		public static bool IsEmoteWheelsOpen()
		{
			EmoteUiPanel emoteUiPanel = emoteUiInstance;
			return emoteUiPanel != null && emoteUiPanel.IsOpen && emoteUiPanel.CurrentView == EmoteUiPanel.UiView.EmoteWheels;
		}

		public static bool IsCustomizePanelOpen()
		{
			EmoteUiPanel emoteUiPanel = emoteUiInstance;
			return emoteUiPanel != null && emoteUiPanel.IsOpen && emoteUiPanel.CurrentView == EmoteUiPanel.UiView.Customize;
		}

		public static bool IsEmoteUiOpen()
		{
			return emoteUiInstance?.IsOpen ?? false;
		}

		public static bool CanOpenEmoteWheels()
		{
			if (_stateController == null)
			{
				return false;
			}
			return _stateController.CanOpenEmoteUi() && !IsCustomizePanelOpen();
		}

		public static void OnLeftWheel()
		{
			if (emoteUiInstance != null && emoteUiInstance.emoteWheelsController != null && IsEmoteWheelsOpen())
			{
				emoteUiInstance.emoteWheelsController.PrevWheel();
			}
		}

		public static void OnRightWheel()
		{
			if (emoteUiInstance != null && emoteUiInstance.emoteWheelsController != null && IsEmoteWheelsOpen())
			{
				emoteUiInstance.emoteWheelsController.NextWheel();
			}
		}

		public static void OpenEmoteWheels()
		{
			if (emoteUiInstance != null && CanOpenEmoteWheels())
			{
				emoteUiInstance.Show();
				_stateController?.DisableKeybinds();
			}
		}

		public static void CloseEmoteWheels()
		{
			if (emoteUiInstance != null && IsEmoteWheelsOpen())
			{
				emoteUiInstance.Hide();
				_stateController?.EnableKeybinds();
			}
		}

		public static void CloseCustomizationPanel()
		{
			if (emoteUiInstance != null && IsCustomizePanelOpen())
			{
				emoteUiInstance.Hide();
				_stateController?.EnableKeybinds();
			}
		}

		public static void CloseUiGracefully()
		{
			if (emoteUiInstance != null)
			{
				emoteUiInstance.CloseGracefully();
				_stateController?.EnableKeybinds();
			}
		}

		public static void ShowDmcaPrompt()
		{
			if (_stateController == null || _hasShownDmcaPrompt)
			{
				return;
			}
			ThreadPool.QueueUserWorkItem(delegate
			{
				while (emoteUiInstance == null)
				{
					Thread.Sleep(250);
				}
				_hasShownDmcaPrompt = true;
				_stateController.EnqueueWorkOnUnityThread(emoteUiInstance.ShowDmcaPrompt);
			});
		}

		public static float GetUIScale()
		{
			if (emoteUiInstance == null)
			{
				Debug.LogWarning((object)"EmoteUiInstance is null!");
				return 0f;
			}
			return ((Component)((Component)emoteUiInstance).transform.parent).GetComponent<Canvas>().scaleFactor;
		}
	}
	public class EmoteUiPanel : MonoBehaviour
	{
		internal enum UiView
		{
			None,
			EmoteWheels,
			Customize,
			DmcaPrompt,
			DmcaVerificationPrompt
		}

		public EmoteWheelsController? emoteWheelsController;

		public CustomizePanel? customizePanel;

		public RectTransform? customizeButton;

		public GameObject? dmcaPromptPrefab;

		public GameObject? dmcaVerificationPromptPrefab;

		private TextMeshProUGUI? _customizeButtonLabel;

		private GameObject? _dmcaPromptInstance;

		private GameObject? _dmcaVerificationPromptInstance;

		private UiView _prevView;

		public bool IsOpen { get; private set; }

		internal UiView CurrentView { get; private set; } = UiView.EmoteWheels;


		private void Awake()
		{
			EmoteUiManager.emoteUiInstance = this;
			if (customizeButton != null && _customizeButtonLabel == null)
			{
				_customizeButtonLabel = ((Component)customizeButton).GetComponentInChildren<TextMeshProUGUI>();
			}
		}

		private void OnEnable()
		{
			if (customizeButton != null && _customizeButtonLabel == null)
			{
				_customizeButtonLabel = ((Component)customizeButton).GetComponentInChildren<TextMeshProUGUI>();
			}
		}

		public void ReloadData()
		{
			if (emoteWheelsController != null)
			{
				emoteWheelsController.ReloadWheels();
			}
		}

		public void Show()
		{
			CurrentView = UiView.EmoteWheels;
			_prevView = UiView.None;
			UpdateCustomizeButton();
			ShowCustomizeButton();
			ShowEmoteWheels();
			EmoteUiManager.LockMouseInput();
			IsOpen = true;
		}

		public void Hide()
		{
			HideCustomizePanel();
			HideCustomizeButton();
			HideEmoteWheels();
			CloseDmcaPrompt();
			CloseDmcaVerificationPrompt();
			CurrentView = UiView.EmoteWheels;
			_prevView = UiView.None;
			EmoteUiManager.UnlockMouseInput();
			EmoteUiManager.UnlockPlayerInput();
			EmoteUiManager.EnableKeybinds();
			IsOpen = false;
		}

		public void CloseGracefully()
		{
			HideCustomizePanel();
			HideCustomizeButton();
			CloseEmoteWheelsGracefully();
			CloseDmcaVerificationPrompt();
			if (_prevView == UiView.DmcaPrompt)
			{
				CurrentView = _prevView;
				_prevView = UiView.None;
				EmoteUiManager.LockMouseInput();
				EmoteUiManager.LockPlayerInput();
				EmoteUiManager.DisableKeybinds();
			}
			else
			{
				CloseDmcaPrompt();
				CurrentView = UiView.EmoteWheels;
				_prevView = UiView.None;
				IsOpen = false;
			}
		}

		public void ToggleCustomizePanel()
		{
			if (emoteWheelsController != null)
			{
				if (CurrentView == UiView.EmoteWheels)
				{
					EmoteUiManager.GetStateController()?.RefreshTME();
					CloseEmoteWheelsGracefully();
					ShowCustomizePanel();
					CurrentView = UiView.Customize;
					EmoteUiManager.LockPlayerInput();
				}
				else if (CurrentView == UiView.Customize)
				{
					Hide();
				}
				UpdateCustomizeButton();
			}
		}

		public void ShowEmoteWheels()
		{
			if (emoteWheelsController != null)
			{
				emoteWheelsController.Show();
				((Component)emoteWheelsController.wheelLabel).gameObject.SetActive(true);
			}
		}

		public void HideEmoteWheels()
		{
			if (emoteWheelsController != null)
			{
				emoteWheelsController.Hide();
				((Component)emoteWheelsController.wheelLabel).gameObject.SetActive(false);
			}
		}

		public void CloseEmoteWheelsGracefully()
		{
			if (emoteWheelsController != null)
			{
				emoteWheelsController.CloseGracefully();
				((Component)emoteWheelsController.wheelLabel).gameObject.SetActive(false);
			}
		}

		public void ShowCustomizePanel()
		{
			if (customizePanel != null)
			{
				((Component)customizePanel).gameObject.SetActive(true);
			}
		}

		public void HideCustomizePanel()
		{
			RebindConflictController.CancelExisting();
			if (customizePanel != null)
			{
				customizePanel.dragDropController.CancelDrag();
				((Component)customizePanel).gameObject.SetActive(false);
				EmoteUiManager.UnlockPlayerInput();
				EmoteUiManager.UnlockMouseInput();
			}
		}

		public void ShowCustomizeButton()
		{
			if (customizeButton != null)
			{
				((Component)customizeButton).gameObject.SetActive(true);
			}
		}

		public void HideCustomizeButton()
		{
			if (customizeButton != null)
			{
				((Component)customizeButton).gameObject.SetActive(false);
			}
		}

		private void UpdateCustomizeButton()
		{
			if (_customizeButtonLabel != null)
			{
				((TMP_Text)_customizeButtonLabel).SetText((CurrentView == UiView.EmoteWheels) ? "Customize" : "Close", true);
			}
		}

		public void ShowDmcaPrompt()
		{
			if (dmcaPromptPrefab != null)
			{
				CloseGracefully();
				if (_dmcaPromptInstance != null && Object.op_Implicit((Object)(object)_dmcaPromptInstance))
				{
					Object.DestroyImmediate((Object)(object)_dmcaPromptInstance);
					_dmcaPromptInstance = null;
				}
				CurrentView = UiView.DmcaPrompt;
				_dmcaPromptInstance = Object.Instantiate<GameObject>(dmcaPromptPrefab, ((Component)this).transform);
				EmoteUiManager.LockMouseInput();
				EmoteUiManager.LockPlayerInput();
				EmoteUiManager.DisableKeybinds();
				IsOpen = true;
			}
		}

		private void CloseDmcaPrompt()
		{
			if (_dmcaPromptInstance != null)
			{
				Object.DestroyImmediate((Object)(object)_dmcaPromptInstance);
				_dmcaPromptInstance = null;
			}
		}

		public void ShowDmcaVerificationPrompt()
		{
			if (dmcaVerificationPromptPrefab != null)
			{
				if (CurrentView == UiView.DmcaPrompt)
				{
					_prevView = UiView.DmcaPrompt;
				}
				else
				{
					CloseGracefully();
				}
				if (_dmcaVerificationPromptInstance != null && Object.op_Implicit((Object)(object)_dmcaVerificationPromptInstance))
				{
					Object.DestroyImmediate((Object)(object)_dmcaVerificationPromptInstance);
					_dmcaVerificationPromptInstance = null;
				}
				CurrentView = UiView.DmcaVerificationPrompt;
				_dmcaVerificationPromptInstance = Object.Instantiate<GameObject>(dmcaVerificationPromptPrefab, ((Component)this).transform);
				EmoteUiManager.LockMouseInput();
				EmoteUiManager.LockPlayerInput();
				EmoteUiManager.DisableKeybinds();
				IsOpen = true;
			}
		}

		private void CloseDmcaVerificationPrompt()
		{
			if (_dmcaVerificationPromptInstance != null)
			{
				Object.DestroyImmediate((Object)(object)_dmcaVerificationPromptInstance);
				_dmcaVerificationPromptInstance = null;
			}
		}

		private void OnDestroy()
		{
			EmoteUiManager.emoteUiInstance = null;
		}
	}
	[ExecuteAlways]
	public class WheelSegmentGen : MonoBehaviour
	{
		public Material segmentMat;

		public ColorBlock colorBlock;

		[Range(1f, 20f)]
		public int segments = 8;

		[Range(-90f, 90f)]
		public float offset;

		[Range(0f, 700f)]
		public float maxRadius = 300f;

		[Range(0f, 699f)]
		public float minRadius = 100f;

		private void OnDrawGizmos()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (minRadius >= maxRadius)
			{
				minRadius = maxRadius - 1f;
			}
			Vector3 position = ((Component)this).transform.position;
			float num = (float)(Math.PI * 2.0 / (double)segments);
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < segments; i++)
			{
				float num2 = (float)i * num + MathF.PI / 180f * offset;
				float num3 = ((float)i * num + (float)(i + 1) * num) / 2f + MathF.PI / 180f * offset;
				float num4 = (float)((double)position.x + Math.Cos(num2) * (double)maxRadius);
				float num5 = (float)((double)position.y + Math.Sin(num2) * (double)maxRadius);
				float num6 = (float)((double)position.x + Math.Cos(num2) * (double)minRadius);
				float num7 = (float)((double)position.y + Math.Sin(num2) * (double)minRadius);
				((Vector3)(ref val))..ctor(num6, num7, position.z);
				((Vector3)(ref val2))..ctor(num4, num5, position.z);
				Gizmos.DrawLine(val, val2);
			}
		}
	}
}
namespace LethalEmotesApi.Ui.Wheel
{
	[RequireComponent(typeof(CanvasGroup))]
	public class EmoteWheel : MonoBehaviour, IPointerMoveHandler, IEventSystemHandler
	{
		private class EmoteSelectedCallback : UnityEvent<string>
		{
		}

		private readonly TweenRunner<AnimCurveTween<Vector3Tween>> _posTweenRunner = new TweenRunner<AnimCurveTween<Vector3Tween>>();

		private readonly TweenRunner<AnimCurveTween<FloatTween>> _alphaTweenRunner = new TweenRunner<AnimCurveTween<FloatTween>>();

		private readonly DelayedActionRunner<DelayedAction> _delayedActionRunner = new DelayedActionRunner<DelayedAction>();

		public CanvasGroup? canvasGroup;

		public WheelStopEmote? wheelStopEmote;

		public ColorBlock colors;

		[Range(1f, 2f)]
		public float scaleMultiplier;

		public int segmentCount = 8;

		public float segmentRotOffset = 22.5f;

		public float minRadius = 100f;

		public float maxRadius = 300f;

		public List<EmoteWheelSegment> wheelSegments = new List<EmoteWheelSegment>();

		public string[] emoteArray;

		private int _currentSegmentIndex = -1;

		private RectTransform? _rectTransform;

		private readonly EmoteSelectedCallback _emoteSelectedCallback = new EmoteSelectedCallback();

		private bool _focused;

		public bool Focused
		{
			get
			{
				return _focused;
			}
			set
			{
				_focused = value;
				foreach (EmoteWheelSegment wheelSegment in wheelSegments)
				{
					wheelSegment.focused = _focused;
				}
				if (!_focused)
				{
					((UnityEventBase)_emoteSelectedCallback).RemoveAllListeners();
				}
			}
		}

		protected EmoteWheel()
		{
			emoteArray = new string[segmentCount];
			_posTweenRunner.Init((MonoBehaviour)(object)this);
			_alphaTweenRunner.Init((MonoBehaviour)(object)this);
			_delayedActionRunner.Init((MonoBehaviour)(object)this);
		}

		private void Awake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			_rectTransform = ((Component)this).GetComponent<RectTransform>();
			if (canvasGroup == null)
			{
				canvasGroup = ((Component)this).GetComponent<CanvasGroup>();
			}
			foreach (EmoteWheelSegment wheelSegment in wheelSegments)
			{
				wheelSegment.colors = colors;
				wheelSegment.scaleMultiplier = scaleMultiplier;
				wheelSegment.targetGraphic.segmentCount = segmentCount;
				wheelSegment.targetGraphic.segmentRotOffset = segmentRotOffset;
				wheelSegment.targetGraphic.minRadius = minRadius;
				wheelSegment.targetGraphic.maxRadius = maxRadius;
				wheelSegment.ResetState();
			}
		}

		private void OnEnable()
		{
			ResetState();
		}

		public void OnPointerMove(PointerEventData eventData)
		{
			//IL_001c: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (!_focused)
			{
				return;
			}
			Vector2 val = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, eventData.position, eventData.enterEventCamera, ref val);
			Rect rect = _rectTransform.rect;
			float num = Vector2.Distance(Vector2.zero, val);
			if (num < minRadius)
			{
				DeSelectAll();
				((UnityEvent<string>)(object)_emoteSelectedCallback).Invoke("none");
				wheelStopEmote.OnPointerEnter(eventData);
				return;
			}
			if (val.x > ((Rect)(ref rect)).xMax || val.x < ((Rect)(ref rect)).xMin || val.y > ((Rect)(ref rect)).yMax || val.y < ((Rect)(ref rect)).yMin)
			{
				DeSelectAll();
				((UnityEvent<string>)(object)_emoteSelectedCallback).Invoke("");
				return;
			}
			int closestSegmentIndex = GetClosestSegmentIndex(val);
			if (closestSegmentIndex != _currentSegmentIndex)
			{
				wheelStopEmote.OnPointerExit(eventData);
				if (_currentSegmentIndex > -1)
				{
					wheelSegments[_currentSegmentIndex].OnPointerExit(eventData);
				}
				_currentSegmentIndex = closestSegmentIndex;
				wheelSegments[closestSegmentIndex].OnPointerEnter(eventData);
				((UnityEvent<string>)(object)_emoteSelectedCallback).Invoke(emoteArray[_currentSegmentIndex]);
			}
		}

		public void DeSelectAll()
		{
			_currentSegmentIndex = -1;
			foreach (EmoteWheelSegment wheelSegment in wheelSegments)
			{
				wheelSegment.DeSelect();
			}
		}

		public void ResetState()
		{
			_currentSegmentIndex = -1;
			foreach (EmoteWheelSegment wheelSegment in wheelSegments)
			{
				wheelSegment.ResetState();
			}
			_posTweenRunner.StopTween();
			_alphaTweenRunner.StopTween();
			_delayedActionRunner.StopAction();
			canvasGroup.alpha = 1f;
		}

		public void LoadEmotes(string[] emotes)
		{
			emoteArray = emotes;
			for (int i = 0; i < emoteArray.Length; i++)
			{
				wheelSegments[i].targetLabel?.SetEmote(emoteArray[i]);
			}
		}

		private int GetClosestSegmentIndex(Vector2 mousePos)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			int result = -1;
			float num = float.MaxValue;
			for (int i = 0; i < wheelSegments.Count; i++)
			{
				EmoteWheelSegment emoteWheelSegment = wheelSegments[i];
				Vector2 val = Vector2.op_Implicit(((Transform)emoteWheelSegment.segmentRectTransform).position - ((Transform)_rectTransform).position);
				float num2 = Vector2.Distance(val, mousePos);
				if (num2 < num)
				{
					num = num2;
					result = i;
				}
			}
			return result;
		}

		public void AddOnEmoteSelectedCallback(UnityAction<string> callback)
		{
			((UnityEvent<string>)(object)_emoteSelectedCallback).AddListener(callback);
		}

		public void TweenPos(Vector3 targetPos, AnimationCurve curve, float duration, bool ignoreTimeScale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.localPosition == targetPos)
			{
				_posTweenRunner.StopTween();
				return;
			}
			Vector3Tween vector3Tween = default(Vector3Tween);
			vector3Tween.Duration = duration;
			vector3Tween.StartValue = ((Component)this).transform.localPosition;
			vector3Tween.TargetValue = targetPos;
			vector3Tween.IgnoreTimeScale = ignoreTimeScale;
			Vector3Tween wrappedTweenValue = vector3Tween;
			wrappedTweenValue.AddOnChangedCallback(TweenPosChanged);
			AnimCurveTween<Vector3Tween> animCurveTween = default(AnimCurveTween<Vector3Tween>);
			animCurveTween.WrappedTweenValue = wrappedTweenValue;
			animCurveTween.Curve = curve;
			AnimCurveTween<Vector3Tween> tweenValue = animCurveTween;
			_posTweenRunner.StartTween(tweenValue);
		}

		private void TweenPosChanged(Vector3 pos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localPosition = pos;
		}

		public void TweenAlpha(float targetAlpha, AnimationCurve curve, float duration, bool ignoreTimeScale)
		{
			if (canvasGroup != null)
			{
				if (canvasGroup.alpha == targetAlpha)
				{
					_alphaTweenRunner.StopTween();
					return;
				}
				FloatTween floatTween = default(FloatTween);
				floatTween.Duration = duration;
				floatTween.StartValue = canvasGroup.alpha;
				floatTween.TargetValue = targetAlpha;
				floatTween.IgnoreTimeScale = ignoreTimeScale;
				FloatTween wrappedTweenValue = floatTween;
				wrappedTweenValue.AddOnChangedCallback(TweenAlphaChanged);
				AnimCurveTween<FloatTween> animCurveTween = default(AnimCurveTween<FloatTween>);
				animCurveTween.WrappedTweenValue = wrappedTweenValue;
				animCurveTween.Curve = curve;
				AnimCurveTween<FloatTween> tweenValue = animCurveTween;
				_alphaTweenRunner.StartTween(tweenValue);
			}
		}

		private void TweenAlphaChanged(float alpha)
		{
			canvasGroup.alpha = alpha;
		}

		public void DisableAfterDuration(float duration, bool ignoreTimeScale)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (!((Component)this).gameObject.activeInHierarchy)
			{
				_delayedActionRunner.StopAction();
				return;
			}
			DelayedAction delayedAction = default(DelayedAction);
			delayedAction.Duration = duration;
			delayedAction.IgnoreTimeScale = ignoreTimeScale;
			delayedAction.Action = new UnityAction(DelayedDisable);
			DelayedAction delayedAction2 = delayedAction;
			_delayedActionRunner.StartAction(delayedAction2);
		}

		private void DelayedDisable()
		{
			((Component)this).gameObject.SetActive(false);
		}
	}
	public class EmoteWheelsController : MonoBehaviour
	{
		public GameObject? wheelPrefab;

		public RectTransform? wheelContainer;

		public TextMeshProUGUI? wheelLabel;

		public float fadeDist = 500f;

		public float fadeDuration = 0.5f;

		public AnimationCurve? fadeCurve;

		private EmoteWheel[] _wheels = Array.Empty<EmoteWheel>();

		private int _currentWheelIndex;

		private string _selectedEmote = "";

		private bool _wheelLock;

		private EmoteWheelSetData WheelSetData => EmoteUiManager.LoadEmoteWheelSetData();

		public void Start()
		{
			InitWheels();
		}

		private void OnEnable()
		{
			ReloadWheels();
		}

		public void ReloadWheels()
		{
			if (WheelSetData.EmoteWheels.Length != _wheels.Length)
			{
				EmoteWheel[] wheels = _wheels;
				foreach (EmoteWheel emoteWheel in wheels)
				{
					Object.DestroyImmediate((Object)(object)((Component)emoteWheel).gameObject);
				}
				InitWheels();
			}
			else
			{
				for (int j = 0; j < _wheels.Length; j++)
				{
					EmoteWheel emoteWheel2 = _wheels[j];
					EmoteWheelData emoteWheelData = WheelSetData.EmoteWheels[j];
					((Component)emoteWheel2).gameObject.SetActive(true);
					emoteWheel2.LoadEmotes(emoteWheelData.Emotes);
				}
			}
		}

		public void LockWheels()
		{
			_wheelLock = true;
			if (_currentWheelIndex >= 0)
			{
				_wheels[_currentWheelIndex].DeSelectAll();
			}
		}

		public void UnlockWheels()
		{
			_wheelLock = false;
		}

		private void InitWheels()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (wheelPrefab == null || wheelContainer == null)
			{
				return;
			}
			int num = WheelSetData.EmoteWheels.Length;
			if (_wheels.Length != num)
			{
				_wheels = new EmoteWheel[num];
				for (int i = 0; i < _wheels.Length; i++)
				{
					GameObject val = Object.Instantiate<GameObject>(wheelPrefab, (Transform)(object)wheelContainer);
					val.transform.localPosition = Vector3.zero;
					EmoteWheel component = val.GetComponent<EmoteWheel>();
					EmoteWheelData emoteWheelData = WheelSetData.EmoteWheels[i];
					component.LoadEmotes(emoteWheelData.Emotes);
					component.Focused = false;
					((Component)component).gameObject.SetActive(false);
					_wheels[i] = component;
				}
				_currentWheelIndex = 0;
				int num2 = WheelSetData.IndexOfDefault();
				if (num2 >= 0)
				{
					_currentWheelIndex = num2;
				}
				UpdateWheelState();
			}
		}

		public void NextWheel()
		{
			if (!_wheelLock)
			{
				int currentWheelIndex = _currentWheelIndex;
				_currentWheelIndex++;
				if (_currentWheelIndex >= _wheels.Length)
				{
					_currentWheelIndex = 0;
				}
				EmoteWheel emoteWheel = _wheels[currentWheelIndex];
				emoteWheel.Focused = false;
				emoteWheel.DeSelectAll();
				FadeWheelLeft(currentWheelIndex);
				UpdateWheelState();
			}
		}

		public void PrevWheel()
		{
			if (!_wheelLock)
			{
				int currentWheelIndex = _currentWheelIndex;
				_currentWheelIndex--;
				if (_currentWheelIndex < 0)
				{
					_currentWheelIndex = _wheels.Length - 1;
				}
				EmoteWheel emoteWheel = _wheels[currentWheelIndex];
				emoteWheel.Focused = false;
				emoteWheel.DeSelectAll();
				FadeWheelRight(currentWheelIndex);
				UpdateWheelState();
			}
		}

		public void Show()
		{
			UnlockWheels();
			if (wheelContainer != null)
			{
				int num = WheelSetData.IndexOfDefault();
				if (num >= 0)
				{
					_currentWheelIndex = num;
				}
				EmoteWheel currentWheel = GetCurrentWheel();
				((Component)currentWheel).gameObject.SetActive(true);
				((Component)wheelContainer).gameObject.SetActive(true);
				if (wheelLabel != null)
				{
					((Component)wheelLabel).gameObject.SetActive(true);
					UpdateWheelState();
				}
			}
		}

		public void Hide()
		{
			UnlockWheels();
			if (wheelContainer == null)
			{
				return;
			}
			EmoteWheel[] wheels = _wheels;
			foreach (EmoteWheel emoteWheel in wheels)
			{
				((Component)emoteWheel).gameObject.SetActive(false);
			}
			((Component)wheelContainer).gameObject.SetActive(false);
			if (!string.IsNullOrEmpty(_selectedEmote))
			{
				EmoteUiManager.PlayEmote(_selectedEmote);
				_selectedEmote = "none";
				if (wheelLabel != null)
				{
					((Component)wheelLabel).gameObject.SetActive(false);
				}
			}
		}

		public void CloseGracefully()
		{
			if (wheelContainer != null)
			{
				EmoteWheel[] wheels = _wheels;
				foreach (EmoteWheel emoteWheel in wheels)
				{
					((Component)emoteWheel).gameObject.SetActive(false);
				}
				((Component)wheelContainer).gameObject.SetActive(false);
				_selectedEmote = "";
				if (wheelLabel != null)
				{
					((Component)wheelLabel).gameObject.SetActive(false);
				}
			}
		}

		private EmoteWheel GetCurrentWheel()
		{
			return _wheels[_currentWheelIndex];
		}

		private void UpdateWheelState()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			EmoteWheel currentWheel = GetCurrentWheel();
			((Component)currentWheel).gameObject.SetActive(true);
			Transform transform = ((Component)currentWheel).transform;
			transform.SetAsLastSibling();
			transform.localPosition = Vector3.zero;
			currentWheel.ResetState();
			currentWheel.Focused = true;
			currentWheel.AddOnEmoteSelectedCallback(UpdateSelectedEmote);
			EmoteWheelData emoteWheelData = WheelSetData.EmoteWheels[_currentWheelIndex];
			((TMP_Text)wheelLabel).SetText(emoteWheelData.Name, true);
		}

		private void UpdateSelectedEmote(string selectedEmote)
		{
			_selectedEmote = selectedEmote;
		}

		private void FadeWheelLeft(int wheelIndex, bool instant = false)
		{
			FadeWheel(wheelIndex, left: true, instant);
		}

		private void FadeWheelRight(int wheelIndex, bool instant = false)
		{
			FadeWheel(wheelIndex, left: false, instant);
		}

		private void FadeWheel(int wheelIndex, bool left, bool instant = false)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (fadeCurve != null)
			{
				EmoteWheel emoteWheel = _wheels[wheelIndex];
				Vector3 targetPos = default(Vector3);
				((Vector3)(ref targetPos))..ctor(left ? (0f - fadeDist) : fadeDist, 0f, 0f);
				emoteWheel.TweenPos(targetPos, fadeCurve, instant ? 0f : fadeDuration, ignoreTimeScale: true);
				emoteWheel.TweenAlpha(0f, fadeCurve, instant ? 0f : fadeDuration, ignoreTimeScale: true);
				emoteWheel.DisableAfterDuration(instant ? 0f : fadeDuration, ignoreTimeScale: true);
			}
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(RectTransform))]
	[ExecuteAlways]
	public class EmoteWheelSegment : UIBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public WheelSegmentGraphic? targetGraphic;

		public SegmentLabel? targetLabel;

		public RectTransform? segmentRectTransform;

		public ColorBlock colors;

		[Range(1f, 2f)]
		public float scaleMultiplier;

		public bool selected;

		public bool focused;

		private bool IsSelected()
		{
			return selected && focused;
		}

		protected override void Awake()
		{
			((UIBehaviour)this).Awake();
			if (targetGraphic == null)
			{
				targetGraphic = ((Component)this).GetComponentInChildren<WheelSegmentGraphic>();
			}
			if (targetLabel == null)
			{
				targetLabel = ((Component)this).GetComponentInChildren<SegmentLabel>();
			}
		}

		protected override void OnEnable()
		{
			((UIBehaviour)this).OnEnable();
			UpdateState(requireFocus: false, instant: true);
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			selected = true;
			UpdateState();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			selected = false;
			UpdateState();
		}

		public void DeSelect()
		{
			selected = false;
			UpdateState(requireFocus: false);
		}

		public void ResetState()
		{
			selected = false;
			UpdateState(requireFocus: false, instant: true);
		}

		private Color GetColor()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (IsSelected())
			{
				return ((ColorBlock)(ref colors)).selectedColor;
			}
			return ((ColorBlock)(ref colors)).normalColor;
		}

		private float GetScale()
		{
			if (IsSelected())
			{
				return scaleMultiplier;
			}
			return 1f;
		}

		private void UpdateState(bool requireFocus = true, bool instant = false)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!(!focused && requireFocus))
			{
				Color color = GetColor();
				StartColorTween(color * ((ColorBlock)(ref colors)).colorMultiplier, instant);
				StartScaleTween(GetScale(), instant);
			}
		}

		private void StartColorTween(Color targetColor, bool instant)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (targetGraphic != null)
			{
				((Graphic)targetGraphic).CrossFadeColor(targetColor, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, true, true);
			}
		}

		private void StartScaleTween(float targetScale, bool instant)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (targetGraphic != null && targetLabel != null)
			{
				targetGraphic.TweenScale(new Vector3(targetScale, targetScale, targetScale), instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, ignoreTimeScale: true);
				targetLabel.TweenScale(new Vector3(targetScale, targetScale, targetScale), instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, ignoreTimeScale: true);
			}
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(RectTransform))]
	[ExecuteAlways]
	public class SegmentLabel : UIBehaviour
	{
		private readonly TweenRunner<Vector3Tween> _scaleTweenRunner = new TweenRunner<Vector3Tween>();

		public RectTransform? targetLabel;

		public TextMeshProUGUI? targetText;

		public RectTransform? missingLabel;

		public TextMeshProUGUI? missingText;

		public RectTransform? lockedLabel;

		public TextMeshProUGUI? lockedText;

		private RectTransform? _rectTransform;

		private string? _emoteKey;

		protected DrivenRectTransformTracker tracker;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		protected SegmentLabel()
		{
			_scaleTweenRunner.Init((MonoBehaviour)(object)this);
		}

		protected override void OnEnable()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			((UIBehaviour)this).OnEnable();
			if (targetLabel != null && missingLabel != null && lockedLabel != null)
			{
				((DrivenRectTransformTracker)(ref tracker)).Add((Object)(object)this, targetLabel, (DrivenTransformProperties)16);
				((DrivenRectTransformTracker)(ref tracker)).Add((Object)(object)this, missingLabel, (DrivenTransformProperties)16);
				((DrivenRectTransformTracker)(ref tracker)).Add((Object)(object)this, lockedLabel, (DrivenTransformProperties)16);
				Vector3 eulerAngles = ((Transform)RectTransform).eulerAngles;
				((Transform)targetLabel).localEulerAngles = -eulerAngles;
				((Transform)missingLabel).localEulerAngles = -eulerAngles;
				((Transform)lockedLabel).localEulerAngles = -eulerAngles;
				UpdateText();
			}
		}

		protected override void OnDisable()
		{
			((UIBehaviour)this).OnDisable();
			((DrivenRectTransformTracker)(ref tracker)).Clear();
		}

		public void SetEmote(string? emoteKey)
		{
			_emoteKey = emoteKey;
			UpdateText();
		}

		private void UpdateText()
		{
			if (targetText != null && missingLabel != null && missingText != null && _emoteKey != null)
			{
				string emoteName = EmoteUiManager.GetEmoteName(_emoteKey);
				((Component)lockedLabel).gameObject.SetActive(false);
				((Component)missingLabel).gameObject.SetActive(false);
				if (!EmoteUiManager.EmoteDb.EmoteExists(_emoteKey))
				{
					((TMP_Text)targetText).SetText("", true);
					string emoteModName = EmoteUiManager.GetEmoteModName(_emoteKey);
					((TMP_Text)missingText).SetText("<color=#FFFFFF>" + emoteName + "</color>\n<color=#eed202>Requires</color>\n<color=#FFFFFF>" + emoteModName + "</color>", true);
					((Component)missingLabel).gameObject.SetActive(true);
				}
				else if (!EmoteUiManager.GetEmoteVisibility(_emoteKey))
				{
					((TMP_Text)targetText).SetText("", true);
					((TMP_Text)lockedText).SetText("<color=#eed202>Unlock</color>\n" + emoteName + "\n<color=#eed202>With</color>\nTooManyEmotes", true);
					((Component)lockedLabel).gameObject.SetActive(true);
				}
				else
				{
					((TMP_Text)targetText).SetText(emoteName, true);
				}
			}
		}

		public void TweenScale(Vector3 targetScale, float duration, bool ignoreTimeScale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.localScale == targetScale)
			{
				_scaleTweenRunner.StopTween();
				return;
			}
			Vector3Tween vector3Tween = default(Vector3Tween);
			vector3Tween.Duration = duration;
			vector3Tween.StartValue = ((Component)this).transform.localScale;
			vector3Tween.TargetValue = targetScale;
			vector3Tween.IgnoreTimeScale = ignoreTimeScale;
			Vector3Tween tweenValue = vector3Tween;
			tweenValue.AddOnChangedCallback(TweenScaleChanged);
			_scaleTweenRunner.StartTween(tweenValue);
		}

		private void TweenScaleChanged(Vector3 scale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localScale = scale;
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(CanvasRenderer))]
	[ExecuteAlways]
	public class WheelSegmentGraphic : Graphic
	{
		private readonly TweenRunner<Vector3Tween> _scaleTweenRunner = new TweenRunner<Vector3Tween>();

		public int segmentCount = 8;

		public float segmentRotOffset = 22.5f;

		public float minRadius = 100f;

		public float maxRadius = 300f;

		protected WheelSegmentGraphic()
		{
			_scaleTweenRunner.Init((MonoBehaviour)(object)this);
		}

		protected override void OnEnable()
		{
			((Graphic)this).OnEnable();
			((Graphic)this).raycastTarget = false;
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0111: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			Color32 val = Color32.op_Implicit(((Graphic)this).color);
			float num = (float)(Math.PI * 2.0 / (double)segmentCount);
			float num2 = num + MathF.PI / 180f * segmentRotOffset;
			int num3 = 0;
			float num4 = MathF.PI / 180f;
			Vector3 val2 = CosSin(num2, minRadius);
			Vector3 val3 = CosSin(num2 + num, minRadius);
			Vector3 val4 = -Vector3.Lerp(val2, val3, 0.5f);
			float num5 = num + num4 / 2f - num4;
			for (float num6 = 0f; num6 < num5; num6 += num4)
			{
				float rad = num2 + num6;
				Vector3 val5 = CosSin(rad, minRadius) + val4;
				Vector3 val6 = CosSin(rad, maxRadius) + val4;
				rad = num2 + num6 + num4;
				Vector3 val7 = CosSin(rad, minRadius) + val4;
				Vector3 val8 = CosSin(rad, maxRadius) + val4;
				float num7 = num6 / num5;
				float num8 = (num6 + num4) / num5;
				vh.AddVert(val5, val, Vector4.op_Implicit(new Vector2(num7, 0f)));
				vh.AddVert(val6, val, Vector4.op_Implicit(new Vector2(num7, 1f)));
				vh.AddVert(val7, val, Vector4.op_Implicit(new Vector2(num8, 0f)));
				vh.AddVert(val8, val, Vector4.op_Implicit(new Vector2(num8, 1f)));
				vh.AddTriangle(num3 + 2, num3 + 1, num3);
				vh.AddTriangle(num3 + 3, num3 + 1, num3 + 2);
				num3 += 4;
			}
		}

		private static Vector3 CosSin(float rad, float dist)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)(Math.Cos(rad) * (double)dist);
			float num2 = (float)(Math.Sin(rad) * (double)dist);
			return new Vector3(num, num2, 0f);
		}

		public void TweenScale(Vector3 targetScale, float duration, bool ignoreTimeScale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.localScale == targetScale)
			{
				_scaleTweenRunner.StopTween();
				return;
			}
			Vector3Tween vector3Tween = default(Vector3Tween);
			vector3Tween.Duration = duration;
			vector3Tween.StartValue = ((Component)this).transform.localScale;
			vector3Tween.TargetValue = targetScale;
			vector3Tween.IgnoreTimeScale = ignoreTimeScale;
			Vector3Tween tweenValue = vector3Tween;
			tweenValue.AddOnChangedCallback(TweenScaleChanged);
			_scaleTweenRunner.StartTween(tweenValue);
		}

		private void TweenScaleChanged(Vector3 scale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localScale = scale;
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(RectTransform))]
	[ExecuteAlways]
	public class WheelStopEmote : UIBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public WheelStopEmoteGraphic? backgroundGraphic;

		public Graphic? foregroundGraphic;

		public LeUiScaleTweener? scaleTweener;

		public ColorBlock colors;

		[Range(1f, 2f)]
		public float scaleMultiplier;

		public bool selected;

		protected override void OnEnable()
		{
			((UIBehaviour)this).OnEnable();
			UpdateState(instant: true);
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			selected = true;
			UpdateState();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			selected = false;
			UpdateState();
		}

		private Color GetBackgroundColor()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (selected)
			{
				return ((ColorBlock)(ref colors)).selectedColor;
			}
			return ((ColorBlock)(ref colors)).normalColor;
		}

		private Color GetForegroundColor()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (selected)
			{
				return ((ColorBlock)(ref colors)).highlightedColor;
			}
			return ((ColorBlock)(ref colors)).disabledColor;
		}

		private float GetScale()
		{
			if (selected)
			{
				return scaleMultiplier;
			}
			return 1f;
		}

		private void UpdateState(bool instant = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			Color backgroundColor = GetBackgroundColor();
			Color foregroundColor = GetForegroundColor();
			StartColorTween(foregroundColor * ((ColorBlock)(ref colors)).colorMultiplier, backgroundColor * ((ColorBlock)(ref colors)).colorMultiplier, instant);
			float scale = GetScale();
			StartScaleTween(scale, instant);
		}

		private void StartColorTween(Color foregroundColor, Color backgroundColor, bool instant)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)backgroundGraphic).CrossFadeColor(backgroundColor, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, true, true);
			foregroundGraphic.CrossFadeColor(foregroundColor, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, true, true);
		}

		private void StartScaleTween(float scale, bool instant)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (scaleTweener != null)
			{
				Vector3 targetScale = default(Vector3);
				((Vector3)(ref targetScale))..ctor(scale, scale, scale);
				scaleTweener.TweenScale(targetScale, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, ignoreTimeScale: true);
			}
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(CanvasRenderer))]
	[ExecuteAlways]
	public class WheelStopEmoteGraphic : Graphic
	{
		public float radius = 95f;

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			Color32 val = Color32.op_Implicit(((Graphic)this).color);
			float num = MathF.PI * 2f;
			int num2 = 0;
			float num3 = MathF.PI / 180f;
			for (float num4 = 0f; num4 + num3 < num; num4 += num3)
			{
				float rad = num4;
				Vector3 val2 = CosSin(rad, radius);
				rad = num4 + num3;
				Vector3 val3 = CosSin(rad, radius);
				vh.AddVert(Vector3.zero, val, Vector4.op_Implicit(new Vector2(0f, 0f)));
				vh.AddVert(val2, val, Vector4.op_Implicit(new Vector2(0f, 1f)));
				vh.AddVert(Vector3.zero, val, Vector4.op_Implicit(new Vector2(1f, 0f)));
				vh.AddVert(val3, val, Vector4.op_Implicit(new Vector2(1f, 1f)));
				vh.AddTriangle(num2 + 2, num2 + 1, num2);
				vh.AddTriangle(num2 + 3, num2 + 1, num2 + 2);
				num2 += 4;
			}
		}

		private static Vector3 CosSin(float rad, float dist)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)(Math.Cos(rad) * (double)dist);
			float num2 = (float)(Math.Sin(rad) * (double)dist);
			return new Vector3(num, num2, 0f);
		}
	}
}
namespace LethalEmotesApi.Ui.Utils
{
	internal static class RectTransformUtils
	{
		private static Camera? _uiCamera;

		private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4];

		private static Camera GetUiCamera()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (_uiCamera != null && Object.op_Implicit((Object)(object)_uiCamera))
			{
				return _uiCamera;
			}
			_uiCamera = null;
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "Systems"));
			if (val == null)
			{
				Debug.LogWarning((object)"Failed to find UICamera in active scene, falling back to Camera.current!");
				return Camera.current;
			}
			Transform val2 = val.transform.Find("UI/UICamera");
			if (val2 == null)
			{
				Debug.LogWarning((object)"Failed to find UICamera at MainMenu, falling back to Camera.current!");
				return Camera.current;
			}
			Camera component = ((Component)val2).GetComponent<Camera>();
			if (component == null)
			{
				Debug.LogWarning((object)"Failed to find Camera component on UICamera, falling back to Camera.current!");
				return Camera.current;
			}
			_uiCamera = component;
			return _uiCamera;
		}

		public static Rect GetRelativeRect(this RectTransform root, RectTransform worldRectTransform)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			Camera uiCamera = GetUiCamera();
			worldRectTransform.GetWorldCorners(Corners);
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			for (int i = 0; i < Corners.Length; i++)
			{
				array[i] = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint(uiCamera, Corners[i]));
			}
			Vector2[] array2 = (Vector2[])(object)new Vector2[4];
			for (int j = 0; j < array.Length; j++)
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(root, Vector2.op_Implicit(array[j]), uiCamera, ref array2[j]);
			}
			Vector2 val = Vector2.zero;
			Vector2 val2 = Vector2.zero;
			Vector2[] array3 = array2;
			foreach (Vector2 val3 in array3)
			{
				val = Vector2.Min(val, val3);
				val2 = Vector2.Max(val2, val3);
			}
			Vector2 val4 = val2 - val;
			return new Rect(val.x, val.y, val4.x, val4.y);
		}
	}
}
namespace LethalEmotesApi.Ui.Options
{
	public class DmcaFreeDropdown : LeUiDropdown
	{
		protected override int GetCurrentValue()
		{
			return EmoteUiManager.DmcaFree;
		}

		protected override void SetCurrentValue(int value)
		{
			EmoteUiManager.DmcaFree = value;
		}
	}
	public class DontShowDmcaPromptToggle : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.DontShowDmcaPrompt;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.DontShowDmcaPrompt = value;
		}
	}
	public class EmotesAlertEnemies : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.EmotesAlertEnemies;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.EmotesAlertEnemies = value;
		}
	}
	public class EmoteVolumeSlider : MonoBehaviour
	{
		public Slider? volumeSlider;

		private bool _hasListener;

		private void Awake()
		{
			UpdateSliderValue();
			EnsureListener();
		}

		private void Start()
		{
			UpdateSliderValue();
			EnsureListener();
		}

		private void OnEnable()
		{
			UpdateSliderValue();
			EnsureListener();
		}

		private void UpdateStateBroadcast()
		{
			UpdateSliderValue();
		}

		private void UpdateSliderValue()
		{
			if (volumeSlider != null)
			{
				volumeSlider.value = EmoteUiManager.EmoteVolume;
			}
		}

		private void EnsureListener()
		{
			if (volumeSlider != null && !_hasListener)
			{
				((UnityEvent<float>)(object)volumeSlider.onValueChanged).AddListener((UnityAction<float>)SliderChanged);
				_hasListener = true;
			}
		}

		private void SliderChanged(float value)
		{
			EmoteUiManager.EmoteVolume = value;
			SetValueWithoutNotify(value);
		}

		private void SetValueWithoutNotify(float value)
		{
			if (volumeSlider != null)
			{
				volumeSlider.SetValueWithoutNotify(value);
			}
		}
	}
	public class HideJoinSpots : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.HideJoinSpots;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.HideJoinSpots = value;
		}
	}
	public class ImportBetterEmotes : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.ImportBetterEmotes;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.ImportBetterEmotes = value;
		}
	}
	public class ImportTME : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.ImportTME;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.ImportTME = value;
		}
	}
	public abstract class LeUiDropdown : MonoBehaviour
	{
		public TMP_Dropdown? dropdown;

		private bool _hasListener;

		private void Awake()
		{
			UpdateDropdown();
			EnsureListener();
		}

		private void Start()
		{
			UpdateDropdown();
			EnsureListener();
		}

		private void OnEnable()
		{
			UpdateDropdown();
			EnsureListener();
		}

		private void UpdateDropdown()
		{
			if (dropdown != null)
			{
				dropdown.value = GetCurrentValue();
			}
		}

		private void EnsureListener()
		{
			if (dropdown != null && !_hasListener)
			{
				((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)DropdownChanged);
				_hasListener = true;
			}
		}

		private void DropdownChanged(int value)
		{
			SetCurrentValue(value);
			SetValueWithoutNotify(value);
		}

		protected abstract int GetCurrentValue();

		protected abstract void SetCurrentValue(int value);

		private void SetValueWithoutNotify(int value)
		{
			if (dropdown != null)
			{
				dropdown.SetValueWithoutNotify(value);
			}
		}

		private void UpdateStateBroadcast()
		{
			UpdateDropdown();
		}
	}
	public abstract class LeUiToggle : MonoBehaviour
	{
		public Image? checkboxImage;

		private void Awake()
		{
			UpdateCheckbox();
		}

		private void Start()
		{
			UpdateCheckbox();
		}

		private void OnEnable()
		{
			UpdateCheckbox();
		}

		public void Toggle()
		{
			SetCurrentValue(!GetCurrentValue());
			UpdateCheckbox();
		}

		private void UpdateCheckbox()
		{
			if (checkboxImage != null)
			{
				((Behaviour)checkboxImage).enabled = GetCurrentValue();
			}
		}

		protected abstract bool GetCurrentValue();

		protected abstract void SetCurrentValue(bool value);

		private void UpdateStateBroadcast()
		{
			UpdateCheckbox();
		}
	}
	public class NearestEmoteText : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.NearestEmoteText;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.NearestEmoteText = value;
		}
	}
	public class NearestEmoteTextTutorial : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.NearestEmoteTutorial;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.NearestEmoteTutorial = value;
		}
	}
	public class PermanentEmotingHealthbar : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.PermanentEmotingHealthbar;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.PermanentEmotingHealthbar = value;
		}
	}
	public class RootMotionTypeDropdown : LeUiDropdown
	{
		protected override int GetCurrentValue()
		{
			return EmoteUiManager.RootMotionType;
		}

		protected override void SetCurrentValue(int value)
		{
			EmoteUiManager.RootMotionType = value;
		}
	}
	public class ThirdPersonDropdown : LeUiDropdown
	{
		protected override int GetCurrentValue()
		{
			return EmoteUiManager.ThirdPerson;
		}

		protected override void SetCurrentValue(int value)
		{
			EmoteUiManager.ThirdPerson = value;
		}
	}
	public class UseGlobalSettings : LeUiToggle
	{
		protected override bool GetCurrentValue()
		{
			return EmoteUiManager.UseGlobalSettings;
		}

		protected override void SetCurrentValue(bool value)
		{
			EmoteUiManager.UseGlobalSettings = !value;
			EmoteUiManager.UseGlobalSettings = value;
			EmoteUiManager.RefreshBothLists();
			EmoteUiManager.emoteUiInstance.ReloadData();
			((Component)((Component)this).GetComponentInParent<CustomizePanel>()).gameObject.BroadcastMessage("UpdateStateBroadcast");
		}
	}
}
namespace LethalEmotesApi.Ui.Hud
{
	[DefaultExecutionOrder(-4)]
	public class HealthEmoteRenderer : MonoBehaviour
	{
		public SkinnedMeshRenderer? emoteSkinnedMeshRenderer;

		public Material? material;

		public RenderTexture? targetRenderTexture;

		private CommandBuffer? _cmdBuf;

		private readonly Matrix4x4 _projMat = Matrix4x4.Perspective(60f, 1f, 0.3f, 15f);

		private Matrix4x4 GetViewMatrix()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			Matrix4x4 val = Matrix4x4.Rotate(Quaternion.Inverse(transform.rotation)) * Matrix4x4.Translate(-transform.position);
			if (SystemInfo.usesReversedZBuffer)
			{
				val.m20 = 0f - val.m20;
				val.m21 = 0f - val.m21;
				val.m22 = 0f - val.m22;
				val.m23 = 0f - val.m23;
			}
			return val;
		}

		private void Start()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			_cmdBuf = new CommandBuffer();
		}

		private void LateUpdate()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			_cmdBuf.Clear();
			_cmdBuf.SetViewProjectionMatrices(GetViewMatrix(), _projMat);
			_cmdBuf.DrawRenderer((Renderer)(object)emoteSkinnedMeshRenderer, material);
			Graphics.SetRenderTarget(targetRenderTexture);
			GL.Clear(false, true, Color.green);
			Graphics.ExecuteCommandBuffer(_cmdBuf);
		}

		private void OnDestroy()
		{
			CommandBuffer? cmdBuf = _cmdBuf;
			if (cmdBuf != null)
			{
				cmdBuf.Dispose();
			}
		}
	}
}
namespace LethalEmotesApi.Ui.Elements
{
	[DisallowMultipleComponent]
	public class LeUiButton : UIBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
	{
		public Graphic? targetGraphic;

		public LeUiScaleTweener? scaleTweener;

		public ColorBlock colors;

		[Range(0f, 2f)]
		public float scaleSelected;

		[Range(0f, 2f)]
		public float scalePressed;

		public UnityEvent onClick = new UnityEvent();

		public UnityEvent onEnter = new UnityEvent();

		public UnityEvent onExit = new UnityEvent();

		private bool _selected;

		private bool _pressed;

		protected override void OnEnable()
		{
			((UIBehaviour)this).OnEnable();
			UpdateState(instant: true);
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			_selected = true;
			onEnter.Invoke();
			UpdateState();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			_selected = false;
			onExit.Invoke();
			UpdateState();
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			_pressed = _selected;
			UpdateState();
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			_pressed = false;
			UpdateState();
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			onClick.Invoke();
		}

		private Color GetColor()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (_pressed)
			{
				return ((ColorBlock)(ref colors)).pressedColor;
			}
			if (_selected)
			{
				return ((ColorBlock)(ref colors)).selectedColor;
			}
			return ((ColorBlock)(ref colors)).normalColor;
		}

		private float GetScale()
		{
			if (_pressed)
			{
				return scalePressed;
			}
			if (_selected)
			{
				return scaleSelected;
			}
			return 1f;
		}

		private void UpdateState(bool instant = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			Color color = GetColor();
			targetGraphic.CrossFadeColor(color, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, true, true);
			float scale = GetScale();
			Vector3 targetScale = default(Vector3);
			((Vector3)(ref targetScale))..ctor(scale, scale, scale);
			scaleTweener.TweenScale(targetScale, instant ? 0f : ((ColorBlock)(ref colors)).fadeDuration, ignoreTimeScale: true);
		}
	}
	[DisallowMultipleComponent]
	[ExecuteAlways]
	public class LeUiScaleTweener : MonoBehaviour
	{
		private readonly TweenRunner<Vector3Tween> _scaleTweenRunner = new TweenRunner<Vector3Tween>();

		private Vector3 _internalScale = Vector3.one;

		public List<RectTransform> targets = new List<RectTransform>();

		protected LeUiScaleTweener()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			_scaleTweenRunner.Init((MonoBehaviour)(object)this);
		}

		public void TweenScale(Vector3 targetScale, float duration, bool ignoreTimeScale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			if (_internalScale == targetScale)
			{
				_scaleTweenRunner.StopTween();
				return;
			}
			Vector3Tween vector3Tween = default(Vector3Tween);
			vector3Tween.Duration = duration;
			vector3Tween.IgnoreTimeScale = ignoreTimeScale;
			vector3Tween.StartValue = _internalScale;
			vector3Tween.TargetValue = targetScale;
			Vector3Tween tweenValue = vector3Tween;
			tweenValue.AddOnChangedCallback(TweenScaleChanged);
			_scaleTweenRunner.StartTween(tweenValue);
		}

		private void TweenScaleChanged(Vector3 scale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			_internalScale = scale;
			foreach (RectTransform target in targets)
			{
				((Transform)target).localScale = scale;
			}
		}
	}
	public class LeUiSelectOutline : UIBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public Image? selectImage;

		public void OnPointerEnter(PointerEventData eventData)
		{
			if (selectImage != null)
			{
				((Behaviour)selectImage).enabled = true;
			}
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			if (selectImage != null)
			{
				((Behaviour)selectImage).enabled = false;
			}
		}
	}
}
namespace LethalEmotesApi.Ui.Elements.Recycle
{
	public interface IRecycleViewItem<in TData>
	{
		int ConstraintIndex { get; set; }

		RectTransform RectTransform { get; }

		void BindData(TData data);
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(RectTransform))]
	public abstract class RecycleListView<TRecycleItem, TData> : UIBehaviour where TRecycleItem : Component, IRecycleViewItem<TData>
	{
		public enum Constraint
		{
			Columns,
			Rows
		}

		public ScrollRect? scrollRect;

		public GameObject? listItemPrefab;

		public RectOffset padding = new RectOffset();

		public float spacing;

		public Vector2 preferredItemSize;

		public Corner startCorner;

		public Constraint constraint;

		public int maxInConstraint;

		public int minPoolSize = 10;

		public float requiredCoverageMultiplier = 1.5f;

		public float recyclingThreshold = 0.2f;

		private RectTransform? _recycleViewTransform;

		private RectTransform? _viewport;

		private RectTransform? _content;

		private Bounds _viewBounds;

		private Vector2 _prevAnchoredPos;

		private bool _recycling;

		private bool _firstUpdate;

		private readonly RecyclePool<TRecycleItem, TData> _pool = new RecyclePool<TRecycleItem, TData>();

		private DrivenRectTransformTracker _tracker;

		private DrivenRectTransformTracker _poolTracker;

		protected abstract IList<TData> ListData { get; }

		protected override void Awake()
		{
			((UIBehaviour)this).Awake();
			_recycleViewTransform = ((Component)this).GetComponent<RectTransform>();
			if (scrollRect != null)
			{
				_viewport = scrollRect.viewport;
				_content = scrollRect.content;
				if (_viewport != null && _content != null)
				{
					((DrivenRectTransformTracker)(ref _tracker)).Add((Object)(object)this, _content, (DrivenTransformProperties)65286);
					((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)HandleScroll);
				}
			}
		}

		protected override void Start()
		{
			((UIBehaviour)this).Start();
			UpdateState();
		}

		protected override void OnEnable()
		{
			((UIBehaviour)this).OnEnable();
		}

		protected virtual void Update()
		{
			if (!_firstUpdate)
			{
				UpdateState();
				_firstUpdate = true;
			}
		}

		private void OnValidate()
		{
			UpdateState();
		}

		public void UpdateState()
		{
			UpdateContentSize();
			UpdateViewBounds();
			SetupPool();
		}

		private void UpdateContentSize()
		{
			//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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (_content != null)
			{
				int num = Mathf.CeilToInt((float)ListData.Count / (float)maxInConstraint);
				float num2 = ((constraint == Constraint.Columns) ? preferredItemSize.y : preferredItemSize.x);
				int num3 = ((constraint == Constraint.Columns) ? (padding.top + padding.bottom) : (padding.left + padding.right));
				float num4 = (float)num3 + (spacing * (float)(num - 1) + num2 * (float)num);
				_content.sizeDelta = ((constraint == Constraint.Columns) ? new Vector2(_content.sizeDelta.x, num4) : new Vector2(num4, _content.sizeDelta.y));
			}
		}

		private void UpdateViewBounds()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			if (_recycleViewTransform != null && _viewport != null)
			{
				Rect relativeRect = _recycleViewTransform.GetRelativeRect(_viewport);
				float num = ((Rect)(ref relativeRect)).width / 2f * recyclingThreshold;
				float num2 = ((Rect)(ref relativeRect)).height / 2f * recyclingThreshold;
				((Bounds)(ref _viewBounds)).min = new Vector3(((Rect)(ref relativeRect)).xMin - num, ((Rect)(ref relativeRect)).yMin - num2);
				((Bounds)(ref _viewBounds)).max = new Vector3(((Rect)(ref relativeRect)).xMax + num, ((Rect)(ref relativeRect)).yMax + num2);
			}
		}

		private void SetupPool()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Invalid comparison between Unknown and I4
			//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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Invalid comparison between Unknown and I4
			//IL_029c: 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_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Expected I4, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Expected I4, but got Unknown
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			if (listItemPrefab == null || _viewport == null || _content == null)
			{
				return;
			}
			((DrivenRectTransformTracker)(ref _poolTracker)).Clear();
			_pool.Clear();
			if (ListData.Count <= 0)
			{
				return;
			}
			Rect rect;
			float num;
			if (constraint != 0)
			{
				rect = _viewport.rect;
				num = ((Rect)(ref rect)).height;
			}
			else
			{
				rect = _viewport.rect;
				num = ((Rect)(ref rect)).width;
			}
			float num2 = num;
			float num3 = requiredCoverageMultiplier * num2;
			Corner val = startCorner;
			bool flag = (((int)val == 0 || (int)val == 2) ? true : false);
			float num4 = (flag ? padding.left : (-padding.right));
			val = startCorner;
			flag = val - 2 <= 1;
			float num5 = (flag ? (-padding.bottom) : (-padding.top));
			int num6 = ((constraint == Constraint.Columns) ? (padding.left + padding.right) : (padding.top + padding.bottom));
			float num7 = (num2 - (float)num6) / (float)maxInConstraint - spacing * (float)(maxInConstraint - 1);
			Vector2 sizeDelta = ((constraint == Constraint.Columns) ? new Vector2(Mathf.Min(preferredItemSize.x, num7), preferredItemSize.y) : new Vector2(preferredItemSize.x, Mathf.Min(preferredItemSize.y, num7)));
			val = startCorner;
			flag = (((int)val == 0 || (int)val == 2) ? true : false);
			float num8 = (flag ? 0f : 1f);
			val = startCorner;
			flag = val - 2 <= 1;
			float num9 = (flag ? 0f : 1f);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(num8, num9);
			float num10 = 0f;
			int num11 = 0;
			while ((_pool.Size < minPoolSize || num10 < num3) && _pool.Size < ListData.Count)
			{
				TRecycleItem component = Object.Instantiate<GameObject>(listItemPrefab, (Transform)(object)_content).GetComponent<TRecycleItem>();
				((Object)((Component)component).gameObject).name = $"RecycleViewListItem {_pool.Size + 1}";
				OnInstantiateListItem(component);
				component.ConstraintIndex = num11;
				RectTransform rectTransform = component.RectTransform;
				rectTransform.anchoredPosition = new Vector2(num4, num5);
				rectTransform.anchorMin = val2;
				rectTransform.anchorMax = val2;
				rectTransform.pivot = val2;
				rectTransform.sizeDelta = sizeDelta;
				Rect rect2 = component.RectTransform.rect;
				num11++;
				switch (constraint)
				{
				case Constraint.Columns:
				{
					Corner val5 = startCorner;
					Corner val6 = val5;
					switch ((int)val6)
					{
					case 0:
						num4 = rectTransform.anchoredPosition.x + ((Rect)(ref rect2)).width + spacing;
						if (num11 >= maxInConstraint)
						{
							num4 = padding.left;
							num5 = rectTransform.anchoredPosition.y - (((Rect)(ref rect2)).height + spacing);
						}
						break;
					case 1:
						num4 = rectTransform.anchoredPosition.x - (((Rect)(ref rect2)).width + spacing);
						if (num11 >= maxInConstraint)
						{
							num4 = -padding.right;
							num5 = rectTransform.anchoredPosition.y - (((Rect)(ref rect2)).height + spacing);
						}
						break;
					case 2:
						num4 = rectTransform.anchoredPosition.x + ((Rect)(ref rect2)).width + spacing;
						if (num11 >= maxInConstraint)
						{
							num4 = padding.left;
							num5 = rectTransform.anchoredPosition.y + ((Rect)(ref rect2)).height + spacing;
						}
						break;
					case 3:
						num4 = rectTransform.anchoredPosition.x - (((Rect)(ref rect2)).width + spacing);
						if (num11 >= maxInConstraint)
						{
							num4 = -padding.right;
							num5 = rectTransform.anchoredPosition.y + ((Rect)(ref rect2)).height + spacing;
						}
						break;
					default:
						throw new ArgumentOutOfRangeException();
					}
					if (num11 >= maxInConstraint)
					{
						num11 = 0;
						num10 += ((Rect)(ref rect2)).height + spacing;
					}
					break;
				}
				case Constraint.Rows:
				{
					Corner val3 = startCorner;
					Corner val4 = val3;
					switch ((int)val4)
					{
					case 0:
						num5 = rectTransform.anchoredPosition.y - (((Rect)(ref rect2)).height + spacing);
						if (num11 >= maxInConstraint)
						{
							num4 = rectTransform.anchoredPosition.x + ((Rect)(ref rect2)).width + spacing;
							num5 = -padding.top;
						}
						break;
					case 1:
						num5 = rectTransform.anchoredPosition.y - (((Rect)(ref rect2)).height + spacing);
						if (num11 >= maxInConstraint)
						{
							num4 = rectTransform.anchoredPosition.x - (((Rect)(ref rect2)).width + spacing);
							num5 = -padding.top;
						}
						break;
					case 2:
						num5 = rectTransform.anchoredPosition.y + ((Rect)(ref rect2)).height + spacing;
						if (num11 >= maxInConstraint)
						{
							num4 = rectTransform.anchoredPosition.x + ((Rect)(ref rect2)).width + spacing;
							num5 = padding.bottom;
						}
						break;
					case 3:
						num5 = rectTransform.anchoredPosition.y + ((Rect)(ref rect2)).height + spacing;
						if (num11 >= maxInConstraint)
						{
							num4 = rectTransform.anchoredPosition.x - (((Rect)(ref rect2)).width + spacing);
							num5 = padding.bottom;
						}
						break;
					default:
						throw new ArgumentOutOfRangeException();
					}
					if (num11 >= maxInConstraint)
					{
						num11 = 0;
						num10 += ((Rect)(ref rect2)).width + spacing;
					}
					break;
				}
				default:
					throw new ArgumentOutOfRangeException();
				}
				((DrivenRectTransformTracker)(ref _poolTracker)).Add((Object)(object)this, rectTransform, (DrivenTransformProperties)65286);
				component.BindData(ListData[_pool.Size]);
				_pool.Add(component);
			}
		}

		protected abstract void OnInstantiateListItem(TRecycleItem instance);

		private void RefreshView()
		{
			int num = _pool.FirstIndex;
			foreach (TRecycleItem item in _pool)
			{
				item.BindData(ListData[num]);
				num++;
			}
		}

		private void HandleScroll(Vector2 _)
		{
			//IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (_content != null)
			{
				Vector2 dir = _content.anchoredPosition - _prevAnchoredPos;
				RecycleOnScroll(dir);
				_prevAnchoredPos = _content.anchoredPosition;
			}
		}

		private void RecycleOnScroll(Vector2 dir)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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)
			//IL_008c: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_0255: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Invalid comparison between Unknown and I4
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Invalid comparison between Unknown and I4
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Invalid comparison between Unknown and I4
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Invalid comparison between Unknown and I4
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Invalid comparison between Unknown and I4
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Invalid comparison between Unknown and I4
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Invalid comparison between Unknown and I4
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Invalid comparison between Unknown and I4
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Invalid comparison between Unknown and I4
			if (_recycling || _recycleViewTransform == null || ListData.Count <= 0)
			{
				return;
			}
			UpdateViewBounds();
			if (dir.y > 0f || dir.x > 0f)
			{
				TRecycleItem last = _pool.GetLast();
				Rect relativeRect = _recycleViewTransform.GetRelativeRect(last.RectTransform);
				switch (constraint)
				{
				case Constraint.Columns:
				{
					bool flag6 = ((Rect)(ref relativeRect)).yMax > ((Bounds)(ref _viewBounds)).min.y;
					bool flag7 = flag6;
					if (flag7)
					{
						Corner val = startCorner;
						bool flag3 = (int)val <= 1;
						flag7 = flag3;
					}
					if (flag7)
					{
						ScrollRecycleForwards();
						break;
					}
					bool flag8 = ((Rect)(ref relativeRect)).yMin < ((Bounds)(ref _viewBounds)).max.y;
					bool flag9 = flag8;
					if (flag9)
					{
						Corner val = startCorner;
						bool flag3 = val - 2 <= 1;
						flag9 = flag3;
					}
					if (flag9)
					{
						ScrollRecycleBackwards();
					}
					break;
				}
				case Constraint.Rows:
				{
					bool flag = ((Rect)(ref relativeRect)).xMax > ((Bounds)(ref _viewBounds)).min.x;
					bool flag2 = flag;
					if (flag2)
					{
						Corner val = startCorner;
						bool flag3 = (((int)val == 0 || (int)val == 2) ? true : false);
						flag2 = flag3;
					}
					if (flag2)
					{
						ScrollRecycleForwards();
						break;
					}
					bool flag4 = ((Rect)(ref relativeRect)).xMin < ((Bounds)(ref _viewBounds)).max.x;
					bool flag5 = flag4;
					if (flag5)
					{
						Corner val = startCorner;