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 AdvancedSigns v0.6.0
AdvancedSigns.dll
Decompiled a week agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.6.0")] [assembly: AssemblyInformationalVersion("0.6.0+7ea477afb0bf2a944ab01c21d6b4523c02de09a0")] [assembly: AssemblyVersion("0.6.0.0")] namespace AdvancedSigns; [BepInPlugin("cjayride.AdvancedSigns", "Advanced Signs", "0.6.0")] public class BepInExPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Sign), "Awake")] private static class Sign_Awake_Patch { private static void Postfix(Sign __instance) { ApplySignStyle(__instance); } } [HarmonyPatch(typeof(Sign), "OnCheckPermissionCompleted")] private static class Sign_OnCheckPermissionCompleted_Patch { private static void Postfix(Sign __instance) { ApplyDisplayedText(__instance); } } private Harmony harmony; public static ConfigEntry<bool> modEnabled; public static ConfigEntry<bool> useRichText; public static ConfigEntry<string> fontName; public static ConfigEntry<string> defaultColor; public static ConfigEntry<bool> removeRichText; public static ConfigEntry<Vector2> textPositionOffset; public static ConfigEntry<Vector3> signScale; private static TMP_FontAsset currentFont; private static string lastFontName; private static Dictionary<string, TMP_FontAsset> fontCache; private static readonly FieldRef<Sign, bool> isViewableRef = AccessTools.FieldRefAccess<Sign, bool>("m_isViewable"); private static readonly FieldRef<Sign, string> currentTextRef = AccessTools.FieldRefAccess<Sign, string>("m_currentText"); private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod"); signScale = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Signs", "SignScale", new Vector3(1f, 1f, 1f), "Sign scale (w,h,d)"); textPositionOffset = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Signs", "TextPositionOffset", new Vector2(0f, 0f), "Text position offset"); useRichText = ((BaseUnityPlugin)this).Config.Bind<bool>("Signs", "UseRichText", true, "Enable rich text"); fontName = ((BaseUnityPlugin)this).Config.Bind<string>("Signs", "FontName", "AveriaSerifLibre-Bold", "Font name"); defaultColor = ((BaseUnityPlugin)this).Config.Bind<string>("Signs", "DefaultColor", "#00ffffff", "Default color"); removeRichText = ((BaseUnityPlugin)this).Config.Bind<bool>("Signs", "RemoveRichText", false, "Remove rich text"); if (modEnabled.Value) { ((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged; harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); harmony.PatchAll(); } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.SettingChanged -= OnSettingChanged; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private static void OnSettingChanged(object sender, SettingChangedEventArgs e) { fontCache = null; currentFont = null; lastFontName = null; Sign[] array = Object.FindObjectsByType<Sign>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { ApplySignStyle(array[i]); ApplyDisplayedText(array[i]); } } private static void ApplySignStyle(Sign sign) { //IL_0029: 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_0035: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && !((Object)(object)sign == (Object)null) && !((Object)(object)sign.m_textWidget == (Object)null)) { Vector3 value = signScale.Value; if (((Component)sign).transform.localScale != value) { ((Component)sign).transform.localScale = value; } TMP_Text textWidget = (TMP_Text)(object)sign.m_textWidget; bool value2 = useRichText.Value; if (textWidget.richText != value2) { textWidget.richText = value2; } if (sign.m_characterLimit != 0) { sign.m_characterLimit = 0; } if ((Object)(object)((Graphic)textWidget).material != (Object)null) { ((Graphic)textWidget).material = null; } RectTransform rectTransform = textWidget.rectTransform; Vector2 value3 = textPositionOffset.Value; if (rectTransform.anchoredPosition != value3) { rectTransform.anchoredPosition = value3; } TMP_FontAsset val = ResolveFont(); if ((Object)(object)val != (Object)null && (Object)(object)textWidget.font != (Object)(object)val) { textWidget.font = val; } } } private static void ApplyDisplayedText(Sign sign) { if (!modEnabled.Value || (Object)(object)sign == (Object)null || (Object)(object)sign.m_textWidget == (Object)null || !isViewableRef.Invoke(sign)) { return; } string text = currentTextRef.Invoke(sign); if (string.IsNullOrEmpty(text)) { return; } string text2 = text; if (removeRichText.Value) { if (text.IndexOf('<') >= 0) { text2 = StringExtensionMethods.RemoveRichTextTags(text); } } else { string value = defaultColor.Value; if (useRichText.Value && !string.IsNullOrEmpty(value) && text.IndexOf('<') < 0) { text2 = "<color=" + value + ">" + text; } } if (currentTextRef.Invoke(sign) != text2) { currentTextRef.Invoke(sign) = text2; } TMP_Text textWidget = (TMP_Text)(object)sign.m_textWidget; if (textWidget.text != text2) { textWidget.text = text2; } } private static TMP_FontAsset ResolveFont() { string value = fontName.Value; if ((Object)(object)currentFont != (Object)null && lastFontName == value) { return currentFont; } lastFontName = value; EnsureFontCache(); if (fontCache.TryGetValue(value, out var value2)) { currentFont = value2; return value2; } currentFont = null; return null; } private static void EnsureFontCache() { if (fontCache != null) { return; } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); fontCache = new Dictionary<string, TMP_FontAsset>(array.Length); foreach (TMP_FontAsset val in array) { if ((Object)(object)val != (Object)null && !fontCache.ContainsKey(((Object)val).name)) { fontCache.Add(((Object)val).name, val); } } } }