Decompiled source of Mauga PortDePaix v1.0.0

plugins/MaugaPortDePaix/MaugaPortDePaix.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using ModelReplacement;
using ModelReplacement.AvatarBodyUpdater;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MaugaPortDePaix;

[BepInPlugin("aj.mauga.portdepaix", "Mauga Port de Paix", "0.1.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	internal static GameObject Prefab;

	private AssetBundle bundle;

	private void Awake()
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_0570: Unknown result type (might be due to invalid IL or missing references)
		//IL_0594: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_060e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_064b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Unknown result type (might be due to invalid IL or missing references)
		//IL_0688: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0702: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_073f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0758: Unknown result type (might be due to invalid IL or missing references)
		//IL_077c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0795: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_080f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0833: Unknown result type (might be due to invalid IL or missing references)
		//IL_084c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0870: Unknown result type (might be due to invalid IL or missing references)
		//IL_0889: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0903: Unknown result type (might be due to invalid IL or missing references)
		//IL_0927: Unknown result type (might be due to invalid IL or missing references)
		//IL_0940: Unknown result type (might be due to invalid IL or missing references)
		//IL_0964: Unknown result type (might be due to invalid IL or missing references)
		//IL_097d: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_09de: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f7: Unknown result type (might be due to invalid IL or missing references)
		bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "maugaportassets"));
		if (!Object.op_Implicit((Object)(object)bundle))
		{
			throw new Exception("Mauga Port asset bundle missing");
		}
		Prefab = bundle.LoadAsset<GameObject>("Assets/MaugaPort/MaugaPortDePaix.prefab");
		if (!Object.op_Implicit((Object)(object)Prefab))
		{
			throw new Exception("Mauga Port prefab missing");
		}
		Animator componentInChildren = Prefab.GetComponentInChildren<Animator>();
		if (!Object.op_Implicit((Object)(object)componentInChildren) || !componentInChildren.isHuman)
		{
			throw new Exception("Mauga Port humanoid invalid");
		}
		OffsetBuilder obj = ((Component)componentInChildren).gameObject.AddComponent<OffsetBuilder>();
		obj.rootScale = Vector3.one;
		obj.rootPositionOffset = Vector3.zero;
		obj.GenerateViewModel = false;
		Apply(componentInChildren, "LeftLowerArm", new Quaternion(-0.7046245f, 0.70844114f, 0.033515144f, -0.022199526f), new Quaternion(-0.0105037745f, -0.09538018f, 0.045421287f, 0.9943487f));
		Apply(componentInChildren, "Head", new Quaternion(0.017403882f, 1.1210217E-07f, 5.577656E-08f, 0.99984884f), new Quaternion(-0.0053172777f, 2.3251351E-07f, 5.1505566E-08f, 0.9999861f));
		Apply(componentInChildren, "Left Thumb Proximal", new Quaternion(-0.21466082f, 0.6048781f, 0.749175f, 0.16364832f), new Quaternion(0.104095966f, (float)Math.E * 77f / 310f, 0.25973865f, 0.68251306f));
		Apply(componentInChildren, "Hips", new Quaternion(-0.7071069f, 5.744918E-15f, -1.0986727E-14f, 0.70710677f), new Quaternion(-0.79081154f, 1.4592635E-07f, 1.885441E-07f, 0.6120598f));
		Apply(componentInChildren, "LeftUpperArm", new Quaternion(0.7289471f, -0.68451166f, 0.0013474178f, 0.00886638f), new Quaternion(-0.026259882f, 0.07833261f, -0.011584526f, -0.99651414f));
		Apply(componentInChildren, "Right Middle Intermediate", new Quaternion(0.46973386f, 0.43143642f, 0.6687906f, -0.3820114f), new Quaternion(-0.10425274f, 0.5968648f, 0.07843716f, -0.7916644f));
		Apply(componentInChildren, "RightToes", new Quaternion(5.889287E-07f, 0.674072f, 0.73866564f, 6.397197E-08f), new Quaternion(0.001572002f, 0.024189109f, -0.028645046f, 0.999296f));
		Apply(componentInChildren, "Right Thumb Proximal", new Quaternion(0.21466017f, 0.60487825f, 0.7491752f, -0.16364768f), new Quaternion(-0.05024603f, 0.6675385f, 0.25531194f, -0.6976277f));
		Apply(componentInChildren, "Left Index Proximal", new Quaternion(-0.48711988f, 0.47100183f, 0.6308608f, 0.37800378f), new Quaternion(-0.013938686f, 0.6819777f, 0.19358613f, 0.70515054f));
		Apply(componentInChildren, "UpperChest", new Quaternion(-0.13728917f, 1.07006876E-07f, 7.2030645E-08f, 0.99053127f), new Quaternion(-0.10182974f, 2.2341894E-07f, 8.5647365E-08f, 0.9948019f));
		Apply(componentInChildren, "Right Little Intermediate", new Quaternion(0.53814834f, 0.47355324f, 0.610485f, -0.336827f), new Quaternion(-0.16132891f, 0.6320671f, 0.1863722f, -0.7346634f));
		Apply(componentInChildren, "LeftShoulder", new Quaternion(-0.46142855f, 0.5315864f, 0.46571925f, 0.5362888f), new Quaternion(0.05987964f, 0.005299839f, -0.0009534326f, 0.9981913f));
		Apply(componentInChildren, "RightUpperLeg", new Quaternion(0.9978794f, 0.05348973f, 0.0004051795f, 0.037087627f), new Quaternion(-0.020566516f, 0.032673806f, -0.041166347f, 0.9984061f));
		Apply(componentInChildren, "Chest", new Quaternion(-0.09277f, 1.1544902E-07f, 5.5689824E-08f, 0.9956877f), new Quaternion(-0.11028221f, 2.3512912E-07f, 6.446378E-08f, 0.9939004f));
		Apply(componentInChildren, "RightLowerLeg", new Quaternion(0.9987851f, 0.015411388f, -0.00027104645f, -0.046805833f), new Quaternion(0.028484266f, 0.029245792f, -0.015293689f, 0.99904937f));
		Apply(componentInChildren, "Right Middle Proximal", new Quaternion(0.4859401f, 0.47129986f, 0.62978125f, -0.38093945f), new Quaternion(0.04448355f, 0.6578162f, 0.17750603f, -0.73061043f));
		Apply(componentInChildren, "LeftLowerLeg", new Quaternion(0.9987852f, -0.015411392f, 0.00027105297f, -0.046805844f), new Quaternion(17f / (164f * (float)Math.PI), -0.02966162f, 0.017516213f, 0.9988618f));
		Apply(componentInChildren, "Spine", new Quaternion(0.0050373916f, 1.0927937E-07f, 9.043406E-09f, 0.9999875f), new Quaternion(-0.090695515f, 2.283612E-07f, 9.354435E-09f, 0.9958787f));
		Apply(componentInChildren, "LeftHand", new Quaternion(0.7641798f, -0.64218247f, -0.05502292f, 0.024576299f), new Quaternion(0.1462848f, -0.68713367f, -0.0068933833f, -0.7116184f));
		Apply(componentInChildren, "RightUpperArm", new Quaternion(0.728947f, 0.68451184f, -0.0013476958f, 0.008866387f), new Quaternion(-0.003734426f, 0.6880562f, 0.00029217143f, -0.72564846f));
		Apply(componentInChildren, "Right Ring Proximal", new Quaternion(0.48196203f, 0.468968f, 0.6268595f, -0.39348376f), new Quaternion(0.022951754f, 0.6427967f, 0.22274269f, -0.7325793f));
		Apply(componentInChildren, "Left Ring Proximal", new Quaternion(-0.48196164f, 0.4689686f, 0.62685907f, 0.39348432f), new Quaternion(0.037790608f, 0.6583081f, 0.2626676f, 0.70442104f));
		Apply(componentInChildren, "RightLowerArm", new Quaternion(0.70462453f, 0.70844114f, 0.033515204f, 0.022199588f), new Quaternion(0.036936495f, -0.1675329f, 0.039932106f, -0.9843653f));
		Apply(componentInChildren, "Left Middle Intermediate", new Quaternion(-0.46973544f, 0.43143392f, 0.6687935f, 0.38200715f), new Quaternion(0.13288003f, 0.6527844f, 0.060467158f, 0.74334383f));
		Apply(componentInChildren, "RightFoot", new Quaternion(0.89587235f, 4.2992934E-07f, 7.5390126E-08f, 0.44431153f), new Quaternion(-0.0015695206f, 0.03569569f, 0.011470113f, 0.99929583f));
		Apply(componentInChildren, "Right Index Intermediate", new Quaternion(0.51879776f, 0.46810317f, 0.6291544f, -0.34043184f), new Quaternion(-0.09156327f, 0.6723106f, 0.050513975f, -0.7328465f));
		Apply(componentInChildren, "LeftFoot", new Quaternion(0.8958725f, -4.0969712E-07f, -6.58795E-08f, 0.44431162f), new Quaternion(0.0029454872f, -0.037284967f, -0.010713695f, 0.99924314f));
		Apply(componentInChildren, "Left Little Proximal", new Quaternion(-0.42731124f, 0.43113172f, 0.66927296f, 0.4284914f), new Quaternion(0.049730502f, 0.6636151f, 0.25199392f, 0.7025965f));
		Apply(componentInChildren, "RightShoulder", new Quaternion(-0.46142697f, -0.53158784f, -0.46571773f, 0.53629017f), new Quaternion(0.061919242f, -0.0053016753f, 0.0009424845f, 0.9980669f));
		Apply(componentInChildren, "Left Index Intermediate", new Quaternion(-0.5187976f, 0.46810392f, 0.6291542f, 0.34043142f), new Quaternion(0.16441715f, 0.7087535f, 0.0039437767f, 0.68601793f));
		Apply(componentInChildren, "LeftToes", new Quaternion(-5.731474E-07f, 0.6740723f, 0.7386655f, -5.111725E-08f), new Quaternion(-0.0029435526f, -0.02593908f, 0.028846247f, 0.9992432f));
		Apply(componentInChildren, "Right Index Proximal", new Quaternion(0.48711902f, 0.47100252f, 0.63086075f, -0.37800395f), new Quaternion(0.066287056f, 0.6718245f, 0.1096749f, -0.72954106f));
		Apply(componentInChildren, "Left Middle Proximal", new Quaternion(-0.48594126f, 0.471299f, 0.6297812f, 0.38093925f), new Quaternion(0.02288521f, 0.6746723f, 0.18444186f, 0.71433556f));
		Apply(componentInChildren, "Right Ring Intermediate", new Quaternion(0.509517f, 0.47900414f, 0.62906045f, -0.33945718f), new Quaternion(-0.15616556f, 0.63118553f, 0.15121324f, -0.74454886f));
		Apply(componentInChildren, "Right Little Proximal", new Quaternion(0.4273102f, 0.43113294f, 0.66927266f, -0.4284917f), new Quaternion(0.03761272f, 0.5724875f, 0.29404625f, -0.7644481f));
		Apply(componentInChildren, "Left Ring Intermediate", new Quaternion(-0.5095167f, 0.4790051f, 0.6290594f, 0.33945817f), new Quaternion(0.17432314f, 0.6889039f, 11f / (36f * (float)Math.PI), 0.6968238f));
		Apply(componentInChildren, "LeftUpperLeg", new Quaternion(0.99787945f, -0.05348973f, -0.0004051795f, 0.037087627f), new Quaternion(-0.016086996f, -0.033524282f, 0.04332151f, 0.9983691f));
		Apply(componentInChildren, "RightHand", new Quaternion(0.76418f, 0.64218235f, 0.05502296f, 0.024576146f), new Quaternion(0.13572784f, 0.6610523f, -0.016803715f, -0.7377711f));
		Apply(componentInChildren, "Left Little Intermediate", new Quaternion(-0.53814787f, 0.47355482f, 0.6104829f, 0.33682948f), new Quaternion(193f / (279f * (float)Math.PI), 0.6290908f, 0.2238834f, 0.7110817f));
		ModelReplacementAPI.RegisterSuitModelReplacement("Mauga Port de Paix", typeof(PortBody));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mauga Port de Paix normal-sized suit registered.");
	}

	private static void Apply(Animator anim, string human, Quaternion referenceRotation, Quaternion referenceOffset)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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)
		int num = Array.IndexOf(HumanTrait.BoneName, human);
		if (num >= 0)
		{
			Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)num);
			if (Object.op_Implicit((Object)(object)boneTransform))
			{
				((Component)boneTransform).gameObject.AddComponent<RotationOffset>().offset = referenceOffset * Quaternion.Inverse(referenceRotation) * boneTransform.rotation;
			}
		}
	}
}
public class PortBody : BodyReplacementBase
{
	private static Material eyeMaterial;

	protected override GameObject LoadAssetsAndReturnModel()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		SkinnedMeshRenderer[] componentsInChildren = Plugin.Prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
		foreach (SkinnedMeshRenderer val in componentsInChildren)
		{
			if (((Object)val).name.IndexOf("Eyes", StringComparison.OrdinalIgnoreCase) < 0)
			{
				continue;
			}
			Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
			for (int j = 0; j < sharedMaterials.Length; j++)
			{
				if (!Object.op_Implicit((Object)(object)eyeMaterial))
				{
					Texture mainTexture = sharedMaterials[j].mainTexture;
					Shader val2 = Shader.Find("HDRP/Lit");
					if (!Object.op_Implicit((Object)(object)val2))
					{
						val2 = ((Renderer)((BodyReplacementBase)this).controller.thisPlayerModel).sharedMaterial.shader;
					}
					eyeMaterial = new Material(val2)
					{
						name = "Mauga Port Eyes"
					};
					eyeMaterial.SetTexture("_BaseColorMap", mainTexture);
					eyeMaterial.SetColor("_BaseColor", Color.white);
					eyeMaterial.SetFloat("_Metallic", 0f);
					eyeMaterial.SetFloat("_Smoothness", 0.35f);
					eyeMaterial.SetFloat("_AORemapMin", 1f);
					eyeMaterial.SetFloat("_AORemapMax", 1f);
					eyeMaterial.SetFloat("_NormalScale", 0f);
					eyeMaterial.SetFloat("_EnableSpecularOcclusion", 0f);
					eyeMaterial.SetFloat("_SupportDecals", 0f);
					eyeMaterial.SetFloat("_ReceivesSSR", 0f);
					eyeMaterial.SetFloat("_UseEmissiveIntensity", 0f);
					eyeMaterial.SetTexture("_EmissiveColorMap", mainTexture);
					eyeMaterial.SetColor("_EmissiveColor", new Color(0.035f, 0.035f, 0.035f, 1f));
					eyeMaterial.SetFloat("_EmissiveExposureWeight", 1f);
					HDMaterial.ValidateMaterial(eyeMaterial);
				}
				sharedMaterials[j] = eyeMaterial;
			}
			((Renderer)val).sharedMaterials = sharedMaterials;
		}
		return Plugin.Prefab;
	}
}