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 RoomNames v1.0.0
RoomNames.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("McHorse")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+594b8ef7ca3bcb0b7cdde1e53542b5313881563c")] [assembly: AssemblyProduct("RoomNames")] [assembly: AssemblyTitle("RoomNames")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 RoomNames { internal sealed class MapResolutionDriver : MonoBehaviour { private static RenderTexture? _trackedRt; private static bool _haveBaseline; private static int _baselineWidth; private static int _baselineHeight; private void OnEnable() { RoomNames instance = RoomNames.Instance; instance.MapResolutionOverride.SettingChanged += OnMapResolutionConfigChanged; instance.MapResolutionWidth.SettingChanged += OnMapResolutionConfigChanged; instance.MapResolutionHeight.SettingChanged += OnMapResolutionConfigChanged; SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { RoomNames instance = RoomNames.Instance; if (!((Object)(object)instance == (Object)null)) { instance.MapResolutionOverride.SettingChanged -= OnMapResolutionConfigChanged; instance.MapResolutionWidth.SettingChanged -= OnMapResolutionConfigChanged; instance.MapResolutionHeight.SettingChanged -= OnMapResolutionConfigChanged; SceneManager.sceneLoaded -= OnSceneLoaded; } } private static void OnMapResolutionConfigChanged(object? sender, EventArgs e) { ApplyImmediate(); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ResetTracking(); ApplyImmediate(); } private static void ResetTracking() { _trackedRt = null; _haveBaseline = false; } internal static void ApplyAfterMapActiveChanged() { ApplyImmediate(); } private static void ApplyImmediate() { RoomNames instance = RoomNames.Instance; if ((Object)(object)instance == (Object)null) { return; } RenderTexture val = ResolveMapDisplayRenderTexture(); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)_trackedRt != (Object)(object)val) { _trackedRt = val; _haveBaseline = false; } if (!_haveBaseline) { _baselineWidth = ((Texture)val).width; _baselineHeight = ((Texture)val).height; _haveBaseline = true; } if (!instance.MapResolutionOverride.Value) { if (((Texture)val).width != _baselineWidth || ((Texture)val).height != _baselineHeight) { ApplyRenderTextureSize(val, _baselineWidth, _baselineHeight); } return; } int num = Mathf.Clamp(instance.MapResolutionWidth.Value, 64, 4096); int num2 = Mathf.Clamp(instance.MapResolutionHeight.Value, 64, 4096); if (((Texture)val).width != num || ((Texture)val).height != num2) { ApplyRenderTextureSize(val, num, num2); } } private static RenderTexture? ResolveMapDisplayRenderTexture() { if ((Object)(object)PlayerController.instance == (Object)null || (Object)(object)PlayerController.instance.playerAvatarScript == (Object)null) { return null; } MapToolController mapToolController = PlayerController.instance.playerAvatarScript.mapToolController; if ((Object)(object)mapToolController == (Object)null) { return null; } if ((Object)(object)mapToolController.DisplayMesh != (Object)null) { RenderTexture val = TryGetRenderTextureFromMaterial(((Renderer)mapToolController.DisplayMesh).sharedMaterial); if ((Object)(object)val != (Object)null) { return val; } } return TryGetRenderTextureFromMaterial(mapToolController.DisplayMaterial) ?? TryGetRenderTextureFromMaterial(mapToolController.DisplayMaterialClient); } private static RenderTexture? TryGetRenderTextureFromMaterial(Material? mat) { if ((Object)(object)mat == (Object)null) { return null; } Texture mainTexture = mat.mainTexture; RenderTexture val = (RenderTexture)(object)((mainTexture is RenderTexture) ? mainTexture : null); if ((Object)(object)val == (Object)null && mat.HasProperty("_MainTex")) { Texture texture = mat.GetTexture("_MainTex"); val = (RenderTexture)(object)((texture is RenderTexture) ? texture : null); } if ((Object)(object)val == (Object)null && mat.HasProperty("_BaseMap")) { Texture texture2 = mat.GetTexture("_BaseMap"); val = (RenderTexture)(object)((texture2 is RenderTexture) ? texture2 : null); } return val; } private static void ApplyRenderTextureSize(RenderTexture rt, int width, int height) { if (((Texture)rt).width == width && ((Texture)rt).height == height) { return; } rt.Release(); ((Texture)rt).width = width; ((Texture)rt).height = height; rt.Create(); Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); foreach (Camera val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.targetTexture != (Object)(object)rt)) { bool enabled = ((Behaviour)val).enabled; val.targetTexture = rt; ((Behaviour)val).enabled = false; ((Behaviour)val).enabled = enabled; } } } } internal sealed class MapRoomLabelDriver : MonoBehaviour { private readonly struct MapVisualStyle { internal readonly int Layer; internal readonly int SortingLayerId; internal readonly int SortingOrder; internal MapVisualStyle(int layer, int sortingLayerId, int sortingOrder) { Layer = layer; SortingLayerId = sortingLayerId; SortingOrder = sortingOrder; } } private const float YOffsetAboveFloor = 0.06f; private const float CanvasWorldScale = 0.012f; private Module? _module; private Transform? _visualRoot; private TMP_Text? _tmp; private Color _rgb = Color.white; private float _alphaScale = 1f; internal void Setup(Module module, string text, int configFontSize, TMP_FontAsset? font, Color labelColor) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00a1: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) _module = module; Map instance = Map.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.OverLayerParent == (Object)null) { Object.Destroy((Object)(object)this); return; } MapVisualStyle mapVisualStyle = ResolveMapVisualStyle(instance); GameObject val = new GameObject("RN-MapRoomLabel-" + text); val.transform.SetParent(instance.OverLayerParent, false); ApplyLayerRecursive(val, mapVisualStyle.Layer); _visualRoot = val.transform; GameObject val2 = new GameObject("Canvas"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one * 0.012f; Canvas val3 = val2.AddComponent<Canvas>(); val3.renderMode = (RenderMode)2; val3.overrideSorting = true; val3.sortingLayerID = mapVisualStyle.SortingLayerId; val3.sortingOrder = mapVisualStyle.SortingOrder + 500; val2.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)0; GameObject val4 = new GameObject("Text"); RectTransform val5 = val4.AddComponent<RectTransform>(); TextMeshProUGUI val6 = val4.AddComponent<TextMeshProUGUI>(); val4.transform.SetParent(val2.transform, false); val5.anchorMin = new Vector2(0.5f, 0.5f); val5.anchorMax = new Vector2(0.5f, 0.5f); val5.pivot = new Vector2(0.5f, 0.5f); val5.sizeDelta = new Vector2(900f, 360f); val5.anchoredPosition = Vector2.zero; ((TMP_Text)val6).text = text; ((TMP_Text)val6).enableAutoSizing = false; ((TMP_Text)val6).fontSize = ScaleFontForMap(configFontSize, instance.Scale); ((TMP_Text)val6).alignment = (TextAlignmentOptions)514; ((TMP_Text)val6).verticalAlignment = (VerticalAlignmentOptions)512; ((TMP_Text)val6).horizontalAlignment = (HorizontalAlignmentOptions)2; ((TMP_Text)val6).enableWordWrapping = false; ((TMP_Text)val6).overflowMode = (TextOverflowModes)0; ((TMP_Text)val6).richText = false; ((Graphic)val6).raycastTarget = false; if ((Object)(object)font != (Object)null) { ((TMP_Text)val6).font = font; } ((TMP_Text)val6).lineSpacing = (0f - ((TMP_Text)val6).fontSize) * 1.5f; _rgb = new Color(labelColor.r, labelColor.g, labelColor.b, 1f); _alphaScale = labelColor.a; ((TMP_Text)val6).outlineWidth = 0f; ((Graphic)val6).color = new Color(_rgb.r, _rgb.g, _rgb.b, _alphaScale); _tmp = (TMP_Text?)(object)val6; ApplyLayerRecursive(val2, mapVisualStyle.Layer); } private void LateUpdate() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_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_0184: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_module == (Object)null || !((Component)_module).gameObject.activeInHierarchy) { DestroyVisual(); Object.Destroy((Object)(object)this); return; } Map instance = Map.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.OverLayerParent == (Object)null || (Object)(object)_visualRoot == (Object)null) { return; } instance.CustomPositionSet(_visualRoot, ((Component)_module).transform); Transform? visualRoot = _visualRoot; visualRoot.localPosition += new Vector3(0f, 0.06f, 0f); if ((Object)(object)DirtFinderMapPlayer.Instance != (Object)null) { Vector3 eulerAngles = ((Component)DirtFinderMapPlayer.Instance).transform.eulerAngles; _visualRoot.rotation = Quaternion.Euler(90f, eulerAngles.y, eulerAngles.z); } if (!((Object)(object)_tmp == (Object)null)) { if (instance.Active) { MapLayer layerParent = instance.GetLayerParent(((Component)_module).transform.position.y + 1f); float num = ((layerParent.layer == instance.PlayerLayer) ? 1f : 0.35f); Color rgb = _rgb; rgb.a = Mathf.Clamp01(num * _alphaScale); ((Graphic)_tmp).color = rgb; } else { Color rgb2 = _rgb; rgb2.a = 0f; ((Graphic)_tmp).color = rgb2; } } } private void OnDestroy() { DestroyVisual(); } private void DestroyVisual() { if ((Object)(object)_visualRoot != (Object)null) { Object.Destroy((Object)(object)((Component)_visualRoot).gameObject); _visualRoot = null; } } private static MapVisualStyle ResolveMapVisualStyle(Map map) { SpriteRenderer[] componentsInChildren = ((Component)map).GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val in componentsInChildren) { if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { return new MapVisualStyle(((Component)val).gameObject.layer, ((Renderer)val).sortingLayerID, ((Renderer)val).sortingOrder); } } int layer = ((Component)map.OverLayerParent).gameObject.layer; return new MapVisualStyle(layer, SortingLayer.NameToID("Default"), 0); } private static void ApplyLayerRecursive(GameObject go, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown go.layer = layer; foreach (Transform item in go.transform) { Transform val = item; ApplyLayerRecursive(((Component)val).gameObject, layer); } } private static float ScaleFontForMap(float configSize, float mapScale) { float num = Mathf.Max(0.02f, mapScale); return configSize * (0.1f / num); } } internal static class RoomLabelFormatter { private static readonly Regex RoomMetadataPrefixRegex = new Regex("^[^-]+?\\s*-\\s*[A-Z]+\\s*-\\s*\\d+\\s*-\\s*(.+)$", RegexOptions.Compiled); internal static string CleanRoomName(string source) { string text = StripPrefix(CleanBasicName(source), "Module - "); if (text.IndexOf("Start Room", StringComparison.OrdinalIgnoreCase) >= 0) { return "Start Room"; } Match match = RoomMetadataPrefixRegex.Match(text); if (match.Success) { string text2 = match.Groups[1].Value.Trim(); if (!string.IsNullOrWhiteSpace(text2)) { return text2; } } return text; } private static string CleanBasicName(string source) { if (string.IsNullOrWhiteSpace(source)) { return "Unknown"; } return source.Replace("(Clone)", string.Empty).Trim(); } private static string StripPrefix(string source, string prefix) { if (source.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { return source.Substring(prefix.Length).Trim(); } return source; } internal static string FormatForMapLabel(string cleanedName, int maxWords) { if (string.IsNullOrWhiteSpace(cleanedName)) { return cleanedName; } if (maxWords < 1) { maxWords = 1; } string[] array = cleanedName.Split(new char[4] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return cleanedName.Trim(); } int count = Math.Min(maxWords, array.Length); return string.Join("\n", array, 0, count); } } [BepInPlugin("McHorse.RoomNames", "RoomNames", "1.0")] public class RoomNames : BaseUnityPlugin { internal static RoomNames Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } internal ConfigEntry<bool> LabelsEnabled { get; private set; } = null; internal ConfigEntry<int> LabelFontSize { get; private set; } = null; internal ConfigEntry<int> LabelMaxWords { get; private set; } = null; internal ConfigEntry<bool> LabelTruckRooms { get; private set; } = null; internal ConfigEntry<bool> LabelExtractionRooms { get; private set; } = null; internal ConfigEntry<bool> LabelStartRoom { get; private set; } = null; internal ConfigEntry<float> LabelColorR { get; private set; } = null; internal ConfigEntry<float> LabelColorG { get; private set; } = null; internal ConfigEntry<float> LabelColorB { get; private set; } = null; internal ConfigEntry<float> LabelColorA { get; private set; } = null; internal ConfigEntry<bool> MapResolutionOverride { get; private set; } = null; internal ConfigEntry<int> MapResolutionWidth { get; private set; } = null; internal ConfigEntry<int> MapResolutionHeight { get; private set; } = null; private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown Instance = this; LabelsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Map labels", "Enabled", true, "Show a module name label on the map when a room is discovered."); LabelFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Map labels", "FontSize", 26, new ConfigDescription("Label font size (scaled for the miniature map).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 60), Array.Empty<object>())); LabelMaxWords = ((BaseUnityPlugin)this).Config.Bind<int>("Map labels", "MaxWords", 3, "Maximum words shown; each word is placed on its own centered line."); LabelTruckRooms = ((BaseUnityPlugin)this).Config.Bind<bool>("Map labels", "LabelTruckRooms", false, "Also label truck room volumes (vanilla map hides truck tiles)."); LabelExtractionRooms = ((BaseUnityPlugin)this).Config.Bind<bool>("Map labels", "LabelExtractionRooms", false, "Also label extraction room volumes."); LabelStartRoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Map labels", "LabelStartRoom", false, "Also label the start room (module with StartRoom component)."); AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 1f); LabelColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Label color", "R", 0.8f, new ConfigDescription("Red (0–1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); LabelColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Label color", "G", 1f, new ConfigDescription("Green (0–1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); LabelColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Label color", "B", 0.8f, new ConfigDescription("Blue (0–1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); LabelColorA = ((BaseUnityPlugin)this).Config.Bind<float>("Label color", "A", 1f, new ConfigDescription("Alpha multiplier for map visibility (0–1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); AcceptableValueRange<int> val2 = new AcceptableValueRange<int>(64, 4096); MapResolutionOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("Map resolution", "Override", true, "When true, resizes the handheld map display render texture to Width x Height. When false, restores the size captured when the map was first seen this session (or after a scene load)."); MapResolutionWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Map resolution", "Width", 512, new ConfigDescription("Map display render texture width in pixels (used when Override is true).", (AcceptableValueBase)(object)val2, Array.Empty<object>())); MapResolutionHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Map resolution", "Height", 512, new ConfigDescription("Map display render texture height in pixels (used when Override is true).", (AcceptableValueBase)(object)val2, Array.Empty<object>())); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); ((Component)this).gameObject.AddComponent<MapResolutionDriver>(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal Color GetLabelColor() { //IL_0041: 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_0049: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(LabelColorR.Value), Mathf.Clamp01(LabelColorG.Value), Mathf.Clamp01(LabelColorB.Value), Mathf.Clamp01(LabelColorA.Value)); } } } namespace RoomNames.Patches { [HarmonyPatch(typeof(Map), "ActiveSet")] internal static class MapActiveSetMapResolutionPatch { [HarmonyPostfix] private static void Postfix() { MapResolutionDriver.ApplyAfterMapActiveChanged(); } } internal static class LabeledModuleIds { internal static readonly HashSet<int> LabeledModuleInstanceIds = new HashSet<int>(); } [HarmonyPatch(typeof(LevelGenerator))] internal static class LevelGeneratorMapLabelsPatch { [HarmonyPostfix] [HarmonyPatch("GenerateDone")] private static void ClearLabeledModules(PhotonMessageInfo _info) { LabeledModuleIds.LabeledModuleInstanceIds.Clear(); } } [HarmonyPatch(typeof(RoomVolume))] internal static class RoomVolumeMapLabelsPatch { private static TMP_FontAsset? _cachedFont; [HarmonyPostfix] [HarmonyPatch("SetExplored")] private static void AfterSetExplored(RoomVolume __instance) { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) RoomNames instance = RoomNames.Instance; if ((Object)(object)instance == (Object)null || !instance.LabelsEnabled.Value) { return; } Module module = __instance.Module; if ((Object)(object)module == (Object)null || (!instance.LabelTruckRooms.Value && __instance.Truck) || (!instance.LabelExtractionRooms.Value && __instance.Extraction) || (!instance.LabelStartRoom.Value && (Object)(object)((Component)module).GetComponent<StartRoom>() != (Object)null)) { return; } Map instance2 = Map.Instance; if ((Object)(object)instance2 == (Object)null || (Object)(object)instance2.OverLayerParent == (Object)null) { return; } int instanceID = ((Object)module).GetInstanceID(); if (LabeledModuleIds.LabeledModuleInstanceIds.Add(instanceID)) { string cleanedName = RoomLabelFormatter.CleanRoomName(((Object)module).name); string text = RoomLabelFormatter.FormatForMapLabel(cleanedName, instance.LabelMaxWords.Value); if (string.IsNullOrWhiteSpace(text)) { LabeledModuleIds.LabeledModuleInstanceIds.Remove(instanceID); return; } Color labelColor = instance.GetLabelColor(); TMP_FontAsset font = ResolveFont(); MapRoomLabelDriver mapRoomLabelDriver = ((Component)RoomNames.Instance).gameObject.AddComponent<MapRoomLabelDriver>(); mapRoomLabelDriver.Setup(module, text, instance.LabelFontSize.Value, font, labelColor); } } private static TMP_FontAsset? ResolveFont() { if ((Object)(object)_cachedFont != (Object)null) { return _cachedFont; } GameObject val = GameObject.Find("Tax Haul"); TMP_Text val2 = default(TMP_Text); if ((Object)(object)val != (Object)null && val.TryGetComponent<TMP_Text>(ref val2) && (Object)(object)val2.font != (Object)null) { _cachedFont = val2.font; } return _cachedFont; } } }