Decompiled source of MoreCustomization v1.0.5

BepInEx/plugins/FaceCustomization.dll

Decompiled 8 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using TMPro;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FaceCustomization")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FaceCustomization")]
[assembly: AssemblyTitle("FaceCustomization")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourdomain.FaceCustomization", "Face Customization", "1.0.4")]
public class Class1 : BaseUnityPlugin
{
	[HarmonyPatch(typeof(PlayerCustomizer), "RunTerminal")]
	public static class PlayerCustomizer_RunTerminal_Patch
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_I4_3)
				{
					list[i].opcode = OpCodes.Ldc_I4;
					list[i].operand = 128;
					break;
				}
			}
			return list.AsEnumerable();
		}
	}

	[HarmonyPatch(typeof(PlayerCustomizer))]
	public class PlayerCustomizerPatches
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePostfix(PlayerCustomizer __instance, TextMeshProUGUI ___faceText, PhotonView ___view_g)
		{
			if (Input.GetKey((KeyCode)127))
			{
				___view_g.RPC("SetFaceText", (RpcTarget)0, new object[1] { "" });
			}
			else if ((Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)118))
			{
				string systemCopyBuffer = GUIUtility.systemCopyBuffer;
				___view_g.RPC("SetFaceText", (RpcTarget)0, new object[1] { systemCopyBuffer });
			}
			else if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
			{
				string text = ((TMP_Text)___faceText).text;
				string text2 = text + "\n";
				___view_g.RPC("SetFaceText", (RpcTarget)0, new object[1] { text2 });
			}
		}
	}

	[HarmonyPatch(typeof(PlayerCustomizer), "RunTerminal")]
	public static class PlayerCustomizer_RunTerminal_Paste
	{
		[HarmonyPostfix]
		public static void PostfixRunTerminal(PlayerCustomizer __instance)
		{
			if ((Object)(object)__instance.faceText != (Object)null)
			{
				((TMP_Text)__instance.faceText).enableAutoSizing = true;
				((TMP_Text)__instance.faceText).fontSizeMin = 10f;
				((TMP_Text)__instance.faceText).fontSizeMax = 40f;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerCustomizer))]
	public static class Patch_PlayerCustomizer
	{
		[HarmonyPatch("SetFaceText")]
		[HarmonyPostfix]
		public static void PostfixSetFaceText(ref PlayerCustomizer __instance, string text)
		{
			if (Object.op_Implicit((Object)(object)__instance.playerInTerminal))
			{
				Debug.Log((object)("Patching SetFaceText with full text: " + text));
				((TMP_Text)__instance.faceText).text = text;
				((TMP_Text)__instance.playerInTerminal.refs.visor.visorFaceText).text = text;
				if ((Object)(object)__instance.faceText != (Object)null)
				{
					((TMP_Text)__instance.faceText).enableAutoSizing = true;
					((TMP_Text)__instance.faceText).fontSizeMin = 10f;
					((TMP_Text)__instance.faceText).fontSizeMax = 40f;
				}
			}
		}
	}

	[HarmonyPatch(typeof(PlayerVisor), "RPCA_SetVisorText")]
	public static class Patch_PlayerVisor
	{
		[HarmonyPrefix]
		public static bool PrefixRPCA_SetVisorText(PlayerVisor __instance, ref string text)
		{
			if ((Object)(object)__instance.visorFaceText != (Object)null)
			{
				((TMP_Text)__instance.visorFaceText).text = text;
				((TMP_Text)__instance.visorFaceText).enableAutoSizing = true;
				((TMP_Text)__instance.visorFaceText).fontSizeMin = 10f;
				((TMP_Text)__instance.visorFaceText).fontSizeMax = 40f;
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(PlayerCustomizer), "OnChangeFaceSize")]
	public class PlayerCustomizer_OnChangeFaceSize_Patch
	{
		private static bool Prefix(PlayerCustomizer __instance, bool smaller)
		{
			//IL_000c: 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)
			float x = ((TMP_Text)__instance.faceText).transform.localScale.x;
			float num = 0.05f;
			float num2 = (smaller ? (x - num) : (x + num));
			((TMP_Text)__instance.faceText).transform.localScale = new Vector3(num2, num2, 1f);
			Debug.Log((object)$"Adjusted face size to: {num2}");
			return false;
		}
	}

	private const string modGUID = "x002.Face Customization";

	private const string modName = "FaceCustomization";

	private const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("x002.Face Customization");

	private void Awake()
	{
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin x002.Face Customization is loaded!");
	}
}