Decompiled source of Extended Player Names v1.1.0

CWEXTCUSTOM.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CWEXTCUSTOM")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CWEXTCUSTOM")]
[assembly: AssemblyTitle("CWEXTCUSTOM")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ContentWarningPlugin;

[HarmonyPatch(typeof(PlayerVisor))]
internal class PlayerVisorPatch
{
	[HarmonyPatch("RPCA_SetVisorText")]
	[HarmonyPrefix]
	private static bool SetVisorTextPatch(ref PlayerVisor __instance, string text)
	{
		((TMP_Text)__instance.visorFaceText).text = text;
		return false;
	}

	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	private static void AwakePatch(ref PlayerVisor __instance)
	{
		((TMP_Text)__instance.visorFaceText).enableWordWrapping = false;
	}
}
[HarmonyPatch(typeof(PlayerCustomizer))]
internal class CustomizerPatch
{
	private static float sizeDelta;

	private static float pasteDelta;

	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	private static void AwakePatch(ref PlayerCustomizer __instance)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0067: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		float num = (__instance.faceSizeMinMax.y - __instance.faceSizeMinMax.x) / (float)__instance.faceSizeStepCount;
		Vector2 val = __instance.visorFaceSizeMinMax / __instance.faceSizeMinMax;
		sizeDelta = num;
		__instance.faceSizeMinMax = new Vector2(__instance.faceSizeMinMax.x - num * 4f, __instance.faceSizeMinMax.y + num * 8f);
		__instance.visorFaceSizeMinMax = __instance.faceSizeMinMax * val;
		((TMP_Text)__instance.faceText).enableWordWrapping = false;
	}

	[HarmonyPatch("RPCA_ChangeFaceSize")]
	[HarmonyPrefix]
	private static bool ChangeFaceSizePatch(ref PlayerCustomizer __instance, bool smaller)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance.playerInTerminal == (Object)null))
		{
			float num = ((TMP_Text)__instance.faceText).transform.localScale.x + (smaller ? (0f - sizeDelta) : sizeDelta);
			float num3 = (__instance.FaceSize = Mathf.Clamp(num, __instance.faceSizeMinMax.x, __instance.faceSizeMinMax.y));
			num = num3;
			float faceSize = __instance.FaceSizeUiToVisor(num);
			__instance.playerInTerminal.refs.visor.FaceSize = faceSize;
		}
		return false;
	}

	[HarmonyPatch("SetFaceText")]
	[HarmonyPrefix]
	private static bool SetFaceTextPatch(ref PlayerCustomizer __instance, string text)
	{
		if (Object.op_Implicit((Object)(object)__instance.playerInTerminal))
		{
			((TMP_Text)__instance.faceText).text = text;
			((TMP_Text)__instance.playerInTerminal.refs.visor.visorFaceText).text = text;
		}
		return false;
	}

	[HarmonyPatch("EnterTerminal")]
	[HarmonyPrefix]
	private static void EnterTerminalPatch()
	{
		Input.imeCompositionMode = (IMECompositionMode)1;
	}

	[HarmonyPatch("OnDestroy")]
	[HarmonyPrefix]
	private static void OnDestroyPatch()
	{
		Input.imeCompositionMode = (IMECompositionMode)0;
	}

	[HarmonyPatch("OnApply")]
	[HarmonyPrefix]
	private static void OnApplyPatch()
	{
		Input.imeCompositionMode = (IMECompositionMode)0;
	}

	[HarmonyPatch("OnQuit")]
	[HarmonyPrefix]
	private static void OnQuitPatch()
	{
		Input.imeCompositionMode = (IMECompositionMode)0;
	}

	[HarmonyPatch("RunTerminal")]
	[HarmonyPrefix]
	private static bool RunTerminalPatch(ref PlayerCustomizer __instance)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		PhotonView val = (PhotonView)Traverse.Create((object)__instance).Field("view_g").GetValue();
		if (Input.GetKeyDown((KeyCode)27))
		{
			__instance.backSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
			val.RPC("RPCA_PlayerLeftTerminal", (RpcTarget)0, new object[1] { false });
			pasteDelta = 0f;
		}
		else if (Input.GetKeyDown((KeyCode)127))
		{
			__instance.typeSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
			val.RPC("SetFaceText", (RpcTarget)0, new object[1] { "" });
		}
		else if (Input.GetKey((KeyCode)306) && Input.GetKey((KeyCode)118))
		{
			if (pasteDelta <= 0f)
			{
				pasteDelta += 0.1f;
				__instance.typeSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
				val.RPC("SetFaceText", (RpcTarget)0, new object[1] { ((TMP_Text)__instance.faceText).text + GUIUtility.systemCopyBuffer });
			}
			else
			{
				pasteDelta -= Time.deltaTime;
			}
		}
		else
		{
			string inputString = Input.inputString;
			if (inputString.Length >= 1)
			{
				if (inputString.StartsWith("\b"))
				{
					__instance.backSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
					if (((TMP_Text)__instance.faceText).text.Length != 0)
					{
						StringInfo stringInfo = new StringInfo(((TMP_Text)__instance.faceText).text);
						string text = stringInfo.SubstringByTextElements(0, stringInfo.LengthInTextElements - 1);
						val.RPC("SetFaceText", (RpcTarget)0, new object[1] { text });
					}
				}
				else if ((byte)inputString[0] == 13)
				{
					__instance.backSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
					val.RPC("SetFaceText", (RpcTarget)0, new object[1] { ((TMP_Text)__instance.faceText).text + "\n" });
				}
				else
				{
					__instance.typeSound.Play(((Component)__instance).transform.position, false, 1f, (Transform)null);
					val.RPC("SetFaceText", (RpcTarget)0, new object[1] { ((TMP_Text)__instance.faceText).text + inputString });
				}
			}
			pasteDelta = 0f;
		}
		return false;
	}
}
[BepInPlugin("CWEXTCUSTOM", "CWEXTCUSTOM", "1.0.0")]
[BepInProcess("Content Warning.exe")]
public class Plugin : BaseUnityPlugin
{
	private Harmony _harmony;

	private void Awake()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CWEXTCUSTOM is loaded!");
		_harmony = new Harmony("CWEXTCUSTOM");
		_harmony.PatchAll();
	}

	private void Update()
	{
	}
}
public static class MyPluginInfo
{
	public const string PLUGIN_GUID = "CWEXTCUSTOM";

	public const string PLUGIN_NAME = "CWEXTCUSTOM";

	public const string PLUGIN_VERSION = "1.0.0";
}