Decompiled source of Maranaras Models v0.1.1

plugins/VS.dll

Decompiled a week 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 Dissonance;
using GameNetcodeStuff;
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("VS")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VS")]
[assembly: AssemblyTitle("VS")]
[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;
		}
	}
}
public class AvatarFace : MonoBehaviour
{
	[Header("Blinking")]
	public Renderer eyeMR;

	public int matOffset;

	public Vector2 blinkUvOffset;

	private Vector2 openUvOffset;

	public float blinkLength;

	public float blinkFrequency;

	public float blinkVariance;

	public float blinkBrowHeight;

	private float blinkT;

	private bool blunked;

	private float blinkD;

	private bool eyeClosed;

	[Header("Brow")]
	public Transform lfBrow;

	public Transform rtBrow;

	public float browSpeed;

	public float browADSHeight;

	private Vector3 dBrowPosL;

	private Vector3 dBrowPosR;

	public float lfBrowHeight;

	public float rtBrowHeight;

	private Transform head;

	private void Awake()
	{
		GetRefs();
	}

	private void OnEnable()
	{
	}

	private void OnDisable()
	{
	}

	private void Log(string log)
	{
	}

	private void GetRefs()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//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)
		dBrowPosL = lfBrow.localPosition;
		dBrowPosR = rtBrow.localPosition;
		openUvOffset = eyeMR.sharedMaterials[matOffset].mainTextureOffset;
	}

	private void Update()
	{
		if (blinkT > 0f)
		{
			if (!blunked && blinkT < blinkD - blinkLength)
			{
				if (!eyeClosed)
				{
					Blink(open: true);
				}
				blunked = true;
			}
			blinkT -= Time.deltaTime;
		}
		else
		{
			BlinkTick();
		}
		BrowTick();
	}

	private void BrowTick()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: 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)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = dBrowPosL;
		val.y += lfBrowHeight;
		lfBrow.localPosition = Vector3.Lerp(lfBrow.localPosition, val, browSpeed * Time.deltaTime);
		Vector3 val2 = dBrowPosR;
		val2.y += rtBrowHeight;
		rtBrow.localPosition = Vector3.Lerp(rtBrow.localPosition, val2, browSpeed * Time.deltaTime);
	}

	private void BlinkTick()
	{
		blinkD = blinkFrequency + Random.Range(0f - blinkVariance, blinkVariance);
		blinkT = blinkD;
		Blink(open: false);
		blunked = false;
	}

	public void ToggleEye(bool open)
	{
		eyeClosed = !open;
		Blink(open);
	}

	private void Blink(bool open)
	{
		//IL_005a: 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)
		if (open)
		{
			lfBrowHeight = 0f;
			rtBrowHeight = 0f;
		}
		else
		{
			lfBrowHeight = blinkBrowHeight;
			rtBrowHeight = blinkBrowHeight;
		}
		int num = matOffset;
		eyeMR.materials[num].mainTextureOffset = (open ? openUvOffset : blinkUvOffset);
	}
}
public class JawSync : MonoBehaviour
{
	public PlayerControllerB player;

	public float maxJawOpening = 35f;

	public float sensibility = 80f;

	protected VoicePlayerState voice;

	private void Start()
	{
	}

	private void Update()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)StartOfRound.Instance.voiceChatModule == (Object)null)
		{
			return;
		}
		if (voice == null)
		{
			Init();
		}
		if (voice != null)
		{
			float num = 0f;
			float num2 = voice.Amplitude * sensibility;
			if (voice.IsSpeaking)
			{
				num = Mathf.Clamp(num2, 0f, maxJawOpening);
			}
			num += 98f;
			Quaternion localRotation = ((Component)this).transform.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			((Component)this).transform.localRotation = Quaternion.Euler(num, eulerAngles.y, eulerAngles.z);
		}
	}

	public void Init()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0044: Expected O, but got Unknown
		StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
		voice = player.voicePlayerState;
		if (voice == null && (Object)player == (Object)StartOfRound.Instance.localPlayerController)
		{
			voice = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName);
		}
	}
}
namespace MilksoupProtag
{
	public class MRMILKSOUPPROTAGONIST : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "MilksoupProtagonist";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRMARAPOSS : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "PossMaraArmature";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void AddModelScripts()
		{
			((BodyReplacementBase)this).AddModelScripts();
			Transform val = base.replacementModel.transform.Find("Mara.001/mixamorig:Hips/mixamorig:Spine/mixamorig:Spine1/mixamorig:Spine2/mixamorig:Neck/mixamorig:Head/mixamorig:Jaw");
			JawSync jawSync = ((Component)val).gameObject.AddComponent<JawSync>();
			jawSync.player = ((BodyReplacementBase)this).controller;
			jawSync.Init();
		}
	}
	[BepInPlugin("com.maranara.milksoupprotag", "Milksoup Protagonist Model", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

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

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

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

		private static void InitConfig()
		{
			enableModelForAllSuits = config.Bind<bool>("Suits to Replace Settings", "Enable Model for all Suits", false, "Enable to model replace every suit. Set to false to specify suits");
			enableModelAsDefault = config.Bind<bool>("Suits to Replace Settings", "Enable Model as default", false, "Enable to model replace every suit that hasn't been otherwise registered.");
			suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for", "Default,Orange suit", "Enter a comma separated list of suit names.(Additionally, [Green suit,Pajama suit,Hazard suit])");
		}

		private void Awake()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			ModelReplacementAPI.RegisterSuitModelReplacement("Milksoup Protagonist", typeof(MRMILKSOUPPROTAGONIST));
			ModelReplacementAPI.RegisterSuitModelReplacement("Maranara (Poss)", typeof(MRMARAPOSS));
			Harmony val = new Harmony("com.maranara.milksoupprotag");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.maranara.milksoupprotag is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "milksoupprotagonist";

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