using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.UI; [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("AllyClarityOwnerLabels")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AllyClarityOwnerLabels")] [assembly: AssemblyTitle("AllyClarityOwnerLabels")] [assembly: AssemblyVersion("1.0.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 AllyClarityOwnerLabels { [BepInPlugin("local.allyclarity.ownerlabels", "AllyClarityOwnerLabels", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class OwnerLabelsPlugin : BaseUnityPlugin { private sealed class LabelRecord { public CharacterBody Body; public string Caption; public Color Tint; public float DistanceSq; } private readonly List labels = new List(32); private readonly List textPool = new List(32); private GameObject canvasObject; private Canvas overlay; private float nextRefresh; private Camera viewCamera; private CharacterMaster viewerMaster; private ConfigEntry enabledLabels; private ConfigEntry showUnitName; private ConfigEntry includeUnowned; private ConfigEntry hideCloaked; private ConfigEntry maxDistance; private ConfigEntry maxLabels; private ConfigEntry fontSize; private ConfigEntry heightOffset; private ConfigEntry refreshInterval; private ConfigEntry ownColor; private ConfigEntry teammateColor; private ConfigEntry unownedColor; private void Awake() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown enabledLabels = ((BaseUnityPlugin)this).Config.Bind("Labels", "Enable", true, "Show owner labels over allied non-player units."); showUnitName = ((BaseUnityPlugin)this).Config.Bind("Labels", "ShowUnitName", true, "Show Owner's Unit rather than only Owner."); includeUnowned = ((BaseUnityPlugin)this).Config.Bind("Labels", "IncludeUnowned", true, "Show unowned allied units as just their unit name, without Owner's."); hideCloaked = ((BaseUnityPlugin)this).Config.Bind("Labels", "HideInvisibleAndCloaked", true, "Do not expose invisible or cloaked allied units with labels."); maxDistance = ((BaseUnityPlugin)this).Config.Bind("Display", "MaxDistance", 65f, new ConfigDescription("Maximum label distance in meters.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 250f), Array.Empty())); maxLabels = ((BaseUnityPlugin)this).Config.Bind("Display", "MaxLabels", 20, new ConfigDescription("Maximum simultaneously displayed labels.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); fontSize = ((BaseUnityPlugin)this).Config.Bind("Display", "FontSize", 18, new ConfigDescription("TextMeshPro font size.", (AcceptableValueBase)(object)new AcceptableValueRange(10, 36), Array.Empty())); heightOffset = ((BaseUnityPlugin)this).Config.Bind("Display", "HeightOffset", 1.25f, new ConfigDescription("Extra height over the unit in meters.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); refreshInterval = ((BaseUnityPlugin)this).Config.Bind("Display", "RefreshInterval", 0.45f, new ConfigDescription("Seconds between ownership and name refreshes.", (AcceptableValueBase)(object)new AcceptableValueRange(0.15f, 3f), Array.Empty())); ownColor = ((BaseUnityPlugin)this).Config.Bind("Colors", "OwnLabel", new Color(1f, 0.87f, 0.28f, 1f), "Yellow text for your summons. Separate from AllyClarity outline color."); teammateColor = ((BaseUnityPlugin)this).Config.Bind("Colors", "Teammate", new Color(0.45f, 0.8f, 1f, 1f), "Light-blue text for teammates' summons."); unownedColor = ((BaseUnityPlugin)this).Config.Bind("Colors", "Unowned", new Color(0.95f, 0.95f, 0.85f, 1f), "Neutral text for allied units that have no identifiable player owner."); canvasObject = new GameObject("AllyClarityOwnerLabels Canvas", new Type[2] { typeof(RectTransform), typeof(Canvas) }); canvasObject.transform.SetParent(((Component)this).transform, false); overlay = canvasObject.GetComponent(); overlay.renderMode = (RenderMode)0; overlay.overrideSorting = true; overlay.sortingOrder = -500; ((Behaviour)overlay).enabled = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Owner labels v1.1 loaded: game TMP font, no background, hide on pause menu."); } private void Update() { if (!enabledLabels.Value) { if (labels.Count > 0) { labels.Clear(); } if (Object.op_Implicit((Object)(object)overlay)) { ((Behaviour)overlay).enabled = false; } } else if (!(Time.unscaledTime < nextRefresh)) { nextRefresh = Time.unscaledTime + refreshInterval.Value; Refresh(); } } private void Refresh() { //IL_00a5: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Invalid comparison between Unknown and I4 //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) labels.Clear(); viewCamera = null; viewerMaster = null; ReadOnlyCollection readOnlyInstancesList = CameraRigController.readOnlyInstancesList; for (int i = 0; i < readOnlyInstancesList.Count; i++) { CameraRigController val = readOnlyInstancesList[i]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.sceneCam) && val.localUserViewer != null) { viewCamera = val.sceneCam; viewerMaster = val.localUserViewer.cachedMaster; break; } } if (!Object.op_Implicit((Object)(object)viewCamera) || !Object.op_Implicit((Object)(object)viewerMaster)) { return; } Vector3 position = ((Component)viewCamera).transform.position; float num = maxDistance.Value * maxDistance.Value; ReadOnlyCollection readOnlyInstancesList2 = CharacterBody.readOnlyInstancesList; for (int j = 0; j < readOnlyInstancesList2.Count; j++) { CharacterBody val2 = readOnlyInstancesList2[j]; if (!Object.op_Implicit((Object)(object)val2) || !((Behaviour)val2).isActiveAndEnabled || val2.isPlayerControlled || !Object.op_Implicit((Object)(object)val2.teamComponent) || (int)val2.teamComponent.teamIndex != 1 || (Object.op_Implicit((Object)(object)val2.healthComponent) && !val2.healthComponent.alive) || (hideCloaked.Value && IsHidden(val2))) { continue; } Vector3 val3 = val2.corePosition - position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude > num) { continue; } CharacterMaster val4 = null; CharacterMaster master = val2.master; if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.minionOwnership)) { val4 = master.minionOwnership.ownerMaster; } string text = null; if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val4.playerCharacterMasterController) && Object.op_Implicit((Object)(object)val4.playerCharacterMasterController.networkUser)) { text = val4.playerCharacterMasterController.networkUser.userName; } bool flag = !string.IsNullOrWhiteSpace(text); if (flag || includeUnowned.Value) { string text2 = val2.GetDisplayName(); if (string.IsNullOrWhiteSpace(text2)) { text2 = ((Object)((Component)val2).gameObject).name.Replace("(Clone)", "").Trim(); } string text3 = ((!flag) ? text2 : (showUnitName.Value ? (text + "'s " + text2) : text)); if (text3.Length > 100) { text3 = text3.Substring(0, 100); } Color tint = ((!flag) ? unownedColor.Value : (((Object)(object)val4 == (Object)(object)viewerMaster) ? ownColor.Value : teammateColor.Value)); labels.Add(new LabelRecord { Body = val2, Caption = text3, Tint = tint, DistanceSq = sqrMagnitude }); } } if (labels.Count > maxLabels.Value) { labels.Sort((LabelRecord a, LabelRecord b) => a.DistanceSq.CompareTo(b.DistanceSq)); labels.RemoveRange(maxLabels.Value, labels.Count - maxLabels.Value); } } private static bool IsHidden(CharacterBody body) { //IL_003b: 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_0049: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)body.modelLocator) || !Object.op_Implicit((Object)(object)body.modelLocator.modelTransform)) { return false; } CharacterModel component = ((Component)body.modelLocator.modelTransform).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { if ((int)component.visibility != 0) { return (int)component.visibility == 1; } return true; } return false; } private HGTextMeshProUGUI NewTextLabel() { //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_0041: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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) GameObject val = new GameObject("Owner Label", new Type[2] { typeof(RectTransform), typeof(HGTextMeshProUGUI) }); val.transform.SetParent(canvasObject.transform, false); HGTextMeshProUGUI component = val.GetComponent(); component.useLanguageDefaultFont = true; if ((Object)(object)HGTextMeshProUGUI.defaultLanguageFont != (Object)null) { ((TMP_Text)component).font = HGTextMeshProUGUI.defaultLanguageFont; } ((Graphic)component).raycastTarget = false; ((TMP_Text)component).alignment = (TextAlignmentOptions)514; ((TMP_Text)component).fontStyle = (FontStyles)0; ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).overflowMode = (TextOverflowModes)0; ((TMP_Text)component).outlineColor = new Color32((byte)12, (byte)15, (byte)18, (byte)225); ((TMP_Text)component).outlineWidth = 0.12f; ((TMP_Text)component).fontSize = fontSize.Value; RectTransform rectTransform = ((TMP_Text)component).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(720f, 34f); val.SetActive(false); return component; } private void LateUpdate() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00f6: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)overlay)) { return; } if (!enabledLabels.Value || PauseScreenController.instancesList.Count > 0 || !Object.op_Implicit((Object)(object)viewCamera) || !Object.op_Implicit((Object)(object)viewerMaster) || labels.Count == 0) { ((Behaviour)overlay).enabled = false; return; } ((Behaviour)overlay).enabled = true; Rect pixelRect = viewCamera.pixelRect; int num = 0; foreach (LabelRecord label in labels) { if (!Object.op_Implicit((Object)(object)label.Body) || !((Component)label.Body).gameObject.activeInHierarchy) { continue; } Vector3 val = label.Body.corePosition + Vector3.up * (heightOffset.Value + label.Body.radius); Vector3 val2 = viewCamera.WorldToScreenPoint(val); if (!(val2.z <= 0f) && ((Rect)(ref pixelRect)).Contains(new Vector2(val2.x, val2.y))) { if (num >= textPool.Count) { textPool.Add(NewTextLabel()); } HGTextMeshProUGUI val3 = textPool[num++]; if ((Object)(object)HGTextMeshProUGUI.defaultLanguageFont != (Object)null && (Object)(object)((TMP_Text)val3).font != (Object)(object)HGTextMeshProUGUI.defaultLanguageFont) { ((TMP_Text)val3).font = HGTextMeshProUGUI.defaultLanguageFont; } if (((TMP_Text)val3).text != label.Caption) { ((TMP_Text)val3).text = label.Caption; } if (((Graphic)val3).color != label.Tint) { ((Graphic)val3).color = label.Tint; } if (((TMP_Text)val3).fontSize != (float)fontSize.Value) { ((TMP_Text)val3).fontSize = fontSize.Value; } ((TMP_Text)val3).rectTransform.anchoredPosition = new Vector2(val2.x - (float)Screen.width * 0.5f, val2.y - (float)Screen.height * 0.5f - ((TMP_Text)val3).rectTransform.sizeDelta.y * 0.5f); if (!((Component)val3).gameObject.activeSelf) { ((Component)val3).gameObject.SetActive(true); } } } for (int i = num; i < textPool.Count; i++) { if (((Component)textPool[i]).gameObject.activeSelf) { ((Component)textPool[i]).gameObject.SetActive(false); } } if (num == 0) { ((Behaviour)overlay).enabled = false; } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)canvasObject)) { Object.Destroy((Object)(object)canvasObject); } textPool.Clear(); } } }