Decompiled source of F ckYouMOD v1.0.0

BepInEx/plugins/FuckYouMod.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using FuckYouMod.Patch;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FuckYouMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FuckYouMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ecc2bf2-af12-4e83-a6f1-cf2eacbf3060")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FuckYouMod
{
	[BepInPlugin("FuckYouMod", "FuckYouEmote-Sligili", "1.0.0")]
	public class FuckYouModInitialization : BaseUnityPlugin
	{
		private Harmony _harmony;

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"FuckYouMod loaded");
			EmotePatch.assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FuckYouMod/fuckyoumod"));
			_harmony = new Harmony("FuckYouMod");
			_harmony.PatchAll(typeof(EmotePatch));
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "FuckYouMod";

		public const string Name = "FuckYouEmote-Sligili";

		public const string Ver = "1.0.0";
	}
}
namespace FuckYouMod.Patch
{
	internal class EmotePatch
	{
		public static AssetBundle assetBundle;

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPrefix]
		private static void StartPrefix(PlayerControllerB __instance)
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				Debug.LogError((object)"FUCKYOUMOD: The asset bundle is NULL");
			}
			GameObject gameObject = ((Component)((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel")).gameObject.transform.Find("metarig")).gameObject;
			gameObject.AddComponent<ChangeAnimationClip>();
		}

		[HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")]
		[HarmonyPostfix]
		private static void ReviveDeadPlayersPostfix(StartOfRound __instance)
		{
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(ChangeAnimationClip));
			for (int i = 0; i < array.Length; i++)
			{
				ChangeAnimationClip changeAnimationClip = array[i] as ChangeAnimationClip;
				((MonoBehaviour)changeAnimationClip).Invoke("SetClips", 0.1f);
			}
		}
	}
	internal class ChangeAnimationClip : MonoBehaviour
	{
		public string animatorStateName = "Dance2";

		private Animator animator;

		private AnimationClip newAnim;

		private void Start()
		{
			((MonoBehaviour)this).Invoke("SetClips", 0.1f);
		}

		public void SetClips()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			newAnim = EmotePatch.assetBundle.LoadAsset<AnimationClip>("Assets/FuckYouMod/newDance2.anim");
			if ((Object)(object)newAnim != (Object)null)
			{
				Debug.Log((object)("Succesfully loaded animation " + ((Object)newAnim).name));
				animator = ((Component)this).GetComponent<Animator>();
				AnimatorOverrideController val = new AnimatorOverrideController(animator.runtimeAnimatorController);
				List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>();
				AnimationClip[] animationClips = ((RuntimeAnimatorController)val).animationClips;
				foreach (AnimationClip val2 in animationClips)
				{
					if (((Object)val2).name == animatorStateName)
					{
						list.Add(new KeyValuePair<AnimationClip, AnimationClip>(val2, newAnim));
					}
				}
				val.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list);
				animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)val;
			}
			else
			{
				Debug.LogError((object)"FUCKYOUMOD: Animation has not been loaded correctly");
			}
		}
	}
}