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 ComfySigns v1.13.0
ComfySigns.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ComfySigns")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ComfySigns")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1a56448b-9dac-4352-a528-d9e3f64f992e")] [assembly: AssemblyFileVersion("1.13.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.13.0.0")] [module: UnverifiableCode] [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 ComfySigns { [BepInPlugin("redseiko.valheim.comfysigns", "ComfySigns", "1.13.0")] public sealed class ComfySigns : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.comfysigns"; public const string PluginName = "ComfySigns"; public const string PluginVersion = "1.13.0"; private static ManualLogSource _logger; private void Awake() { _logger = ((BaseUnityPlugin)this).Logger; ComfyConfigUtils.BindConfig(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.comfysigns"); } public static void LogInfo(object obj) { _logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } public static void LogWarning(object obj) { _logger.LogWarning((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } } public static class PluginConfig { public static ConfigFile CurrentConfig { get; private set; } public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<bool> UseFallbackFonts { get; private set; } public static ConfigEntry<bool> SuppressUnicodeNotFoundWarning { get; private set; } public static ConfigEntry<string> SignDefaultTextFontAsset { get; private set; } public static ConfigEntry<Color> SignDefaultTextFontColor { get; private set; } public static ConfigEntry<float> SignTextMaximumRenderDistance { get; private set; } public static ConfigEntry<bool> SignTextIgnoreSizeTags { get; private set; } public static ConfigEntry<Vector3> SignCanvasLocalPositionOffset { get; private set; } public static ConfigEntry<float> SignEffectMaximumRenderDistance { get; private set; } public static ConfigEntry<bool> SignEffectEnablePartyEffect { get; private set; } [ComfyConfig] public static void BindConfig(ConfigFile config) { CurrentConfig = config; IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); UseFallbackFonts = config.BindInOrder("Fonts", "useFallbackFonts", defaultValue: true, "Use fallback fonts to support additional characters."); } [ComfyConfig(typeof(FejdStartup), "Awake")] public static void BindLoggingConfig(ConfigFile config) { SuppressUnicodeNotFoundWarning = config.BindInOrder("Logging", "suppressUnicodeNotFoundWarning", defaultValue: true, "Hide 'The character with Unicode value ... was not found...' log warnings."); SuppressUnicodeNotFoundWarning.OnSettingChanged<bool>(SetWarningsDisabled); SetWarningsDisabled(SuppressUnicodeNotFoundWarning.Value); } private static void SetWarningsDisabled(bool warningsDiabled) { TMP_Settings.instance.m_warningsDisabled = warningsDiabled; } [ComfyConfig(typeof(FejdStartup), "Awake")] public static void BindSignConfig(ConfigFile config) { //IL_00e0: 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) string[] array = (from f in (from f in Resources.FindObjectsOfTypeAll<TMP_FontAsset>() select ((Object)f).name).Concat(from f in Resources.FindObjectsOfTypeAll<Font>() select ((Object)f).name).Distinct() orderby f select f).ToArray(); SignDefaultTextFontAsset = config.BindInOrder("Sign.Text", "defaultTextFontAsset", "Valheim-Norse", "Sign.m_textWidget.fontAsset (TMP) default value.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array)); SignDefaultTextFontAsset.OnSettingChanged<string>(SignUtils.OnSignConfigChanged); SignDefaultTextFontColor = config.BindInOrder<Color>("Sign.Text", "defaultTextFontColor", Color.white, "Sign.m_textWidget.color default value."); SignDefaultTextFontColor.OnSettingChanged<Color>(SignUtils.OnSignConfigChanged); SignTextMaximumRenderDistance = config.BindInOrder("Sign.Text.Render", "maximumRenderDistance", 192f, "Maximum distance that signs can be from player to render sign text.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 192f)); SignTextIgnoreSizeTags = config.Bind<bool>("Sign.Text.Tags", "ignoreSizeTags", false, "if set, ignore any and all <size> tags in sign text when rendered locally."); SignTextIgnoreSizeTags.OnSettingChanged<bool>(SignUtils.OnSignTextTagsConfigChanged); SignCanvasLocalPositionOffset = config.Bind<Vector3>("Sign.Canvas", "localPositionOffset", new Vector3(0f, 0f, 0.03f), "Sign.Canvas.localPosition offset value (changes require restart)."); } [ComfyConfig(typeof(FejdStartup), "Awake")] public static void BindSignEffectConfig(ConfigFile config) { SignEffectMaximumRenderDistance = config.BindInOrder("SignEffect", "maximumRenderDistance", 64f, "Maximum distance that signs can be from player to render sign effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 128f)); SignEffectMaximumRenderDistance.OnSettingChanged<float>(SignUtils.OnSignEffectConfigChanged); SignEffectEnablePartyEffect = config.BindInOrder("SignEffect.Party", "enablePartyEffect", defaultValue: false, "Enables the 'Party' Sign effect for signs using the party tag."); SignEffectEnablePartyEffect.OnSettingChanged<bool>(SignUtils.OnSignEffectConfigChanged); } } public static class SignUtils { public static readonly Regex SizeRegex = new Regex("</?size(?:\\s*=[^>]*)?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(100.0)); public static void AddFallbackFont(TMP_FontAsset font, TMP_FontAsset fallbackFont) { if (Object.op_Implicit((Object)(object)font) && Object.op_Implicit((Object)(object)fallbackFont) && !((Object)(object)fallbackFont == (Object)(object)font)) { if (font.fallbackFontAssets == null) { font.fallbackFontAssets = new List<TMP_FontAsset>(1) { fallbackFont }; } else if (!font.fallbackFontAssets.Contains(fallbackFont)) { font.fallbackFontAssets.Add(fallbackFont); } } } public static void AddFallbackFonts(TMP_FontAsset font) { AddFallbackFont(font, UIFonts.GetFontAsset("Valheim-Norse")); AddFallbackFont(font, UIFonts.GetFontAsset("Valheim-Norsebold")); AddFallbackFont(font, UIFonts.GetFontAsset("Fallback-NotoSansNormal")); } public static bool HasSignEffect(TextMeshProUGUI textComponent, string effectId) { //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_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) if (((TMP_Text)textComponent).text.Length <= 0 || !((TMP_Text)textComponent).text.StartsWith("<link", StringComparison.Ordinal)) { return false; } TMP_LinkInfo[] linkInfo = ((TMP_Text)textComponent).textInfo.linkInfo; for (int i = 0; i < linkInfo.Length; i++) { TMP_LinkInfo val = linkInfo[i]; if (val.linkTextfirstCharacterIndex == 0 && val.linkTextLength == ((TMP_Text)textComponent).textInfo.characterCount && ((TMP_LinkInfo)(ref val)).GetLinkID() == effectId) { return true; } } return false; } public static void OnSignConfigChanged() { SetupSignPrefabs(ZNetScene.s_instance); } public static void OnSignEffectConfigChanged() { Sign[] array = Resources.FindObjectsOfTypeAll<Sign>(); foreach (Sign val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.m_nview) && val.m_nview.IsValid() && Object.op_Implicit((Object)(object)val.m_textWidget)) { ProcessSignEffect(val); } } } public static void OnSignTextTagsConfigChanged() { Sign[] array = Resources.FindObjectsOfTypeAll<Sign>(); foreach (Sign val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.m_nview) && val.m_nview.IsValid() && Object.op_Implicit((Object)(object)val.m_textWidget)) { if (PluginConfig.SignTextIgnoreSizeTags.Value) { ProcessSignText(val); } else if (val.m_isViewable) { ((TMP_Text)val.m_textWidget).text = val.m_currentText; } } } } public static void ProcessSignEffect(Sign sign) { TextMeshProUGUI textWidget = sign.m_textWidget; bool flag = ((Behaviour)textWidget).enabled && HasSignEffect(textWidget, "party") && ShouldRenderSignEffect(sign); VertexColorCycler vertexColorCycler = default(VertexColorCycler); if (((Component)textWidget).gameObject.TryGetComponent<VertexColorCycler>(ref vertexColorCycler)) { if (((Behaviour)vertexColorCycler).enabled != flag) { ((Behaviour)vertexColorCycler).enabled = flag; } } else if (flag) { ((Component)textWidget).gameObject.AddComponent<VertexColorCycler>(); } } public static void ProcessSignText(Sign sign) { if (PluginConfig.SignTextIgnoreSizeTags.Value) { string text = ((TMP_Text)sign.m_textWidget).text; string text2 = SizeRegex.Replace(text, string.Empty); if ((object)text != text2) { ((TMP_Text)sign.m_textWidget).text = text2; } } } public static void SetupSignFont(Sign sign, TMP_FontAsset fontAsset, Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI textWidget = sign.m_textWidget; if ((Object)(object)((TMP_Text)textWidget).font != (Object)(object)fontAsset) { ((TMP_Text)textWidget).font = fontAsset; } if ((Object)(object)((TMP_Text)textWidget).fontSharedMaterial != (Object)(object)((TMP_Asset)fontAsset).material) { ((TMP_Text)textWidget).fontSharedMaterial = ((TMP_Asset)fontAsset).material; } ((Graphic)textWidget).color = color; } public static void SetupSignPrefabs(ZNetScene netScene) { //IL_001e: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)netScene)) { return; } TMP_FontAsset fontAsset = UIFonts.GetFontAsset(PluginConfig.SignDefaultTextFontAsset.Value); Color value = PluginConfig.SignDefaultTextFontColor.Value; if (PluginConfig.UseFallbackFonts.Value) { ComfySigns.LogInfo("Adding fallback fonts to font: " + ((Object)fontAsset).name); AddFallbackFonts(fontAsset); } Sign val = default(Sign); foreach (GameObject value2 in netScene.m_namedPrefabs.Values) { if (value2.TryGetComponent<Sign>(ref val) && Object.op_Implicit((Object)(object)val.m_textWidget)) { SetupSignFont(val, fontAsset, value); } } Sign val2 = default(Sign); foreach (ZNetView value3 in netScene.m_instances.Values) { if (((Component)value3).TryGetComponent<Sign>(ref val2) && Object.op_Implicit((Object)(object)val2.m_textWidget)) { SetupSignFont(val2, fontAsset, value); } } } public static bool ShouldRenderSignText(Sign sign) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Vector3.Distance(((Component)sign).transform.position, ((Component)Player.m_localPlayer).transform.position) <= PluginConfig.SignTextMaximumRenderDistance.Value; } return false; } public static bool ShouldRenderSignEffect(Sign sign) { //IL_0022: 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) if (PluginConfig.SignEffectEnablePartyEffect.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)sign).transform.position) <= PluginConfig.SignEffectMaximumRenderDistance.Value; } return false; } } public sealed class TextInputPanelDragger : MonoBehaviour, IDragHandler, IEventSystemHandler { private RectTransform _rectTransform; private Canvas _canvas; private void Start() { _rectTransform = ((Component)this).GetComponent<RectTransform>(); _canvas = ((Component)this).GetComponentInParent<Canvas>(); } public void OnDrag(PointerEventData eventData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = _rectTransform; rectTransform.anchoredPosition += eventData.delta / _canvas.scaleFactor; } } public sealed class VertexColorCycler : MonoBehaviour { private static readonly WaitForSeconds _longWait = new WaitForSeconds(1f); private static readonly WaitForSeconds _shortWait = new WaitForSeconds(0.05f); private TMP_Text _textComponent; private void Awake() { _textComponent = ((Component)this).GetComponent<TMP_Text>(); } private void OnEnable() { ((MonoBehaviour)this).StartCoroutine(AnimateVertexColors()); } private void OnDisable() { ((MonoBehaviour)this).StopAllCoroutines(); if (Object.op_Implicit((Object)(object)_textComponent)) { _textComponent.ForceMeshUpdate(true, false); } } private IEnumerator AnimateVertexColors() { int currentCharacter = 0; Color32 val2 = default(Color32); while (true) { TMP_TextInfo textInfo = _textComponent.textInfo; int characterCount = textInfo.characterCount; if (characterCount == 0) { yield return _longWait; continue; } if (currentCharacter >= characterCount) { currentCharacter = 0; } TMP_CharacterInfo val = textInfo.characterInfo[currentCharacter]; int materialReferenceIndex = val.materialReferenceIndex; if (materialReferenceIndex < 0 || materialReferenceIndex >= textInfo.meshInfo.Length) { yield return _shortWait; continue; } Color32[] colors = textInfo.meshInfo[materialReferenceIndex].colors32; int vertexIndex = val.vertexIndex; if (colors == null || vertexIndex + 3 >= colors.Length) { yield return _shortWait; continue; } if (val.isVisible) { ((Color32)(ref val2))..ctor((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), byte.MaxValue); colors[vertexIndex] = val2; colors[vertexIndex + 1] = val2; colors[vertexIndex + 2] = val2; colors[vertexIndex + 3] = val2; _textComponent.UpdateVertexData((TMP_VertexDataUpdateFlags)16); } int num = currentCharacter; currentCharacter = (currentCharacter + 1) % characterCount; yield return (num < currentCharacter) ? _shortWait : _longWait; } } } [HarmonyPatch(typeof(Sign))] internal static class SignPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(Sign __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) if (PluginConfig.IsModEnabled.Value) { __instance.m_characterLimit = 999; if (((Component)(object)__instance.m_textWidget).TryGetComponentInParent<Canvas>(out Canvas component)) { Transform transform = ((Component)component).transform; transform.localPosition += PluginConfig.SignCanvasLocalPositionOffset.Value; } } } [HarmonyPostfix] [HarmonyPatch("SetText")] private static void SetTextPostfix(Sign __instance) { if (PluginConfig.IsModEnabled.Value) { SignUtils.ProcessSignText(__instance); SignUtils.ProcessSignEffect(__instance); } } [HarmonyPostfix] [HarmonyPatch("UpdateText")] private static void UpdateTextPostfix(Sign __instance) { if (PluginConfig.IsModEnabled.Value) { ((Behaviour)__instance.m_textWidget).enabled = SignUtils.ShouldRenderSignText(__instance); SignUtils.ProcessSignEffect(__instance); } } [HarmonyPostfix] [HarmonyPatch("OnCheckPermissionCompleted")] private static void CanAccessResultFuncPostfix(Sign __instance) { if (PluginConfig.IsModEnabled.Value) { SignUtils.ProcessSignText(__instance); } } } [HarmonyPatch(typeof(TextInput))] internal static class TextInputPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(TextInput __instance) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)__instance.m_inputField)) { SetupTextInput(__instance); } } private static void SetupTextInput(TextInput textInput) { textInput.m_panel.GetOrAddComponent<TextInputPanelDragger>(); ((TMP_InputField)textInput.m_inputField).richText = false; } } [HarmonyPatch(typeof(ZNetScene))] internal static class ZNetScenePatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(ZNetScene __instance) { if (PluginConfig.IsModEnabled.Value) { SignUtils.SetupSignPrefabs(__instance); } } } } namespace ComfyLib { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public sealed class ComfyConfigAttribute : Attribute { internal readonly MethodBase TargetMethod; public ComfyConfigAttribute() { TargetMethod = null; } public ComfyConfigAttribute(Type lateBindType, string lateBindMethodName) { TargetMethod = AccessTools.Method(lateBindType, lateBindMethodName, (Type[])null, (Type[])null); } } [HarmonyPatch] public static class ComfyConfigUtils { private sealed class ConfigBinder { public readonly ConfigFile ConfigFile; public readonly MethodBase TargetMethod; public readonly MethodBase BindConfigMethod; public ConfigBinder(ConfigFile configFile, MethodBase targetMethod, MethodBase bindConfigMethod) { ConfigFile = configFile; TargetMethod = targetMethod; BindConfigMethod = bindConfigMethod; } } private static readonly Dictionary<MethodBase, List<ConfigBinder>> _configBinders = new Dictionary<MethodBase, List<ConfigBinder>>(); private static IEnumerable<MethodBase> TargetMethods() { return _configBinders.Keys; } private static void Postfix(MethodBase __originalMethod) { if (_configBinders.Count <= 0 || !_configBinders.TryGetValue(__originalMethod, out var value)) { return; } foreach (ConfigBinder item in value) { item.BindConfigMethod.Invoke(null, new object[1] { item.ConfigFile }); } value.Clear(); _configBinders.Remove(__originalMethod); } public static void BindConfig(ConfigFile config) { foreach (MethodInfo bindConfigMethod in GetBindConfigMethods(Assembly.GetExecutingAssembly())) { ComfyConfigAttribute customAttribute = bindConfigMethod.GetCustomAttribute<ComfyConfigAttribute>(inherit: false); if (customAttribute.TargetMethod == null) { bindConfigMethod.Invoke(null, new object[1] { config }); } else { AddConfigBinder(config, customAttribute.TargetMethod, bindConfigMethod); } } } private static void AddConfigBinder(ConfigFile configFile, MethodBase targetMethod, MethodBase bindConfigMethod) { if (!_configBinders.TryGetValue(targetMethod, out var value)) { value = new List<ConfigBinder>(); _configBinders[targetMethod] = value; } value.Add(new ConfigBinder(configFile, targetMethod, bindConfigMethod)); } private static List<MethodInfo> GetBindConfigMethods(Assembly assembly) { List<MethodInfo> list = new List<MethodInfo>(); Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttribute<ComfyConfigAttribute>(inherit: false) != null) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ConfigFile)) { list.Add(methodInfo); } } } } return list; } } public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)(object)((SettingChangedEventArgs)eventArgs).ChangedSetting); }; } } public static class ComponentExtensions { public static bool TryGetComponentInParent<T>(this Component source, out T component) where T : Component { component = source.GetComponentInParent<T>(); return Object.op_Implicit((Object)(object)component); } } public static class GameObjectExtensions { public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component { T result = default(T); if (!gameObject.TryGetComponent<T>(ref result)) { return gameObject.AddComponent<T>(); } return result; } } public static class ObjectExtensions { public static T FirstByNameOrDefault<T>(this IEnumerable<T> unityObjects, string name) where T : Object { foreach (T unityObject in unityObjects) { if (((Object)unityObject).name == name) { return unityObject; } } return default(T); } public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object { foreach (T unityObject in unityObjects) { if (((Object)unityObject).name == name) { return unityObject; } } throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}"); } public static T Ref<T>(this T unityObject) where T : Object { if (!Object.op_Implicit((Object)(object)unityObject)) { return default(T); } return unityObject; } } public static class RectMask2DExtensions { public static RectMask2D SetPadding(this RectMask2D rectMask, float left, float top, float right, float bottom) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) rectMask.padding = new Vector4(left, bottom, right, top); return rectMask; } public static RectMask2D SetSoftness(this RectMask2D rectMask, int horizontal, int vertical) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) rectMask.softness = new Vector2Int(horizontal, vertical); return rectMask; } } public static class TMPInputFieldExtensions { public static TMP_InputField SetRichText(this TMP_InputField inputField, bool richText) { inputField.richText = richText; return inputField; } public static TMP_InputField SetTextViewport(this TMP_InputField inputField, RectTransform viewport) { inputField.textViewport = viewport; return inputField; } } public static class TextMeshProUGUIExtensions { public static TextMeshProUGUI SetColor(this TextMeshProUGUI text, Color color) { //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_000f: Unknown result type (might be due to invalid IL or missing references) if (((Graphic)text).color != color) { ((Graphic)text).color = color; } return text; } public static TextMeshProUGUI SetFont(this TextMeshProUGUI text, TMP_FontAsset font) { if ((Object)(object)((TMP_Text)text).font != (Object)(object)font) { ((TMP_Text)text).font = font; } return text; } } public static class UIFonts { public static readonly Dictionary<string, Font> FontCache = new Dictionary<string, Font>(); public const string ValheimAveriaSansLibre = "Valheim-AveriaSansLibre"; public const string ValheimNorse = "Valheim-Norse"; public const string ValheimNorsebold = "Valheim-Norsebold"; public const string FallbackNotoSansNormal = "Fallback-NotoSansNormal"; public static readonly Dictionary<string, TMP_FontAsset> FontAssetCache = new Dictionary<string, TMP_FontAsset>(); public static Font GetFont(string fontName) { if (!FontCache.TryGetValue(fontName, out var value)) { value = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstByNameOrThrow<Font>(fontName); FontCache[fontName] = value; } return value; } public static TMP_FontAsset GetFontAsset(string fontName) { if (!FontAssetCache.TryGetValue(fontName, out var value)) { value = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstByNameOrDefault<TMP_FontAsset>(fontName); if (!Object.op_Implicit((Object)(object)value)) { value = TMP_FontAsset.CreateFontAsset(GetFont(fontName)); ((Object)value).name = fontName; } FontAssetCache[fontName] = value; } return value; } } }