using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [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: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("ModdedWolf")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Shows 3D world-space text above portals with their tag name.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Teleporter_Overhead_Text")] [assembly: AssemblyTitle("Teleporter_Overhead_Text")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 Teleporter_Overhead_Text { internal sealed class PortalLabel : MonoBehaviour { private const string EmptyPlaceholder = "(unnamed)"; private static readonly Vector3[] OutlineOffsets = (Vector3[])(object)new Vector3[4] { new Vector3(-0.04f, 0f, 0f), new Vector3(0.04f, 0f, 0f), new Vector3(0f, -0.04f, 0f), new Vector3(0f, 0.04f, 0f) }; private static readonly RaycastHit[] RayHits = (RaycastHit[])(object)new RaycastHit[16]; private static int? _solidMask; private TeleportWorld _portal; private TextMesh _textMesh; private TextMesh[] _outlineMeshes; private MeshRenderer _renderer; private MeshRenderer[] _outlineRenderers; private Transform _labelRoot; private string _lastText; private string _lastFontName; private int _lastFontSize; private float _cachedTopLocalY; private bool _topMeasured; private float _refreshTimer; private const float AboveMeshClearance = 0.45f; private static int SolidMask { get { if (!_solidMask.HasValue) { _solidMask = LayerMask.GetMask(new string[8] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "viewblock", "Water" }); } return _solidMask.Value; } } internal static void Attach(TeleportWorld portal) { if (!((Object)(object)portal == (Object)null) && !((Object)(object)((Component)portal).GetComponent() != (Object)null)) { ((Component)portal).gameObject.AddComponent(); } } private void Awake() { _portal = ((Component)this).GetComponent(); CreateLabel(); RefreshText(force: true); } private void OnDestroy() { if ((Object)(object)_labelRoot != (Object)null) { Object.Destroy((Object)(object)((Component)_labelRoot).gameObject); _labelRoot = null; } } private void CreateLabel() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002f: 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_004a: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00ea: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TeleporterOverheadText"); _labelRoot = val.transform; _labelRoot.SetParent(((Component)this).transform, false); _labelRoot.localPosition = Vector3.up * ResolveLabelLocalY(); _labelRoot.localRotation = Quaternion.identity; _labelRoot.localScale = Vector3.one; Font font = TeleporterOverheadTextConfig.ResolveFont(); _lastFontName = TeleporterOverheadTextConfig.FontName.Value; _lastFontSize = TeleporterOverheadTextConfig.FontSize.Value; _outlineMeshes = (TextMesh[])(object)new TextMesh[OutlineOffsets.Length]; _outlineRenderers = (MeshRenderer[])(object)new MeshRenderer[OutlineOffsets.Length]; for (int i = 0; i < OutlineOffsets.Length; i++) { GameObject val2 = new GameObject("Outline_" + i); val2.transform.SetParent(_labelRoot, false); val2.transform.localPosition = OutlineOffsets[i]; _outlineMeshes[i] = CreateTextMesh(val2, font, new Color(0f, 0f, 0f, 0.85f)); _outlineRenderers[i] = val2.GetComponent(); } GameObject val3 = new GameObject("Front"); val3.transform.SetParent(_labelRoot, false); val3.transform.localPosition = new Vector3(0f, 0f, -0.01f); _textMesh = CreateTextMesh(val3, font, TeleporterOverheadTextConfig.ResolveTextColor()); _renderer = val3.GetComponent(); } private static TextMesh CreateTextMesh(GameObject go, Font font, Color color) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) TextMesh val = go.AddComponent(); val.anchor = (TextAnchor)4; val.alignment = (TextAlignment)1; val.characterSize = TeleporterOverheadTextConfig.Size.Value; val.fontSize = TeleporterOverheadTextConfig.FontSize.Value; val.color = color; val.text = string.Empty; if ((Object)(object)font != (Object)null) { val.font = font; MeshRenderer component = go.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)font.material != (Object)null) { ((Renderer)component).sharedMaterial = font.material; } } MeshRenderer component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; } return val; } private void LateUpdate() { if ((Object)(object)_labelRoot == (Object)null || (Object)(object)_textMesh == (Object)null) { return; } if (!TeleporterOverheadTextConfig.Enabled.Value || !TeleporterOverheadTextPlugin.LabelsVisible) { SetVisible(visible: false); return; } float value = TeleporterOverheadTextConfig.UpdateInterval.Value; _refreshTimer += Time.deltaTime; if (_refreshTimer >= value) { _refreshTimer = 0f; RefreshText(force: false); } ApplyAppearance(); BillboardToCamera(); UpdateVisibility(); } private void RefreshText(bool force) { if ((Object)(object)_portal == (Object)null || (Object)(object)_textMesh == (Object)null) { return; } string empty = string.Empty; try { empty = _portal.GetText() ?? string.Empty; empty = StringExtensionMethods.RemoveRichTextTags(empty); } catch { return; } empty = empty.Trim(); string text = ((!string.IsNullOrEmpty(empty)) ? empty : (TeleporterOverheadTextConfig.ShowWhenEmpty.Value ? "(unnamed)" : string.Empty)); if (!force && text == _lastText) { return; } _lastText = text; _textMesh.text = text; if (_outlineMeshes == null) { return; } for (int i = 0; i < _outlineMeshes.Length; i++) { if ((Object)(object)_outlineMeshes[i] != (Object)null) { _outlineMeshes[i].text = text; } } } private void ApplyAppearance() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) float num = ResolveLabelLocalY(); if (!Mathf.Approximately(_labelRoot.localPosition.y, num)) { _labelRoot.localPosition = Vector3.up * num; } string value = TeleporterOverheadTextConfig.FontName.Value; int value2 = TeleporterOverheadTextConfig.FontSize.Value; if (value != _lastFontName || value2 != _lastFontSize) { Font font = TeleporterOverheadTextConfig.ResolveFont(); ApplyFont(font, value2); _lastFontName = value; _lastFontSize = value2; } float value3 = TeleporterOverheadTextConfig.Size.Value; if (!Mathf.Approximately(_textMesh.characterSize, value3)) { _textMesh.characterSize = value3; if (_outlineMeshes != null) { for (int i = 0; i < _outlineMeshes.Length; i++) { if ((Object)(object)_outlineMeshes[i] != (Object)null) { _outlineMeshes[i].characterSize = value3; } } } } Color val = TeleporterOverheadTextConfig.ResolveTextColor(); if (TeleporterOverheadTextConfig.IsRgbCyclePreset() || _textMesh.color != val) { _textMesh.color = val; } } private float ResolveLabelLocalY() { float value = TeleporterOverheadTextConfig.HeightOffset.Value; float portalTopLocalY = GetPortalTopLocalY(); if (portalTopLocalY <= 0.01f) { return value; } return Mathf.Max(value, portalTopLocalY + 0.45f); } private float GetPortalTopLocalY() { //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_006b: 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_007c: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0155: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (_topMeasured) { return _cachedTopLocalY; } float num = 0f; bool flag = false; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); Bounds bounds; foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (!((Object)(object)_labelRoot != (Object)null) || !((Component)val).transform.IsChildOf(_labelRoot))) { Transform transform = ((Component)this).transform; bounds = val.bounds; float x = ((Bounds)(ref bounds)).center.x; bounds = val.bounds; float y = ((Bounds)(ref bounds)).max.y; bounds = val.bounds; float y2 = transform.InverseTransformPoint(new Vector3(x, y, ((Bounds)(ref bounds)).center.z)).y; if (!flag || y2 > num) { num = y2; flag = true; } } } if (!flag) { Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !val2.isTrigger && (!((Object)(object)_labelRoot != (Object)null) || !((Component)val2).transform.IsChildOf(_labelRoot))) { Transform transform2 = ((Component)this).transform; bounds = val2.bounds; float x2 = ((Bounds)(ref bounds)).center.x; bounds = val2.bounds; float y3 = ((Bounds)(ref bounds)).max.y; bounds = val2.bounds; float y4 = transform2.InverseTransformPoint(new Vector3(x2, y3, ((Bounds)(ref bounds)).center.z)).y; if (!flag || y4 > num) { num = y4; flag = true; } } } } if (flag && num > 0.5f) { _cachedTopLocalY = num; _topMeasured = true; } if (!flag) { return 0f; } return num; } private void ApplyFont(Font font, int fontSize) { if ((Object)(object)font == (Object)null) { return; } ApplyFontToMesh(_textMesh, font, fontSize); if (_outlineMeshes != null) { for (int i = 0; i < _outlineMeshes.Length; i++) { ApplyFontToMesh(_outlineMeshes[i], font, fontSize); } } } private static void ApplyFontToMesh(TextMesh textMesh, Font font, int fontSize) { if (!((Object)(object)textMesh == (Object)null)) { textMesh.font = font; textMesh.fontSize = fontSize; MeshRenderer component = ((Component)textMesh).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)font.material != (Object)null) { ((Renderer)component).sharedMaterial = font.material; } } } private void BillboardToCamera() { //IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_004d: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if (!((Object)(object)mainCamera == (Object)null)) { Vector3 val = _labelRoot.position - ((Component)mainCamera).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { _labelRoot.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } } } private void UpdateVisibility() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) if (string.IsNullOrEmpty(_lastText)) { SetVisible(visible: false); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { SetVisible(visible: false); return; } float value = TeleporterOverheadTextConfig.MaxDistance.Value; if (value > 0f) { Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > value * value) { SetVisible(visible: false); return; } } if (TeleporterOverheadTextConfig.RequireLineOfSight.Value && !HasLineOfSight()) { SetVisible(visible: false); } else { SetVisible(visible: true); } } private bool HasLineOfSight() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0037: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera == (Object)null) { return false; } Vector3 position = ((Component)mainCamera).transform.position; Vector3 val = ((Component)this).transform.position + Vector3.up * 1.2f - position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.05f) { return true; } int num = Physics.RaycastNonAlloc(position, val / magnitude, RayHits, magnitude, SolidMask, (QueryTriggerInteraction)1); if (num <= 0) { return true; } float num2 = float.MaxValue; Collider val2 = null; for (int i = 0; i < num; i++) { RaycastHit val3 = RayHits[i]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(((Component)Player.m_localPlayer).transform)) && ((RaycastHit)(ref val3)).distance < num2) { num2 = ((RaycastHit)(ref val3)).distance; val2 = ((RaycastHit)(ref val3)).collider; } } if ((Object)(object)val2 == (Object)null) { return true; } Transform transform = ((Component)val2).transform; if (!((Object)(object)transform == (Object)(object)((Component)this).transform)) { return transform.IsChildOf(((Component)this).transform); } return true; } private void SetVisible(bool visible) { if ((Object)(object)_renderer != (Object)null && ((Renderer)_renderer).enabled != visible) { ((Renderer)_renderer).enabled = visible; } if (_outlineRenderers == null) { return; } for (int i = 0; i < _outlineRenderers.Length; i++) { MeshRenderer val = _outlineRenderers[i]; if ((Object)(object)val != (Object)null && ((Renderer)val).enabled != visible) { ((Renderer)val).enabled = visible; } } } } internal enum ColorPreset { Custom, White, SoftGold, Red, Green, Blue, Yellow, Cyan, Magenta, Orange, RGBCycleSlow, RGBCycleMedium, RGBCycleFast } internal static class TeleporterOverheadTextConfig { internal static ConfigEntry Enabled; internal static ConfigEntry ToggleKey; internal static ConfigEntry HeightOffset; internal static ConfigEntry FontName; internal static ConfigEntry Size; internal static ConfigEntry FontSize; internal static ConfigEntry ColorPreset; internal static ConfigEntry ColorR; internal static ConfigEntry ColorG; internal static ConfigEntry ColorB; internal static ConfigEntry ColorA; internal static ConfigEntry MaxDistance; internal static ConfigEntry RequireLineOfSight; internal static ConfigEntry ShowWhenEmpty; internal static ConfigEntry UpdateInterval; internal static void Init(ConfigFile config) { //IL_0030: 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_0077: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown Enabled = config.Bind("General", "Enabled", true, "Master toggle for portal overhead labels."); ToggleKey = config.Bind("General", "ToggleKey", new KeyboardShortcut((KeyCode)280, Array.Empty()), "Keybind to show/hide portal overhead labels in-game. Set to None to disable the hotkey."); HeightOffset = config.Bind("Appearance", "HeightOffset", 2.5f, new ConfigDescription("Minimum label height above the portal origin, in meters. Tall portals (Portal Stone) also lift the label above the mesh top.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 8f), Array.Empty())); FontName = config.Bind("Appearance", "Font", "Arial", "Font name for portal labels. Builtin (Arial) or an installed OS font name."); Size = config.Bind("Appearance", "Size", 0.12f, new ConfigDescription("World-space size of the label text (TextMesh character size).", (AcceptableValueBase)(object)new AcceptableValueRange(0.03f, 0.5f), Array.Empty())); FontSize = config.Bind("Appearance", "FontSize", 64, new ConfigDescription("Font resolution / glyph size used by TextMesh.", (AcceptableValueBase)(object)new AcceptableValueRange(16, 128), Array.Empty())); ColorPreset = config.Bind("Appearance", "ColorPreset", Teleporter_Overhead_Text.ColorPreset.SoftGold, "Named color preset. Custom uses ColorR/G/B/A. RGBCycleSlow/Medium/Fast animate rainbow hues."); ColorR = config.Bind("Appearance", "ColorR", 255, new ConfigDescription("Red channel (0-255) when ColorPreset is Custom.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); ColorG = config.Bind("Appearance", "ColorG", 184, new ConfigDescription("Green channel (0-255) when ColorPreset is Custom.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); ColorB = config.Bind("Appearance", "ColorB", 56, new ConfigDescription("Blue channel (0-255) when ColorPreset is Custom.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); ColorA = config.Bind("Appearance", "ColorA", 255, new ConfigDescription("Alpha channel (0-255) when ColorPreset is Custom or an RGBCycle preset.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); MaxDistance = config.Bind("Visibility", "MaxDistance", 40f, new ConfigDescription("Hide labels farther than this many meters from the local player. 0 = always show.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 200f), Array.Empty())); RequireLineOfSight = config.Bind("Visibility", "RequireLineOfSight", true, "When enabled, hide labels if a wall or other solid blocks view of the teleporter."); ShowWhenEmpty = config.Bind("Visibility", "ShowWhenEmpty", false, "When enabled, portals with no tag still show a placeholder label."); UpdateInterval = config.Bind("Advanced", "UpdateInterval", 0.5f, new ConfigDescription("How often (seconds) each label refreshes its tag text from the portal.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); MigrateLegacyTextScale(config); MigrateLegacyRgbCycle(config); RewriteLegacyJsonTextColor(config); } internal static bool IsRgbCyclePreset() { ColorPreset value = ColorPreset.Value; if ((uint)(value - 10) <= 2u) { return true; } return false; } internal static Color ResolveTextColor() { //IL_0185: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_011a: 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_0130: 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) return (Color)(ColorPreset.Value switch { Teleporter_Overhead_Text.ColorPreset.White => Color.white, Teleporter_Overhead_Text.ColorPreset.SoftGold => new Color(1f, 0.72f, 0.22f, 1f), Teleporter_Overhead_Text.ColorPreset.Red => new Color(1f, 0.25f, 0.25f, 1f), Teleporter_Overhead_Text.ColorPreset.Green => new Color(0.35f, 1f, 0.4f, 1f), Teleporter_Overhead_Text.ColorPreset.Blue => new Color(0.35f, 0.65f, 1f, 1f), Teleporter_Overhead_Text.ColorPreset.Yellow => new Color(1f, 0.92f, 0.2f, 1f), Teleporter_Overhead_Text.ColorPreset.Cyan => new Color(0.3f, 0.95f, 1f, 1f), Teleporter_Overhead_Text.ColorPreset.Magenta => new Color(1f, 0.35f, 0.9f, 1f), Teleporter_Overhead_Text.ColorPreset.Orange => new Color(1f, 0.55f, 0.15f, 1f), Teleporter_Overhead_Text.ColorPreset.RGBCycleSlow => ResolveCycleColor(0.1f), Teleporter_Overhead_Text.ColorPreset.RGBCycleMedium => ResolveCycleColor(0.25f), Teleporter_Overhead_Text.ColorPreset.RGBCycleFast => ResolveCycleColor(0.75f), _ => new Color((float)ColorR.Value / 255f, (float)ColorG.Value / 255f, (float)ColorB.Value / 255f, (float)ColorA.Value / 255f), }); } private static Color ResolveCycleColor(float cyclesPerSecond) { //IL_001b: 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_0039: Unknown result type (might be due to invalid IL or missing references) Color result = Color.HSVToRGB(Mathf.Repeat(Time.unscaledTime * cyclesPerSecond, 1f), 1f, 1f); result.a = (float)ColorA.Value / 255f; return result; } internal static Font ResolveFont() { string text = ((FontName.Value != null) ? FontName.Value.Trim() : string.Empty); if (string.IsNullOrEmpty(text)) { text = "Arial"; } Font builtinResource = Resources.GetBuiltinResource(text.EndsWith(".ttf", StringComparison.OrdinalIgnoreCase) ? text : (text + ".ttf")); if ((Object)(object)builtinResource != (Object)null) { return builtinResource; } try { Font val = Font.CreateDynamicFontFromOSFont(text, FontSize.Value); if ((Object)(object)val != (Object)null) { return val; } } catch { } return Resources.GetBuiltinResource("Arial.ttf"); } private static void MigrateLegacyTextScale(ConfigFile config) { string configFilePath = config.ConfigFilePath; if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath)) { return; } string text = File.ReadAllText(configFilePath); int num = text.IndexOf("TextScale = ", StringComparison.Ordinal); if (num >= 0) { int num2 = num + "TextScale = ".Length; int i; for (i = num2; i < text.Length && (char.IsDigit(text[i]) || text[i] == '.' || text[i] == '-'); i++) { } if (i > num2 && float.TryParse(text.Substring(num2, i - num2), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && Mathf.Approximately(Size.Value, 0.12f) && !Mathf.Approximately(result, Size.Value)) { Size.Value = result; config.Save(); } } } private static void MigrateLegacyRgbCycle(ConfigFile config) { string configFilePath = config.ConfigFilePath; if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath)) { return; } string text = File.ReadAllText(configFilePath); int num = text.IndexOf("ColorPreset = RGBCycle", StringComparison.Ordinal); if (num >= 0) { int num2 = num + "ColorPreset = RGBCycle".Length; if (num2 >= text.Length || !char.IsLetterOrDigit(text[num2])) { text = text.Substring(0, num) + "ColorPreset = RGBCycleFast" + text.Substring(num2); File.WriteAllText(configFilePath, text); ColorPreset.Value = Teleporter_Overhead_Text.ColorPreset.RGBCycleFast; config.Save(); } } } private static void RewriteLegacyJsonTextColor(ConfigFile config) { string configFilePath = config.ConfigFilePath; if (!string.IsNullOrEmpty(configFilePath) && File.Exists(configFilePath) && File.ReadAllText(configFilePath).IndexOf("\"r\":", StringComparison.Ordinal) >= 0) { config.Save(); } } } [BepInPlugin("ModdedWolf.Teleporter_Overhead_Text", "Teleporter Overhead Text", "1.0.0")] public class TeleporterOverheadTextPlugin : BaseUnityPlugin { public const string GUID = "ModdedWolf.Teleporter_Overhead_Text"; public const string NAME = "Teleporter Overhead Text"; public const string VERSION = "1.0.0"; internal static TeleporterOverheadTextPlugin Instance; internal static ManualLogSource Log; internal static bool LabelsVisible = true; private Harmony _harmony; private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; TeleporterOverheadTextConfig.Init(((BaseUnityPlugin)this).Config); LabelsVisible = TeleporterOverheadTextConfig.Enabled.Value; _harmony = new Harmony("ModdedWolf.Teleporter_Overhead_Text"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Teleporter Overhead Text v1.0.0 loaded."); } private void Update() { if (WasTogglePressed() && !IsTextInputFocused()) { LabelsVisible = !LabelsVisible; ((BaseUnityPlugin)this).Logger.LogInfo((object)(LabelsVisible ? "Portal overhead labels shown." : "Portal overhead labels hidden.")); } } private static bool WasTogglePressed() { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) KeyboardShortcut value = TeleporterOverheadTextConfig.ToggleKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey == 0) { return false; } if (((KeyboardShortcut)(ref value)).IsDown()) { return true; } if (!ZInput.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey, true)) { return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey); } return true; } private static bool IsTextInputFocused() { if (Console.IsVisible()) { return true; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } if (TextInput.IsVisible()) { return true; } return false; } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Instance = null; } } } namespace Teleporter_Overhead_Text.Patches { [HarmonyPatch(typeof(TeleportWorld))] internal static class TeleportWorldPatches { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(TeleportWorld __instance) { PortalLabel.Attach(__instance); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }