Decompiled source of ShyGal Playermodels v1.1.0

ShyGalPlayermodelsMod.dll

Decompiled 3 months ago
using System;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using TooManyEmotes;
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-CSharp")]
[assembly: AssemblyCompany("ShyGalPlayermodelsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+150848936ac19a06722a51504a7181e3b5d2ffaf")]
[assembly: AssemblyProduct("ShyGalPlayermodelsMod")]
[assembly: AssemblyTitle("ShyGalPlayermodelsMod")]
[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 ShyGalModelReplacement
{
	public class MRSHYGALBASE : BodyReplacementBase
	{
		private int danceID = 0;

		private int previousDanceID = 0;

		protected string model_name;

		protected FaceExpression defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

		protected FaceExpression happyExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0);

		protected FaceExpression happyEyesClosedExpression = new FaceExpression(0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 65, 0, 0, 0, 0);

		protected FaceExpression surprisedExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0);

		protected FaceExpression closedEyesExpression = new FaceExpression(0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

		protected FaceExpression deadExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 25, 0, 0, 50, 0);

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

		protected virtual void OnEmote(int emoteId)
		{
			if (Plugin.enableEmoteExpressions.Value)
			{
				SkinnedMeshRenderer componentInChildren = base.replacementModel.GetComponentInChildren<SkinnedMeshRenderer>();
				switch (emoteId)
				{
				case -302:
				case -194:
				case -129:
				case -52:
				case -18:
				case 1:
					happyExpression.setExpression(componentInChildren);
					break;
				case -155:
				case 2:
					surprisedExpression.setExpression(componentInChildren);
					break;
				case -89:
				case -3:
					closedEyesExpression.setExpression(componentInChildren);
					break;
				case -219:
				case -170:
				case -133:
				case -46:
				case -36:
					happyEyesClosedExpression.setExpression(componentInChildren);
					break;
				default:
					defaultExpression.setExpression(componentInChildren);
					break;
				}
			}
		}

		protected override void OnDeath()
		{
			if (Plugin.enableDeathExpressions.Value)
			{
				deadExpression.setExpression(base.replacementDeadBody.GetComponentInChildren<SkinnedMeshRenderer>());
			}
		}

		public void LateUpdate()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			((BodyReplacementBase)this).LateUpdate();
			previousDanceID = danceID;
			AnimatorStateInfo currentAnimatorStateInfo = ((BodyReplacementBase)this).controller.playerBodyAnimator.GetCurrentAnimatorStateInfo(1);
			int fullPathHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash;
			if (((BodyReplacementBase)this).controller.performingEmote)
			{
				switch (fullPathHash)
				{
				case -462656950:
					danceID = 1;
					break;
				case 2103786480:
					danceID = 2;
					break;
				default:
					danceID = 3;
					break;
				}
			}
			else
			{
				danceID = 0;
			}
			int num = 0;
			if (ModelReplacementAPI.tooManyEmotesPresent)
			{
				num = getTooManyEmotesCurrentEmoteID();
			}
			if (num != 0)
			{
				danceID = num;
			}
			if (previousDanceID != danceID)
			{
				OnEmote(danceID);
			}
		}

		private int getTooManyEmotesCurrentEmoteID()
		{
			if (EmoteControllerPlayer.allPlayerEmoteControllers.TryGetValue(((BodyReplacementBase)this).controller, out var value) && ((EmoteController)value).IsPerformingCustomEmote())
			{
				return ((EmoteController)value).performingEmote.emoteId * -1 - 1;
			}
			return 0;
		}

		protected override void OnHitEnemy(bool dead)
		{
		}

		protected override void OnHitAlly(PlayerControllerB ally, bool dead)
		{
		}

		protected override void OnDamageTaken(bool dead)
		{
		}

		protected override void OnDamageTakenByAlly(PlayerControllerB ally, bool dead)
		{
		}

		protected override void OnEmoteStart(int emoteId)
		{
		}

		protected override void OnEmoteEnd()
		{
		}
	}
	public class MRSHYGALRED : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Red";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALBLUE : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Blue";
			defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0);
			happyExpression = happyEyesClosedExpression;
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALBLACK : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Black";
			defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0);
			happyExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 100, 0, 0, 0, 0);
			surprisedExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0);
			deadExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 100, 10, 0, 0, 0, 0, 0, 0);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALGREEN : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Green";
			defaultExpression = new FaceExpression(0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
			happyExpression = new FaceExpression(0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0);
			surprisedExpression = new FaceExpression(0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
			deadExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 100, 25, 0, 0, 0, 0, 25, 0);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALYELLOW : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Yellow";
			deadExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 50, 30);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALWHITE : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal White";
			defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0);
			happyExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 100, 0, 0, 0, 0);
			deadExpression = new FaceExpression(0, 0, 0, 0, 20, 0, 0, 100, 65, 0, 0, 0, 0, 50, 0);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALPURPLE : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Purple";
			defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0);
			happyExpression = new FaceExpression(0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 0);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class MRSHYGALPINK : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Pink";
			defaultExpression = new FaceExpression(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0);
			happyExpression = new FaceExpression(100, 0, 0, 0, 0, 75, 0, 0, 0, 0, 65, 0, 0, 0, 0);
			surprisedExpression = new FaceExpression(0, 0, 100, 0, 0, 0, 0, 20, 0, 0, 100, 0, 0, 0, 0);
			deadExpression = new FaceExpression(0, 0, 0, 0, 95, 0, 0, 100, 50, 0, 30, 0, 30, 0, 30);
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}

		protected override void OnEmote(int emoteId)
		{
			base.OnEmote(emoteId);
			if (emoteId == -18)
			{
				surprisedExpression.setExpression(((BodyReplacementBase)this).replacementModel.GetComponentInChildren<SkinnedMeshRenderer>());
			}
		}
	}
	public class MRSHYGALORANGE : MRSHYGALBASE
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			model_name = "Shygal Orange";
			happyExpression = happyEyesClosedExpression;
			return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
		}
	}
	public class FaceExpression
	{
		private short[] faceBlendshapes;

		public FaceExpression(short blush, short tribal, short heartEyes, short eyesHalfClosed, short eyesClosed, short eyesClosedHappy, short eyesAngry, short eyesSurprised, short eyesSad, short eyesConfused, short eyesHappy, short eyesSmug, short a, short o, short ch)
		{
			faceBlendshapes = new short[15]
			{
				blush, tribal, heartEyes, eyesHalfClosed, eyesClosed, eyesClosedHappy, eyesAngry, eyesSurprised, eyesSad, eyesConfused,
				eyesHappy, eyesSmug, a, o, ch
			};
		}

		public void setExpression(SkinnedMeshRenderer mask)
		{
			for (int i = 0; i < faceBlendshapes.Length; i++)
			{
				mask.SetBlendShapeWeight(i, (float)faceBlendshapes[i]);
			}
		}
	}
	[BepInPlugin("com.cydern.shygalplayermodels", "Shy Gal Playermodels", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		public static ConfigEntry<bool> enableEmoteExpressions { get; private set; }

		public static ConfigEntry<bool> enableDeathExpressions { get; private set; }

		private static void InitConfig()
		{
			enableEmoteExpressions = config.Bind<bool>("Expressions (Client-Sided)", "Enable Expressions on Emote", true, "When enabled, ShyGals will change expressions when emoting.");
			enableDeathExpressions = config.Bind<bool>("Expressions (Client-Sided)", "Enable Expressions on Death", true, "When enabled, ShyGals will change expressions on death");
		}

		private void Awake()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Red", typeof(MRSHYGALRED));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Blue", typeof(MRSHYGALBLUE));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Black", typeof(MRSHYGALBLACK));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Green", typeof(MRSHYGALGREEN));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Yellow", typeof(MRSHYGALYELLOW));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal White", typeof(MRSHYGALWHITE));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Purple", typeof(MRSHYGALPURPLE));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Pink", typeof(MRSHYGALPINK));
			ModelReplacementAPI.RegisterSuitModelReplacement("Shygal Orange", typeof(MRSHYGALORANGE));
			Harmony val = new Harmony("com.cydern.shygalplayermodels");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.cydern.shygalplayermodels is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "ShyGalPlayermodels";

		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)
		{
		}
	}
}