Decompiled source of Bunch Of Emotes v1.5.1

Dragsun-Bunch_Of_Emotes/BunchOfEmotes.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BunchOfEmotes;
using BunchOfEmotes.Patches;
using HarmonyLib;
using MapStation.API;
using Reptile;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MyUnityGameMod1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyUnityGameMod1")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e59b1fb1-39dd-4018-81da-ce9714f55f21")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[HarmonyPatch(typeof(SitAbility))]
internal class SitAbilityPatch
{
	[HarmonyPrefix]
	[HarmonyPatch("SetState")]
	private static bool SetState_Prefix(SitAbility __instance, State setState)
	{
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Invalid comparison between Unknown and I4
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Invalid comparison between Unknown and I4
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Invalid comparison between Unknown and I4
		if (BunchOfEmotesPlugin.customMenu)
		{
			if ((int)setState != 1)
			{
				return true;
			}
			if ((int)setState == 1)
			{
				int childCount = ((Component)BunchOfEmotesPlugin.player).transform.GetChild(0).childCount;
				((Ability)__instance).p.StopCurrentAbility();
				((Component)((Component)BunchOfEmotesPlugin.player).transform.GetChild(0).GetChild(childCount - 1).GetChild(0)).GetComponent<Animator>().runtimeAnimatorController = BunchOfEmotesPlugin.myAnim;
				BunchOfEmotesPlugin.player.anim.SetLayerWeight(5, 0f);
			}
			if (((Ability)__instance).p.curAnim != __instance.startSitHash && ((Ability)__instance).p.curAnim != __instance.stopSitHash)
			{
				BunchOfEmotesPlugin.player.anim.SetLayerWeight(5, 0f);
				((Ability)__instance).p.StopCurrentAbility();
				return false;
			}
			return true;
		}
		if ((int)setState == 1 && !BunchOfEmotesPlugin.inAnimation)
		{
			((Ability)__instance).p.PlayAnim(__instance.stopSitHash, false, false, -1f);
			return true;
		}
		if ((int)setState != 1)
		{
			return true;
		}
		if (((Ability)__instance).p.curAnim != __instance.startSitHash && ((Ability)__instance).p.curAnim != __instance.stopSitHash)
		{
			BunchOfEmotesPlugin.inAnimation = false;
			int childCount2 = ((Component)BunchOfEmotesPlugin.player).transform.GetChild(0).childCount;
			BunchOfEmotesPlugin.player.anim.SetLayerWeight(5, 0f);
			((Component)((Component)BunchOfEmotesPlugin.player).transform.GetChild(0).GetChild(childCount2 - 1).GetChild(0)).GetComponent<Animator>().runtimeAnimatorController = BunchOfEmotesPlugin.myAnim;
			((Ability)__instance).p.StopCurrentAbility();
			return false;
		}
		return true;
	}
}
namespace BunchOfEmotes
{
	[BepInPlugin("com.Dragsun.BunchOfEmotes", "Bunch of emotes", "1.3.0")]
	public class BunchOfEmotesPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.Dragsun.BunchOfEmotes";

		private const string PluginName = "Bunch of emotes";

		private const string VersionString = "1.3.0";

		public static string KeyboardPlusKey = "Next emote";

		public static string KeyboardMinusKey = "Previous emote";

		public static string KeyboardConfirmKey = "Confirm / Open menu";

		public static string KeyboardSwapKey = "Swap between custom and normal menu";

		public static ConfigEntry<KeyboardShortcut> KeyboardPlus;

		public static ConfigEntry<KeyboardShortcut> KeyboardMinus;

		public static ConfigEntry<KeyboardShortcut> KeyboardConfirm;

		public static ConfigEntry<KeyboardShortcut> KeyboardSwap;

		public static ConfigEntry<bool> customList;

		public static ConfigEntry<bool> wantACustomListOfInject;

		public static ConfigEntry<string> myCustomList;

		public static ConfigEntry<string> myCustomListOfInject;

		public static DieAbility dieAbility;

		public static StageManager stageManager;

		public static bool showMenu = false;

		public static bool myVariable = true;

		public static float timer = 0f;

		public static bool keyIsPressed = false;

		public static bool inAnimation = false;

		public static string customListKey = "Do you want to use a custom list ?";

		public static string wantACustomListOfInjectKey = "Do you want your list of injected animation to be customised ?";

		public static string myCustomListKey = "Enter your custom list";

		public static string myCustomListOfInjectKey = "Custom list for the injected animations (works for the in game one too)";

		private static readonly Harmony Harmony = new Harmony("com.Dragsun.BunchOfEmotes");

		public static ManualLogSource Log = new ManualLogSource("Bunch of emotes");

		public static GameplayUI ui;

		private readonly string animationFolder = Path.Combine(Application.streamingAssetsPath, "Mods", "BunchOfEmotes", "Anims");

		public static Vector3 playerpos1;

		private float keyPressStartTime = 0f;

		public static int myAnimationKey = 0;

		public static int childcount = 0;

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

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

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

		public static string BunchOfEmotesPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public static bool customMenu = false;

		public static NPC myNPC;

		public static RuntimeAnimatorController myAnim;

		public static RuntimeAnimatorController myAnimBMX;

		public static RuntimeAnimatorController myAnimInlines;

		public static RuntimeAnimatorController myAnimSkateboard;

		public static RuntimeAnimatorController myAnimUntouched;

		public static RuntimeAnimatorController myAnim2;

		public static Animation anim;

		public static AssetBundle bundle;

		public static AssetBundle bundleController;

		public static AssetBundle bundleControllerinlines;

		public static AssetBundle bundleControllerSkateboard;

		public static int[] customemoteshash;

		public static int[] customemotesCheck = null;

		public static AnimatorOverrideController[] Controllers;

		public static RuntimeAnimatorController[] AControllers;

		public static Animator playerAn;

		public static Player player { get; set; }

		public DirectoryInfo AssetFolder { get; protected set; }

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			KeyboardPlus = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Menu controls", KeyboardPlusKey, new KeyboardShortcut((KeyCode)91, Array.Empty<KeyCode>()), (ConfigDescription)null);
			KeyboardMinus = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Menu controls", KeyboardMinusKey, new KeyboardShortcut((KeyCode)93, Array.Empty<KeyCode>()), (ConfigDescription)null);
			KeyboardConfirm = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Open menu / Confirm", KeyboardConfirmKey, new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), (ConfigDescription)null);
			KeyboardSwap = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Custom emotes", KeyboardSwapKey, new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), (ConfigDescription)null);
			customList = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom list", customListKey, false, "A custom list of emotes is the list that is gonna be replacing the basic one that appears when you trigger the mod in game. A list of all of them can be found on my Github");
			myCustomList = ((BaseUnityPlugin)this).Config.Bind<string>("Custom list", myCustomListKey, "jumpNEW,fallNEW,wallRunLeftNEW,grafSlashUP_RIGHT", "Your custom list of animations they must be without any spaces and separated by ,");
			wantACustomListOfInject = ((BaseUnityPlugin)this).Config.Bind<bool>("Injected emotes list", wantACustomListOfInjectKey, false, "A custom list but for the injected animations");
			myCustomListOfInject = ((BaseUnityPlugin)this).Config.Bind<string>("Injected emotes list", myCustomListOfInjectKey, "jumpNEW,fallNEW,wallRunLeftNEW,grafSlashUP_RIGHT", "Same thing as the custom list but this one also accept custom animations. Write their name with the spaces and uppercases.");
			KeyboardPlus.SettingChanged += ConfigSettingChanged;
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Bunch of emotes, VersionString: 1.3.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private void Update()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_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_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player != (Object)null))
			{
				return;
			}
			if (myCustomAnims.Count == 0 && (Object)(object)myAnim != (Object)null)
			{
				string clipPath = BunchOfEmotesPath + "/bunchofemotes";
				AddAnimationClipToController(myAnim, clipPath);
				initEmotes();
			}
			KeyboardShortcut value = KeyboardMinus.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && myAnimationKey != 0)
			{
				myAnimationKey--;
			}
			value = KeyboardPlus.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && myAnimationKey != myCustomAnims.Count - 1)
			{
				myAnimationKey++;
			}
			value = KeyboardSwap.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && myCustomAnims2 != null)
			{
				customMenu = !customMenu;
				initEmotes();
			}
			if (showMenu)
			{
				if (myAnimationKey == 0)
				{
					if (myCustomAnims.Count != 1)
					{
						UI.Instance.ShowNotification("", myCustomAnims.ElementAt(myAnimationKey).Value + " <", myCustomAnims.ElementAt(myAnimationKey + 1).Value);
					}
					else
					{
						UI.Instance.ShowNotification("", myCustomAnims.ElementAt(myAnimationKey).Value + " <", "");
					}
				}
				else if (myAnimationKey == myCustomAnims.Count - 1)
				{
					UI.Instance.ShowNotification(myCustomAnims.ElementAt(myAnimationKey - 1).Value, myCustomAnims.ElementAt(myAnimationKey).Value + " <", "");
				}
				else
				{
					UI.Instance.ShowNotification(myCustomAnims.ElementAt(myAnimationKey - 1).Value, myCustomAnims.ElementAt(myAnimationKey).Value + " <", myCustomAnims.ElementAt(myAnimationKey + 1).Value);
				}
				value = KeyboardConfirm.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					inAnimation = true;
					childcount = ((Component)player).transform.GetChild(0).childCount;
					if (customMenu && !wantACustomListOfInject.Value)
					{
						player.ActivateAbility((Ability)(object)player.sitAbility);
						player.PlayAnim(myCustomAnims2.ElementAt(myAnimationKey).Key, false, false, -1f);
					}
					else if (customMenu && wantACustomListOfInject.Value)
					{
						player.ActivateAbility((Ability)(object)player.sitAbility);
						player.PlayAnim(myCustomAnimsInject.ElementAt(myAnimationKey).Key, false, false, -1f);
					}
					else
					{
						player.ActivateAbility((Ability)(object)player.sitAbility);
						player.PlayAnim(myCustomAnims.ElementAt(myAnimationKey).Key, false, false, -1f);
					}
					UI.Instance.HideNotification();
					timer = 0.1f;
					showMenu = false;
					player.ui.TurnOn(true);
				}
			}
			value = KeyboardConfirm.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && ((object)(MoveStyle)(ref player.moveStyle)).ToString() == "ON_FOOT")
			{
				initEmotes();
			}
			if (timer > 0f)
			{
				timer -= Time.deltaTime;
			}
			if (!showMenu && timer <= 0f)
			{
				UI.Instance.HideNotification();
				value = KeyboardConfirm.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					showMenu = true;
				}
			}
		}

		public static void initEmotes()
		{
			childcount = ((Component)player).transform.GetChild(0).childCount;
			AnimationClip[] animationClips = myAnim.animationClips;
			if (customList.Value && myCustomList.Value != "")
			{
				myCustomAnims = FillDictionaryFromCommaSeparatedString(myCustomList.Value);
			}
			else
			{
				string input = "lieDown,sit,SolaceSit,surrender,HandsOnHipsIdle,belStandingPhoneIdle,redCrouchIdle,tryceCrossedArms,headScrewing,leanWall,leanWallStill,rightHandOnHipIdle,presentingIdle,redKnockedOut,redsitGroundIdle,crouchingIdle,berlageStorySitIdle1,berlageStorySitIdle2,berlageStorySitIdle3,copStoryIdle,copStoryIdleCrossedArms,copStorySaluteIdle,squatPhone,squatPhoneHuh,FauxSit,sitLaidback,oldheadAIdle,oldheadASitIdle,oldheadBIdle,oldheadBSitIdle,oldheadCIdle,oldheadCSitIdle,tryceCrouch,tryceCrouchLook,copRadio,belCrouchLook,belCrouch,sniperCaptainSlumpedIdle,Ayoooo,shoutStory,sitLegsCrossed,RedSnipedHandOnEyeIdle,RedSnipedEndIdle,sniperCaptainKO,VinylStrangledIdle,DJStranglesIdle,RedHeadacheIdle,SolaceBetweenBuildingsIdle,sitSadFloor,storyLookAround,belShowsToStandingPhone,IrenePowerPose,sitPhoneHighTyping,sitPhoneHigh,solaceLayingDown,IreneCall,belShowsIdlePhone,sitPhoneTyping,leanWallSlowClappingIdle,onCouchIdle,RedLyingOnCouch,injuredLookUp,protectArmsWideIdle,layingFloor,highFiveIdle,eclipseStand_idle,eclipse_foresight02_idle,eclipse_foresight01_idle,gaspShock,squat";
				myCustomAnims = FillDictionaryFromCommaSeparatedString(input);
			}
			if (customMenu && !wantACustomListOfInject.Value)
			{
				myCustomAnims = myCustomAnims2;
			}
			else if (customMenu && wantACustomListOfInject.Value)
			{
				myCustomAnims = myCustomAnimsInject;
			}
			if (myAnimationKey > myCustomAnims.Count - 1)
			{
				myAnimationKey = myCustomAnims.Count - 1;
			}
		}

		public static void AddAnimationClipToController(RuntimeAnimatorController baseController, string clipPath = null)
		{
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			if (clipPath == null)
			{
				clipPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bunchofemotes");
			}
			string path = BunchOfEmotesPath + "/bunchofemotescontroller";
			string text = BunchOfEmotesPath + "/bunchofemotescontrollerbmx";
			string path2 = BunchOfEmotesPath + "/bunchofemotescontrollerinlines";
			string path3 = BunchOfEmotesPath + "/bunchofemotescontrollerskateboard";
			string path4 = BunchOfEmotesPath + "/replace";
			string path5 = BunchOfEmotesPath + "/replacebmx";
			string path6 = BunchOfEmotesPath + "/replaceinline";
			string path7 = BunchOfEmotesPath + "/replaceskateboard";
			AssetBundle bundleTemp = null;
			AssetBundle bundleTemp2 = null;
			AssetBundle bundleTemp3 = null;
			AssetBundle bundleTemp4 = null;
			AnimationClip[] array = null;
			AnimationClip[] array2 = null;
			AnimationClip[] array3 = null;
			AnimationClip[] array4 = null;
			RuntimeAnimatorController[] array5 = null;
			RuntimeAnimatorController[] array6 = null;
			RuntimeAnimatorController[] array7 = null;
			bundleController = loadFromString(path, bundleController);
			bundleControllerinlines = loadFromString(path2, bundleControllerinlines);
			bundleControllerSkateboard = loadFromString(path3, bundleControllerSkateboard);
			bundleTemp = loadFromString(path4, bundleTemp);
			bundleTemp2 = loadFromString(path5, bundleTemp2);
			bundleTemp3 = loadFromString(path6, bundleTemp3);
			bundleTemp4 = loadFromString(path7, bundleTemp4);
			if (AControllers == null)
			{
				AControllers = bundleController.LoadAllAssets<RuntimeAnimatorController>();
			}
			if ((Object)(object)bundleControllerinlines != (Object)null)
			{
				array5 = bundleControllerinlines.LoadAllAssets<RuntimeAnimatorController>();
			}
			if ((Object)(object)bundleControllerSkateboard != (Object)null)
			{
				array7 = bundleControllerSkateboard.LoadAllAssets<RuntimeAnimatorController>();
			}
			if (array == null && (Object)(object)bundleTemp != (Object)null)
			{
				array = bundleTemp.LoadAllAssets<AnimationClip>();
			}
			if (array2 == null && (Object)(object)bundleTemp2 != (Object)null)
			{
				array2 = bundleTemp2.LoadAllAssets<AnimationClip>();
			}
			if (array3 == null && (Object)(object)bundleTemp3 != (Object)null)
			{
				array3 = bundleTemp3.LoadAllAssets<AnimationClip>();
			}
			if (array4 == null && (Object)(object)bundleTemp4 != (Object)null)
			{
				array4 = bundleTemp4.LoadAllAssets<AnimationClip>();
			}
			if ((Object)(object)bundle == (Object)null)
			{
				if (!File.Exists(clipPath))
				{
					Log.LogError((object)"No custom animation files found, mod will work with only the one from the game.");
					myAnim2 = null;
					return;
				}
				bundle = AssetBundle.LoadFromFile(clipPath);
			}
			AnimationClip val = null;
			AnimatorOverrideController val2 = new AnimatorOverrideController();
			AnimatorOverrideController val3 = new AnimatorOverrideController();
			AnimatorOverrideController val4 = new AnimatorOverrideController();
			AnimatorOverrideController val5 = new AnimatorOverrideController();
			RuntimeAnimatorController[] aControllers = AControllers;
			foreach (RuntimeAnimatorController runtimeAnimatorController in aControllers)
			{
				bool flag = true;
				val2.runtimeAnimatorController = runtimeAnimatorController;
			}
			if (array5 != null)
			{
				RuntimeAnimatorController[] array8 = array5;
				foreach (RuntimeAnimatorController runtimeAnimatorController2 in array8)
				{
					bool flag2 = true;
					val4.runtimeAnimatorController = runtimeAnimatorController2;
					((Object)val4).name = "BunchOfEmotesControllerinlines";
				}
			}
			if (array7 != null)
			{
				RuntimeAnimatorController[] array9 = array7;
				foreach (RuntimeAnimatorController runtimeAnimatorController3 in array9)
				{
					bool flag3 = true;
					val5.runtimeAnimatorController = runtimeAnimatorController3;
					((Object)val5).name = "BunchOfEmotesControllerSkateboard";
				}
			}
			Log.LogDebug((object)((Object)val2.runtimeAnimatorController).name);
			((Object)val2).name = "BunchOfEmotesController";
			int num = 0;
			AnimationClip[] animationClips = bundle.LoadAllAssets<AnimationClip>();
			HashSet<string> hashSet = new HashSet<string>();
			List<int> list = new List<int>();
			AnimationClip[] animationClips2 = baseController.animationClips;
			foreach (AnimationClip val6 in animationClips2)
			{
				if (!((Object)(object)val6 != (Object)null))
				{
					continue;
				}
				CollectionExtensions.AddItem<int>((IEnumerable<int>)customemoteshash, ((object)val6).GetHashCode());
				string name = ((Object)val6).name;
				if (!hashSet.Contains(name))
				{
					try
					{
						string name2 = ((Object)val6).name;
						val2[name2] = val6;
						hashSet.Add(name);
					}
					catch (Exception)
					{
						Log.LogError((object)(((Object)val6).name + " is causing problems"));
					}
				}
			}
			AnimationClip[] animationClips3 = player.animatorControllerSkates.animationClips;
			foreach (AnimationClip val7 in animationClips3)
			{
				if (!((Object)(object)val7 != (Object)null) || array5 == null)
				{
					continue;
				}
				CollectionExtensions.AddItem<int>((IEnumerable<int>)customemoteshash, ((object)val7).GetHashCode());
				string name3 = ((Object)val7).name;
				if (!hashSet.Contains(name3))
				{
					try
					{
						string name4 = ((Object)val7).name;
						val4[name4] = val7;
						hashSet.Add(name3);
					}
					catch (Exception)
					{
						Log.LogError((object)(((Object)val7).name + " is causing problems"));
					}
				}
			}
			if ((Object)(object)bundleControllerinlines != (Object)null)
			{
				player.animatorControllerSkates = (RuntimeAnimatorController)(object)val4;
			}
			AnimationClip[] animationClips4 = player.animatorControllerSkateboard.animationClips;
			foreach (AnimationClip val8 in animationClips4)
			{
				if (!((Object)(object)val8 != (Object)null) || array5 == null)
				{
					continue;
				}
				CollectionExtensions.AddItem<int>((IEnumerable<int>)customemoteshash, ((object)val8).GetHashCode());
				string name5 = ((Object)val8).name;
				if (!hashSet.Contains(name5))
				{
					try
					{
						string name6 = ((Object)val8).name;
						val5[name6] = val8;
						hashSet.Add(name5);
					}
					catch (Exception)
					{
						Log.LogError((object)(((Object)val8).name + " is causing problems"));
					}
				}
			}
			if ((Object)(object)bundleControllerSkateboard != (Object)null)
			{
				player.animatorControllerSkateboard = (RuntimeAnimatorController)(object)val5;
			}
			int num2 = 0;
			AnimationClip[] animationClips5 = ((RuntimeAnimatorController)val2).animationClips;
			foreach (AnimationClip val9 in animationClips5)
			{
				try
				{
					if (((Object)val9).name == "z1")
					{
						num2 = num;
						Log.LogDebug((object)("found " + num));
						break;
					}
				}
				catch (Exception ex4)
				{
					Log.LogError((object)ex4.Message);
				}
				num++;
			}
			num = AddAnimations(animationClips, val2, num, list);
			injectAnimation(array, val2);
			injectAnimation(array2, player.animatorControllerBMX);
			injectAnimation(array3, player.animatorControllerSkates);
			injectAnimation(array4, player.animatorControllerSkateboard);
			string pattern = "bunchofemotes\\d";
			Regex regex = new Regex(pattern);
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(Paths.ConfigPath, "BunchOfEmotes"));
			if (!Directory.Exists(Path.Combine(Paths.ConfigPath, "BunchOfEmotes")))
			{
				Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "BunchOfEmotes"));
			}
			FileInfo[] files = directoryInfo.GetFiles();
			FileInfo[] array10 = files;
			foreach (FileInfo fileInfo in array10)
			{
				if (regex.IsMatch(fileInfo.Name))
				{
					Log.LogInfo((object)" hahahahahahha");
					bundle.Unload(false);
					bundle = AssetBundle.LoadFromFile(fileInfo.FullName);
					animationClips = bundle.LoadAllAssets<AnimationClip>();
					num = AddAnimations(animationClips, val2, num, list);
					Log.LogMessage((object)(fileInfo.Name + " loaded"));
				}
			}
			customemotesCheck = list.ToArray();
			Log.LogMessage((object)"Custom animations succesfully loaded.");
			myAnim = (RuntimeAnimatorController)(object)val2;
			myAnimBMX = player.animatorControllerBMX;
			myAnimInlines = player.animatorControllerSkates;
			myAnimSkateboard = player.animatorControllerSkateboard;
		}

		public static Dictionary<int, string> FillDictionaryFromCommaSeparatedString(string input)
		{
			Dictionary<int, string> dictionary = new Dictionary<int, string>();
			string[] array = input.Split(new char[1] { ',' });
			string[] array2 = array;
			foreach (string text in array2)
			{
				int key = Animator.StringToHash(text);
				dictionary[key] = text;
			}
			return dictionary;
		}

		private void ConfigSettingChanged(object sender, EventArgs e)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
			if (val != null && val.ChangedSetting.Definition.Key == KeyboardPlusKey)
			{
				KeyboardShortcut val2 = (KeyboardShortcut)val.ChangedSetting.BoxedValue;
			}
		}

		private static AssetBundle loadFromString(string path, AssetBundle bundleTemp)
		{
			if ((Object)(object)bundleTemp == (Object)null)
			{
				if (!File.Exists(path))
				{
					return null;
				}
				bundleTemp = AssetBundle.LoadFromFile(path);
			}
			return bundleTemp;
		}

		private static void injectAnimation(AnimationClip[] replaceAnimations, AnimatorOverrideController animatorOverrideController)
		{
			if (replaceAnimations == null)
			{
				return;
			}
			foreach (AnimationClip val in replaceAnimations)
			{
				try
				{
					animatorOverrideController[((Object)val).name] = val;
					Log.LogDebug((object)("successfully replaced " + ((Object)val).name));
				}
				catch (Exception)
				{
					Log.LogMessage((object)(((Object)val).name + " is causing problems in the replace"));
				}
			}
		}

		private static void injectAnimation(AnimationClip[] replaceAnimations, RuntimeAnimatorController animatorOverrideController)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			if (replaceAnimations == null)
			{
				return;
			}
			AnimatorOverrideController val = new AnimatorOverrideController();
			val.runtimeAnimatorController = animatorOverrideController;
			foreach (AnimationClip val2 in replaceAnimations)
			{
				try
				{
					val[((Object)val2).name] = val2;
					Log.LogMessage((object)(((Object)val2).name + " > " + (object)val2));
				}
				catch (Exception)
				{
					Log.LogError((object)(((Object)val2).name + " is causing problems in the replace"));
				}
			}
			animatorOverrideController = (RuntimeAnimatorController)(object)val;
		}

		private static int AddAnimations(AnimationClip[] animationClips, AnimatorOverrideController animatorOverrideController, int count, List<int> termsList)
		{
			if (myCustomAnimsInject.Count == 0)
			{
				myCustomAnimsInject = FillDictionaryFromCommaSeparatedString(myCustomListOfInject.Value);
			}
			foreach (AnimationClip val in animationClips)
			{
				AnimationClip val2 = val;
				if ((Object)(object)val2 == (Object)null)
				{
					Debug.LogError((object)("Animation clip not found: " + animationClips));
					break;
				}
				termsList.Add(((object)val2).GetHashCode());
				string name = ((Object)((RuntimeAnimatorController)animatorOverrideController).animationClips[count]).name;
				myCustomAnims2[Animator.StringToHash(name)] = ((Object)val2).name;
				animatorOverrideController[name] = val2;
				string name2 = ((Object)val2).name;
				int key = Animator.StringToHash(name2);
				if (myCustomAnimsInject.ContainsKey(key))
				{
					int key2 = Animator.StringToHash(((Object)val2).name);
					if (myCustomAnimsInject.Remove(key2))
					{
						myCustomAnimsInject.Add(Animator.StringToHash(name), ((Object)val2).name);
					}
					else
					{
						Log.LogError((object)"Failed to remove the key.");
					}
				}
				count++;
			}
			return count;
		}
	}
}
namespace BunchOfEmotes.Patches
{
	[HarmonyPatch(typeof(StageManager))]
	internal class StageManagerPatches
	{
		[HarmonyPatch("SetupWorldHandler")]
		[HarmonyPostfix]
		public static void SetupWorldHandler_Postfix(StageManager __instance)
		{
			BunchOfEmotesPlugin.stageManager = __instance;
		}
	}
	[HarmonyPatch(typeof(GameplayUI))]
	public class GameplayUIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Init")]
		public static void Init(GameplayUI __instance)
		{
			BunchOfEmotesPlugin.ui = __instance;
			((Component)__instance.gameplayScreen).gameObject.AddComponent<UI>();
		}
	}
	[HarmonyPatch(typeof(CharacterVisual))]
	internal class CharacterVisualAnimationEventRelayPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		public static void Init_Prefix(CharacterVisual __instance, ref RuntimeAnimatorController animatorController)
		{
			if ((Object)(object)BunchOfEmotesPlugin.myNPC != (Object)null)
			{
				if (BunchOfEmotesPlugin.myNPC.animators.Length != 0)
				{
					animatorController = BunchOfEmotesPlugin.myNPC.animators[0].runtimeAnimatorController;
				}
				else if ((Object)(object)BunchOfEmotesPlugin.myAnimUntouched != (Object)null)
				{
					animatorController = BunchOfEmotesPlugin.myAnimUntouched;
				}
			}
		}
	}
	[HarmonyPatch(typeof(NPC))]
	internal class NPCPatches
	{
		[HarmonyPatch("InitSceneObject")]
		[HarmonyPostfix]
		public static void Awake_Postfix(NPC __instance)
		{
			//IL_0040: 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_004f: Invalid comparison between Unknown and I4
			try
			{
				if ((Object)(object)BunchOfEmotesPlugin.myNPC == (Object)null && __instance.anim.Length > 6)
				{
					BunchOfEmotesPlugin.myNPC = __instance;
				}
				if ((Object)(object)BunchOfEmotesPlugin.myAnim == (Object)null && (int)__instance.crew != 0 && (int)__instance.character != 11 && __instance.animators != null && (Object)(object)BunchOfEmotesPlugin.myAnim == (Object)null)
				{
					BunchOfEmotesPlugin.myAnim = ((Component)((Component)__instance).transform.GetChild(0).GetChild(1)).GetComponent<Animator>().runtimeAnimatorController;
					if ((Object)(object)BunchOfEmotesPlugin.myAnimUntouched == (Object)null)
					{
						BunchOfEmotesPlugin.myAnimUntouched = ((Component)((Component)__instance).transform.GetChild(0).GetChild(1)).GetComponent<Animator>().runtimeAnimatorController;
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(DieAbility))]
	internal class DieAbilityPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPostfix]
		public static void Init_Postfix(DieAbility __instance)
		{
			BunchOfEmotesPlugin.dieAbility = __instance;
		}
	}
	public class UI : MonoBehaviour
	{
		public static UI Instance;

		private TextMeshProUGUI m_label = null;

		private TextMeshProUGUI m_label1 = null;

		private TextMeshProUGUI m_label2 = null;

		private float m_notificationTimer = 5f;

		private bool m_active;

		private void Awake()
		{
			Instance = this;
			SetupLabel();
			SetupLabelPause();
		}

		public void ShowNotification(string textbef, string textmid, string textaft)
		{
			((TMP_Text)m_label1).text = textbef;
			((TMP_Text)m_label).text = textmid;
			((TMP_Text)m_label2).text = textaft;
			m_notificationTimer = 5f;
			((Component)m_label).gameObject.SetActive(true);
			((Component)m_label1).gameObject.SetActive(true);
			((Component)m_label2).gameObject.SetActive(true);
		}

		public void HideNotification()
		{
			((Component)m_label1).gameObject.SetActive(false);
			((Component)m_label).gameObject.SetActive(false);
			((Component)m_label2).gameObject.SetActive(false);
		}

		private void SetupLabel()
		{
			//IL_0007: 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_0031: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: 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)
			m_label = new GameObject("Emote").AddComponent<TextMeshProUGUI>();
			m_label1 = new GameObject("EmotePrev").AddComponent<TextMeshProUGUI>();
			m_label2 = new GameObject("EmoteAft").AddComponent<TextMeshProUGUI>();
			UIManager uIManager = Core.Instance.UIManager;
			GameplayUI value = Traverse.Create((object)uIManager).Field<GameplayUI>("gameplay").Value;
			TextMeshProUGUI graffitiNewLabel = value.graffitiNewLabel;
			((TMP_Text)m_label).font = ((TMP_Text)graffitiNewLabel).font;
			((TMP_Text)m_label1).font = ((TMP_Text)graffitiNewLabel).font;
			((TMP_Text)m_label2).font = ((TMP_Text)graffitiNewLabel).font;
			((TMP_Text)m_label2).alpha = 0.3f;
			((TMP_Text)m_label1).alpha = 0.3f;
			((TMP_Text)m_label).fontSize = 32f;
			((TMP_Text)m_label1).fontSize = 32f;
			((TMP_Text)m_label2).fontSize = 32f;
			((TMP_Text)m_label).fontMaterial = ((TMP_Text)graffitiNewLabel).fontMaterial;
			((TMP_Text)m_label1).fontMaterial = ((TMP_Text)graffitiNewLabel).fontMaterial;
			((TMP_Text)m_label2).fontMaterial = ((TMP_Text)graffitiNewLabel).fontMaterial;
			((TMP_Text)m_label).alignment = (TextAlignmentOptions)260;
			((TMP_Text)m_label1).alignment = (TextAlignmentOptions)260;
			((TMP_Text)m_label2).alignment = (TextAlignmentOptions)260;
			RectTransform rectTransform = ((TMP_Text)m_label).rectTransform;
			RectTransform rectTransform2 = ((TMP_Text)m_label1).rectTransform;
			RectTransform rectTransform3 = ((TMP_Text)m_label2).rectTransform;
			rectTransform.anchorMin = new Vector2(0.1f, 0.5f);
			rectTransform2.anchorMin = new Vector2(0.1f, 0.5f);
			rectTransform3.anchorMin = new Vector2(0.1f, 0.5f);
			rectTransform.anchorMax = new Vector2(0.868f, 0.9f);
			rectTransform2.anchorMax = new Vector2(0.868f, 0.95f);
			rectTransform3.anchorMax = new Vector2(0.868f, 0.85f);
			rectTransform.pivot = new Vector2(0f, 1f);
			rectTransform2.pivot = new Vector2(0f, 1f);
			rectTransform3.pivot = new Vector2(0f, 1f);
			rectTransform.anchoredPosition = new Vector2(1f, 0.2f);
			rectTransform2.anchoredPosition = new Vector2(1f, 0.2f);
			rectTransform3.anchoredPosition = new Vector2(1f, 0.2f);
			((Transform)((TMP_Text)m_label).rectTransform).SetParent((Transform)(object)((Component)value.gameplayScreen).GetComponent<RectTransform>(), false);
			((Transform)((TMP_Text)m_label1).rectTransform).SetParent((Transform)(object)((Component)value.gameplayScreen).GetComponent<RectTransform>(), false);
			((Transform)((TMP_Text)m_label2).rectTransform).SetParent((Transform)(object)((Component)value.gameplayScreen).GetComponent<RectTransform>(), false);
		}

		private void SetupLabelPause()
		{
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		public static bool Awake_Prefix(Player __instance)
		{
			if ((Object)(object)BunchOfEmotesPlugin.player == (Object)null)
			{
				BunchOfEmotesPlugin.player = __instance;
			}
			return true;
		}

		[HarmonyPatch("EnablePlayer")]
		[HarmonyPostfix]
		public static void EnablePlayer(Player __instance)
		{
			bool flag = ((Object)__instance).name.Contains("AI") || ((Object)__instance).name.Contains("(Clone)");
			if ((Object)(object)__instance.animatorController != (Object)(object)BunchOfEmotesPlugin.myAnim && !flag)
			{
				__instance.animatorController = BunchOfEmotesPlugin.myAnim;
			}
		}

		[HarmonyPatch("PlayAnim")]
		[HarmonyPostfix]
		public static void PlayAnim(Player __instance)
		{
			//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_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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected I4, but got Unknown
			bool flag = ((Object)__instance).name.Contains("AI") || ((Object)__instance).name.Contains("(Clone)");
			IMapStationAPI aPI = APIManager.API;
			if (aPI != null && (Object)(object)BunchOfEmotesPlugin.myAnimUntouched == (Object)null)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				Stage val = Utility.SceneNameToStage(((Scene)(ref activeScene)).name);
				ICustomStage customStageByID = aPI.GetCustomStageByID((int)val);
				bool flag2 = customStageByID != null;
				BunchOfEmotesPlugin.Log.LogMessage((object)(flag2 + " is my stage"));
				if (flag2 && (Object)(object)BunchOfEmotesPlugin.myAnimUntouched == (Object)null && (Object)(object)BunchOfEmotesPlugin.myAnim == (Object)null)
				{
					BunchOfEmotesPlugin.myAnim = __instance.animatorController;
					BunchOfEmotesPlugin.myAnimUntouched = __instance.animatorController;
				}
			}
			if (!flag)
			{
				if ((Object)(object)BunchOfEmotesPlugin.myAnimUntouched == (Object)null)
				{
					BunchOfEmotesPlugin.Log.LogMessage((object)((Object)__instance.animatorController).name);
					BunchOfEmotesPlugin.myAnimUntouched = __instance.animatorController;
				}
				if ((Object)(object)__instance.animatorController != (Object)(object)BunchOfEmotesPlugin.myAnim)
				{
					__instance.animatorController = BunchOfEmotesPlugin.myAnim;
					__instance.anim.runtimeAnimatorController = BunchOfEmotesPlugin.myAnim;
				}
				if ((Object)(object)BunchOfEmotesPlugin.myAnimBMX != (Object)null && (Object)(object)__instance.animatorControllerBMX != (Object)(object)BunchOfEmotesPlugin.myAnimBMX)
				{
					__instance.animatorControllerBMX = BunchOfEmotesPlugin.myAnimBMX;
				}
				if ((Object)(object)BunchOfEmotesPlugin.myAnimInlines != (Object)null && (Object)(object)__instance.animatorControllerSkates != (Object)(object)BunchOfEmotesPlugin.myAnimInlines)
				{
					__instance.animatorControllerSkates = BunchOfEmotesPlugin.myAnimInlines;
				}
				if ((Object)(object)BunchOfEmotesPlugin.myAnimSkateboard != (Object)null && (Object)(object)__instance.animatorControllerSkateboard != (Object)(object)BunchOfEmotesPlugin.myAnimSkateboard)
				{
					__instance.animatorControllerSkateboard = BunchOfEmotesPlugin.myAnimSkateboard;
				}
			}
			else if (((Object)__instance).name.Contains("(Clone)") && (Object)(object)__instance.anim.runtimeAnimatorController != (Object)(object)BunchOfEmotesPlugin.myNPC.animators[0].runtimeAnimatorController)
			{
				__instance.animatorController = BunchOfEmotesPlugin.myNPC.animators[0].runtimeAnimatorController;
				__instance.anim.runtimeAnimatorController = BunchOfEmotesPlugin.myNPC.animators[0].runtimeAnimatorController;
			}
		}
	}
}

Dragsun-Bunch_Of_Emotes/MapStation.API.dll

Decompiled 10 months ago
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("MapStation.API")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e29beb12f09c74ad87616376e0c82b9912de6311")]
[assembly: AssemblyProduct("MapStation.API")]
[assembly: AssemblyTitle("MapStation.API")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MapStation.API
{
	public static class APIManager
	{
		public static IMapStationAPI API;

		public static bool Initialized;

		public static event Action OnInitialized;

		public static void Initialize(IMapStationAPI api)
		{
			API = api;
			Initialized = true;
			APIManager.OnInitialized?.Invoke();
		}
	}
	public interface ICustomStage
	{
		string DisplayName { get; }

		string InternalName { get; }

		string AuthorName { get; }

		int StageID { get; }
	}
	public interface IMapStationAPI
	{
		ReadOnlyCollection<ICustomStage> CustomStages { get; }

		ICustomStage GetCustomStageByID(int stageID);

		int GetStageID(string stageInternalName);
	}
}