Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ComfortViewReforged v1.0.1
plugins/ComfortView.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("ComfortView")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("ComfortView Reforged")] [assembly: AssemblyTitle("ComfortView Reforged")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.1.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 ComfortView { [BepInPlugin("mishka.valheim.comfortview", "ComfortView Reforged", "1.0.1")] public class ComfortViewPlugin : BaseUnityPlugin { private enum DisplayMode { All, ActiveOnly, Picker } private enum MenuTab { Items, Nearby } private class RingEntry { public GameObject Root; public LineRenderer Ring; public LineRenderer Post; public LineRenderer Spoke; public GameObject SphereRoot; public LineRenderer[] SphereRings; public Color Color; } public const string PluginGUID = "mishka.valheim.comfortview"; public const string PluginName = "ComfortView Reforged"; public const string PluginVersion = "1.0.1"; private const float ComfortRadius = 10f; private const float ScanRadius = 20f; private const float RefreshInterval = 1f; private const int Segments = 48; private const float HeightOffset = 0.05f; private const float DimWidth = 0.04f; private const float HoverWidth = 0.12f; private const float DimAlpha = 0.35f; private const float PostHeight = 2.5f; private const float HoverRayDistance = 50f; private const float SoloAimTolerance = 1.2f; private const float SpokeAlpha = 0.6f; private const float SpokeWidth = 0.05f; private const float SpokeDashesPerRadius = 10f; private const float SphereFillAlpha = 0.12f; private static Material s_ringMaterial; private static Material s_dashMaterial; private static Material s_sphereFillMaterial; private static Vector3[] s_localCircle; private static TMP_FontAsset s_font; private static Sprite s_panelSprite; private static int s_pieceRayMask = -1; private static List<(string key, string label, ComfortGroup group, int comfort)> s_allComfortTypes; private static readonly List<Piece> s_scanBuffer = new List<Piece>(); private static readonly List<Piece> s_activeBuffer = new List<Piece>(); private static readonly List<Piece> s_visibleBuffer = new List<Piece>(); private static readonly List<Piece> s_staleBuffer = new List<Piece>(); private ConfigEntry<KeyboardShortcut> toggleKey; private ConfigEntry<KeyboardShortcut> menuKey; private ConfigEntry<KeyboardShortcut> soloKey; private bool visible; private bool menuOpen; private DisplayMode mode; private MenuTab activeTab; private bool sphereMode; private float refreshTimer; private int menuIndex; private const int ListColumnCount = 3; private GameObject menuRoot; private TMP_Text[] modeTexts; private TMP_Text shapeText; private TMP_Text tabsText; private GameObject itemsSection; private GameObject nearbySection; private Transform[] listColumns; private Transform[] nearbyColumns; private readonly List<TMP_Text> listRowTexts = new List<TMP_Text>(); private readonly List<int> listRowItemIndex = new List<int>(); private readonly List<int> listNavToDataIndex = new List<int>(); private int listRowsBuiltFor = -1; private readonly List<TMP_Text> nearbyRowTexts = new List<TMP_Text>(); private readonly List<Piece> nearbyNavPieces = new List<Piece>(); private readonly HashSet<Piece> lastNearbySet = new HashSet<Piece>(); private float navRepeatTimer; private const float NavInitialDelay = 0.35f; private const float NavRepeatInterval = 0.08f; private readonly Dictionary<Piece, RingEntry> activeRings = new Dictionary<Piece, RingEntry>(); private readonly HashSet<Piece> pinned = new HashSet<Piece>(); private readonly HashSet<string> selectedTypes = new HashSet<string>(); private Piece hoveredPiece; private const int ShapeRowIndex = 2; private const int TabRowIndex = 3; private const int FirstListRowIndex = 4; private static readonly ComfortGroup[] GroupOrder; private static Color CategoryColor(ComfortGroup group) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) return Color32.op_Implicit((Color32)((group - 1) switch { 0 => new Color32((byte)227, (byte)154, (byte)59, byte.MaxValue), 3 => new Color32((byte)199, (byte)95, (byte)50, byte.MaxValue), 4 => new Color32((byte)138, (byte)118, (byte)72, byte.MaxValue), 1 => new Color32((byte)156, (byte)138, (byte)192, byte.MaxValue), 2 => new Color32((byte)76, (byte)134, (byte)168, byte.MaxValue), 5 => new Color32((byte)127, (byte)166, (byte)80, byte.MaxValue), _ => new Color32((byte)138, (byte)134, (byte)114, byte.MaxValue), })); } private void Awake() { //IL_001b: 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_0079: 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_00a1: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle Radius", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Key used to toggle the comfort radius rings on and off."); menuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle Menu", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key used to open the comfort radius selection menu."); soloKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Pin Looked-At Item", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Key used to pin or unpin the exact comfort item you're looking at."); s_ringMaterial = new Material(Shader.Find("Sprites/Default")); Texture2D val = new Texture2D(4, 1, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)0; val.SetPixels((Color[])(object)new Color[4] { Color.white, Color.white, new Color(1f, 1f, 1f, 0f), new Color(1f, 1f, 1f, 0f) }); val.Apply(); s_dashMaterial = new Material(Shader.Find("Sprites/Default")); s_dashMaterial.mainTexture = (Texture)(object)val; s_dashMaterial.mainTextureScale = new Vector2(10f, 1f); s_sphereFillMaterial = new Material(Shader.Find("Sprites/Default")); s_localCircle = (Vector3[])(object)new Vector3[49]; for (int i = 0; i <= 48; i++) { float num = (float)i * (float)Math.PI * 2f / 48f; s_localCircle[i] = new Vector3(Mathf.Cos(num) * 10f, 0.05f, Mathf.Sin(num) * 10f); } } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_003d: 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) KeyboardShortcut value = toggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { visible = !visible; if (!visible) { ClearRings(); } } value = soloKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { TogglePin(RaycastForComfortPiece()); } value = menuKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() || (menuOpen && Input.GetKeyDown((KeyCode)27))) { menuOpen = !menuOpen; if (menuOpen) { BuildMenu(); visible = true; menuIndex = 0; } if ((Object)(object)menuRoot != (Object)null) { menuRoot.SetActive(menuOpen); } } if (menuOpen) { UpdateMenuInput(); UpdateMenuVisuals(); } if (!visible) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { ClearRings(); return; } refreshTimer -= Time.deltaTime; if (refreshTimer <= 0f) { refreshTimer = 1f; RefreshRings(localPlayer); if ((Object)(object)menuRoot != (Object)null && NearbySetChanged()) { RebuildNearbyRows(localPlayer); } } UpdateHover(); } private void TogglePin(Piece target) { if (!((Object)(object)target == (Object)null)) { if (!pinned.Add(target)) { pinned.Remove(target); } mode = DisplayMode.Picker; visible = true; refreshTimer = 0f; } } private static int PieceRayMask() { if (s_pieceRayMask == -1) { s_pieceRayMask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle" }); } return s_pieceRayMask; } private static Piece RaycastForComfortPiece() { //IL_0036: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : null); Player localPlayer = Player.m_localPlayer; if ((Object)(object)val == (Object)null || (Object)(object)localPlayer == (Object)null) { return null; } RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val.position, val.forward, ref val2, 50f, PieceRayMask())) { Piece componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Piece>(); if (IsRealComfortPiece(componentInParent)) { return componentInParent; } } s_scanBuffer.Clear(); Piece.GetAllComfortPiecesInRadius(((Component)localPlayer).transform.position, 20f, s_scanBuffer); Piece result = null; float num = 1.2f; foreach (Piece item in s_scanBuffer) { if (!IsRealComfortPiece(item)) { continue; } float num2 = Vector3.Dot(((Component)item).transform.position - val.position, val.forward); if (!(num2 <= 0f) && !(num2 > 50f)) { float num3 = Vector3.Distance(val.position + val.forward * num2, ((Component)item).transform.position); if (num3 < num) { num = num3; result = item; } } } return result; } private int MenuRowCount() { return 4 + ((activeTab == MenuTab.Items) ? listNavToDataIndex.Count : nearbyNavPieces.Count); } private void UpdateMenuInput() { int num = MenuRowCount(); menuIndex = Mathf.Clamp(menuIndex, 0, num - 1); int num2 = 0; if (Input.GetKeyDown((KeyCode)274)) { num2 = 1; navRepeatTimer = 0.35f; } else if (Input.GetKeyDown((KeyCode)273)) { num2 = -1; navRepeatTimer = 0.35f; } else if (Input.GetKey((KeyCode)274) || Input.GetKey((KeyCode)273)) { navRepeatTimer -= Time.unscaledDeltaTime; if (navRepeatTimer <= 0f) { num2 = (Input.GetKey((KeyCode)274) ? 1 : (-1)); navRepeatTimer = 0.08f; } } if (num2 != 0) { menuIndex = (menuIndex + num2 + num) % num; } bool keyDown = Input.GetKeyDown((KeyCode)275); bool keyDown2 = Input.GetKeyDown((KeyCode)276); if (menuIndex == 3) { if (keyDown || keyDown2) { activeTab = ((activeTab == MenuTab.Items) ? MenuTab.Nearby : MenuTab.Items); } } else if (keyDown) { ActivateMenuRow(menuIndex); } } private void ActivateMenuRow(int index) { switch (index) { case 0: ToggleMode(DisplayMode.All); return; case 1: ToggleMode(DisplayMode.ActiveOnly); return; case 2: sphereMode = !sphereMode; refreshTimer = 0f; return; } int num = index - 4; if (activeTab == MenuTab.Nearby) { if (num >= 0 && num < nearbyNavPieces.Count) { TogglePin(nearbyNavPieces[num]); } } else if (s_allComfortTypes != null && num >= 0 && num < listNavToDataIndex.Count) { string item = s_allComfortTypes[listNavToDataIndex[num]].key; if (!selectedTypes.Add(item)) { selectedTypes.Remove(item); } mode = DisplayMode.Picker; visible = true; refreshTimer = 0f; } } private void ToggleMode(DisplayMode targetMode) { if (mode == targetMode && visible) { visible = false; ClearRings(); } else { mode = targetMode; visible = true; refreshTimer = 0f; } } private unsafe static string GroupLabel(ComfortGroup group) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)group != 0) { return ((object)(*(ComfortGroup*)(&group))/*cast due to .constrained prefix*/).ToString(); } return "Other"; } private static bool IsRealComfortPiece(Piece piece) { if ((Object)(object)piece != (Object)null) { return piece.m_comfort > 0; } return false; } private static bool EnsureAllComfortTypes() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (s_allComfortTypes != null) { return true; } if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } List<(string, string, ComfortGroup, int)> list = new List<(string, string, ComfortGroup, int)>(); HashSet<string> hashSet = new HashSet<string>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { Piece component = prefab.GetComponent<Piece>(); if (IsRealComfortPiece(component) && hashSet.Add(component.m_name)) { list.Add((component.m_name, Localization.instance.Localize(component.m_name), component.m_comfortGroup, component.m_comfort)); } } list.Sort(delegate((string key, string label, ComfortGroup group, int comfort) a, (string key, string label, ComfortGroup group, int comfort) b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) int num = Array.IndexOf(GroupOrder, a.group).CompareTo(Array.IndexOf(GroupOrder, b.group)); return (num != 0) ? num : string.CompareOrdinal(a.label, b.label); }); s_allComfortTypes = list; return true; } private static bool EnsureFont() { if ((Object)(object)s_font != (Object)null) { return true; } s_font = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Valheim-AveriaSerifLibre")); return (Object)(object)s_font != (Object)null; } private static bool EnsurePanelSprite() { if ((Object)(object)s_panelSprite != (Object)null) { return true; } s_panelSprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "woodpanel_crafting")); return (Object)(object)s_panelSprite != (Object)null; } private void BuildMenu() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_007a: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_0222: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)menuRoot != (Object)null) && EnsureFont() && EnsurePanelSprite()) { menuRoot = new GameObject("ComfortViewMenu"); Canvas obj = menuRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 9990; menuRoot.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)0; GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(menuRoot.transform, false); Image obj2 = val.AddComponent<Image>(); obj2.sprite = s_panelSprite; obj2.type = (Type)1; ((Graphic)obj2).color = RenderSettings.ambientLight; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(20f, -20f); component.sizeDelta = new Vector2(620f, 0f); VerticalLayoutGroup obj3 = val.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj3).padding = new RectOffset(12, 12, 12, 12); ((HorizontalOrVerticalLayoutGroup)obj3).spacing = 3f; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false; ((LayoutGroup)obj3).childAlignment = (TextAnchor)0; val.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; CreateText((Transform)(object)component, "ComfortView Reforged", (TextAlignmentOptions)513, 15f, Color.white); CreateText((Transform)(object)component, "Up/Down move * Right select/pin/toggle * Esc close", (TextAlignmentOptions)513, 9f, new Color(0.8f, 0.8f, 0.8f)); modeTexts = (TMP_Text[])(object)new TMP_Text[2]; for (int i = 0; i < modeTexts.Length; i++) { modeTexts[i] = CreateText((Transform)(object)component, "", (TextAlignmentOptions)513, 11f, Color.white); } shapeText = CreateText((Transform)(object)component, "", (TextAlignmentOptions)513, 11f, Color.white); tabsText = CreateText((Transform)(object)component, "", (TextAlignmentOptions)513, 11f, Color.white); itemsSection = BuildColumnSection((Transform)(object)component, out listColumns); nearbySection = BuildColumnSection((Transform)(object)component, out nearbyColumns); EnsureAllComfortTypes(); } } private static GameObject BuildColumnSection(Transform parent, out Transform[] columns) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown GameObject val = new GameObject("Section", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 14f; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).childAlignment = (TextAnchor)0; columns = (Transform[])(object)new Transform[3]; for (int i = 0; i < 3; i++) { GameObject val2 = new GameObject("Col" + i, new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); VerticalLayoutGroup obj2 = val2.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 1f; columns[i] = val2.transform; } return val; } private static TMP_Text CreateText(Transform parent, string text, TextAlignmentOptions alignment, float fontSize, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = s_font; ((TMP_Text)obj).fontSharedMaterial = ((TMP_Asset)s_font).material; ((TMP_Text)obj).fontSize = fontSize; ((Graphic)obj).color = color; ((TMP_Text)obj).text = text; ((TMP_Text)obj).alignment = alignment; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; return (TMP_Text)(object)obj; } private void UpdateMenuVisuals() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) UpdateModeRowText(0, "Show all nearby"); UpdateModeRowText(1, "Show active only"); bool flag = menuIndex == 2; shapeText.text = (flag ? "> " : " ") + "Shape: " + (sphereMode ? "Spheres" : "Circles"); ((Graphic)shapeText).color = (flag ? Color.yellow : Color.white); bool flag2 = menuIndex == 3; string text = ((activeTab == MenuTab.Items) ? "[ Items ] Nearby" : " Items [ Nearby ]"); tabsText.text = (flag2 ? "> " : " ") + text; ((Graphic)tabsText).color = (flag2 ? Color.yellow : Color.white); itemsSection.SetActive(activeTab == MenuTab.Items); nearbySection.SetActive(activeTab == MenuTab.Nearby); EnsureAllComfortTypes(); if (s_allComfortTypes == null) { return; } if (listRowsBuiltFor != s_allComfortTypes.Count) { RebuildListRows(); } for (int i = 0; i < listRowTexts.Count; i++) { int num = listRowItemIndex[i]; if (num >= 0) { (string, string, ComfortGroup, int) tuple = s_allComfortTypes[listNavToDataIndex[num]]; bool flag3 = selectedTypes.Contains(tuple.Item1); bool flag4 = activeTab == MenuTab.Items && menuIndex == 4 + num; listRowTexts[i].text = (flag4 ? "> " : " ") + (flag3 ? "[x] " : "[ ] ") + $"{tuple.Item2} (+{tuple.Item4})"; ((Graphic)listRowTexts[i]).color = (flag4 ? Color.yellow : CategoryColor(tuple.Item3)); } } for (int j = 0; j < nearbyRowTexts.Count; j++) { if (j < nearbyNavPieces.Count) { Piece val = nearbyNavPieces[j]; bool flag5 = pinned.Contains(val); bool flag6 = activeTab == MenuTab.Nearby && menuIndex == 4 + j; Player localPlayer = Player.m_localPlayer; float num2 = (((Object)(object)localPlayer != (Object)null) ? Vector3.Distance(((Component)localPlayer).transform.position, ((Component)val).transform.position) : 0f); nearbyRowTexts[j].text = (flag6 ? "> " : " ") + (flag5 ? "[x] " : "[ ] ") + $"{Localization.instance.Localize(val.m_name)} ({num2:0}m)"; ((Graphic)nearbyRowTexts[j]).color = (flag6 ? Color.yellow : CategoryColor(val.m_comfortGroup)); } } } private void UpdateModeRowText(int index, string label) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) bool flag = index == (int)mode && visible; bool flag2 = menuIndex == index; modeTexts[index].text = (flag2 ? "> " : " ") + (flag ? "(*) " : "( ) ") + label; ((Graphic)modeTexts[index]).color = (flag2 ? Color.yellow : Color.white); } private static int ShortestColumn(int[] colLoad) { int num = 0; for (int i = 1; i < colLoad.Length; i++) { if (colLoad[i] < colLoad[num]) { num = i; } } return num; } private void RebuildListRows() { //IL_0020: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_00f3: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) Transform[] array = listColumns; for (int i = 0; i < array.Length; i++) { foreach (Transform item3 in array[i]) { Object.Destroy((Object)(object)((Component)item3).gameObject); } } listRowTexts.Clear(); listRowItemIndex.Clear(); listNavToDataIndex.Clear(); List<List<(int, int, ComfortGroup)>> list = new List<List<(int, int, ComfortGroup)>>(); for (int j = 0; j < listColumns.Length; j++) { list.Add(new List<(int, int, ComfortGroup)>()); } int[] array2 = new int[listColumns.Length]; int num = 0; while (num < s_allComfortTypes.Count) { ComfortGroup item = s_allComfortTypes[num].group; int k; for (k = num; k < s_allComfortTypes.Count && s_allComfortTypes[k].group == item; k++) { } int num2 = ShortestColumn(array2); array2[num2] += 1 + (k - num); list[num2].Add((num, k, item)); num = k; } for (int l = 0; l < listColumns.Length; l++) { foreach (var item4 in list[l]) { TMP_Text item2 = CreateText(listColumns[l], GroupLabel(item4.Item3), (TextAlignmentOptions)513, 10f, CategoryColor(item4.Item3)); listRowTexts.Add(item2); listRowItemIndex.Add(-1); var (m, _, _) = item4; for (; m < item4.Item2; m++) { listRowTexts.Add(CreateText(listColumns[l], "", (TextAlignmentOptions)513, 10f, Color.white)); listRowItemIndex.Add(listNavToDataIndex.Count); listNavToDataIndex.Add(m); } } } listRowsBuiltFor = s_allComfortTypes.Count; } private bool NearbySetChanged() { if (s_scanBuffer.Count != lastNearbySet.Count) { return true; } foreach (Piece item in s_scanBuffer) { if (!lastNearbySet.Contains(item)) { return true; } } return false; } private void RebuildNearbyRows(Player player) { //IL_00cc: 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_01ba: Unknown result type (might be due to invalid IL or missing references) lastNearbySet.Clear(); lastNearbySet.UnionWith(s_scanBuffer); Transform[] array = nearbyColumns; for (int i = 0; i < array.Length; i++) { foreach (Transform item in array[i]) { Object.Destroy((Object)(object)((Component)item).gameObject); } } nearbyRowTexts.Clear(); nearbyNavPieces.Clear(); if (s_scanBuffer.Count == 0) { CreateText(nearbyColumns[0], "(none in range)", (TextAlignmentOptions)513, 10f, new Color(0.7f, 0.7f, 0.7f)); return; } List<Piece> list = s_scanBuffer.OrderBy((Piece p) => Vector3.Distance(((Component)player).transform.position, ((Component)p).transform.position)).ToList(); List<List<Piece>> list2 = new List<List<Piece>>(); for (int num = 0; num < nearbyColumns.Length; num++) { list2.Add(new List<Piece>()); } int[] array2 = new int[nearbyColumns.Length]; foreach (Piece item2 in list) { int num2 = ShortestColumn(array2); array2[num2]++; list2[num2].Add(item2); } for (int num3 = 0; num3 < nearbyColumns.Length; num3++) { foreach (Piece item3 in list2[num3]) { nearbyRowTexts.Add(CreateText(nearbyColumns[num3], "", (TextAlignmentOptions)513, 10f, Color.white)); nearbyNavPieces.Add(item3); } } } private void UpdateHover() { //IL_0027: 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) Piece val = null; Transform val2 = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : null); RaycastHit val3 = default(RaycastHit); if ((Object)(object)val2 != (Object)null && Physics.Raycast(val2.position, val2.forward, ref val3, 50f, PieceRayMask())) { Piece componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Piece>(); if ((Object)(object)componentInParent != (Object)null && activeRings.ContainsKey(componentInParent)) { val = componentInParent; } } if (!((Object)(object)val == (Object)(object)hoveredPiece)) { if ((Object)(object)hoveredPiece != (Object)null && activeRings.TryGetValue(hoveredPiece, out var value)) { SetHover(value, isHovered: false); } hoveredPiece = val; if ((Object)(object)hoveredPiece != (Object)null && activeRings.TryGetValue(hoveredPiece, out var value2)) { SetHover(value2, isHovered: true); } } } private void RefreshRings(Player player) { //IL_0010: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) s_scanBuffer.Clear(); Piece.GetAllComfortPiecesInRadius(((Component)player).transform.position, 20f, s_scanBuffer); s_scanBuffer.RemoveAll((Piece p) => !IsRealComfortPiece(p)); pinned.RemoveWhere((Piece p) => (Object)(object)p == (Object)null); s_visibleBuffer.Clear(); switch (mode) { case DisplayMode.ActiveOnly: ComputeActiveSet(s_scanBuffer, ((Component)player).transform.position, s_visibleBuffer); break; case DisplayMode.Picker: foreach (Piece item in s_scanBuffer) { if (pinned.Contains(item) || selectedTypes.Contains(item.m_name)) { s_visibleBuffer.Add(item); } } break; default: s_visibleBuffer.AddRange(s_scanBuffer); break; } s_staleBuffer.Clear(); foreach (KeyValuePair<Piece, RingEntry> activeRing in activeRings) { if ((Object)(object)activeRing.Key == (Object)null || !s_visibleBuffer.Contains(activeRing.Key)) { s_staleBuffer.Add(activeRing.Key); } } foreach (Piece item2 in s_staleBuffer) { if (activeRings.TryGetValue(item2, out var value) && (Object)(object)value.Root != (Object)null) { Object.Destroy((Object)(object)value.Root); } activeRings.Remove(item2); if ((Object)(object)hoveredPiece == (Object)(object)item2) { hoveredPiece = null; } } foreach (Piece item3 in s_visibleBuffer) { if (!((Object)(object)item3 == (Object)null) && !activeRings.ContainsKey(item3)) { activeRings[item3] = CreateRing(((Component)item3).transform, CategoryColor(item3.m_comfortGroup)); } } foreach (KeyValuePair<Piece, RingEntry> activeRing2 in activeRings) { activeRing2.Value.SphereRoot.SetActive(sphereMode); } } private static void ComputeActiveSet(List<Piece> nearby, Vector3 playerPos, List<Piece> output) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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) s_activeBuffer.Clear(); foreach (Piece item in nearby) { if ((Object)(object)item != (Object)null && Vector3.Distance(((Component)item).transform.position, playerPos) < 10f) { s_activeBuffer.Add(item); } } s_activeBuffer.Sort(CompareComfort); for (int i = 0; i < s_activeBuffer.Count; i++) { Piece val = s_activeBuffer[i]; if (i > 0) { Piece val2 = s_activeBuffer[i - 1]; if (((int)val.m_comfortGroup != 0 && val.m_comfortGroup == val2.m_comfortGroup) || val.m_name == val2.m_name) { continue; } } output.Add(val); } } private static int CompareComfort(Piece x, Piece y) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (x.m_comfortGroup != y.m_comfortGroup) { ref ComfortGroup comfortGroup = ref x.m_comfortGroup; object target = y.m_comfortGroup; return ((Enum)Unsafe.As<ComfortGroup, ComfortGroup>(ref comfortGroup)/*cast due to .constrained prefix*/).CompareTo(target); } float num = x.GetComfort(); float num2 = y.GetComfort(); if (num != num2) { return num2.CompareTo(num); } return string.CompareOrdinal(y.m_name, x.m_name); } private static RingEntry CreateRing(Transform parent, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ComfortRing"); val.transform.SetParent(parent, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.useWorldSpace = false; val2.loop = true; val2.positionCount = s_localCircle.Length; val2.SetPositions(s_localCircle); ((Renderer)val2).material = s_ringMaterial; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; GameObject val3 = new GameObject("Post"); val3.transform.SetParent(val.transform, false); LineRenderer val4 = val3.AddComponent<LineRenderer>(); val4.useWorldSpace = false; val4.loop = false; val4.positionCount = 2; val4.SetPositions((Vector3[])(object)new Vector3[2] { Vector3.zero, Vector3.up * 2.5f }); val4.widthMultiplier = 0.04f; ((Renderer)val4).material = s_ringMaterial; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val4).receiveShadows = false; val3.SetActive(false); GameObject val5 = new GameObject("Spoke"); val5.transform.SetParent(val.transform, false); LineRenderer val6 = val5.AddComponent<LineRenderer>(); val6.useWorldSpace = false; val6.loop = false; val6.positionCount = 2; val6.SetPositions((Vector3[])(object)new Vector3[2] { Vector3.zero, new Vector3(10f, 0.05f, 0f) }); val6.widthMultiplier = 0.05f; ((Renderer)val6).material = s_dashMaterial; val6.textureMode = (LineTextureMode)1; ((Renderer)val6).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val6).receiveShadows = false; Color val7 = color; val7.a = 0.6f; val6.startColor = val7; val6.endColor = val7; GameObject val8 = new GameObject("Sphere"); val8.transform.SetParent(val.transform, false); LineRenderer[] sphereRings = (LineRenderer[])(object)new LineRenderer[4] { CreateSphereRing(val8.transform, Quaternion.Euler(90f, 0f, 0f)), CreateSphereRing(val8.transform, Quaternion.Euler(0f, 0f, 90f)), CreateSphereRing(val8.transform, Quaternion.Euler(45f, 0f, 45f)), CreateSphereRing(val8.transform, Quaternion.Euler(-45f, 0f, 45f)) }; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "SphereFill"; obj.transform.SetParent(val8.transform, false); obj.transform.localScale = Vector3.one * 20f; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); MeshRenderer component = obj.GetComponent<MeshRenderer>(); ((Renderer)component).material = s_sphereFillMaterial; ((Renderer)component).material.color = new Color(color.r, color.g, color.b, 0.12f); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; val8.SetActive(false); RingEntry obj2 = new RingEntry { Root = val, Ring = val2, Post = val4, Spoke = val6, SphereRoot = val8, SphereRings = sphereRings, Color = color }; SetHover(obj2, isHovered: false); return obj2; } private static LineRenderer CreateSphereRing(Transform parent, Quaternion localRotation) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SphereRing"); val.transform.SetParent(parent, false); val.transform.localRotation = localRotation; LineRenderer obj = val.AddComponent<LineRenderer>(); obj.useWorldSpace = false; obj.loop = true; obj.positionCount = s_localCircle.Length; obj.SetPositions(s_localCircle); ((Renderer)obj).material = s_ringMaterial; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; return obj; } private static void SetHover(RingEntry entry, bool isHovered) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Color color = entry.Color; color.a = (isHovered ? 1f : 0.35f); float widthMultiplier = (isHovered ? 0.12f : 0.04f); entry.Ring.widthMultiplier = widthMultiplier; entry.Ring.startColor = color; entry.Ring.endColor = color; LineRenderer[] sphereRings = entry.SphereRings; foreach (LineRenderer obj in sphereRings) { obj.widthMultiplier = widthMultiplier; obj.startColor = color; obj.endColor = color; } Color color2 = entry.Color; color2.a = 1f; entry.Post.startColor = color2; entry.Post.endColor = color2; ((Component)entry.Post).gameObject.SetActive(isHovered); } private void ClearRings() { foreach (RingEntry value in activeRings.Values) { if ((Object)(object)value.Root != (Object)null) { Object.Destroy((Object)(object)value.Root); } } activeRings.Clear(); hoveredPiece = null; } static ComfortViewPlugin() { ComfortGroup[] array = new ComfortGroup[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); GroupOrder = (ComfortGroup[])(object)array; } } }