using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
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("SignalTranslatorAligner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("SignalTranslatorAligner")]
[assembly: AssemblyTitle("SignalTranslatorAligner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace SignalTranslatorAligner;
[HarmonyPatch(typeof(HUDManager), "DisplaySignalTranslatorMessage")]
internal class DisplaySignalTranslatorMessage
{
private static void Prefix(ref bool __runOriginal, ref IEnumerator __result, Animator ___signalTranslatorAnimator, AudioSource ___UIAudio, TextMeshProUGUI ___signalTranslatorText, string signalMessage, int seed, SignalTranslator signalTranslator)
{
__runOriginal = false;
Plugin.Instance.LogInfo("DisplaySignalTranslatorMessage hooked");
__result = ReplacedRoutine();
IEnumerator ReplacedRoutine()
{
Random signalMessageRandom = new Random(seed + StartOfRound.Instance.randomMapSeed);
___signalTranslatorAnimator.SetBool("transmitting", true);
signalTranslator.localAudio.Play();
___UIAudio.PlayOneShot(signalTranslator.startTransmissionSFX, 1f);
string trimedMessage = signalMessage.Trim();
((TMP_Text)___signalTranslatorText).text = "<#00000000>" + trimedMessage + "</color>";
yield return (object)new WaitForSeconds(1.21f);
for (int i = 0; i <= trimedMessage.Length; i++)
{
if ((Object)(object)signalTranslator == (Object)null)
{
break;
}
if (!((Component)signalTranslator).gameObject.activeSelf)
{
break;
}
___UIAudio.PlayOneShot(signalTranslator.typeTextClips[Random.Range(0, signalTranslator.typeTextClips.Length)]);
string text = trimedMessage.Substring(0, i) + "<#00000000>" + trimedMessage.Substring(i, trimedMessage.Length - i) + "</color>";
((TMP_Text)___signalTranslatorText).text = text;
float num = Mathf.Min((float)signalMessageRandom.Next(-1, 4) * 0.5f, 0f);
yield return (object)new WaitForSeconds(0.7f + num);
}
if ((Object)(object)signalTranslator != (Object)null)
{
___UIAudio.PlayOneShot(signalTranslator.finishTypingSFX);
signalTranslator.localAudio.Stop();
}
yield return (object)new WaitForSeconds(0.5f);
___signalTranslatorAnimator.SetBool("transmitting", false);
}
}
}
[HarmonyPatch(typeof(HUDManager), "Awake")]
internal class AwakePatch
{
private static void Postfix(TextMeshProUGUI ___signalTranslatorText)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0032: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
Transform parent = ((TMP_Text)___signalTranslatorText).transform.GetParent();
RectTransform val = (RectTransform)parent.GetChild(1);
RectTransform val2 = (RectTransform)parent.GetChild(2);
val.anchorMin = new Vector2(0f, 0.5f);
val.anchorMax = new Vector2(1f, 0.5f);
val.sizeDelta = new Vector2(0f, val.sizeDelta.y);
TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
((TMP_Text)component).margin = new Vector4(0f, 0f, val.anchoredPosition.x * 2f, 0f);
((TMP_Text)component).alignment = (TextAlignmentOptions)514;
val2.anchorMin = new Vector2(0f, 0.5f);
val2.anchorMax = new Vector2(1f, 0.5f);
val2.sizeDelta = new Vector2(0f, val2.sizeDelta.y);
TextMeshProUGUI component2 = ((Component)val2).GetComponent<TextMeshProUGUI>();
((TMP_Text)component2).margin = new Vector4(0f, 0f, val2.anchoredPosition.x * 2f, 0f);
((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
((TMP_Text)___signalTranslatorText).alignment = (TextAlignmentOptions)514;
((TMP_Text)___signalTranslatorText).rectTransform.anchorMin = new Vector2(0f, 0.5f);
((TMP_Text)___signalTranslatorText).rectTransform.anchorMax = new Vector2(1f, 0.5f);
((TMP_Text)___signalTranslatorText).rectTransform.anchoredPosition = new Vector2(0f, ((TMP_Text)___signalTranslatorText).rectTransform.anchoredPosition.y);
((TMP_Text)___signalTranslatorText).rectTransform.sizeDelta = new Vector2(0f, ((TMP_Text)___signalTranslatorText).rectTransform.sizeDelta.y);
}
}
internal class PluginInfo
{
public const string GUID = "lekakid.lcsignaltranslatoraligner";
public const string Name = "SignalTranslatorAligner";
public const string Version = "1.0.0";
}
[BepInPlugin("lekakid.lcsignaltranslatoraligner", "SignalTranslatorAligner", "1.0.0")]
internal class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
public void LogInfo(string msg)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)msg);
}
public void LogWarning(string msg)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)msg);
}
public void LogError(string msg)
{
((BaseUnityPlugin)this).Logger.LogError((object)msg);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SignalTranslatorAligner";
public const string PLUGIN_NAME = "SignalTranslatorAligner";
public const string PLUGIN_VERSION = "1.1.0";
}