Please disclose if your mod was created primarily 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 Enhuddlement v1.4.0
Enhuddlement.dll
Decompiled 9 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComfyLib; 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: AssemblyTitle("Enhuddlement")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Enhuddlement")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("76613fb2-45a2-4253-b205-58d12f10984e")] [assembly: AssemblyFileVersion("1.4.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Enhuddlement { public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<bool> ShowEnemyHealthValue { get; private set; } public static ConfigEntry<bool> PlayerHudShowLocalPlayer { get; private set; } public static ConfigEntry<Vector3> PlayerHudPositionOffset { get; private set; } public static ConfigEntry<int> PlayerHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> PlayerHudNameTextColor { get; private set; } public static ConfigEntry<Color> PlayerHudNameTextPvPColor { get; private set; } public static ConfigEntry<int> PlayerHudHealthTextFontSize { get; private set; } public static ConfigEntry<Color> PlayerHudHealthTextColor { get; private set; } public static ConfigEntry<float> PlayerHudHealthBarWidth { get; private set; } public static ConfigEntry<float> PlayerHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> PlayerHudHealthBarColor { get; private set; } public static ConfigEntry<bool> FloatingBossHud { get; private set; } public static ConfigEntry<Vector3> BossHudPositionOffset { get; private set; } public static ConfigEntry<int> BossHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> BossHudNameTextColorTop { get; private set; } public static ConfigEntry<Color> BossHudNameTextColorBottom { get; private set; } public static ConfigEntry<int> BossHudHealthTextFontSize { get; private set; } public static ConfigEntry<Color> BossHudHealthTextFontColor { get; private set; } public static ConfigEntry<float> BossHudHealthBarWidth { get; private set; } public static ConfigEntry<float> BossHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> BossHudHealthBarColor { get; private set; } public static ConfigEntry<Vector3> EnemyHudPositionOffset { get; private set; } public static ConfigEntry<int> EnemyHudNameTextFontSize { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextColor { get; private set; } public static ConfigEntry<bool> EnemyHudUseNameForStatus { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextAlertedColor { get; private set; } public static ConfigEntry<Color> EnemyHudNameTextAwareColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthTextColor { get; private set; } public static ConfigEntry<int> EnemyHudHealthTextFontSize { get; private set; } public static ConfigEntry<bool> EnemyHudHealthTextShowMaxHealth { get; private set; } public static ConfigEntry<bool> EnemyHudHealthTextShowInfiniteHealth { get; private set; } public static ConfigEntry<float> EnemyHudHealthTextInfiniteHealthThreshold { get; private set; } public static ConfigEntry<float> EnemyHudHealthBarWidth { get; private set; } public static ConfigEntry<float> EnemyHudHealthBarHeight { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarFriendlyColor { get; private set; } public static ConfigEntry<Color> EnemyHudHealthBarTamedColor { get; private set; } public static ConfigEntry<bool> EnemyLevelShowByName { get; private set; } public static ConfigEntry<bool> EnemyLevelUseVanillaStar { get; private set; } public static ConfigEntry<string> EnemyLevelStarSymbol { get; private set; } public static ConfigEntry<int> EnemyLevelStarCutoff { get; private set; } public static ConfigEntry<int> EnemyLevelTextMinFontSize { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); ShowEnemyHealthValue = config.BindInOrder("EnemyHud", "showEnemyHealthValue", defaultValue: true, "Show enemy health values."); BindPlayerHudConfig(config); BindBossHudConfig(config); BindEnemyHudConfig(config); BindEnemyLevelConfig(config); } public static void BindPlayerHudConfig(ConfigFile config) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_01af: Unknown result type (might be due to invalid IL or missing references) PlayerHudShowLocalPlayer = config.BindInOrder("PlayerHud", "showLocalPlayer", defaultValue: false, "If true, shows a PlayerHud for the local player."); PlayerHudPositionOffset = config.BindInOrder<Vector3>("PlayerHud.Position", "positionOffset", new Vector3(0f, 0.3f, 0f), "PlayerHud position offset from head point."); PlayerHudNameTextFontSize = config.BindInOrder("PlayerHud.Name", "nameTextFontSize", 20, "PlayerHud.Name text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); PlayerHudNameTextColor = config.BindInOrder<Color>("PlayerHud.Name", "nameTextColor", new Color(1f, 0.7176f, 0.3603f, 1f), "PlayerHud.Name text color."); PlayerHudNameTextPvPColor = config.BindInOrder<Color>("PlayerHud.Name", "nameTextPvPColor", Color.red, "PlayerHud.Name text color when player has PvP enabled."); PlayerHudHealthTextFontSize = config.BindInOrder("PlayerHud.HealthText", "healthTextFontSize", 16, "PlayerHud.HealthText text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); PlayerHudHealthTextColor = config.BindInOrder<Color>("PlayerHud.HealthText", "healthTextColor", Color.white, "PlayerHud.HealthText text color."); PlayerHudHealthBarWidth = config.BindInOrder("PlayerHud.HealthBar", "healthBarWidth", 125f, "PlayerHud.HealthBar width (vanilla: 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); PlayerHudHealthBarHeight = config.BindInOrder("PlayerHud.HealthBar", "healthBarHeight", 22f, "PlayerHud.HealthBar height (vanilla: 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); PlayerHudHealthBarColor = config.BindInOrder<Color>("PlayerHud.HealthBar", "healthBarColor", new Color(0.2638f, 1f, 0.125f, 1f), "PlayerHud.HealthBar fast color for regular players."); } public static void BindBossHudConfig(ConfigFile config) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_019b: Unknown result type (might be due to invalid IL or missing references) FloatingBossHud = config.BindInOrder("BossHud", "floatingBossHud", defaultValue: true, "If set, each BossHud will float over the target enemy."); BossHudPositionOffset = config.BindInOrder<Vector3>("BossHud.Position", "positionOffset", new Vector3(0f, 1f, 0f), "BossHud position offset from top point."); BossHudNameTextFontSize = config.BindInOrder("BossHud.Name", "nameTextFontSize", 32, "BossHud.Name text font size (vanilla: 32).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 64)); BossHudNameTextColorTop = config.BindInOrder<Color>("BossHud.Name", "nameTextColorTop", Color.red, "BossHud.Name text top-color for vertical gradient."); BossHudNameTextColorBottom = config.BindInOrder<Color>("BossHud.Name", "nameTextColorBottom", Color.black, "BossHud.Name text bottom color for vertical gradient."); BossHudHealthTextFontSize = config.BindInOrder("BossHud.HealthText", "healthTextFontSize", 24, "BossHud.HealthText font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 64)); BossHudHealthTextFontColor = config.BindInOrder<Color>("BossHud.HealthText", "healthTextColor", Color.white, "BossHud.HealthText text color."); BossHudHealthBarWidth = config.BindInOrder("BossHud.HealthBar", "healthBarWidth", 300f, "BossHud.HealthBar width (vanilla: 600).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); BossHudHealthBarHeight = config.BindInOrder("BossHud.HealthBar", "healthBarHeight", 30f, "BossHud.HealthBar height (vanilla: 15).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); BossHudHealthBarColor = config.BindInOrder<Color>("BossHud.HealthBar", "healthBarColor", new Color(1f, 0f, 0.3931f, 1f), "BossHud.HealthBar fast color."); } public static void BindEnemyHudConfig(ConfigFile config) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) EnemyHudPositionOffset = config.BindInOrder<Vector3>("EnemyHud.Position", "positionOffset", new Vector3(0f, 0.1f, 0f), "EnemyHud position offset from top point."); EnemyHudNameTextFontSize = config.BindInOrder("EnemyHud.Name", "nameTextFontSize", 16, "EnemyHud.Name text font size (vanilla: 16).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); EnemyHudNameTextColor = config.BindInOrder<Color>("EnemyHud.Name", "nameTextColor", Color.white, "EnemyHud.Name text color (vanilla: white)."); EnemyHudUseNameForStatus = config.BindInOrder("EnemyHud.Name.Status", "useNameForStatus", defaultValue: true, "Use the EnemyHud.Name text color for alerted/aware status."); EnemyHudNameTextAlertedColor = config.BindInOrder<Color>("EnemyHud.Name.Status", "nameTextAlertedColor", Color.red, "EnemyHud.Name text color for alerted status."); EnemyHudNameTextAwareColor = config.BindInOrder<Color>("EnemyHud.Name.Status", "nameTextAwareColor", Color.yellow, "EnemyHud.Name text color for aware status."); EnemyHudHealthTextFontSize = config.BindInOrder("EnemyHud.HealthText", "healthTextFontSize", 14, "EnemyHud.HealthText text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); EnemyHudHealthTextColor = config.BindInOrder<Color>("EnemyHud.HealthText", "healthTextColor", Color.white, "EnemyHud.HealthText text color."); EnemyHudHealthTextShowMaxHealth = config.BindInOrder("EnemyHud.HealthText", "showMaxHealth", defaultValue: true, "EnemyHud.HealthText, if set will show the max health value."); EnemyHudHealthTextShowInfiniteHealth = config.BindInOrder("EnemyHud.HealthText", "showInfiniteHealth", defaultValue: false, "EnemeyHud.HealthText, if set will show infinite symbol when health exceeds threshold value."); EnemyHudHealthTextInfiniteHealthThreshold = config.BindInOrder("EnemyHud.HealthText", "infiniteHealthThreshold", 1E+13f, "EnemyHud.HealthText, threshold value for infinite symbol to be shown for health."); EnemyHudHealthBarWidth = config.BindInOrder("EnemyHud.HealthBar", "healthBarWidth", 125f, "EnemyHud.HealthBar width (vanilla: 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f)); EnemyHudHealthBarHeight = config.BindInOrder("EnemyHud.HealthBar", "healthBarHeight", 22f, "EnemyHud.HealthBar height (vanilla: 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f)); EnemyHudHealthBarColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarColor", new Color(1f, 0.333f, 0.333f, 1f), "EnemyHud.HealthBar fast color for regular mobs."); EnemyHudHealthBarFriendlyColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarFriendlyColor", new Color(0.2638f, 1f, 0.125f, 1f), "EnemyHud.HealthBar fast color for friendly (but not tamed) mobs."); EnemyHudHealthBarTamedColor = config.BindInOrder<Color>("EnemyHud.HealthBar", "healthBarTamedColor", Color.green, "EnemyHud.HealthBar fast color for tamed mobs."); } public static void BindEnemyLevelConfig(ConfigFile config) { EnemyLevelShowByName = config.BindInOrder("EnemyLevel", "enemyLevelShowByName", defaultValue: false, "If true, shows the enemy level after the name, otherwise below healthbar."); EnemyLevelUseVanillaStar = config.BindInOrder("EnemyLevel", "enemyLevelUseVanillaStar", defaultValue: false, "If true, uses the vanilla 'star' image for 1* and 2* monsters."); EnemyLevelStarSymbol = config.BindInOrder("EnemyLevel", "enemyLevelStarSymbol", "★", "Symbol to use for 'star' for enemy levels above vanilla 2*.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[6] { "★", "☆", "✴", "✳", "❖", "✖" })); EnemyLevelStarCutoff = config.BindInOrder("EnemyLevel", "enemyLevelStarCutoff", 2, "When showing enemy levels using stars, max stars to show before switching to 'X★' format.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10)); EnemyLevelTextMinFontSize = config.BindInOrder("EnemyLevel", "enemyLevelMinFontSize", 20, "Sets a minimum font size for the enemy level text which is inherited from enemy name text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32)); } } public static class EnemyHudManager { public static readonly ConditionalWeakTable<HudData, TextMeshProUGUI> HealthTextCache = new ConditionalWeakTable<HudData, TextMeshProUGUI>(); private static readonly List<Character> _keysToRemove = new List<Character>(12); public static void SetupPlayerHud(HudData hudData) { //IL_0010: 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_0053: Unknown result type (might be due to invalid IL or missing references) SetupName(hudData, PluginConfig.PlayerHudNameTextFontSize.Value, PluginConfig.PlayerHudNameTextColor.Value); SetupHud(hudData, PluginConfig.PlayerHudHealthTextFontSize.Value, PluginConfig.PlayerHudHealthTextColor.Value, PluginConfig.PlayerHudHealthBarWidth.Value, PluginConfig.PlayerHudHealthBarHeight.Value); hudData.m_healthFast.SetColor(PluginConfig.PlayerHudHealthBarColor.Value); } public static void SetupBossHud(HudData hudData) { //IL_0010: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) SetupName(hudData, PluginConfig.BossHudNameTextFontSize.Value, PluginConfig.BossHudNameTextColorTop.Value); SetupHud(hudData, PluginConfig.BossHudHealthTextFontSize.Value, PluginConfig.BossHudHealthTextFontColor.Value, PluginConfig.BossHudHealthBarWidth.Value, PluginConfig.BossHudHealthBarHeight.Value); hudData.m_healthFast.SetColor(PluginConfig.BossHudHealthBarColor.Value); SetupNameGradient(hudData, PluginConfig.BossHudNameTextColorTop.Value, PluginConfig.BossHudNameTextColorBottom.Value); } public static void SetupEnemyHud(HudData hudData) { //IL_0010: 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_005f: Unknown result type (might be due to invalid IL or missing references) SetupName(hudData, PluginConfig.EnemyHudNameTextFontSize.Value, PluginConfig.EnemyHudNameTextColor.Value); SetupHud(hudData, PluginConfig.EnemyHudHealthTextFontSize.Value, PluginConfig.EnemyHudHealthTextColor.Value, PluginConfig.EnemyHudHealthBarWidth.Value, PluginConfig.EnemyHudHealthBarHeight.Value); SetupAlerted(hudData); SetupAware(hudData); hudData.m_healthFast.SetColor(PluginConfig.EnemyHudHealthBarColor.Value); } public static void SetupName(HudData hudData, int nameTextFontSize, Color nameTextColor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) hudData.m_name.SetColor<TextMeshProUGUI>(nameTextColor).SetFontSize<TextMeshProUGUI>((float)nameTextFontSize).SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0) .SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0) .SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)1026) .SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false); ((Component)hudData.m_name).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(new Vector2(0f, 8f)) .SetSizeDelta(new Vector2(((TMP_Text)hudData.m_name).preferredWidth, ((TMP_Text)hudData.m_name).preferredHeight)); } public static void SetupNameGradient(HudData hudData, Color topColor, Color bottomColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_0034: 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) ((TMP_Text)hudData.m_name).enableVertexGradient = true; ((TMP_Text)hudData.m_name).colorGradient = new VertexGradient { topLeft = topColor, topRight = topColor, bottomLeft = bottomColor, bottomRight = bottomColor }; } public static void SetupHud(HudData hudData, int healthTextFontSize, Color healthTextFontColor, float healthBarWidth, float healthBarHeight) { //IL_0026: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) Transform val = hudData.m_gui.transform.Find("Health"); ((Component)val).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 1f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); SetupHealthBars(hudData, healthBarWidth, healthBarHeight); TextMeshProUGUI value = CreateHealthText(hudData, val, healthTextFontSize, healthTextFontColor); HealthTextCache.Add(hudData, value); SetupLevel(hudData, val); } public static void SetupHealthBars(HudData hudData, float healthBarWidth, float healthBarHeight) { //IL_0017: 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) //IL_002b: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00da: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) hudData.m_healthFast.m_width = healthBarWidth; ((Component)hudData.m_healthFast).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); hudData.m_healthFast.m_bar.SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); ((Component)hudData.m_healthFast).gameObject.SetActive(true); hudData.m_healthSlow.m_width = healthBarWidth; ((Component)hudData.m_healthSlow).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); hudData.m_healthSlow.m_bar.SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(healthBarWidth, healthBarHeight)); ((Component)hudData.m_healthSlow).gameObject.SetActive(true); GuiBar obj = hudData.m_healthFastFriendly.Ref<GuiBar>(); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } } public static void SetupAlerted(HudData hudData) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hudData.m_alerted)) { TextMeshProUGUI component = ((Component)hudData.m_alerted).GetComponent<TextMeshProUGUI>(); ((Transform)hudData.m_alerted).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_alerted.SetAnchorMin(new Vector2(0.5f, 1f)).SetAnchorMax(new Vector2(0.5f, 1f)).SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(((TMP_Text)component).GetPreferredValues()); ((Component)hudData.m_alerted).gameObject.SetActive(!PluginConfig.EnemyHudUseNameForStatus.Value); } } public static void SetupAware(HudData hudData) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) if (Object.op_Implicit((Object)(object)hudData.m_aware)) { ((Transform)hudData.m_aware).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_aware.SetAnchorMin(new Vector2(0.5f, 1f)).SetAnchorMax(new Vector2(0.5f, 1f)).SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(30f, 30f)); ((Component)hudData.m_aware).gameObject.SetActive(!PluginConfig.EnemyHudUseNameForStatus.Value); } } public static TextMeshProUGUI CreateHealthText(HudData hudData, Transform parentTransform, int healthTextFontSize, Color healthTextFontColor) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(hudData.m_name); ((TMP_Text)obj).transform.SetParent(parentTransform, false); ((Object)obj).name = "HealthText"; ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero); ((TMP_Text)obj).text = string.Empty; ((TMP_Text)obj).fontSize = healthTextFontSize; ((Graphic)obj).color = healthTextFontColor; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; return obj; } public static void SetupLevel(HudData hudData, Transform healthTransform) { if (!PluginConfig.EnemyLevelUseVanillaStar.Value || hudData.m_character.m_level > (hudData.m_character.IsBoss() ? 1 : 3)) { CreateEnemyLevelText(hudData, healthTransform); RectTransform obj = hudData.m_level2.Ref<RectTransform>(); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } RectTransform obj2 = hudData.m_level3.Ref<RectTransform>(); if (obj2 != null) { ((Component)obj2).gameObject.SetActive(false); } } else { SetupEnemyLevelStars(hudData, healthTransform); } } public static TextMeshProUGUI CreateEnemyLevelText(HudData hudData, Transform healthTransform) { //IL_005f: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_016c: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_00c1: 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_00e9: 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) //IL_0109: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(hudData.m_name); ((Object)val).name = "LevelText"; ((TMP_Text)val).text = string.Empty; ((TMP_Text)val).fontSize = Mathf.Clamp((float)(int)((TMP_Text)hudData.m_name).fontSize, (float)PluginConfig.EnemyLevelTextMinFontSize.Value, 64f); ((Graphic)val).color = new Color(1f, 0.85882f, 0.23137f, 1f); ((TMP_Text)val).enableAutoSizing = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; if (PluginConfig.EnemyLevelShowByName.Value) { ((TMP_Text)val).transform.SetParent(((TMP_Text)hudData.m_name).transform, false); ((Component)val).GetComponent<RectTransform>().SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(5f, 0f)) .SetSizeDelta(new Vector2(100f, ((TMP_Text)val).GetPreferredValues().y + 5f)); ((TMP_Text)val).alignment = (TextAlignmentOptions)513; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; } else { ((TMP_Text)val).transform.SetParent(healthTransform, false); Vector2 sizeDelta = ((Component)healthTransform).GetComponent<RectTransform>().sizeDelta; sizeDelta.y = ((TMP_Text)val).GetPreferredValues().y * 2f; ((Component)val).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero) .SetPivot(Vector2.zero) .SetPosition(new Vector2(0f, 0f - sizeDelta.y - 2f)) .SetSizeDelta(sizeDelta); ((TMP_Text)val).alignment = (TextAlignmentOptions)257; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)1; } int num = hudData.m_character.m_level - 1; ((TMP_Text)val).SetText((num <= PluginConfig.EnemyLevelStarCutoff.Value) ? string.Concat(Enumerable.Repeat(PluginConfig.EnemyLevelStarSymbol.Value, num)) : $"{num}{PluginConfig.EnemyLevelStarSymbol.Value}"); return val; } public static void SetupEnemyLevelStars(HudData hudData, Transform healthTransform) { //IL_00a8: 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_00bc: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hudData.m_level2)) { if (PluginConfig.EnemyLevelShowByName.Value) { ((Transform)hudData.m_level2).SetParent(((TMP_Text)hudData.m_name).transform); hudData.m_level2.SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(12f, 0f)) .SetSizeDelta(Vector2.zero); } else { ((Transform)hudData.m_level2).SetParent(healthTransform, false); hudData.m_level2.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero).SetPivot(Vector2.zero) .SetPosition(new Vector2(7.5f, -10f)) .SetSizeDelta(Vector2.zero); } ((Component)hudData.m_level2).gameObject.SetActive(hudData.m_character.GetLevel() == 2); } if (Object.op_Implicit((Object)(object)hudData.m_level3)) { if (PluginConfig.EnemyLevelShowByName.Value) { ((Transform)hudData.m_level3).SetParent(((TMP_Text)hudData.m_name).transform, false); hudData.m_level3.SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)).SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(20f, 0f)) .SetSizeDelta(Vector2.zero); } else { ((Transform)hudData.m_level3).SetParent(healthTransform, false); hudData.m_level3.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.zero).SetPivot(Vector2.zero) .SetPosition(new Vector2(15.5f, -10f)) .SetSizeDelta(Vector2.zero); } ((Component)hudData.m_level3).gameObject.SetActive(hudData.m_character.GetLevel() == 3); } } public static void UpdateHuds(ref EnemyHud enemyHud, ref Player player, ref Sadle sadle, float dt) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if (!Object.op_Implicit((Object)(object)mainCamera)) { return; } Sadle obj = sadle.Ref<Sadle>(); Character val = ((obj != null) ? obj.GetCharacter() : null); Player obj2 = player.Ref<Player>(); Character val2 = ((obj2 != null) ? obj2.GetHoverCreature() : null); _keysToRemove.Clear(); int width = Screen.width; int height = Screen.height; foreach (KeyValuePair<Character, HudData> hud in enemyHud.m_huds) { HudData value = hud.Value; Character character = value.m_character; if (!Object.op_Implicit((Object)(object)character) || !enemyHud.TestShow(character, true) || (Object)(object)character == (Object)(object)val) { _keysToRemove.Add(character); Object.Destroy((Object)(object)value.m_gui); continue; } if ((Object)(object)character == (Object)(object)val2) { value.m_hoverTimer = 0f; } value.m_hoverTimer += dt; if (character.IsPlayer() || character.IsBoss() || value.m_isMount || value.m_hoverTimer < enemyHud.m_hoverShowDuration) { value.m_gui.SetActive(true); ((TMP_Text)value.m_name).text = Localization.m_instance.Localize(character.GetHoverName()); if (character.IsPlayer()) { value.m_name.SetColor<TextMeshProUGUI>(character.IsPVPEnabled() ? PluginConfig.PlayerHudNameTextPvPColor.Value : PluginConfig.PlayerHudNameTextColor.Value); } else if (Object.op_Implicit((Object)(object)character.m_baseAI) && !character.IsBoss()) { bool flag = character.m_baseAI.HaveTarget(); bool flag2 = character.m_baseAI.IsAlerted(); if (PluginConfig.EnemyHudUseNameForStatus.Value) { value.m_name.SetColor<TextMeshProUGUI>((!(flag || flag2)) ? PluginConfig.EnemyHudHealthTextColor.Value : (flag2 ? PluginConfig.EnemyHudNameTextAlertedColor.Value : PluginConfig.EnemyHudNameTextAwareColor.Value)); } else { ((Component)value.m_alerted).gameObject.SetActive(flag2); ((Component)value.m_aware).gameObject.SetActive(flag && !flag2); } } } else { value.m_gui.SetActive(false); } float health = character.GetHealth(); float maxHealth = character.GetMaxHealth(); float value2 = health / maxHealth; if (PluginConfig.ShowEnemyHealthValue.Value && HealthTextCache.TryGetValue(value, out var value3)) { if (PluginConfig.EnemyHudHealthTextShowInfiniteHealth.Value && health > PluginConfig.EnemyHudHealthTextInfiniteHealthThreshold.Value) { ((TMP_Text)value3).SetText("∞"); } else if (PluginConfig.EnemyHudHealthTextShowMaxHealth.Value) { ((TMP_Text)value3).SetText($"{health:N0} / {maxHealth:N0}"); } else { ((TMP_Text)value3).SetText($"{health:N0}"); } } value.m_healthSlow.SetValue(value2); value.m_healthFast.SetValue(value2); if (Object.op_Implicit((Object)(object)value.m_healthFastFriendly)) { value.m_healthFast.SetColor(character.IsTamed() ? PluginConfig.EnemyHudHealthBarTamedColor.Value : ((Object.op_Implicit((Object)(object)player) && !BaseAI.IsEnemy((Character)(object)player, character)) ? PluginConfig.EnemyHudHealthBarFriendlyColor.Value : PluginConfig.EnemyHudHealthBarColor.Value)); } if (value.m_isMount && Object.op_Implicit((Object)(object)sadle)) { float stamina = sadle.GetStamina(); float maxStamina = sadle.GetMaxStamina(); value.m_stamina.SetValue(stamina / maxStamina); ((TMP_Text)value.m_healthText).text = $"{health:N0}"; ((TMP_Text)value.m_staminaText).text = $"{stamina:N0}"; } if (value.m_gui.activeSelf && (PluginConfig.FloatingBossHud.Value || !character.IsBoss())) { Vector3 val3 = (character.IsPlayer() ? (character.GetHeadPoint() + PluginConfig.PlayerHudPositionOffset.Value) : (character.IsBoss() ? (character.GetTopPoint() + PluginConfig.BossHudPositionOffset.Value) : ((!value.m_isMount || !Object.op_Implicit((Object)(object)player)) ? (character.GetTopPoint() + PluginConfig.EnemyHudPositionOffset.Value) : (((Component)((Component)player).transform).transform.position - ((Component)player).transform.up * 0.5f)))); Vector3 val4 = Utils.WorldToScreenPointScaled(mainCamera, val3); if (val4.x < 0f || val4.x > (float)width || val4.y < 0f || val4.y > (float)height || val4.z > 0f) { value.m_gui.transform.position = val4; value.m_gui.SetActive(true); } else { value.m_gui.SetActive(false); } } } for (int i = 0; i < _keysToRemove.Count; i++) { enemyHud.m_huds.Remove(_keysToRemove[i]); } _keysToRemove.Clear(); } } public static class HarmonyUtils { public static readonly HashSet<string> TargetHarmonyIds = new HashSet<string> { "MK_BetterUI" }; public static void UnpatchType(Type type) { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { UnpatchMethod(declaredMethod); } } private static void UnpatchMethod(MethodInfo method) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)method); if (patchInfo == null) { return; } foreach (string owner in patchInfo.Owners) { if (TargetHarmonyIds.Contains(owner)) { Enhuddlement.HarmonyInstance.Unpatch((MethodBase)method, (HarmonyPatchType)0, owner); } } } } [BepInPlugin("redseiko.valheim.enhuddlement", "Enhuddlement", "1.4.0")] public sealed class Enhuddlement : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.enhuddlement"; public const string PluginName = "Enhuddlement"; public const string PluginVersion = "1.4.0"; private static ManualLogSource _logger; public static Harmony HarmonyInstance { get; private set; } private void Awake() { _logger = ((BaseUnityPlugin)this).Logger; PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.enhuddlement"); } public static void LogInfo(object obj) { _logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } public static void LogError(object obj) { _logger.LogError((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } } [HarmonyPatch(typeof(EnemyHud))] internal static class EnemyHudPatch { [HarmonyPrefix] [HarmonyPatch("ShowHud")] private static void ShowHudPrefix(ref EnemyHud __instance, ref Character c, ref bool __state) { __state = __instance.m_huds.ContainsKey(c); } [HarmonyPostfix] [HarmonyPatch("ShowHud")] private static void ShowHudPostfix(ref EnemyHud __instance, ref Character c, ref bool isMount, ref bool __state) { if (!(!PluginConfig.IsModEnabled.Value | __state) && __instance.m_huds.TryGetValue(c, out var value)) { if (c.IsPlayer()) { EnemyHudManager.SetupPlayerHud(value); } else if (c.IsBoss()) { EnemyHudManager.SetupBossHud(value); } else if (!isMount) { EnemyHudManager.SetupEnemyHud(value); } } } [HarmonyPrefix] [HarmonyPatch("UpdateHuds")] private static bool UpdateHudsPrefix(ref EnemyHud __instance, ref Player player, ref Sadle sadle, float dt) { if (PluginConfig.IsModEnabled.Value) { EnemyHudManager.UpdateHuds(ref __instance, ref player, ref sadle, dt); return false; } return true; } [HarmonyTranspiler] [HarmonyPatch("LateUpdate")] private static IEnumerable<CodeInstruction> LateUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchStartForward((CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Stloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null) }).Advance(3).ThrowIfInvalid("Could not patch EnemyHud.LateUpdate()! (character-local-player-equality)") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(EnemyHudPatch), "CharacterLocalPlayerEqualityDelegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } private static bool CharacterLocalPlayerEqualityDelegate(Character character, Player player) { if (PluginConfig.PlayerHudShowLocalPlayer.Value) { return false; } return (Object)(object)character == (Object)(object)player; } [HarmonyPostfix] [HarmonyPatch("TestShow")] private static void TestShowPostfix(Character c, ref bool __result) { if (__result && (Object)(object)c == (Object)(object)Player.m_localPlayer) { __result = PluginConfig.IsModEnabled.Value && PluginConfig.PlayerHudShowLocalPlayer.Value; } } } [HarmonyPatch(typeof(FejdStartup))] internal static class FejdStartupPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] [HarmonyPriority(0)] private static void AwakePostfix() { HarmonyUtils.UnpatchType(typeof(EnemyHud)); } } } namespace ComfyLib { public static class CodeMatcherExtensions { public static CodeMatcher CreateLabelOffset(this CodeMatcher matcher, int offset, out Label label) { return matcher.CreateLabelAt(matcher.Pos + offset, ref label); } public static CodeMatcher DeclareLocal(this CodeMatcher matcher, ILGenerator generator, Type localType, out LocalBuilder localBuilder) { localBuilder = generator.DeclareLocal(localType); return matcher; } public static CodeMatcher ExtractLabels(this CodeMatcher matcher, out List<Label> labels) { labels = matcher.Labels.ToList(); matcher.Labels.Clear(); return matcher; } public static CodeMatcher SaveOperand(this CodeMatcher matcher, out object operand) { operand = matcher.Operand; return matcher; } } 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>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } } public static class ChatExtensions { public static void AddMessage(this Chat chat, object obj) { if (Object.op_Implicit((Object)(object)chat)) { ((Terminal)chat).AddString(obj.ToString()); chat.m_hideTimer = 0f; } } } public static class ComponentExtensions { public static bool TryGetComponentInChildren<T>(this GameObject gameObject, out T component) where T : Component { component = gameObject.GetComponentInChildren<T>(); return Object.op_Implicit((Object)(object)component); } public static bool TryGetComponentInParent<T>(this GameObject gameObject, out T component) where T : Component { component = gameObject.GetComponentInParent<T>(); return Object.op_Implicit((Object)(object)component); } } public static class ObjectExtensions { public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object { foreach (T val in unityObjects) { if (((Object)val).name == name) { return val; } } 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 CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class GridLayoutGroupExtensions { public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.cellSize = cellSize; return layoutGroup; } public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.constraint = constraint; return layoutGroup; } public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount) { layoutGroup.constraintCount = constraintCount; return layoutGroup; } public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startAxis = startAxis; return layoutGroup; } public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startCorner = startCorner; return layoutGroup; } public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.spacing = spacing; return layoutGroup; } } public static class LayoutGroupExtensions { public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : LayoutGroup { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetMaterial(this Image image, Material material) { ((Graphic)image).material = material; return image; } public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier) { image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class LayoutElementExtensions { public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } } public static class RectMask2DExtensions { public static T SetPadding<T>(this T rectMask, Vector4 padding) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).padding = padding; return rectMask; } public static T SetSoftness<T>(this T rectMask, Vector2Int softness) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).softness = softness; return rectMask; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class ScrollbarExtensions { public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Scrollbar)scrollbar).direction = direction; return scrollbar; } public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar { ((Scrollbar)scrollbar).handleRect = handleRect; return scrollbar; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).spriteState = spriteState; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class SliderExtensions { public static T SetDirection<T>(this T slider, Direction direction) where T : Slider { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Slider)slider).direction = direction; return slider; } public static T SetFillRect<T>(this T slider, RectTransform fillRect) where T : Slider { ((Slider)slider).fillRect = fillRect; return slider; } public static T SetHandleRect<T>(this T slider, RectTransform handleRect) where T : Slider { ((Slider)slider).handleRect = handleRect; return slider; } public static T SetMaxValue<T>(this T slider, float maxValue) where T : Slider { ((Slider)slider).maxValue = maxValue; return slider; } public static T SetMinValue<T>(this T slider, float minValue) where T : Slider { ((Slider)slider).minValue = minValue; return slider; } public static T SetValue<T>(this T slider, float value) where T : Slider { ((Slider)slider).value = value; return slider; } public static T SetWholeNumbers<T>(this T slider, bool wholeNumbers) where T : Slider { ((Slider)slider).wholeNumbers = wholeNumbers; return slider; } } public static class ScrollRectExtensions { public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect { ((ScrollRect)scrollRect).content = content; return scrollRect; } public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect { ((ScrollRect)scrollRect).horizontal = horizontal; return scrollRect; } public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).movementType = movementType; return scrollRect; } public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect { ((ScrollRect)scrollRect).scrollSensitivity = sensitivity; return scrollRect; } public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect { ((ScrollRect)scrollRect).vertical = vertical; return scrollRect; } public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect { ((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar; return scrollRect; } public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect { ((ScrollRect)scrollRect).verticalNormalizedPosition = position; return scrollRect; } public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility; return scrollRect; } public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect { ((ScrollRect)scrollRect).viewport = viewport; return scrollRect; } } public static class TextMeshProExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetCharacterSpacing<T>(this T tmpText, float characterSpacing) where T : TMP_Text { ((TMP_Text)tmpText).characterSpacing = characterSpacing; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetLineSpacing<T>(this T tmpText, float lineSpacing) where T : TMP_Text { ((TMP_Text)tmpText).lineSpacing = lineSpacing; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } } public static class ToggleExtensions { public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle { ((Toggle)toggle).graphic = graphic; return toggle; } public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Toggle)toggle).toggleTransition = toggleTransition; return toggle; } } }