Decompiled source of MoreCharacterSelector v1.1.3

BepInEx/plugins/MoreCharacterSelector.dll

Decompiled 9 months ago
using System;
using System.Collections;
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 BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("MoreCharacterSelector")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreCharacterSelector")]
[assembly: AssemblyTitle("MoreCharacterSelector")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace MoreCharacterSelector
{
	public static class SkinnedMeshComponentFinder
	{
		public static SkinnedMeshRenderer GetSkinnedMeshRendererByObjectName(string modelName, string objectName, GameObject replacementModel)
		{
			Console.WriteLine("[MoreCharacterSelector] [Model:" + modelName + "] Trying Get SkinnedMeshRenderer from GetComponentInChildren()");
			SkinnedMeshRenderer componentInChildren = replacementModel.GetComponentInChildren<SkinnedMeshRenderer>();
			if (((Object)componentInChildren).name != objectName)
			{
				Console.WriteLine("[MoreCharacterSelector] [Model:" + modelName + "] Trying Get SkinnedMeshRenderer from Components Array...");
				SkinnedMeshRenderer[] componentsInChildren = replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>();
				foreach (SkinnedMeshRenderer val in componentsInChildren)
				{
					if (((Object)val).name == objectName)
					{
						return val;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)componentInChildren) || ((Object)componentInChildren).name != objectName)
			{
				Console.WriteLine("[MoreCharacterSelector] [Model:" + modelName + "] Getting SkinnedMeshRenderer by ObjectName(" + objectName + ") Failed!");
			}
			return componentInChildren;
		}

		public static SkinnedMeshRenderer GetSkinnedMeshRendererByBlendShapeName(string modelName, string blendShapeName, GameObject replacementModel, out int blendShapeIndex)
		{
			Console.WriteLine("[MoreCharacterSelector] [Model:" + modelName + "] Trying SkinnedMeshRenderer from Components Array...");
			SkinnedMeshRenderer val = null;
			int num = -1;
			SkinnedMeshRenderer[] componentsInChildren = replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val2 in componentsInChildren)
			{
				num = val2.sharedMesh.GetBlendShapeIndex(blendShapeName);
				if (num != -1)
				{
					val = val2;
					blendShapeIndex = num;
					return val;
				}
			}
			if ((Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val) || val.sharedMesh.GetBlendShapeIndex(blendShapeName) == -1)
			{
				Console.WriteLine("[MoreCharacterSelector] [Model:" + modelName + "] Getting SkinnedMeshRenderer by BlendShapeName(" + blendShapeName + ") Failed!");
			}
			blendShapeIndex = num;
			return val;
		}
	}
	public class MRAKULA : BodyReplacementBase
	{
		private const string MODEL_NAME = "Akula";

		public bool Blink = true;

		private SkinnedMeshRenderer _meshRenderer;

		private static WaitForSeconds _eyeCloseWait = new WaitForSeconds(0.2f);

		private static WaitForSeconds _eyeOpenWait = new WaitForSeconds(15f);

		private int _blinkIndex;

		protected override GameObject LoadAssetsAndReturnModel()
		{
			return Assets.MainAssetBundle.LoadAsset<GameObject>("Akula");
		}

		protected override void Start()
		{
			((BodyReplacementBase)this).Start();
			_meshRenderer = SkinnedMeshComponentFinder.GetSkinnedMeshRendererByBlendShapeName("Akula", "EyeClose", base.replacementModel, out _blinkIndex);
			if (_blinkIndex == -1)
			{
				Console.WriteLine("[MoreCharacterSelector] [Model:Akula] Cannot Find BlendShapeIndex [EyeClose]");
				return;
			}
			Console.WriteLine("[MoreCharacterSelector] [Model:Akula] Initialized Successfully!");
			((MonoBehaviour)this).StartCoroutine(OnIdle());
		}

		protected override void AddModelScripts()
		{
			base.UseNoPostProcessing = true;
		}

		protected override void OnEmoteStart(int emoteId)
		{
			_meshRenderer.SetBlendShapeWeight(7, 0f);
			_meshRenderer.SetBlendShapeWeight(62, 0f);
			_meshRenderer.SetBlendShapeWeight(76, 0f);
			_meshRenderer.SetBlendShapeWeight(5, 0f);
			_meshRenderer.SetBlendShapeWeight(42, 0f);
			_meshRenderer.SetBlendShapeWeight(91, 0f);
			switch (emoteId)
			{
			case 1:
				_meshRenderer.SetBlendShapeWeight(5, 100f);
				_meshRenderer.SetBlendShapeWeight(42, 100f);
				_meshRenderer.SetBlendShapeWeight(91, 87.5f);
				break;
			case 2:
				_meshRenderer.SetBlendShapeWeight(7, 100f);
				_meshRenderer.SetBlendShapeWeight(62, 26f);
				_meshRenderer.SetBlendShapeWeight(76, 100f);
				break;
			}
			Blink = false;
		}

		protected override void OnEmoteEnd()
		{
			_meshRenderer.SetBlendShapeWeight(7, 0f);
			_meshRenderer.SetBlendShapeWeight(62, 0f);
			_meshRenderer.SetBlendShapeWeight(76, 0f);
			_meshRenderer.SetBlendShapeWeight(5, 0f);
			_meshRenderer.SetBlendShapeWeight(42, 0f);
			_meshRenderer.SetBlendShapeWeight(91, 0f);
			Blink = true;
		}

		protected override void OnDeath()
		{
			_meshRenderer.SetBlendShapeWeight(_blinkIndex, 100f);
			Blink = false;
		}

		private IEnumerator OnIdle()
		{
			while (true)
			{
				if (Blink)
				{
					_meshRenderer.SetBlendShapeWeight(_blinkIndex, 100f);
					yield return _eyeCloseWait;
					_meshRenderer.SetBlendShapeWeight(_blinkIndex, 0f);
					yield return _eyeOpenWait;
				}
				else
				{
					yield return null;
				}
			}
		}
	}
	public class MRPEPE : BodyReplacementBase
	{
		private const string MODEL_NAME = "pepe";

		public bool Blink = true;

		private SkinnedMeshRenderer _blinkMeshRenderer;

		private SkinnedMeshRenderer _lockMeshRenderer;

		private SkinnedMeshRenderer _sadMeshRenderer;

		private static WaitForSeconds _eyeCloseWait = new WaitForSeconds(0.3f);

		private static WaitForSeconds _eyeOpenWait = new WaitForSeconds(15f);

		private int _blinkIndex;

		private int _lockIndex;

		private int _sadIndex;

		protected override GameObject LoadAssetsAndReturnModel()
		{
			return Assets.MainAssetBundle.LoadAsset<GameObject>("pepe");
		}

		protected override void Start()
		{
			((BodyReplacementBase)this).Start();
			_blinkMeshRenderer = SkinnedMeshComponentFinder.GetSkinnedMeshRendererByBlendShapeName("pepe", "CloseEye", base.replacementModel, out _blinkIndex);
			_lockMeshRenderer = SkinnedMeshComponentFinder.GetSkinnedMeshRendererByBlendShapeName("pepe", "Lock", base.replacementModel, out _lockIndex);
			_sadMeshRenderer = SkinnedMeshComponentFinder.GetSkinnedMeshRendererByBlendShapeName("pepe", "Sad", base.replacementModel, out _sadIndex);
			if (_blinkIndex == -1 || _lockIndex == -1 || _sadIndex == -1)
			{
				Console.WriteLine("[MoreCharacterSelector] [Model:pepe] Cannot Find BlendShapeIndex(s)");
				return;
			}
			Console.WriteLine("[MoreCharacterSelector] [Model:pepe] Initialized Successfully!");
			((MonoBehaviour)this).StartCoroutine(OnIdle());
		}

		protected override void AddModelScripts()
		{
			base.UseNoPostProcessing = true;
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				_lockMeshRenderer.SetBlendShapeWeight(_lockIndex, 100f);
			}
			else
			{
				_lockMeshRenderer.SetBlendShapeWeight(_lockIndex, 0f);
			}
			if (emoteId == 2)
			{
				_sadMeshRenderer.SetBlendShapeWeight(_sadIndex, 100f);
			}
			else
			{
				_sadMeshRenderer.SetBlendShapeWeight(_sadIndex, 0f);
			}
			Blink = false;
		}

		protected override void OnEmoteEnd()
		{
			_lockMeshRenderer.SetBlendShapeWeight(_lockIndex, 0f);
			_sadMeshRenderer.SetBlendShapeWeight(_sadIndex, 0f);
			Blink = true;
		}

		protected override void OnDeath()
		{
			_blinkMeshRenderer.SetBlendShapeWeight(_blinkIndex, 100f);
			Blink = false;
		}

		private IEnumerator OnIdle()
		{
			while (true)
			{
				if (Blink)
				{
					_blinkMeshRenderer.SetBlendShapeWeight(_blinkIndex, 100f);
					yield return _eyeCloseWait;
					_blinkMeshRenderer.SetBlendShapeWeight(_blinkIndex, 0f);
					yield return _eyeOpenWait;
				}
				else
				{
					yield return null;
				}
			}
		}
	}
	[BepInPlugin("com.Humyo.MoreCharacterSelector", "MoreCharacterSelector", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		public static ConfigEntry<string> suitNamesToEnableModelAkula { get; private set; }

		public static ConfigEntry<string> suitNamesToEnableModelPepe { get; private set; }

		private static void InitConfig()
		{
			suitNamesToEnableModelAkula = config.Bind<string>("Suits to Replace Settings (Akula)", "Suits to enable Model for(적용할 슈트 이름)", "Akula", "Enter a comma separated list of suit names.(Additionally, [Default,Orange suit,Green suit,Pajama suit,Hazard suit])(한국어패치기준, [Default,주황색슈트,초록색슈트,파자마슈트,방호복슈트,보라색슈트)");
			suitNamesToEnableModelPepe = config.Bind<string>("Suits to Replace Settings (Pepe)", "Suits to enable Model for(적용할 슈트 이름)", "Pepe", "Enter a comma separated list of suit names.(Additionally, [Default,Orange suit,Green suit,Pajama suit,Hazard suit])(한국어패치기준, [Default,주황색슈트,초록색슈트,파자마슈트,방호복슈트,보라색슈트)");
		}

		private void Awake()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			string[] array = suitNamesToEnableModelAkula.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				ModelReplacementAPI.RegisterSuitModelReplacement(text, typeof(MRAKULA));
			}
			string[] array3 = suitNamesToEnableModelPepe.Value.Split(',');
			string[] array4 = array3;
			foreach (string text2 in array4)
			{
				ModelReplacementAPI.RegisterSuitModelReplacement(text2, typeof(MRPEPE));
			}
			Harmony val = new Harmony("com.Humyo.MoreCharacterSelector");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.Humyo.MoreCharacterSelector is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "MoreCharacterSelector";

		public static AssetBundle MainAssetBundle = null;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}