Decompiled source of Slay Emote v1.0.2

plugins/slay/com.Segtendo.SLAY_Emote_Mod.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using CustomEmotesAPI_Template_Mod;
using EmotesAPI;
using LethalEmotesAPI.ImportV2;
using Lethal_Company_CustomEmotesAPI_Template_Mod;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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: AssemblyInformationalVersion("1.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 Lethal_Company_CustomEmotesAPI_Template_Mod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Segtendo.SLAY_Emote_Mod", "SLAY_EmoteMod", "1.0.1")]
	public class SlayEmoteMod : BaseUnityPlugin
	{
		public const string PluginGUID = "com.Segtendo.SLAY_Emote_Mod";

		public const string PluginName = "SLAY_EmoteMod";

		public const string PluginVersion = "1.0.1";

		public static SlayEmoteMod instance;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			PInfo = ((BaseUnityPlugin)this).Info;
			Assets.LoadAssetBundlesFromFolder("assetbundles");
			CustomEmotesAPI.animChanged += new AnimationChanged(CustomEmotesAPI_animChanged);
			CustomEmoteParams val = new CustomEmoteParams();
			val.primaryAnimationClips = (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("Slay/Slay.anim") };
			val.secondaryAnimationClips = null;
			val.audioLoops = false;
			val.primaryAudioClips = (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("Slay/SLAY.ogg") };
			val.secondaryAudioClips = null;
			val.primaryDMCAFreeAudioClips = null;
			val.secondaryDMCAFreeAudioClips = null;
			val.visible = true;
			val.syncAnim = true;
			val.syncAudio = true;
			val.startPref = -1;
			val.joinPref = -1;
			val.joinSpots = null;
			val.internalName = "Slay";
			val.lockType = (LockType)1;
			val.willGetClaimedByDMCA = false;
			val.audioLevel = 0.3f;
			val.rootBonesToIgnore = null;
			val.soloBonesToIgnore = null;
			val.stopWhenMove = true;
			val.thirdPerson = true;
			val.displayName = "Slay";
			EmoteImporter.ImportEmote(val);
		}

		private void CustomEmotesAPI_animChanged(string newAnimation, BoneMapper mapper)
		{
			if (newAnimation.StartsWith("com.Segtendo.SLAY_Emote_Mod"))
			{
				newAnimation = newAnimation.Split("__")[1];
			}
		}

		public void ImportAnimation(AnimationClip[] primaryClips, AnimationClip[] secondaryClips, bool looping, AudioClip[] primaryAudioClips, bool sync, string customName, bool dmca, bool cantMove, bool thirdPerson)
		{
		}
	}
}
namespace CustomEmotesAPI_Template_Mod
{
	internal static class Assets
	{
		internal static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>();

		private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>();

		internal static void LoadAssetBundlesFromFolder(string folderName)
		{
			folderName = Path.Combine(Path.GetDirectoryName(SlayEmoteMod.PInfo.Location), folderName);
			string[] files = Directory.GetFiles(folderName);
			foreach (string text in files)
			{
				AssetBundle val = AssetBundle.LoadFromFile(text);
				int count = AssetBundles.Count;
				AssetBundles.Add(val);
				string[] allAssetNames = val.GetAllAssetNames();
				foreach (string text2 in allAssetNames)
				{
					string text3 = text2.ToLowerInvariant();
					if (text3.StartsWith("assets/"))
					{
						text3 = text3.Remove(0, "assets/".Length);
					}
					AssetIndices[text3] = count;
				}
				DebugClass.Log((object)("Loaded AssetBundle: " + Path.GetFileName(text)));
			}
		}

		internal static T Load<T>(string assetName) where T : Object
		{
			try
			{
				assetName = assetName.ToLowerInvariant();
				if (assetName.Contains(":"))
				{
					string[] array = assetName.Split(':');
					assetName = array[1].ToLowerInvariant();
				}
				if (assetName.StartsWith("assets/"))
				{
					assetName = assetName.Remove(0, "assets/".Length);
				}
				int index = AssetIndices[assetName];
				return AssetBundles[index].LoadAsset<T>("assets/" + assetName);
			}
			catch (Exception arg)
			{
				DebugClass.Log((object)$"Couldn't load asset [{assetName}] reason: {arg}");
				return default(T);
			}
		}
	}
}