Decompiled source of BetterRunningEmotes v1.0.1

BepInEx/plugins/KarmyDev.BetterRunningEmotes.dll

Decompiled 3 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 BetterRunningEmotes;
using CustomEmotesAPI_Template_Mod;
using EmotesAPI;
using LethalEmotesAPI.ImportV2;
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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KarmyDev.BetterRunningEmotes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterRunningEmotes")]
[assembly: AssemblyTitle("KarmyDev.BetterRunningEmotes")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BetterRunningEmotes
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("KarmyDev.BetterRunningEmotes", "BetterRunningEmotes", "1.0.0")]
	public class BetterRunningEmotes : BaseUnityPlugin
	{
		public static BetterRunningEmotes Instance;

		public static GameObject MetalChairPrefab;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			Instance = this;
			PInfo = ((BaseUnityPlugin)this).Info;
			Assets.LoadAssetBundlesFromFolder("animationsbundle");
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/boulder_move.anim") }, Array.Empty<AnimationClip>(), looping: false, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/boulder_move_audio.ogg") }, syncAnim: false, syncAudio: true, "Boulder move", dmca: false, cantMove: false, thirdPerson: true, (LockType)3);
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/atrain_run.anim") }, (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/atrain_run_loop.anim") }, looping: true, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/atrain_running_sfx.ogg") }, syncAnim: false, syncAudio: true, "A-Train run", dmca: true, cantMove: false, thirdPerson: true, (LockType)3);
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/swim_start.anim") }, (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/swim_loop.anim") }, looping: true, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/swim_sfx.ogg") }, syncAnim: false, syncAudio: true, "Swim", dmca: true, cantMove: false, thirdPerson: true, (LockType)1);
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/csgo_bhop_start.anim") }, (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/csgo_bhop_loop.anim") }, looping: true, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/csgo_bhop_sfx.ogg") }, syncAnim: false, syncAudio: true, "CS:GO Bhop", dmca: true, cantMove: false, thirdPerson: true, (LockType)1);
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/v1_slide_start.anim") }, (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/v1_slide_loop.anim") }, looping: true, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/v1_slide_sfx.ogg") }, syncAnim: false, syncAudio: true, "V1 Slide", dmca: false, cantMove: false, thirdPerson: true, (LockType)1);
			ImportAnimation((AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("BetterRunningEmotes/wanna_see_sth_cool.anim") }, Array.Empty<AnimationClip>(), looping: false, (AudioClip[])(object)new AudioClip[1] { Assets.Load<AudioClip>("BetterRunningEmotes/wanna_see_sth_cool_sfx.ogg") }, syncAnim: false, syncAudio: true, "Wanna see something cool?", dmca: true, cantMove: false, thirdPerson: true, (LockType)1);
			MetalChairPrefab = Assets.Load<GameObject>("BetterRunningEmotes/Props/metal_chair.prefab");
			CustomEmotesAPI.animChanged += new AnimationChanged(CustomEmotesAPI_animChanged);
		}

		private void CustomEmotesAPI_animChanged(string newAnimation, BoneMapper mapper)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if (newAnimation.StartsWith("KarmyDev.BetterRunningEmotes"))
			{
				newAnimation = newAnimation.Split("__")[1];
				switch (newAnimation)
				{
				case "atrain_run":
					mapper.SetAutoWalk(3.9f, false, true);
					break;
				case "csgo_bhop_start":
					mapper.SetAutoWalk(3.9f, false, true);
					break;
				case "v1_slide_start":
					mapper.SetAutoWalk(3.9f, false, true);
					break;
				case "swim_start":
					mapper.SetAutoWalk(2.4f, false, true);
					break;
				case "wanna_see_sth_cool":
					mapper.props.Add(Object.Instantiate<GameObject>(MetalChairPrefab, new Vector3(0f, 0f, -13.2f), Quaternion.Euler(0f, 0f, 0f), mapper.mapperBody.transform));
					break;
				}
			}
		}

		public void ImportAnimation(AnimationClip[] primaryClips, AnimationClip[] secondaryClips, bool looping, AudioClip[] primaryAudioClips, bool syncAnim, bool syncAudio, string customName, bool dmca, bool cantMove, bool thirdPerson, LockType lockType = 1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			CustomEmoteParams val = new CustomEmoteParams();
			val.primaryAnimationClips = primaryClips;
			val.secondaryAnimationClips = secondaryClips;
			val.audioLoops = looping;
			val.primaryAudioClips = primaryAudioClips;
			val.secondaryAudioClips = null;
			val.primaryDMCAFreeAudioClips = null;
			val.secondaryDMCAFreeAudioClips = null;
			val.visible = true;
			val.syncAnim = syncAnim;
			val.syncAudio = syncAudio;
			val.startPref = -1;
			val.joinPref = -1;
			val.joinSpots = null;
			val.internalName = "";
			val.lockType = lockType;
			val.willGetClaimedByDMCA = dmca;
			val.audioLevel = 0.3f;
			val.rootBonesToIgnore = null;
			val.soloBonesToIgnore = null;
			val.stopWhenMove = cantMove;
			val.thirdPerson = thirdPerson;
			val.displayName = customName;
			EmoteImporter.ImportEmote(val);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "KarmyDev.BetterRunningEmotes";

		public const string PLUGIN_NAME = "BetterRunningEmotes";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
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(global::BetterRunningEmotes.BetterRunningEmotes.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);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}