Decompiled source of SeregaPiratEmotes v1.5.6

plugins/SeregaPiratEmotesMod.dll

Decompiled 3 days 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 EmotesAPI;
using LethalEmotesAPI.ImportV2;
using Lethal_Company_SeregaPiratEmotesMod;
using Microsoft.CodeAnalysis;
using SeregaPiratEmotesLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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 = ".NET Standard 2.1")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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_SeregaPiratEmotesMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.zpydu.seregapiratemotes", "SeregaPiratEmotes", "1.5.6")]
	public class SeregaPiratEmotesMod : BaseUnityPlugin
	{
		public const string PluginGUID = "com.zpydu.seregapiratemotes";

		public const string PluginName = "SeregaPiratEmotes";

		public const string PluginVersion = "1.5.6";

		public static SeregaPiratEmotesMod instance;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			instance = this;
			PInfo = ((BaseUnityPlugin)this).Info;
			SeregaAssets.LoadAssetBundlesFromFolder("seregaassetbundles");
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/apelsin.anim" }, new string[1] { "SeregaPirateEmote/music/apelsin.ogg" }, "Apelsin", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/malishka.anim" }, new string[1] { "SeregaPirateEmote/music/malishka.ogg" }, "Malishka", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/kachalka.anim" }, new string[1] { "SeregaPirateEmote/music/kachalka.ogg" }, "Kachalka", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/svoruyubabki.anim" }, new string[1] { "SeregaPirateEmote/music/svoruyubabki.ogg" }, "Svoruyu Babki", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/mybike.anim" }, new string[1] { "SeregaPirateEmote/music/mybike.ogg" }, "My bike", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/wibeman.anim" }, new string[1] { "SeregaPirateEmote/music/wibeman.ogg" }, "Wibeman", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/natalia.anim" }, new string[1] { "SeregaPirateEmote/music/natalia.ogg" }, "Natalia", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/shizoid.anim" }, new string[1] { "SeregaPirateEmote/music/schizoid2.ogg" }, "Shizoid", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/vorobei.anim" }, new string[1] { "SeregaPirateEmote/music/vorobei.ogg" }, "Vorobei", 0.9f, looping: false, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/vor.anim" }, new string[1] { "SeregaPirateEmote/Music/vor.ogg" }, "Vor", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			ImportAnimation(new string[1] { "SeregaPirateEmote/animations/prazdnick.anim" }, new string[1] { "SeregaPirateEmote/music/prazdnick.ogg" }, "Prazdnick", 0.9f, looping: true, sync: true, cantMove: false, thirdPerson: false);
			CustomEmotesAPI.animChanged += new AnimationChanged(CustomEmotesAPI_animChanged);
		}

		private void CustomEmotesAPI_animChanged(string newAnimation, BoneMapper mapper)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!newAnimation.StartsWith("com.zpydu.seregapiratemotes"))
			{
				return;
			}
			newAnimation = newAnimation.Split("__")[1];
			if (!(newAnimation == "mybike"))
			{
				if (newAnimation == "wibeman")
				{
					SpawnProp("SeregaPirateEmote/props/DiskoBall/discoball_prop.prefab", mapper, new Vector3(0f, 3.5f, 0f));
				}
			}
			else
			{
				SpawnProp("SeregaPirateEmote/props/Bike/BikeProp.prefab", mapper, Vector3.zero);
			}
		}

		private void SpawnProp(string prefabPath, BoneMapper boneMapper, Vector3 pos)
		{
			//IL_0054: 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)
			int count = boneMapper.props.Count;
			boneMapper.props.Add(Object.Instantiate<GameObject>(SeregaAssets.Load<GameObject>(prefabPath)));
			boneMapper.props[count].transform.SetParent(boneMapper.mapperBody.transform);
			boneMapper.props[count].transform.localEulerAngles = Vector3.zero;
			boneMapper.props[count].transform.localPosition = pos;
		}

		private void ImportAnimation(string[] primaryClipsName, string[] primaryAudioClipsName, string customName, float volume, bool looping, bool sync, bool cantMove, bool thirdPerson)
		{
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			AnimationClip[] array = (AnimationClip[])(object)new AnimationClip[primaryClipsName.Length];
			AudioClip[] array2 = (AudioClip[])(object)new AudioClip[primaryAudioClipsName.Length];
			for (int i = 0; i < primaryClipsName.Length; i++)
			{
				array[i] = SeregaAssets.Load<AnimationClip>(primaryClipsName[i]);
				array2[i] = SeregaAssets.Load<AudioClip>(primaryAudioClipsName[i]);
			}
			EmoteImporter.ImportEmote(new CustomEmoteParams
			{
				displayName = customName,
				primaryAnimationClips = array,
				primaryAudioClips = array2,
				lockType = (LockType)1,
				audioLevel = volume,
				syncAnim = sync,
				syncAudio = sync,
				audioLoops = looping,
				willGetClaimedByDMCA = false,
				stopWhenMove = cantMove,
				thirdPerson = thirdPerson,
				visible = true
			});
		}
	}
}
namespace SeregaPiratEmotesLoader
{
	internal static class SeregaAssets
	{
		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(SeregaPiratEmotesMod.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();
				for (int j = 0; j < allAssetNames.Length; j++)
				{
					string text2 = allAssetNames[j].ToLowerInvariant();
					if (text2.StartsWith("assets/"))
					{
						text2 = text2.Remove(0, "assets/".Length);
					}
					AssetIndices[text2] = 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(":"))
				{
					assetName = assetName.Split(':')[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);
			}
		}
	}
}