Decompiled source of Thiccify v2.0.6

Thiccify.dll

Decompiled 7 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Thiccify")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Thiccify")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b08018bb-0896-410e-9dfc-4b3bc456ef3e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Thiccify;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Lodington.Thiccify", "Thiccify", "2.0.3")]
public class ThiccMod : BaseUnityPlugin
{
	private bool isThicc = false;

	private bool setupThicc = false;

	private bool removeScarfAndSkirt = true;

	private bool applyRuntimeMeshModification = true;

	private bool mageMeshThicc = false;

	private bool huntressMeshThicc = false;

	private Vector3 thighPositionLeft = Vector3.zero;

	private Vector3 thighPositionRight = Vector3.zero;

	private Vector3 calfPositionLeft = Vector3.zero;

	private Vector3 calfPositionRight = Vector3.zero;

	private Vector3 pelvisPosition = Vector3.zero;

	public void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		CharacterBody.Start += (hook_Start)delegate(orig_Start orig, CharacterBody self)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			//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)
			//IL_00b3: 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_00b8: 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)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (self.isPlayerControlled)
			{
				Transform modelTransform = self.modelLocator.modelTransform;
				bool flag = Object.op_Implicit((Object)(object)modelTransform.Find("MageArmature"));
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(1.25f, 1.25f, 1.25f);
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(1f, 1f, 1f);
				val2 = Vector3.Scale(val2, new Vector3(1f, 1f / val.y, 1f));
				Vector3 localScale = default(Vector3);
				((Vector3)(ref localScale))..ctor(1.1f, 1f, 1.1f);
				Vector3 val3 = (Vector3)(flag ? new Vector3(0f, 0f, 0.05f) : Vector3.zero);
				Vector3 zero = Vector3.zero;
				Vector3 val4 = Vector3.Scale(zero, new Vector3(0f, -1f, 0f));
				Vector3 val5 = default(Vector3);
				((Vector3)(ref val5))..ctor(-1f, 1f, 1f);
				Transform val6 = null;
				for (int i = 0; i < modelTransform.childCount; i++)
				{
					Transform child = modelTransform.GetChild(i);
					if (Object.op_Implicit((Object)(object)child.Find("ROOT")))
					{
						val6 = child;
						break;
					}
				}
				if (Object.op_Implicit((Object)(object)val6))
				{
					Vector3 val7 = default(Vector3);
					((Vector3)(ref val7))..ctor(val.x, 1f, val.z);
					Transform val8 = val6.Find("ROOT/IKLegTarget.l");
					if (Object.op_Implicit((Object)(object)val8))
					{
						val8.localPosition = Vector3.Scale(val8.localPosition, val7);
					}
					Transform val9 = val6.Find("ROOT/IKLegTarget.r");
					if (Object.op_Implicit((Object)(object)val9))
					{
						val9.localPosition = Vector3.Scale(val9.localPosition, val7);
					}
					Transform val10 = val6.Find("ROOT/base/pelvis");
					if (Object.op_Implicit((Object)(object)val10))
					{
						if (!setupThicc)
						{
							pelvisPosition = val10.localPosition;
						}
						val10.localScale = val;
						val10.localPosition = pelvisPosition + val3;
						Transform val11 = val10.Find("thigh.r");
						Transform val12 = val10.Find("thigh.l");
						if (Object.op_Implicit((Object)(object)val11))
						{
							val11.localScale = val2;
							Transform val13 = val11.Find("calf.r");
							if (Object.op_Implicit((Object)(object)val13))
							{
								val13.localScale = localScale;
								if (!setupThicc)
								{
									thighPositionRight = val11.localPosition;
									calfPositionRight = val13.localPosition;
								}
								val13.localPosition = calfPositionRight + val4;
							}
							val11.localPosition = thighPositionRight + zero;
						}
						if (Object.op_Implicit((Object)(object)val12))
						{
							val12.localScale = val2;
							Transform val14 = val12.Find("calf.l");
							if (Object.op_Implicit((Object)(object)val14))
							{
								val14.localScale = localScale;
								if (!setupThicc)
								{
									thighPositionLeft = val12.localPosition;
									calfPositionLeft = val14.localPosition;
								}
								val14.localPosition = calfPositionLeft + val4;
							}
							val12.localPosition = thighPositionLeft + Vector3.Scale(zero, val5);
						}
						setupThicc = true;
					}
				}
				MakeThicc(self);
			}
		};
	}

	private void MakeThicc(CharacterBody self)
	{
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: 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_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0439: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_043d: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: 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_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0492: 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_04fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0542: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0553: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		//IL_0569: Unknown result type (might be due to invalid IL or missing references)
		Transform modelTransform = self.modelLocator.modelTransform;
		Transform val = null;
		for (int i = 0; i < modelTransform.childCount; i++)
		{
			Transform child = modelTransform.GetChild(i);
			if (Object.op_Implicit((Object)(object)child.Find("ROOT")))
			{
				val = child;
				break;
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		Transform val2 = val.Find("ROOT/base/stomach/chest");
		Transform val3 = val.Find("ROOT/base/stomach/chest/neck/head");
		Transform val4 = val.Find("ROOT/base/stomach/pelvis");
		Vector3 val5 = default(Vector3);
		((Vector3)(ref val5))..ctor(float.NaN, float.NaN, float.NaN);
		if (Object.op_Implicit((Object)(object)modelTransform.Find("MageArmature")))
		{
			if (removeScarfAndSkirt)
			{
				((Component)modelTransform.Find("MageCapeMesh")).gameObject.SetActive(false);
			}
			if (applyRuntimeMeshModification)
			{
				for (int j = 0; j < val2.childCount; j++)
				{
					Transform child2 = val2.GetChild(j);
					if (((Object)child2).name == "JetsOn")
					{
						child2.localScale = Vector3.zero;
					}
					if (((Object)child2).name == "Jets, Right" || ((Object)child2).name == "Jets, Left")
					{
						child2.localScale = Vector3.zero;
					}
				}
				if (!mageMeshThicc)
				{
					SkinnedMeshRenderer component = ((Component)modelTransform.Find("MageMesh")).GetComponent<SkinnedMeshRenderer>();
					Mesh sharedMesh = component.sharedMesh;
					Vector3[] vertices = sharedMesh.vertices;
					BoneWeight[] boneWeights = sharedMesh.boneWeights;
					List<Vector2> list = new List<Vector2>();
					component.sharedMesh.GetUVs(0, list);
					float[] array = new float[17]
					{
						0.15552373f, 0.16142187f, 0.04235405f, 0.0021066386f, 0.11552343f, 0.16974647f, 0.16044061f, 0.54730904f, 0.20829754f, 0.17509449f,
						0.5473088f, 0.5701668f, 0.46927318f, 0.17111078f, 0.17274976f, 0.9341732f, 0.79017234f
					};
					for (int k = 0; k < vertices.Length; k++)
					{
						Vector2 val6 = list[k];
						BoneWeight val7 = boneWeights[k];
						if (((BoneWeight)(ref val7)).boneIndex0 != 3)
						{
							continue;
						}
						for (int l = 0; l < array.Length; l++)
						{
							if (val6.y < 0.3f || Mathf.Abs(val6.x - array[l]) < 0.0005f || Mathf.Abs(val6.y - array[l]) < 0.0005f)
							{
								vertices[k] = val5;
								break;
							}
						}
					}
					component.sharedMesh.vertices = vertices;
					mageMeshThicc = true;
				}
			}
		}
		else if (Object.op_Implicit((Object)(object)modelTransform.Find("HuntressArmature")))
		{
			if (removeScarfAndSkirt)
			{
				((Component)modelTransform.Find("HuntressScarfMesh")).gameObject.SetActive(false);
			}
			if (!huntressMeshThicc && applyRuntimeMeshModification)
			{
				SkinnedMeshRenderer component2 = ((Component)modelTransform.Find("HuntressMesh")).GetComponent<SkinnedMeshRenderer>();
				Mesh sharedMesh2 = component2.sharedMesh;
				Vector3[] vertices2 = sharedMesh2.vertices;
				BoneWeight[] boneWeights2 = sharedMesh2.boneWeights;
				List<Vector2> list2 = new List<Vector2>();
				List<Color32> list3 = new List<Color32>();
				Color32 val8 = default(Color32);
				((Color32)(ref val8))..ctor((byte)0, (byte)0, (byte)0, byte.MaxValue);
				component2.sharedMesh.GetColors(list3);
				component2.sharedMesh.GetUVs(0, list2);
				Vector2 val9 = default(Vector2);
				((Vector2)(ref val9))..ctor(0.7746712f, 0.6335765f);
				Vector3 val10 = default(Vector3);
				((Vector3)(ref val10))..ctor(0f, -0.044645f, 1.419872f);
				Vector3 val11 = default(Vector3);
				((Vector3)(ref val11))..ctor(0.071101f, -0.146735f, 1.416376f);
				for (int m = 0; m < vertices2.Length; m++)
				{
					Vector2 val12 = list2[m];
					BoneWeight val13 = boneWeights2[m];
					if ((((BoneWeight)(ref val13)).boneIndex0 == 39) & (val12.x > 0.6699667f || Mathf.Abs(val12.x - 0.59991926f) < 0.0001f))
					{
						vertices2[m] = val5;
					}
					else if (((BoneWeight)(ref val13)).boneIndex0 == 3)
					{
						Vector3 val14 = vertices2[m];
						float num = Vector2.Distance(val12, val9);
						if (num < 0.05f)
						{
							vertices2[m] = val5;
							val14 = val5;
						}
						else if (val12.x == 0.5669036f || val12.x == 0.58371633f || val12.x == 0.6001201f || val12.x == 0.6146834f || val12.x == 0.6304007f)
						{
							list2[m] = new Vector2(0.63695055f, 0.63893116f);
						}
						if (Mathf.Abs(val14.x) < 0.0765f && val14.y < -0.0875f && val14.x == 0f)
						{
							float num2 = 1f - Mathf.Min(1f, Mathf.Abs(val14.z - 1.317341f) / 0.22f);
							vertices2[m] = Vector3.Lerp(val14, val10, num2 * 0.4f);
							list3[m] = Color32.Lerp(list3[m], val8, num2);
						}
					}
				}
				component2.sharedMesh.vertices = vertices2;
				component2.sharedMesh.SetUVs(0, list2);
				component2.sharedMesh.SetColors(list3);
				component2.sharedMesh.RecalculateNormals();
				huntressMeshThicc = true;
			}
		}
		isThicc = true;
	}
}