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 ClassicRadarName v1.0.0
ClassicRadarName.dll
Decompiled a week agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("ClassicRadarName")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ClassicRadarName")] [assembly: AssemblyTitle("ClassicRadarName")] [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 ClassicRadarName { [BepInPlugin("SleepyMiles.ClassicRadarName", "ClassicRadarName", "1.0.0")] public class Plugin : BaseUnityPlugin { internal enum Corner { TopLeft, TopCenter, TopRight } public const string GUID = "SleepyMiles.ClassicRadarName"; public const string NAME = "ClassicRadarName"; public const string VERSION = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> HideCamera; internal static ConfigEntry<bool> NameOnTop; internal static ConfigEntry<string> Prefix; internal static ConfigEntry<Corner> Place; internal static ConfigEntry<float> Scale; private void Awake() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; HideCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide small camera", true, "Take the small head camera (and the picture shown when you watch yourself) off the radar."); NameOnTop = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Name at the top", true, "Show the watched player's name at the top of the radar, like before v80. Off: the game's own name tag stays where it is."); Prefix = ((BaseUnityPlugin)this).Config.Bind<string>("Name", "Text before the name", "MONITORING: ", "Written before the player's name. Leave it empty for just the name."); Place = ((BaseUnityPlugin)this).Config.Bind<Corner>("Name", "Position", Corner.TopLeft, "Where the name sits at the top of the radar."); Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Name", "Text scale", 1.4f, new ConfigDescription("Size of the name: 1 = the game's own size, 2 = twice as big. Can be changed while playing (LethalConfig).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); new Harmony("SleepyMiles.ClassicRadarName").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"ClassicRadarName 1.0.0 loaded."); } } [HarmonyPatch(typeof(ManualCameraRenderer))] internal static class RadarPatch { private static TextMeshProUGUI label; private static TextMeshProUGUI gameName; private static Vector3 nameScale; private static Vector3 bgScale; private static bool hidden; private static float gameSize; private const float Left = -225f; private const float Right = 235f; private const float Top = 156f; [HarmonyPatch("LateUpdate")] [HarmonyPostfix] [HarmonyPriority(0)] private static void AfterLateUpdate(ManualCameraRenderer __instance) { if ((Object)(object)__instance.headMountedCam == (Object)null) { return; } try { if (Plugin.HideCamera.Value) { ((Behaviour)__instance.headMountedCam).enabled = false; if ((Object)(object)__instance.headMountedCamUI != (Object)null) { ((Behaviour)__instance.headMountedCamUI).enabled = false; } if ((Object)(object)__instance.localPlayerPlaceholder != (Object)null) { ((Behaviour)__instance.localPlayerPlaceholder).enabled = false; } } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)__instance == (Object)(object)instance.mapScreen) { UpdateName(instance); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Radar: " + ex.Message)); } } private static void UpdateName(StartOfRound sor) { TextMeshProUGUI mapScreenPlayerName = sor.mapScreenPlayerName; if ((Object)(object)mapScreenPlayerName == (Object)null) { return; } if (!Plugin.NameOnTop.Value) { ShowGameName(sor, show: true); if ((Object)(object)label != (Object)null) { ((Behaviour)label).enabled = false; } return; } if ((Object)(object)label == (Object)null || (Object)(object)gameName != (Object)(object)mapScreenPlayerName) { Make(mapScreenPlayerName); } ShowGameName(sor, show: false); ((Behaviour)label).enabled = ((Behaviour)mapScreenPlayerName).enabled && ((Component)mapScreenPlayerName).gameObject.activeInHierarchy; string obj = Plugin.Prefix.Value ?? ""; string text = ((TMP_Text)mapScreenPlayerName).text ?? ""; if (text.StartsWith("MONITORING: ")) { text = text.Substring("MONITORING: ".Length); } string text2 = obj + text; if (((TMP_Text)label).text != text2) { ((TMP_Text)label).text = text2; } float num = gameSize * Mathf.Clamp(Plugin.Scale.Value, 0.5f, 3f); if (((TMP_Text)label).fontSize != num) { ((TMP_Text)label).fontSize = num; } Place(); } private static void ShowGameName(StartOfRound sor, bool show) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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_0087: 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) TextMeshProUGUI mapScreenPlayerName = sor.mapScreenPlayerName; Image mapScreenPlayerNameBG = sor.mapScreenPlayerNameBG; if (show == !hidden) { return; } if (show) { ((Transform)((TMP_Text)mapScreenPlayerName).rectTransform).localScale = nameScale; if ((Object)(object)mapScreenPlayerNameBG != (Object)null) { ((Transform)((Graphic)mapScreenPlayerNameBG).rectTransform).localScale = bgScale; } } else { nameScale = ((Transform)((TMP_Text)mapScreenPlayerName).rectTransform).localScale; ((Transform)((TMP_Text)mapScreenPlayerName).rectTransform).localScale = Vector3.zero; if ((Object)(object)mapScreenPlayerNameBG != (Object)null) { bgScale = ((Transform)((Graphic)mapScreenPlayerNameBG).rectTransform).localScale; ((Transform)((Graphic)mapScreenPlayerNameBG).rectTransform).localScale = Vector3.zero; } } hidden = !show; } private static void Make(TextMeshProUGUI name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) gameName = name; hidden = false; GameObject val = new GameObject("ClassicRadarName", new Type[1] { typeof(RectTransform) }) { layer = ((Component)name).gameObject.layer }; RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).SetParent(((TMP_Text)name).transform.parent, false); ((Transform)component).SetAsLastSibling(); label = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)label).font = ((TMP_Text)name).font; ((TMP_Text)label).fontSharedMaterial = ((TMP_Text)name).fontSharedMaterial; ((Graphic)label).color = ((Graphic)name).color; gameSize = (((TMP_Text)name).enableAutoSizing ? ((TMP_Text)name).fontSizeMax : ((TMP_Text)name).fontSize); if (gameSize <= 0f) { gameSize = 20f; } ((TMP_Text)label).fontSize = gameSize; ((TMP_Text)label).enableAutoSizing = false; ((TMP_Text)label).fontStyle = ((TMP_Text)name).fontStyle; ((TMP_Text)label).characterSpacing = ((TMP_Text)name).characterSpacing; ((TMP_Text)label).enableWordWrapping = false; ((TMP_Text)label).overflowMode = (TextOverflowModes)1; ((Graphic)label).raycastTarget = false; Plugin.Log.LogInfo((object)"Name moved to the top of the radar."); } private static void Place() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)label).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.sizeDelta = new Vector2(460f, ((TMP_Text)label).fontSize * 1.5f + 4f); switch (Plugin.Place.Value) { case Plugin.Corner.TopCenter: rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(5f, 156f); ((TMP_Text)label).alignment = (TextAlignmentOptions)258; break; case Plugin.Corner.TopRight: rectTransform.pivot = new Vector2(1f, 1f); rectTransform.anchoredPosition = new Vector2(235f, 156f); ((TMP_Text)label).alignment = (TextAlignmentOptions)260; break; default: rectTransform.pivot = new Vector2(0f, 1f); rectTransform.anchoredPosition = new Vector2(-225f, 156f); ((TMP_Text)label).alignment = (TextAlignmentOptions)257; break; } } } }