Decompiled source of Sylvunny v1.2.4

sylvunny modelswap.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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 BepInEx.Configuration;
using BepInEx.Logging;
using CamVisuals;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using JigglePhysics;
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-CSharp")]
[assembly: AssemblyCompany("sylvunny modelswap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("sylvunny modelswap")]
[assembly: AssemblyTitle("sylvunny modelswap")]
[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 CamVisuals
{
	[BepInPlugin("MRCameraVisualsSylvunny", "Sylvunny", "1.2.4")]
	public class CameraVisuals : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("CameraVisualsSylvunny");

		public static GameObject gameObject;

		private static CameraVisuals Instance;

		public static Vector3 baseSize;

		public static ManualLogSource mls;

		public static bool usingCameraVisuals;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll(typeof(CameraVisuals));
			mls.LogInfo((object)"CAMERA HEIGHTS LOADED");
		}

		[HarmonyPatch(typeof(ModelReplacementAPI), "SetPlayerModelReplacement")]
		[HarmonyPostfix]
		public static void DetectCamera(PlayerControllerB player)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			gameObject = ((Component)player).gameObject;
			Transform val = gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer");
			if ((Object)(object)val != (Object)null)
			{
				GameObject val2 = ((Component)val).gameObject;
				if (Plugin.usingModel && !usingCameraVisuals)
				{
					Transform obj = gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer")
						.Find("MainCamera")
						.Find("HUDHelmetPosition");
					obj.localPosition += new Vector3(0f, 0.005f, 0f);
					gameObject.transform.localScale = new Vector3(gameObject.transform.localScale.x, gameObject.transform.localScale.y * 1.185f, gameObject.transform.localScale.z);
					usingCameraVisuals = true;
				}
			}
			else
			{
				mls.LogInfo((object)"Child GameObject not found.");
			}
		}

		[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
		[HarmonyPostfix]
		public static void DetectCamera()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			baseSize = ((Component)localPlayerController).gameObject.transform.localScale;
			if (Plugin.usingModel && usingCameraVisuals)
			{
				Transform obj = ((Component)localPlayerController).gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer")
					.Find("MainCamera");
				obj.localPosition += new Vector3(0f, -0.31f, -0.018f);
			}
		}

		[HarmonyPatch(typeof(Terminal), "QuitTerminal")]
		[HarmonyPostfix]
		public static void ResetCamera()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (Plugin.usingModel && usingCameraVisuals)
			{
				Transform obj = ((Component)localPlayerController).gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer")
					.Find("MainCamera");
				obj.localPosition -= new Vector3(0f, -0.31f, -0.018f);
			}
		}
	}
}
namespace ModelReplacement
{
	public class MRSYLVUNNY : BodyReplacementBase
	{
		public PlayerControllerB player;

		public SkinnedMeshRenderer skinnedMeshRenderer;

		public SkinnedMeshRenderer skinnedMeshRenderer2;

		public float time = 0f;

		public string EyeShape1 = "LowerLidRaiserL";

		public string EyeShape2 = "lowerBlinkL";

		public string EyeShape3 = "EBAllLowerL";

		public string EyeShape4 = "UpeerLidLowerL";

		public string EyeShape5 = "EBInnerLowererL";

		public string EyeShape6 = "EBOuterLowererL";

		public string CheekShape = "CheekRaiser1L";

		public string MouthShape1 = "UppeLipRaiser";

		public string MouthShape2 = "SmirkL";

		public string MouthShape3 = "CornerLowerL";

		public string MouthShape4 = "LowerLipLower";

		public string MouthShape5 = "MouthOpenL";

		public string MouthShape6 = "StrecherL";

		public string MouthShape7 = "bite1L";

		public int eye1;

		public int eye2;

		public int eye3;

		public int eye4;

		public int eye5;

		public int eye6;

		public int cheek;

		public int mouth1;

		public int mouth2;

		public int mouth3;

		public int mouth4;

		public int mouth5;

		public int mouth6;

		public int mouth7;

		public string fitShapeName = "fit";

		public string armShapeName = "ArmsMuscles";

		public string breastShapeName1 = "Breastsize";

		public string breastShapeName2 = "Breastflatten";

		public string breastShapeName3 = "BreastSmall";

		public string breastShapeName4 = "BreastsizeSUIT";

		public string buttShapeName = "Buttsize";

		public string hipsShapeName = "widehips";

		public string legsShapeName = "Legsize";

		public string bellyShapeName = "Pregnant";

		public string waistShapeName = "waist1";

		public string slimShapeName = "slim";

		public string canonShapeName = "cannonSlim2";

		public string fluffShapeName = "flufback";

		public int fit;

		public int arm;

		public int breast1;

		public int breast2;

		public int breast3;

		public int breast4;

		public int butt;

		public int hips;

		public int legs;

		public int belly;

		public int waist;

		public int slim;

		public int canon;

		public int fluff;

		public float fitValue = Plugin.fitModifier.Value;

		public float armValue = Plugin.armMuscleModifier.Value;

		public float breastValue = Plugin.breastModifier.Value;

		public float buttValue = Plugin.buttModifier.Value;

		public float hipValue = Plugin.hipsModifier.Value;

		public float legValue = Plugin.legsModifier.Value;

		public float bellyValue = Plugin.bellyModifier.Value;

		public float waistValue = Plugin.waistModifier.Value;

		public float slimValue = Plugin.slimModifier.Value;

		public float canonValue = Plugin.canonModifier.Value;

		public float fluffValue = Plugin.fluffModifier.Value;

		private SkinnedMeshRenderer[] Renderers;

		private SkinnedMeshRenderer[] deadRenderers;

		private SkinnedMeshRenderer[] viewModelRenderers;

		private JiggleRigBuilder[] jiggleBones;

		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "sylvunny";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void Start()
		{
			((BodyReplacementBase)this).Start();
			player = ((BodyReplacementBase)this).controller;
			GameObject gameObject = ((Component)base.replacementModel.transform.Find("Bodys.dmx")).gameObject;
			GameObject gameObject2 = ((Component)base.replacementModel.transform.Find("hand supportE")).gameObject;
			if ((Object)(object)skinnedMeshRenderer == (Object)null)
			{
				skinnedMeshRenderer = gameObject.GetComponent<SkinnedMeshRenderer>();
			}
			if ((Object)(object)skinnedMeshRenderer2 == (Object)null)
			{
				skinnedMeshRenderer2 = gameObject2.GetComponent<SkinnedMeshRenderer>();
			}
			Plugin.usingModel = true;
			Plugin.stopBlink = false;
			Plugin.stopMouth = false;
			Renderers = base.replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>();
			jiggleBones = base.replacementModel.GetComponentsInChildren<JiggleRigBuilder>();
			if (ModelReplacementAPI.EnforceViewModelGeneration.Value)
			{
				viewModelRenderers = base.replacementViewModel.GetComponentsInChildren<SkinnedMeshRenderer>();
			}
			fitValue = Mathf.Clamp(fitValue, 0f, 100f);
			armValue = Mathf.Clamp(armValue, 0f, 100f);
			breastValue = Mathf.Clamp(breastValue, -100f, 200f);
			buttValue = Mathf.Clamp(buttValue, 0f, 100f);
			hipValue = Mathf.Clamp(hipValue, 0f, 100f);
			legValue = Mathf.Clamp(legValue, 0f, 100f);
			bellyValue = Mathf.Clamp(bellyValue, 0f, 100f);
			waistValue = Mathf.Clamp(waistValue, 0f, 100f);
			slimValue = Mathf.Clamp(slimValue, 0f, 100f);
			canonValue = Mathf.Clamp(canonValue, 0f, 100f);
			fluffValue = Mathf.Clamp(fluffValue, 0f, 100f);
			eye1 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape1);
			eye2 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape2);
			eye3 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape3);
			eye4 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape4);
			eye5 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape5);
			eye6 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(EyeShape6);
			cheek = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(CheekShape);
			mouth1 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape1);
			mouth2 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape2);
			mouth3 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape3);
			mouth4 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape4);
			mouth5 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape5);
			mouth6 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape6);
			mouth7 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(MouthShape7);
			fit = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(fitShapeName);
			arm = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(armShapeName);
			breast1 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(breastShapeName1);
			breast2 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(breastShapeName2);
			breast3 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(breastShapeName3);
			breast4 = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(breastShapeName4);
			butt = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(buttShapeName);
			hips = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(hipsShapeName);
			legs = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(legsShapeName);
			belly = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(bellyShapeName);
			waist = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(waistShapeName);
			slim = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(slimShapeName);
			canon = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(canonShapeName);
			fluff = skinnedMeshRenderer2.sharedMesh.GetBlendShapeIndex(fluffShapeName);
			if (!Plugin.TMEPatch)
			{
				Renderers[0].SetBlendShapeWeight(eye1, 0f);
				Renderers[0].SetBlendShapeWeight(eye2, 0f);
				Renderers[0].SetBlendShapeWeight(eye3, 0f);
				Renderers[0].SetBlendShapeWeight(eye4, 0f);
				Renderers[0].SetBlendShapeWeight(eye5, 0f);
				Renderers[0].SetBlendShapeWeight(eye6, 0f);
				Renderers[0].SetBlendShapeWeight(cheek, 0f);
				Renderers[0].SetBlendShapeWeight(mouth1, 0f);
				Renderers[0].SetBlendShapeWeight(mouth2, 0f);
				Renderers[0].SetBlendShapeWeight(mouth3, 0f);
				Renderers[0].SetBlendShapeWeight(mouth4, 0f);
				Renderers[0].SetBlendShapeWeight(mouth5, 0f);
				Renderers[0].SetBlendShapeWeight(mouth6, 0f);
				Renderers[0].SetBlendShapeWeight(mouth7, 0f);
			}
			Renderers[0].SetBlendShapeWeight(fit, fitValue);
			Renderers[0].SetBlendShapeWeight(arm, armValue);
			Renderers[0].SetBlendShapeWeight(butt, buttValue);
			Renderers[0].SetBlendShapeWeight(hips, hipValue);
			Renderers[0].SetBlendShapeWeight(legs, legValue);
			Renderers[0].SetBlendShapeWeight(belly, bellyValue);
			Renderers[0].SetBlendShapeWeight(waist, waistValue);
			Renderers[0].SetBlendShapeWeight(slim, slimValue);
			Renderers[0].SetBlendShapeWeight(canon, canonValue);
			Renderers[2].SetBlendShapeWeight(fluff, fluffValue);
			if (ModelReplacementAPI.EnforceViewModelGeneration.Value)
			{
				viewModelRenderers[2].SetBlendShapeWeight(fluff, fluffValue);
			}
			if (breastValue >= 0f)
			{
				float num = Mathf.Clamp(breastValue, 0f, 100f);
				Renderers[0].SetBlendShapeWeight(breast1, num);
				if (breastValue > 100f)
				{
					Renderers[0].SetBlendShapeWeight(breast4, breastValue - 100f);
				}
			}
			else if (breastValue < 0f)
			{
				Renderers[0].SetBlendShapeWeight(breast2, 0f - breastValue);
				Renderers[0].SetBlendShapeWeight(breast3, 0f - breastValue * 0.4f);
				if (breastValue <= -70f)
				{
					((Behaviour)jiggleBones[7]).enabled = false;
					((Behaviour)jiggleBones[8]).enabled = false;
				}
				else
				{
					((Behaviour)jiggleBones[7]).enabled = true;
					((Behaviour)jiggleBones[8]).enabled = true;
				}
			}
			if (breastValue <= 100f)
			{
				Renderers[0].SetBlendShapeWeight(breast4, 0f);
			}
			if (Plugin.fluffEnable.Value)
			{
				((Renderer)Renderers[2]).enabled = true;
				if (ModelReplacementAPI.EnforceViewModelGeneration.Value)
				{
					((Renderer)viewModelRenderers[2]).enabled = true;
				}
			}
			else if (!Plugin.fluffEnable.Value)
			{
				((Renderer)Renderers[2]).enabled = false;
				if (ModelReplacementAPI.EnforceViewModelGeneration.Value)
				{
					((Renderer)viewModelRenderers[2]).enabled = false;
				}
			}
			if (Plugin.EmoteAudio.Value)
			{
				AudioClip randomAudio = Assets.SSpawn.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.4f);
			}
		}

		protected override void OnDamageTaken(bool dead)
		{
			((BodyReplacementBase)this).OnDamageTaken(dead);
			if (!Plugin.TMEPatch)
			{
				Plugin.stopMouth = true;
				Plugin.stopBlink = true;
				((MonoBehaviour)this).StartCoroutine(Hurt());
			}
			if (Plugin.EmoteAudio.Value)
			{
				AudioClip randomAudio = Assets.SHurt.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.9f);
			}
		}

		protected override void OnDeath()
		{
			((BodyReplacementBase)this).OnDeath();
			Plugin.stopMouth = true;
			Plugin.stopBlink = true;
			deadRenderers = base.replacementDeadBody.GetComponentsInChildren<SkinnedMeshRenderer>();
			if (!Plugin.TMEPatch)
			{
				deadRenderers[0].SetBlendShapeWeight(eye2, 100f);
				deadRenderers[0].SetBlendShapeWeight(eye3, 100f);
				deadRenderers[0].SetBlendShapeWeight(mouth3, 70f);
				deadRenderers[0].SetBlendShapeWeight(mouth5, 35f);
				deadRenderers[0].SetBlendShapeWeight(eye1, 0f);
				deadRenderers[0].SetBlendShapeWeight(eye4, 0f);
				deadRenderers[0].SetBlendShapeWeight(eye5, 0f);
				deadRenderers[0].SetBlendShapeWeight(eye6, 0f);
				deadRenderers[0].SetBlendShapeWeight(cheek, 0f);
				deadRenderers[0].SetBlendShapeWeight(mouth1, 0f);
				deadRenderers[0].SetBlendShapeWeight(mouth2, 0f);
				deadRenderers[0].SetBlendShapeWeight(mouth4, 0f);
				deadRenderers[0].SetBlendShapeWeight(mouth6, 0f);
				deadRenderers[0].SetBlendShapeWeight(mouth7, 0f);
			}
			if ((Object)(object)base.replacementDeadBody.GetComponent<AudioSource>() == (Object)null)
			{
				base.replacementDeadBody.AddComponent<AudioSource>();
			}
			if (Plugin.EmoteAudio.Value)
			{
				AudioClip randomAudio = Assets.SDie.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				AudioSource component = base.replacementDeadBody.GetComponent<AudioSource>();
				component.PlayOneShot(randomAudio, 0.5f);
			}
			deadRenderers[0].SetBlendShapeWeight(fit, fitValue);
			deadRenderers[0].SetBlendShapeWeight(arm, armValue);
			deadRenderers[0].SetBlendShapeWeight(butt, buttValue);
			deadRenderers[0].SetBlendShapeWeight(hips, hipValue);
			deadRenderers[0].SetBlendShapeWeight(legs, legValue);
			deadRenderers[0].SetBlendShapeWeight(belly, bellyValue);
			deadRenderers[0].SetBlendShapeWeight(waist, waistValue);
			deadRenderers[0].SetBlendShapeWeight(slim, slimValue);
			deadRenderers[0].SetBlendShapeWeight(canon, canonValue);
			if (breastValue >= 0f)
			{
				float num = Mathf.Clamp(breastValue, 0f, 100f);
				deadRenderers[0].SetBlendShapeWeight(breast1, num);
				if (breastValue > 100f)
				{
					deadRenderers[0].SetBlendShapeWeight(breast4, breastValue - 100f);
				}
			}
			else if (breastValue < 0f)
			{
				deadRenderers[0].SetBlendShapeWeight(breast2, 0f - breastValue);
				deadRenderers[0].SetBlendShapeWeight(breast3, 0f - breastValue * 0.4f);
			}
			if (breastValue <= 100f)
			{
				deadRenderers[0].SetBlendShapeWeight(breast4, 0f);
			}
			if (Plugin.fluffEnable.Value)
			{
				((Renderer)deadRenderers[2]).enabled = true;
			}
			else if (!Plugin.fluffEnable.Value)
			{
				((Renderer)deadRenderers[2]).enabled = false;
			}
		}

		protected override void AddModelScripts()
		{
			((BodyReplacementBase)this).AddModelScripts();
			GameObject gameObject = ((Component)base.replacementModel.transform.Find("Bodys.dmx")).gameObject;
			Blinking blinking = gameObject.AddComponent(typeof(Blinking)) as Blinking;
			blinking.player = ((BodyReplacementBase)this).controller;
			JawSync jawSync = gameObject.AddComponent(typeof(JawSync)) as JawSync;
			jawSync.player = ((BodyReplacementBase)this).controller;
			jawSync.init();
		}

		protected override void OnEmoteStart(int emoteId)
		{
			((BodyReplacementBase)this).OnEmoteStart(emoteId);
			switch (emoteId)
			{
			case 1:
				if (!Plugin.TMEPatch)
				{
					Plugin.stopMouth = true;
					Plugin.stopBlink = true;
					Renderers[0].SetBlendShapeWeight(eye1, 100f);
					Renderers[0].SetBlendShapeWeight(cheek, 60f);
					Renderers[0].SetBlendShapeWeight(mouth1, 60f);
					Renderers[0].SetBlendShapeWeight(mouth2, 70f);
					Renderers[0].SetBlendShapeWeight(mouth4, 40f);
					Renderers[0].SetBlendShapeWeight(eye3, 0f);
					Renderers[0].SetBlendShapeWeight(eye4, 0f);
					Renderers[0].SetBlendShapeWeight(eye5, 0f);
					Renderers[0].SetBlendShapeWeight(mouth5, 0f);
					if (Plugin.EmoteAudio.Value)
					{
						AudioClip randomAudio2 = Assets.SDance.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
						((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.5f);
					}
				}
				break;
			case 2:
				if (!Plugin.TMEPatch)
				{
					Plugin.stopMouth = true;
					Plugin.stopBlink = true;
					Renderers[0].SetBlendShapeWeight(eye3, 100f);
					Renderers[0].SetBlendShapeWeight(eye4, 40f);
					Renderers[0].SetBlendShapeWeight(eye5, 100f);
					Renderers[0].SetBlendShapeWeight(mouth1, 50f);
					Renderers[0].SetBlendShapeWeight(mouth5, 70f);
					Renderers[0].SetBlendShapeWeight(eye1, 0f);
					Renderers[0].SetBlendShapeWeight(cheek, 0f);
					Renderers[0].SetBlendShapeWeight(mouth2, 0f);
					Renderers[0].SetBlendShapeWeight(mouth4, 0f);
					if (Plugin.EmoteAudio.Value)
					{
						AudioClip randomAudio = Assets.SPoint.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
						((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.5f);
					}
				}
				break;
			}
		}

		protected override void OnEmoteEnd()
		{
			((BodyReplacementBase)this).OnEmoteEnd();
			if (!Plugin.TMEPatch)
			{
				Renderers[0].SetBlendShapeWeight(eye1, 0f);
				Renderers[0].SetBlendShapeWeight(eye3, 0f);
				Renderers[0].SetBlendShapeWeight(eye4, 0f);
				Renderers[0].SetBlendShapeWeight(eye5, 0f);
				Renderers[0].SetBlendShapeWeight(cheek, 0f);
				Renderers[0].SetBlendShapeWeight(mouth1, 0f);
				Renderers[0].SetBlendShapeWeight(mouth2, 0f);
				Renderers[0].SetBlendShapeWeight(mouth4, 0f);
				Renderers[0].SetBlendShapeWeight(mouth5, 0f);
				Plugin.stopMouth = false;
				Plugin.stopBlink = false;
			}
		}

		protected override void OnDestroy()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			if (CameraVisuals.usingCameraVisuals)
			{
				Plugin.usingModel = false;
				CameraVisuals.usingCameraVisuals = false;
				if (Plugin.enableResetter.Value)
				{
					((Component)this).gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
					((Component)this).gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer")
						.Find("MainCamera")
						.Find("HUDHelmetPosition")
						.localPosition = new Vector3(0.01f, -0.048f, -0.063f);
					CameraVisuals.mls.LogInfo((object)"Resetting Camera to Default Position");
				}
				else if (!Plugin.enableResetter.Value)
				{
					CameraVisuals.gameObject.transform.localScale = new Vector3(((Component)this).gameObject.transform.localScale.x, ((Component)this).gameObject.transform.localScale.y / 1.185f, ((Component)this).gameObject.transform.localScale.z);
					Transform obj = CameraVisuals.gameObject.transform.Find("ScavengerModel").Find("metarig").Find("CameraContainer")
						.Find("MainCamera")
						.Find("HUDHelmetPosition");
					obj.localPosition -= new Vector3(0f, 0.005f, 0f);
				}
			}
			((BodyReplacementBase)this).OnDestroy();
		}

		private IEnumerator Hurt()
		{
			Renderers[0].SetBlendShapeWeight(eye1, 100f);
			Renderers[0].SetBlendShapeWeight(eye3, 100f);
			Renderers[0].SetBlendShapeWeight(eye4, 40f);
			Renderers[0].SetBlendShapeWeight(eye6, 100f);
			Renderers[0].SetBlendShapeWeight(mouth1, 60f);
			Renderers[0].SetBlendShapeWeight(mouth3, 20f);
			Renderers[0].SetBlendShapeWeight(mouth6, 30f);
			Renderers[0].SetBlendShapeWeight(mouth7, 60f);
			Renderers[0].SetBlendShapeWeight(cheek, 60f);
			yield return (object)new WaitForSeconds(0.4f);
			Renderers[0].SetBlendShapeWeight(eye1, 0f);
			Renderers[0].SetBlendShapeWeight(eye3, 0f);
			Renderers[0].SetBlendShapeWeight(eye4, 0f);
			Renderers[0].SetBlendShapeWeight(eye6, 0f);
			Renderers[0].SetBlendShapeWeight(mouth1, 0f);
			Renderers[0].SetBlendShapeWeight(mouth3, 0f);
			Renderers[0].SetBlendShapeWeight(mouth6, 0f);
			Renderers[0].SetBlendShapeWeight(mouth7, 0f);
			Renderers[0].SetBlendShapeWeight(cheek, 0f);
			Plugin.stopMouth = false;
			Plugin.stopBlink = false;
			yield return null;
		}
	}
	public class Blinking : MonoBehaviour
	{
		public PlayerControllerB player;

		public SkinnedMeshRenderer skinnedMeshRenderer;

		public string blendShapeName = "Blink1L";

		public float minBlinkInterval = 5f;

		public float maxBlinkInterval = 8f;

		public float blinkSpeed = 1100f;

		private float nextBlinkTime;

		private bool isBlinking = false;

		private float blinkWeight = 0f;

		private void Start()
		{
			if ((Object)(object)skinnedMeshRenderer == (Object)null)
			{
				skinnedMeshRenderer = ((Component)this).GetComponent<SkinnedMeshRenderer>();
			}
			skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName), 0f);
			nextBlinkTime = Time.time + Random.Range(minBlinkInterval, maxBlinkInterval);
		}

		private void Update()
		{
			if (!player.isPlayerDead && Time.time >= nextBlinkTime && !isBlinking)
			{
				((MonoBehaviour)this).StartCoroutine(DoBlink());
			}
		}

		private IEnumerator DoBlink()
		{
			isBlinking = true;
			while (blinkWeight < 100f && !Plugin.stopBlink)
			{
				blinkWeight += blinkSpeed * Time.deltaTime;
				blinkWeight = Mathf.Clamp(blinkWeight, 0f, 100f);
				skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName), blinkWeight);
				yield return null;
			}
			yield return (object)new WaitForSeconds(0.04f);
			while (blinkWeight > 0f && !Plugin.stopBlink)
			{
				blinkWeight -= blinkSpeed * Time.deltaTime;
				blinkWeight = Mathf.Clamp(blinkWeight, 0f, 100f);
				skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName), blinkWeight);
				yield return null;
			}
			isBlinking = false;
			nextBlinkTime = Time.time + Random.Range(minBlinkInterval, maxBlinkInterval);
		}
	}
	public class JawSync : MonoBehaviour
	{
		public PlayerControllerB player;

		public float maxOpen1 = 49f;

		public float maxOpen2 = 64f;

		public float maxOpen3 = 68f;

		public SkinnedMeshRenderer skinnedMeshRenderer;

		public float sensibility = 100f * Plugin.voiceSensitivity.Value;

		protected VoicePlayerState voice;

		public string blendShapeName1 = "StrecherL";

		public string blendShapeName2 = "SmirkL";

		public string blendShapeName3 = "MouthOpenL";

		public void Start()
		{
			if ((Object)(object)skinnedMeshRenderer == (Object)null)
			{
				skinnedMeshRenderer = ((Component)this).GetComponent<SkinnedMeshRenderer>();
			}
		}

		private void Update()
		{
			if ((Object)(object)StartOfRound.Instance.voiceChatModule == (Object)null)
			{
				return;
			}
			if (voice == null)
			{
				init();
			}
			if (voice != null && !Plugin.stopMouth)
			{
				float num = 0f;
				float num2 = 0f;
				float num3 = 0f;
				if (voice.IsSpeaking)
				{
					num = (player.isPlayerDead ? 0f : Mathf.Clamp(voice.Amplitude * sensibility, 0f, maxOpen1));
					num2 = (player.isPlayerDead ? 0f : Mathf.Clamp(voice.Amplitude * sensibility, 0f, maxOpen2));
					num3 = (player.isPlayerDead ? 0f : Mathf.Clamp(voice.Amplitude * sensibility, 0f, maxOpen3));
				}
				skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName1), num);
				skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName2), num2);
				skinnedMeshRenderer.SetBlendShapeWeight(skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(blendShapeName3), num3);
			}
		}

		public void init()
		{
			StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			voice = player.voicePlayerState;
			if (voice == null && (Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				voice = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName);
			}
		}
	}
	[BepInPlugin("com.wintermantis.sylvunny", "SylvunnyModel", "1.2.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static bool TMEPatch;

		public static bool usingModel;

		public static bool stopBlink;

		public static bool stopMouth;

		public static ConfigFile config;

		public static ConfigEntry<float> voiceSensitivity { get; private set; }

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

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

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

		public static ConfigEntry<float> fitModifier { get; private set; }

		public static ConfigEntry<float> armMuscleModifier { get; private set; }

		public static ConfigEntry<float> breastModifier { get; private set; }

		public static ConfigEntry<float> buttModifier { get; private set; }

		public static ConfigEntry<float> hipsModifier { get; private set; }

		public static ConfigEntry<float> legsModifier { get; private set; }

		public static ConfigEntry<float> bellyModifier { get; private set; }

		public static ConfigEntry<float> fluffModifier { get; private set; }

		public static ConfigEntry<float> waistModifier { get; private set; }

		public static ConfigEntry<float> slimModifier { get; private set; }

		public static ConfigEntry<float> canonModifier { get; private set; }

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

		private static void InitConfig()
		{
			voiceSensitivity = config.Bind<float>("Voice Sensitivity", "Sensitivity Value", 10f, "Sensitivity of Sylvunny's Jaw. Number from 5 to 20");
			suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for", "Sylvunny", "Enter a comma separated list of suit names.(Additionally, [Green suit,Pajama suit,Hazard suit])");
			enableResetter = config.Bind<bool>("Misc", "Enable Resetter on every suit", true, "Enable the Camera Visual Resetter for every other suit. You should probably only use this if you are not resetting correctly.");
			EmoteAudio = config.Bind<bool>("Misc", "Enable emote audio clips", true, "Plays audio when performing vanilla emotes or when taking damage. Will only work on emotes if the TME Patch is disabled.");
			fitModifier = config.Bind<float>("Body", "Fitness Modifier", 0f, "Modifier of Sylvunny's fitness. Number from 0 to 100.");
			armMuscleModifier = config.Bind<float>("Body", "Arm Muscle Modifier", 0f, "Modifier of Sylvunny's muscles. Number from 0 to 100.");
			breastModifier = config.Bind<float>("Body", "Breast Modifier", 0f, "Modifier of Sylvunny's breast size. Number from -100 to 200.");
			buttModifier = config.Bind<float>("Body", "Butt Modifier", 0f, "Modifier of Sylvunny's butt size. Number from 0 to 100.");
			hipsModifier = config.Bind<float>("Body", "Hips Modifier", 0f, "Modifier of Sylvunny's hip size. Number from 0 to 100.");
			legsModifier = config.Bind<float>("Body", "Legs Modifier", 0f, "Modifier of Sylvunny's leg size. Number from 0 to 100.");
			bellyModifier = config.Bind<float>("Body", "Belly Modifier", 0f, "Modifier of Sylvunny's belly size. Number from 0 to 100.");
			waistModifier = config.Bind<float>("Body", "Waist Modifier", 0f, "Modifier of Sylvunny's waist size. Number from 0 to 100.");
			slimModifier = config.Bind<float>("Body", "Slim Modifier", 0f, "Modifier of Sylvunny's slimness. Number from 0 to 100.");
			canonModifier = config.Bind<float>("Body", "Canon Slim Modifier", 0f, "Modifier to make Sylvunny more accurate to original Lopunny. Number from 0 to 100. Recommended that every other torso blendshape is set to 0 while using this.");
			fluffModifier = config.Bind<float>("Body", "Wrist Fluff Modifier", 0f, "Modifier of Sylvunny's wrist fluff. Number from 0 to 100.");
			fluffEnable = config.Bind<bool>("Body", "Wrist Fluff Enabler", true, "Enable Sylvunny's wrist fluff.");
		}

		private void Awake()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			string[] array = suitNamesToEnableModel.Value.Split(',');
			string[] array2 = array;
			string[] array3 = array2;
			foreach (string text in array3)
			{
				ModelReplacementAPI.RegisterSuitModelReplacement(text, typeof(MRSYLVUNNY));
			}
			if (ModelReplacementAPI.tooManyEmotesPresent)
			{
				TMEPatch = true;
				((BaseUnityPlugin)this).Logger.LogWarning((object)"TooManyEmotes was found, automatically applying compatibility patch.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"TooManyEmotes not found, disabling compatibility patch.");
				TMEPatch = false;
			}
			Harmony val = new Harmony("com.wintermantis.sylvunny");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.wintermantis.sylvunny is loaded!");
		}
	}
	public static class Assets
	{
		public class RandomAudioClip
		{
			private List<AudioClip> clipList = new List<AudioClip>();

			public AudioClip GetRandomAudio(int seed)
			{
				Random random = new Random();
				int num = random.Next(clipList.Count);
				Console.WriteLine($"Get audio N {clipList.Count} > {num}");
				return clipList[num];
			}

			public void AddAudio(string name)
			{
				AudioClip audioClipFromName = GetAudioClipFromName(name);
				if ((Object)(object)audioClipFromName != (Object)null)
				{
					clipList.Add(audioClipFromName);
				}
				else
				{
					Console.WriteLine("clip " + name + " null");
				}
			}
		}

		public static string mainAssetBundleName = "sylvunnybundle";

		public static AssetBundle MainAssetBundle = null;

		public static RandomAudioClip SSpawn = new RandomAudioClip();

		public static RandomAudioClip SDance = new RandomAudioClip();

		public static RandomAudioClip SPoint = new RandomAudioClip();

		public static RandomAudioClip SHurt = new RandomAudioClip();

		public static RandomAudioClip SDie = new RandomAudioClip();

		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);
			}
			SSpawn.AddAudio("Sylveon");
			SDance.AddAudio("Sylveon_Happy");
			SPoint.AddAudio("Sylveon_Angry");
			SPoint.AddAudio("Sylveon_Noise2");
			SHurt.AddAudio("sylv2");
			SDie.AddAudio("Sylveon_Hurt");
		}

		public static AudioClip GetAudioClipFromName(string name)
		{
			Object obj = MainAssetBundle.LoadAsset(name);
			return (AudioClip)(object)((obj is AudioClip) ? obj : null);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}