using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TerminalTypingMirrorLocal")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyInformationalVersion("1.5.0")] [assembly: AssemblyProduct("TerminalTypingMirrorLocal")] [assembly: AssemblyTitle("TerminalTypingMirrorLocal")] [assembly: AssemblyVersion("1.5.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TerminalTypingMirrorLocal { internal static class GlassMesh { internal static Mesh Create(Mesh source, Transform monitor, RectTransform viewport, RectTransform screen) { //IL_0013: 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) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_0202: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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_025b: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_035d: 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_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || source.subMeshCount == 0 || (int)source.GetVertexAttributeFormat((VertexAttribute)0) != 0 || source.GetVertexAttributeDimension((VertexAttribute)0) != 3) { return null; } int vertexAttributeStream = source.GetVertexAttributeStream((VertexAttribute)0); int positionStride = source.GetVertexBufferStride(vertexAttributeStream); int positionOffset = source.GetVertexAttributeOffset((VertexAttribute)0); GraphicsBuffer vertexBuffer = source.GetVertexBuffer(vertexAttributeStream); byte[] vertices; SubMeshDescriptor part; byte[] indices; int indexStride; List glass; List screenUv; List triangles; Dictionary used; Vector2 minimum; Vector2 maximum; Matrix4x4 toScreen; Rect screenRect; Vector3 lift; try { vertices = new byte[source.vertexCount * positionStride]; vertexBuffer.GetData((Array)vertices); part = source.GetSubMesh(0); GraphicsBuffer indexBuffer = source.GetIndexBuffer(); try { indices = new byte[indexBuffer.count * indexBuffer.stride]; indexBuffer.GetData((Array)indices); indexStride = (((int)source.indexFormat == 0) ? 2 : 4); glass = new List(); screenUv = new List(); triangles = new List(); used = new Dictionary(); minimum = new Vector2(float.PositiveInfinity, float.PositiveInfinity); maximum = new Vector2(float.NegativeInfinity, float.NegativeInfinity); Matrix4x4 val = ((Transform)viewport).worldToLocalMatrix * monitor.localToWorldMatrix; toScreen = ((Transform)screen).worldToLocalMatrix * monitor.localToWorldMatrix; screenRect = screen.rect; Rect rect = viewport.rect; Vector3 val2 = Vector2.op_Implicit(((Rect)(ref rect)).center); rect = viewport.rect; Vector3 val3 = Vector2.op_Implicit(((Rect)(ref rect)).size); lift = monitor.InverseTransformVector(((Transform)viewport).forward * -0.0007f); for (int i = ((SubMeshDescriptor)(ref part)).indexStart; i < ((SubMeshDescriptor)(ref part)).indexStart + ((SubMeshDescriptor)(ref part)).indexCount; i += 3) { int index = Index(i); int index2 = Index(i + 1); int index3 = Index(i + 2); Vector3 val4 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(Position(index)) - val2; Vector3 val5 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(Position(index2)) - val2; Vector3 val6 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(Position(index3)) - val2; Vector3 val7 = (val4 + val5 + val6) / 3f; Vector3 val8 = Vector3.Cross(val5 - val4, val6 - val4); Vector3 normalized = ((Vector3)(ref val8)).normalized; if (!(Mathf.Abs(val7.x) > val3.x * 0.555f) && !(Mathf.Abs(val7.y) > val3.y * 0.58f) && !(val7.z < -4f) && !(val7.z > 18f) && !(normalized.z > -0.78f)) { AddVertex(index, val4); AddVertex(index2, val5); AddVertex(index3, val6); } } if (triangles.Count != 30 || maximum.x - minimum.x < val3.x || maximum.y - minimum.y < val3.y) { return null; } Mesh val9 = new Mesh { name = "Curved terminal CRT" }; val9.SetVertices(glass); val9.SetUVs(0, screenUv); val9.SetTriangles(triangles, 0); val9.RecalculateNormals(); val9.RecalculateTangents(); return val9; } finally { ((IDisposable)indexBuffer)?.Dispose(); } } finally { ((IDisposable)vertexBuffer)?.Dispose(); } void AddVertex(int num, Vector3 projected) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!used.TryGetValue(num, out var value)) { value = glass.Count; used.Add(num, value); glass.Add(Position(num) + lift); Vector2 val10 = Vector2.op_Implicit(projected); Vector2 val11 = Vector2.op_Implicit(((Matrix4x4)(ref toScreen)).MultiplyPoint3x4(Position(num))); screenUv.Add(new Vector2((val11.x - ((Rect)(ref screenRect)).xMin) / ((Rect)(ref screenRect)).width, (val11.y - ((Rect)(ref screenRect)).yMin) / ((Rect)(ref screenRect)).height)); minimum = Vector2.Min(minimum, val10); maximum = Vector2.Max(maximum, val10); } triangles.Add(value); } int Index(int num) { int startIndex = num * indexStride; return ((SubMeshDescriptor)(ref part)).baseVertex + (int)((indexStride == 2) ? BitConverter.ToUInt16(indices, startIndex) : BitConverter.ToUInt32(indices, startIndex)); } Vector3 Position(int num2) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) int num = num2 * positionStride + positionOffset; return new Vector3(BitConverter.ToSingle(vertices, num), BitConverter.ToSingle(vertices, num + 4), BitConverter.ToSingle(vertices, num + 8)); } } } internal sealed class PageSource { internal const int CaptureLayer = 31; private static readonly FieldRef CaretVisible = AccessTools.FieldRefAccess("m_CaretVisible"); internal Canvas Canvas; internal Camera Camera; internal TMP_InputField Input; internal ScrollRect Scroll; internal TMP_Text[] Texts; internal Graphic[] Images; internal RectMask2D[] Masks; internal float OpenedAt = -1f; internal int LastSignature; internal PageSource(Canvas canvas, RectTransform screen, TMP_InputField input, ScrollRect scroll, RenderTexture target) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected I4, but got Unknown Canvas = canvas; Input = input; Scroll = scroll; Texts = ((Component)canvas).GetComponentsInChildren(true); List list = new List(); Graphic[] componentsInChildren = ((Component)canvas).GetComponentsInChildren(true); foreach (Graphic val in componentsInChildren) { if ((val is Image || val is RawImage) ? true : false) { list.Add(val); } } Images = list.ToArray(); Masks = ((Component)canvas).GetComponentsInChildren(true); Rect rect = screen.rect; Vector2 size = ((Rect)(ref rect)).size; Vector3 val2 = ((Transform)screen).TransformVector(Vector3.right * size.x); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = ((Transform)screen).TransformVector(Vector3.up * size.y); float magnitude2 = ((Vector3)(ref val2)).magnitude; GameObject val3 = new GameObject("Terminal UI capture camera"); val3.transform.SetParent(((Component)canvas).transform, false); rect = screen.rect; Vector3 val4 = ((Transform)screen).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); val3.transform.SetPositionAndRotation(val4 - ((Component)canvas).transform.forward, ((Component)canvas).transform.rotation); Camera = val3.AddComponent(); Camera.targetTexture = target; Camera.orthographic = true; Camera.orthographicSize = magnitude2 * 0.5f; Camera.aspect = magnitude / magnitude2; Camera.nearClipPlane = 0.2f; Camera.farClipPlane = 2f; Camera.cullingMask = int.MinValue; Camera.allowHDR = false; HDAdditionalCameraData val5 = val3.AddComponent(); val5.clearColorMode = (ClearColorMode)1; val5.backgroundColorHDR = Color.black; val5.volumeLayerMask = LayerMask.op_Implicit(0); val5.customRenderingSettings = true; FrameSettingsField[] array = (FrameSettingsField[])(object)new FrameSettingsField[2] { (FrameSettingsField)15, (FrameSettingsField)32 }; foreach (FrameSettingsField val6 in array) { ((FrameSettings)(ref val5.renderingPathCustomFrameSettings)).SetEnabled(val6, false); ((BitArray128)(ref val5.renderingPathCustomFrameSettingsOverrideMask.mask))[(uint)(int)val6] = true; } canvas.worldCamera = Camera; ((Behaviour)Camera).enabled = false; } internal int Signature(out bool animated) { //IL_004b: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) animated = false; HashCode hashCode = default(HashCode); TMP_Text[] texts = Texts; foreach (TMP_Text val in texts) { bool flag = (Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled; hashCode.Add(flag); if (flag) { hashCode.Add(val.text); hashCode.Add(((Graphic)val).color); hashCode.Add(val.maxVisibleCharacters); hashCode.Add(val.maxVisibleLines); } } Graphic[] images = Images; foreach (Graphic val2 in images) { bool flag2 = (Object)(object)val2 != (Object)null && ((Behaviour)val2).isActiveAndEnabled; hashCode.Add(flag2); if (flag2) { hashCode.Add(val2.color); hashCode.Add(val2.rectTransform.anchoredPosition); hashCode.Add(val2.rectTransform.sizeDelta); RawImage val3 = (RawImage)(object)((val2 is RawImage) ? val2 : null); if (val3 != null && (Object)(object)val3.texture != (Object)null) { hashCode.Add(val3.texture); hashCode.Add(val3.uvRect); animated |= val3.texture is RenderTexture; } } } RectMask2D[] masks = Masks; foreach (RectMask2D val4 in masks) { if ((Object)(object)val4 != (Object)null && ((Behaviour)val4).isActiveAndEnabled) { hashCode.Add(val4.padding); } } if ((Object)(object)Scroll != (Object)null && (Object)(object)Scroll.content != (Object)null) { hashCode.Add(Mathf.Round(Scroll.content.anchoredPosition.y)); } if ((Object)(object)Input != (Object)null) { hashCode.Add(Input.isFocused && CaretVisible.Invoke(Input)); hashCode.Add(Input.caretPosition); hashCode.Add(Input.selectionAnchorPosition); } return hashCode.ToHashCode(); } } internal sealed class MonitorDisplay : MonoBehaviour { private enum Mode { Idle, Local, Remote } internal const string DisplayName = "Terminal Glass Display"; private const float LitShare = 0.12f; private const float VanillaEmission = 10f; private const float FrameTime = 1f / 30f; private const float SendTime = 0.1f; private const float WarmUp = 0.5f; private Terminal terminal; private Canvas stock; private RectTransform stockScreen; private Camera originalUiCamera; private Vector3 stockPosition; private readonly Dictionary originalLayers = new Dictionary(); private PageSource local; private PageSource remote; private TMP_Text remoteCredits; private RawImage remoteImage; private RenderTexture live; private RenderTexture lastPage; private Material material; private Mesh mesh; private Mode mode; private bool remoteOpen; private bool hasPage; private bool localWasOpen; private float remoteScroll; private float nextRender; private float nextSend; private TerminalPage lastSent; private Texture shownTexture; private string capturedText; private string savedText; private string remoteText; private const float KeyTime = 0.04f; private const int MaxReplayedKeys = 16; private string remoteTarget = ""; private string remoteDisplayed; private int remoteShown; private int remoteCaretIndex; private int placedCaretIndex = -1; private Image remoteCaret; private RectMask2D remoteMask; private VideoPlayer remoteVideo; private RenderTexture remoteVideoTexture; private string remoteImageKey; private Dictionary nodeMedia; private float keyClock; private float nextKeySound; private TMP_InputField remoteInput; internal static MonitorDisplay Mount(Terminal terminal, Canvas stock, Transform monitor, RectTransform screen, Mesh mesh, Material original) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown GameObject val = new GameObject("Terminal Glass Display", new Type[3] { typeof(MeshFilter), typeof(MeshRenderer), typeof(MonitorDisplay) }); val.layer = ((Component)monitor).gameObject.layer; val.transform.SetParent(monitor, false); MonitorDisplay component = val.GetComponent(); component.mesh = mesh; try { component.Bind(terminal, stock, screen, original); return component; } catch { Object.Destroy((Object)(object)val); throw; } } private void Bind(Terminal terminal, Canvas stock, RectTransform screen, Material original) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) this.terminal = terminal; this.stock = stock; stockScreen = screen; stockPosition = ((Component)stock).transform.localPosition; originalUiCamera = stock.worldCamera; Rect rect = screen.rect; Vector2 size = ((Rect)(ref rect)).size; Vector3 val = ((Transform)screen).TransformVector(Vector3.right * size.x); float magnitude = ((Vector3)(ref val)).magnitude; val = ((Transform)screen).TransformVector(Vector3.up * size.y); float num = magnitude / ((Vector3)(ref val)).magnitude; int resolution = Plugin.Resolution; int width = Mathf.RoundToInt((float)resolution * num); live = NewTexture(width, resolution, "Live CRT"); lastPage = NewTexture(width, resolution, "Last terminal page"); material = new Material(original) { name = "Terminal CRT phosphor" }; material.SetFloat("_BlendMode", 1f); material.SetFloat("_SrcBlend", 1f); material.SetFloat("_DstBlend", 1f); material.SetFloat("_AlphaSrcBlend", 0f); material.SetFloat("_AlphaDstBlend", 1f); material.SetFloat("_ZWrite", 0f); material.SetFloat("_EnableBlendModePreserveSpecularLighting", 0f); material.SetFloat("_Smoothness", 0f); material.SetFloat("_Metallic", 1f); material.renderQueue = original.renderQueue - 1; material.SetTextureScale("_BaseColorMap", Vector2.one); material.SetTextureOffset("_BaseColorMap", Vector2.zero); material.SetColor("_BaseColor", new Color(0.12f, 0.12f, 0.12f, 1f)); material.SetFloat("_AlbedoAffectEmissive", 1f); material.SetColor("_EmissiveColor", Color.white * (10f * Plugin.Brightness / 0.12f)); material.SetFloat("_EmissiveExposureWeight", 0f); Show((Texture)(object)live); ((Component)this).GetComponent().sharedMesh = mesh; MeshRenderer component = ((Component)this).GetComponent(); ((Renderer)component).sharedMaterial = material; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; Transform transform = ((Component)stock).transform; transform.position += Vector3.down * 300f; Transform[] componentsInChildren = ((Component)stock).GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { originalLayers.Add(((Component)val2).gameObject, ((Component)val2).gameObject.layer); ((Component)val2).gameObject.layer = 31; } local = new PageSource(stock, screen, terminal.screenText, ((Component)terminal.screenText).GetComponentInParent(true), live); RenderPipelineManager.endCameraRendering += RecordPage; } private static RenderTexture NewTexture(int width, int height, string name) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown RenderTexture val = new RenderTexture(width, height, 24, (RenderTextureFormat)0) { name = name, useMipMap = true, autoGenerateMips = true, anisoLevel = 8, filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1 }; val.Create(); return val; } private void Show(Texture texture) { if (!((Object)(object)shownTexture == (Object)(object)texture)) { shownTexture = texture; material.SetTexture("_BaseColorMap", texture); } } internal void ShowRemote(TerminalPage page) { if (remote == null && !CreateRemoteCanvas()) { return; } string text = page.Text ?? ""; int num = text.Length - remoteTarget.Length; if (remoteOpen && page.Open && text.StartsWith(remoteTarget, StringComparison.Ordinal) && num > 0 && num <= 16) { remoteShown = Mathf.Min(remoteShown, remoteTarget.Length); } else { if (remoteOpen && page.Open && num < 0 && -num <= 16 && remoteTarget.StartsWith(text, StringComparison.Ordinal)) { KeySound(); } remoteShown = text.Length; } remoteTarget = text; if ((Object)(object)remoteCredits != (Object)null) { remoteCredits.text = page.Credits ?? ""; } remoteCaretIndex = page.Caret; ShowRemoteImage(page); remoteScroll = page.Scroll; if (page.Open && !remoteOpen) { remote.OpenedAt = Time.unscaledTime; } remoteOpen = page.Open; if (mode != Mode.Local) { mode = Mode.Remote; } } private bool CreateRemoteCanvas() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown try { GameObject val = Object.Instantiate(((Component)stock).gameObject, ((Component)stock).transform.parent); ((Object)val).name = "Terminal remote page"; val.transform.SetPositionAndRotation(((Component)stock).transform.position + Vector3.down * 20f, ((Component)stock).transform.rotation); Camera[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)componentsInChildren[i]).gameObject); } TMP_SelectionCaret[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)componentsInChildren2[i]).gameObject); } BaseRaycaster[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Animator[] componentsInChildren4 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } MonoBehaviour[] componentsInChildren5 = val.GetComponentsInChildren(true); foreach (MonoBehaviour val2 in componentsInChildren5) { if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Assembly == typeof(Terminal).Assembly) { Object.DestroyImmediate((Object)(object)val2); } } TMP_InputField val3 = Twin(val, (Component)(object)terminal.screenText); if ((Object)(object)val3 == (Object)null) { throw new InvalidOperationException("The terminal input field was not found in the copy."); } val3.onValueChanged = new OnChangeEvent(); val3.onSubmit = new SubmitEvent(); val3.onEndEdit = new SubmitEvent(); val3.onSelect = new SelectionEvent(); val3.onDeselect = new SelectionEvent(); ((Selectable)val3).interactable = false; val3.readOnly = true; remoteCredits = Twin(val, (Component)(object)terminal.topRightText); remoteImage = Twin(val, (Component)(object)terminal.terminalImage); if ((Object)(object)remoteImage != (Object)null) { ((Behaviour)remoteImage).enabled = false; } remoteMask = Twin(val, (Component)(object)terminal.terminalImageMask); remoteCaret = CreateCaret(val3); val.SetActive(true); Canvas component = val.GetComponent(); Transform obj = val.transform.Find(((Object)stockScreen).name); RectTransform screen = (RectTransform)(object)((obj is RectTransform) ? obj : null); remote = new PageSource(component, screen, val3, ((Component)val3).GetComponentInParent(true), live); remote.Input = null; remoteInput = val3; return true; } catch (Exception ex) { Debug.LogWarning((object)("[Terminal Typing Mirror] Could not show another player's terminal page. " + ex.Message)); return false; } } private T Twin(GameObject copy, Component original) where T : Component { if ((Object)(object)original == (Object)null) { return default(T); } List list = new List(); Transform val = original.transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)stock).transform) { list.Insert(0, ((Object)val).name); val = val.parent; } Transform val2 = copy.transform.Find(string.Join("/", list)); if (!((Object)(object)val2 != (Object)null)) { return default(T); } return ((Component)val2).GetComponent(); } private void LateUpdate() { if (local == null || (Object)(object)stock == (Object)null) { return; } float unscaledTime = Time.unscaledTime; bool isActiveAndEnabled = ((Behaviour)stock).isActiveAndEnabled; if (isActiveAndEnabled) { if (this.mode != Mode.Local) { local.OpenedAt = unscaledTime; } this.mode = Mode.Local; } else if (this.mode == Mode.Local) { this.mode = Mode.Idle; } ShareLocalPage(isActiveAndEnabled, unscaledTime); Mode mode = this.mode; PageSource pageSource = ((mode == Mode.Local) ? local : ((mode != Mode.Remote || !remoteOpen) ? null : remote)); PageSource pageSource2 = pageSource; if (pageSource2 == remote && remote != null) { ReplayRemoteTyping(unscaledTime); if ((Object)(object)remote.Scroll != (Object)null) { remote.Scroll.verticalNormalizedPosition = remoteScroll; } } bool flag = false; if (pageSource2 != null && unscaledTime >= nextRender) { bool animated; int num = pageSource2.Signature(out animated); flag = animated || unscaledTime - pageSource2.OpenedAt < 0.5f || num != pageSource2.LastSignature; if (flag) { pageSource2.LastSignature = num; nextRender = unscaledTime + 1f / 30f; } } ((Behaviour)local.Camera).enabled = flag && pageSource2 == local; if (remote != null) { ((Behaviour)remote.Camera).enabled = flag && pageSource2 == remote; } Show((Texture)(object)((this.mode == Mode.Idle && hasPage) ? lastPage : live)); } private void ReplayRemoteTyping(float now) { if (remoteShown < remoteTarget.Length) { keyClock += Time.unscaledDeltaTime; while (keyClock >= 0.04f && remoteShown < remoteTarget.Length) { keyClock -= 0.04f; remoteShown++; KeySound(); } } else { keyClock = 0f; } if (remoteDisplayed == null || remoteDisplayed.Length != remoteShown) { remoteDisplayed = remoteTarget.Substring(0, remoteShown); remoteInput.SetTextWithoutNotify(remoteDisplayed); placedCaretIndex = -1; } int num = ((remoteShown < remoteTarget.Length) ? remoteShown : Mathf.Clamp(remoteCaretIndex, 0, remoteShown)); float caretBlinkRate = terminal.screenText.caretBlinkRate; bool flag = caretBlinkRate <= 0f || Mathf.Repeat(now * caretBlinkRate, 1f) < 0.5f; if (!((Object)(object)remoteCaret == (Object)null)) { if (num != placedCaretIndex) { PlaceCaret(num); } ((Behaviour)remoteCaret).enabled = remoteOpen && flag; } } private static Image CreateCaret(TMP_InputField input) { //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_0042: 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_004d: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) TMP_Text textComponent = input.textComponent; GameObject val = new GameObject("Remote caret", new Type[2] { typeof(RectTransform), typeof(Image) }) { layer = ((Component)textComponent).gameObject.layer }; RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)textComponent.rectTransform, false); Vector2 anchorMin = (val2.anchorMax = textComponent.rectTransform.pivot); val2.anchorMin = anchorMin; val2.pivot = Vector2.zero; Image component = val.GetComponent(); ((Graphic)component).raycastTarget = false; ((Graphic)component).color = (input.customCaretColor ? input.caretColor : ((Graphic)textComponent).color); ((Behaviour)component).enabled = false; return component; } private void PlaceCaret(int index) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) TMP_Text textComponent = remoteInput.textComponent; textComponent.ForceMeshUpdate(false, false); TMP_TextInfo textInfo = textComponent.textInfo; if (textInfo.characterCount != 0 && textInfo.lineCount != 0) { TMP_CharacterInfo val = textInfo.characterInfo[Mathf.Clamp(index, 0, textInfo.characterCount - 1)]; TMP_LineInfo val2 = textInfo.lineInfo[Mathf.Clamp(val.lineNumber, 0, textInfo.lineCount - 1)]; float num = ((index < textInfo.characterCount) ? val.origin : val.xAdvance); RectTransform rectTransform = ((Graphic)remoteCaret).rectTransform; rectTransform.anchoredPosition = new Vector2(num, val2.descender); rectTransform.sizeDelta = new Vector2(Mathf.Max(1f, (float)remoteInput.caretWidth), val2.ascender - val2.descender); placedCaretIndex = index; } } private void ShowRemoteImage(TerminalPage page) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)remoteImage == (Object)null) { return; } string text = page.Image + ":" + page.ImageName; if (text != remoteImageKey) { remoteImageKey = text; if ((Object)(object)remoteVideo != (Object)null) { remoteVideo.Stop(); } Texture val = null; switch (page.Image) { case 1: val = (Texture)(object)terminal.playerScreenTex; break; case 2: val = (Texture)(object)terminal.playerScreenTexHighRes; break; case 3: { Object obj2 = NodeMedia(page.ImageName); val = (Texture)(object)((obj2 is Texture) ? obj2 : null); break; } case 4: { Object obj = NodeMedia(page.ImageName); VideoClip val2 = (VideoClip)(object)((obj is VideoClip) ? obj : null); if (val2 != null) { val = PlayRemoteVideo(val2); } break; } } remoteImage.texture = val; ((Behaviour)remoteImage).enabled = (Object)(object)val != (Object)null; } if ((Object)(object)remoteMask != (Object)null) { remoteMask.padding = new Vector4(0f, page.ImageReveal, 0f, 0f); } } private Object NodeMedia(string name) { if (string.IsNullOrEmpty(name)) { return null; } if (nodeMedia == null || !nodeMedia.ContainsKey(name)) { if (nodeMedia == null) { nodeMedia = new Dictionary(); } TerminalNode[] array = Resources.FindObjectsOfTypeAll(); foreach (TerminalNode val in array) { if ((Object)(object)val.displayTexture != (Object)null) { nodeMedia[((Object)val.displayTexture).name] = (Object)(object)val.displayTexture; } if ((Object)(object)val.displayVideo != (Object)null) { nodeMedia[((Object)val.displayVideo).name] = (Object)(object)val.displayVideo; } } } if (!nodeMedia.TryGetValue(name, out var value)) { return null; } return value; } private Texture PlayRemoteVideo(VideoClip clip) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if ((Object)(object)remoteVideo == (Object)null) { RenderTexture videoTexture = terminal.videoTexture; remoteVideoTexture = (((Object)(object)videoTexture != (Object)null) ? new RenderTexture(videoTexture.descriptor) : new RenderTexture(512, 512, 0)); ((Object)remoteVideoTexture).name = "Remote terminal video"; remoteVideo = ((Component)remote.Canvas).gameObject.AddComponent(); remoteVideo.playOnAwake = false; remoteVideo.renderMode = (VideoRenderMode)2; remoteVideo.targetTexture = remoteVideoTexture; remoteVideo.audioOutputMode = (VideoAudioOutputMode)0; remoteVideo.isLooping = (Object)(object)terminal.videoPlayer == (Object)null || terminal.videoPlayer.isLooping; } remoteVideo.clip = clip; remoteVideo.Play(); return (Texture)(object)remoteVideoTexture; } private void KeySound() { float unscaledTime = Time.unscaledTime; AudioClip[] keyboardClips = terminal.keyboardClips; if (!(unscaledTime < nextKeySound) && keyboardClips != null && keyboardClips.Length != 0 && !((Object)(object)terminal.terminalAudio == (Object)null)) { nextKeySound = unscaledTime + 0.05f; terminal.terminalAudio.PlayOneShot(keyboardClips[Random.Range(0, keyboardClips.Length)]); } } private void ShareLocalPage(bool localOpen, float now) { //IL_01c7: Unknown result type (might be due to invalid IL or missing references) if (!localOpen && !localWasOpen) { return; } TerminalPage page = new TerminalPage { Open = localOpen }; if (localOpen) { page.Text = terminal.screenText.text; page.Credits = (((Object)(object)terminal.topRightText != (Object)null) ? ((TMP_Text)terminal.topRightText).text : ""); page.Scroll = (((Object)(object)local.Scroll != (Object)null) ? local.Scroll.verticalNormalizedPosition : 0f); page.Caret = terminal.screenText.caretPosition; RawImage terminalImage = terminal.terminalImage; Texture val = (((Object)(object)terminalImage != (Object)null && ((Behaviour)terminalImage).isActiveAndEnabled) ? terminalImage.texture : null); if ((Object)(object)val == (Object)null) { page.Image = 0; } else if ((Object)(object)val == (Object)(object)terminal.playerScreenTex) { page.Image = 1; } else if ((Object)(object)val == (Object)(object)terminal.playerScreenTexHighRes) { page.Image = 2; } else if ((Object)(object)val == (Object)(object)terminal.videoTexture && (Object)(object)terminal.videoPlayer != (Object)null && (Object)(object)terminal.videoPlayer.clip != (Object)null) { page.Image = 4; page.ImageName = ((Object)terminal.videoPlayer.clip).name; } else { page.Image = 3; page.ImageName = ((Object)val).name; } if ((Object)(object)terminal.terminalImageMask != (Object)null) { page.ImageReveal = terminal.terminalImageMask.padding.y; } } else { page.Text = lastSent.Text; page.Credits = lastSent.Credits; page.Scroll = lastSent.Scroll; } if (!page.Equals(lastSent) && (!localOpen || !localWasOpen || !(now < nextSend))) { PageSync.Send(page); lastSent = page; nextSend = now + 0.1f; localWasOpen = localOpen; } } private void RecordPage(ScriptableRenderContext context, Camera camera) { if (remote != null && (Object)(object)camera == (Object)(object)remote.Camera) { remoteText = ((remoteShown == remoteTarget.Length) ? remoteTarget : null); } else if (!((Object)(object)camera != (Object)(object)local.Camera)) { capturedText = terminal.screenText.text; if (terminal.terminalInUse && terminal.textAdded == 0) { Graphics.CopyTexture((Texture)(object)live, (Texture)(object)lastPage); savedText = capturedText; hasPage = true; } } } private void OnDestroy() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) RenderPipelineManager.endCameraRendering -= RecordPage; if ((Object)(object)stock != (Object)null) { ((Component)stock).transform.localPosition = stockPosition; stock.worldCamera = originalUiCamera; foreach (KeyValuePair originalLayer in originalLayers) { if ((Object)(object)originalLayer.Key != (Object)null) { originalLayer.Key.layer = originalLayer.Value; } } } if ((Object)(object)local?.Camera != (Object)null) { Object.Destroy((Object)(object)((Component)local.Camera).gameObject); } if ((Object)(object)remote?.Canvas != (Object)null) { Object.Destroy((Object)(object)((Component)remote.Canvas).gameObject); } if ((Object)(object)remoteVideoTexture != (Object)null) { Object.Destroy((Object)(object)remoteVideoTexture); } if ((Object)(object)live != (Object)null) { Object.Destroy((Object)(object)live); } if ((Object)(object)lastPage != (Object)null) { Object.Destroy((Object)(object)lastPage); } if ((Object)(object)material != (Object)null) { Object.Destroy((Object)(object)material); } if ((Object)(object)mesh != (Object)null) { Object.Destroy((Object)(object)mesh); } } } internal struct TerminalPage : IEquatable { internal const byte NoImage = 0; internal const byte RadarImage = 1; internal const byte RadarImageHighRes = 2; internal const byte TextureImage = 3; internal const byte VideoImage = 4; internal bool Open; internal string Text; internal string Credits; internal float Scroll; internal int Caret; internal byte Image; internal string ImageName; internal float ImageReveal; public bool Equals(TerminalPage other) { if (Open == other.Open && Text == other.Text && Credits == other.Credits && Mathf.Abs(Scroll - other.Scroll) < 0.001f && Caret == other.Caret && Image == other.Image && ImageName == other.ImageName) { return Mathf.Abs(ImageReveal - other.ImageReveal) < 0.5f; } return false; } } internal static class PageSync { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__Receive; } private const string Channel = "TerminalTypingMirror.Page"; private const int MaxMessageSize = 262144; private const byte Protocol = 2; private static CustomMessagingManager registered; internal static void Register() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown CustomMessagingManager val = (((Object)(object)NetworkManager.Singleton != (Object)null) ? NetworkManager.Singleton.CustomMessagingManager : null); if (Plugin.ShareTyping && val != null && val != registered) { object obj = <>O.<0>__Receive; if (obj == null) { HandleNamedMessageDelegate val2 = Receive; <>O.<0>__Receive = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("TerminalTypingMirror.Page", (HandleNamedMessageDelegate)obj); registered = val; } } internal unsafe static void Send(TerminalPage page) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (!Plugin.ShareTyping || (Object)(object)singleton == (Object)null || !singleton.IsListening) { return; } Register(); FastBufferWriter val = Write(page); try { if (singleton.IsServer) { Forward(singleton, val, singleton.LocalClientId); } else { singleton.CustomMessagingManager.SendNamedMessage("TerminalTypingMirror.Page", 0uL, val, (NetworkDelivery)4); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe static void Receive(ulong sender, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0037: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0097: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0110: Unknown result type (might be due to invalid IL or missing references) TerminalPage page = default(TerminalPage); try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe(ref b, default(ForPrimitives)); if (b != 2) { Debug.LogWarning((object)"[Terminal Typing Mirror] Another player has a different version of the mod; their terminal page is not shown."); return; } ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Open, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Text, false); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Credits, false); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Scroll, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Caret, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.Image, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.ImageName, false); ((FastBufferReader)(ref reader)).ReadValueSafe(ref page.ImageReveal, default(ForPrimitives)); } catch (Exception ex) { Debug.LogWarning((object)("[Terminal Typing Mirror] Ignored a malformed terminal page. " + ex.Message)); return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsServer && sender != singleton.LocalClientId) { FastBufferWriter writer = Write(page); try { Forward(singleton, writer, sender); } finally { ((IDisposable)(*(FastBufferWriter*)(&writer))/*cast due to .constrained prefix*/).Dispose(); } } Terminal val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null && !((Behaviour)val.terminalUIScreen).isActiveAndEnabled) { Plugin.EnsureDisplay(val)?.ShowRemote(page); } } private static FastBufferWriter Write(TerminalPage page) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter result = default(FastBufferWriter); ((FastBufferWriter)(ref result))..ctor(1024, (Allocator)2, 262144); byte b = 2; ((FastBufferWriter)(ref result)).WriteValueSafe(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref page.Open, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(page.Text ?? "", false); ((FastBufferWriter)(ref result)).WriteValueSafe(page.Credits ?? "", false); ((FastBufferWriter)(ref result)).WriteValueSafe(ref page.Scroll, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref page.Caret, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref page.Image, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(page.ImageName ?? "", false); ((FastBufferWriter)(ref result)).WriteValueSafe(ref page.ImageReveal, default(ForPrimitives)); return result; } private static void Forward(NetworkManager network, FastBufferWriter writer, ulong except) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (connectedClientsId != except && connectedClientsId != network.LocalClientId) { network.CustomMessagingManager.SendNamedMessage("TerminalTypingMirror.Page", connectedClientsId, writer, (NetworkDelivery)4); } } } } [BepInPlugin("terminaltypingmirror.local", "Terminal Typing Mirror Local", "1.5.0")] [BepInProcess("Lethal Company.exe")] public sealed class Plugin : BaseUnityPlugin { private const string Id = "terminaltypingmirror.local"; internal static float Brightness = 1f; internal static int Resolution = 1024; internal static bool ShareTyping = true; private void Awake() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00c5: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown Brightness = ((BaseUnityPlugin)this).Config.Bind("Display", "Brightness", 1f, "Brightness of the terminal page on the monitor glass. 1 matches the vanilla screen.").Value; Resolution = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind("Display", "Resolution", 1024, "Height in pixels of the image the terminal page is rendered into (256-2048).").Value, 256, 2048); ShareTyping = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "ShareTyping", true, "Send what you type on the terminal to other players who have this mod, and show what they type.").Value; Harmony val = new Harmony("terminaltypingmirror.local"); val.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "BeginUsingTerminal", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AttachDisplay", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "TerminalStarted", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void TerminalStarted() { PageSync.Register(); } private static void AttachDisplay(Terminal __instance) { EnsureDisplay(__instance); } internal static MonitorDisplay EnsureDisplay(Terminal terminal) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 Canvas val = (((Object)(object)terminal != (Object)null) ? terminal.terminalUIScreen : null); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.parent : null); if ((Object)(object)val2 == (Object)null || (int)val.renderMode != 2) { return null; } Transform val3 = val2.Find("Terminal Glass Display"); if ((Object)(object)val3 != (Object)null) { return ((Component)val3).GetComponent(); } TMP_InputField screenText = terminal.screenText; object obj; if (!((Object)(object)screenText != (Object)null)) { obj = null; } else { ScrollRect componentInParent = ((Component)screenText).GetComponentInParent(true); Transform obj2 = ((componentInParent != null) ? ((Component)componentInParent).transform : null); obj = ((obj2 is RectTransform) ? obj2 : null); } RectTransform val4 = (RectTransform)obj; Transform obj3 = ((Component)val).transform.Find("MainContainer"); RectTransform val5 = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null); MeshFilter component = ((Component)val2).GetComponent(); MeshRenderer component2 = ((Component)val2).GetComponent(); if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { return null; } try { Material val6 = Array.Find(((Renderer)component2).sharedMaterials, (Material m) => (Object)(object)m != (Object)null && m.IsKeywordEnabled("_SURFACE_TYPE_TRANSPARENT")); Mesh val7 = (((Object)(object)val6 != (Object)null) ? GlassMesh.Create(component.sharedMesh, val2, val4, val5) : null); if ((Object)(object)val7 != (Object)null) { return MonitorDisplay.Mount(terminal, val, val2, val5, val7, val6); } Debug.LogWarning((object)"[Terminal Typing Mirror] The terminal CRT geometry was not recognized."); } catch (Exception ex) { Debug.LogWarning((object)("[Terminal Typing Mirror] The stock terminal display is still active. " + ex.Message)); } return null; } } }