Decompiled source of DomainMaster v0.1.2

domainmaster/birdemote.dll

Decompiled 2 years ago
using System;
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 System.Security;
using System.Security.Permissions;
using BepInEx;
using CustomEmotesAPI_Template_Mod;
using EmotesAPI;
using LethalEmotesAPI.ImportV2;
using Lethal_Company_CustomEmotesAPI_Template_Mod;
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("Lethal Company CustomEmotesAPI Template Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lethal Company CustomEmotesAPI Template Mod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("199912ba-43b6-4276-b420-7bfaa3eedbe5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Lethal_Company_CustomEmotesAPI_Template_Mod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.deady.xddxd0496.domainmaster", "DomainMaster", "1.0.0")]
	public class BirdEmote : BaseUnityPlugin
	{
		public const string PluginGUID = "com.deady.xddxd0496.domainmaster";

		public const string PluginName = "DomainMaster";

		public const string PluginVersion = "1.0.0";

		private AudioSource[] audioSources = (AudioSource[])(object)new AudioSource[7];

		public static PluginInfo PInfo { get; private set; }

		public static BirdEmote Instance { get; private set; }

		private void Awake()
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			Instance = this;
			PInfo = ((BaseUnityPlugin)this).Info;
			Assets.LoadAssetBundlesFromFolder("assetbundles");
			ImportEmote("gojo", "Gojo Purple", "gojo_start.anim", "gojo_loop.anim", "gojosound.ogg", looping: false, dmca: false, cantMove: true, 0);
			ImportEmote("omae", "Omae", "omae_start.anim", "omae_loop.anim", "omae.mp3", looping: true, dmca: false, cantMove: false, 1);
			ImportEmote("hakari", "Hakari", "hakari_start.anim", "hakari_loop.anim", "hakari.ogg", looping: true, dmca: false, cantMove: false, 2);
			ImportEmote("livesey", "Dr.Livesey", "livesey_start.anim", "livesey_loop.anim", "livesey.ogg", looping: true, dmca: false, cantMove: false, 3);
			ImportEmote("walk", "Walk", "walk_start.anim", "walk_loop.anim", "walk.ogg", looping: false, dmca: false, cantMove: false, 4);
			ImportEmote("mewing", "Mewing", "mewing_start.anim", "mewing_loop.anim", "mew.ogg", looping: false, dmca: false, cantMove: true, 5);
			ImportEmote("raga", "Raga", "big_raga.start.anim", "big_raga.loop.anim", "Big_Raga.mp3", looping: false, dmca: false, cantMove: true, 6);
			CustomEmotesAPI.animChanged += new AnimationChanged(CustomEmotesAPI_animChanged);
		}

		private void CustomEmotesAPI_animChanged(string newAnimation, BoneMapper mapper)
		{
			if (newAnimation.StartsWith("com.deady.xddxd0496.domainmaster"))
			{
				newAnimation = newAnimation.Split("__")[1];
				string text = newAnimation;
				string text2 = text;
			}
		}

		private void ImportEmote(string name, string displayName, string primaryAnim, string secondaryAnim, string audio, bool looping, bool dmca, bool cantMove, int audioIndex)
		{
			AnimationClip primaryClip = Assets.Load<AnimationClip>(primaryAnim);
			AnimationClip secondaryClip = Assets.Load<AnimationClip>(secondaryAnim);
			AudioClip val = Assets.Load<AudioClip>(audio);
			ImportAnimation(primaryClip, secondaryClip, looping, val, sync: false, displayName, dmca, cantMove, thirdPerson: false);
			audioSources[audioIndex] = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSources[audioIndex].clip = val;
			audioSources[audioIndex].loop = looping;
		}

		private void ImportAnimation(AnimationClip primaryClip, AnimationClip secondaryClip, bool looping, AudioClip audioClip, bool sync, string customName, bool dmca, bool cantMove, bool thirdPerson)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			CustomEmoteParams val = new CustomEmoteParams();
			val.primaryAnimationClips = (AnimationClip[])(object)new AnimationClip[1] { primaryClip };
			val.secondaryAnimationClips = (AnimationClip[])(object)new AnimationClip[1] { secondaryClip };
			val.audioLoops = looping;
			val.primaryAudioClips = (AudioClip[])(object)new AudioClip[1] { audioClip };
			val.secondaryAudioClips = null;
			val.visible = true;
			val.syncAnim = sync;
			val.syncAudio = sync;
			val.startPref = -1;
			val.joinPref = -1;
			val.joinSpots = null;
			val.internalName = customName;
			val.lockType = (LockType)1;
			val.willGetClaimedByDMCA = dmca;
			val.audioLevel = 0.3f;
			val.rootBonesToIgnore = null;
			val.soloBonesToIgnore = null;
			val.stopWhenMove = cantMove;
			val.thirdPerson = thirdPerson;
			val.displayName = customName;
			CustomEmoteParams val2 = val;
			EmoteImporter.ImportEmote(val2);
		}

		private void AddProp(string prefabPath, Vector3 position, BoneMapper mapper)
		{
			//IL_007b: 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)
			int count = mapper.props.Count;
			GameObject val = Assets.Load<GameObject>("Autism Hat/flathat Variant.prefab");
			if ((Object)(object)val != (Object)null)
			{
				mapper.props.Add(Object.Instantiate<GameObject>(val));
				mapper.props[count].transform.SetParent(mapper.mapperBody.transform);
				mapper.props[count].transform.localEulerAngles = new Vector3(90f, 0f, 0f);
				mapper.props[count].transform.localPosition = new Vector3(-0.083f, 1.785f, -4.488f);
			}
		}
	}
}
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>();

		private static BirdEmote birdEmoteInstance;

		internal static void LoadAssetBundlesFromFolder(string folderName)
		{
			folderName = Path.Combine(Path.GetDirectoryName(BirdEmote.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;
				}
				Debug.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);
				}
				if (AssetIndices.TryGetValue(assetName, out var value))
				{
					return AssetBundles[value].LoadAsset<T>("assets/" + assetName);
				}
				Debug.LogError((object)("Asset [" + assetName + "] not found in AssetIndices."));
				return default(T);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Couldn't load asset [{assetName}] reason: {arg}");
				return default(T);
			}
		}
	}
}