Decompiled source of ShowDamage HealthBar v2.0.1
Silksong_HealthBar.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TeamCherry.Localization; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Silksong_HealthBar")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Silksong_HealthBar")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b2226807-f60b-4aa5-8a57-da5712b42343")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace HealthbarPlugin; [BepInPlugin("com.Xiaohai.HealthbarAndDamageShow", "Healthbar&DamageShow", "2.0.0")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.Xiaohai.HealthbarAndDamageShow"; public const string PLUGIN_NAME = "Healthbar&DamageShow"; public const string PLUGIN_VERSION = "2.0.0"; public static ManualLogSource logger; public static ConfigEntry<bool> ShowEnemyHealthBar; public static ConfigEntry<bool> ShowBossHealthBar; public static ConfigEntry<bool> ShowDamageText; public static ConfigEntry<KeyCode> ConfigGUI_Hotkey; public static ConfigEntry<float> DamageTextDuration; public static ConfigEntry<int> DamageTextFontSize; public static ConfigEntry<string> DamageTextColor; public static ConfigEntry<bool> DamageTextUseSign; public static ConfigEntry<string> HealthBarFillColor; public static ConfigEntry<string> HealthBarBackgroundColor; public static ConfigEntry<float> HealthBarWidth; public static ConfigEntry<float> HealthBarHeight; public static ConfigEntry<bool> ShowHealthBarNumbers; public static ConfigEntry<int> HealthBarNumbersFontSize; public static ConfigEntry<string> HealthBarNumbersColor; public static ConfigEntry<float> HealthBarHideDelay; public static ConfigEntry<float> HealthBarNumbersVerticalOffset; public static ConfigEntry<bool> HealthBarNumbersInsideBar; public static ConfigEntry<bool> HealthBarNumbersAutoWhiteOnLowHealth; public static ConfigEntry<float> HealthBarFillMarginTop; public static ConfigEntry<float> HealthBarFillMarginBottom; public static ConfigEntry<int> BossHealthThreshold; public static ConfigEntry<string> BossHealthBarFillColor; public static ConfigEntry<string> BossHealthBarBackgroundColor; public static ConfigEntry<float> BossHealthBarWidth; public static ConfigEntry<float> BossHealthBarHeight; public static ConfigEntry<bool> BossHealthBarBottomPosition; public static ConfigEntry<string> BossHealthBarNameColor; public static ConfigEntry<bool> ShowBossHealthBarNumbers; public static ConfigEntry<string> BossHealthBarNumbersColor; public static ConfigEntry<float> BossMaxHealth; public static ConfigEntry<float> BossHealthBarFillMarginTop; public static ConfigEntry<float> BossHealthBarFillMarginBottom; public static ConfigEntry<float> BossHealthBarFillMarginLeft; public static ConfigEntry<float> BossHealthBarFillMarginRight; public static ConfigEntry<int> HealthBarShape; public static ConfigEntry<int> BossHealthBarShape; public static ConfigEntry<int> HealthBarCornerRadius; public static ConfigEntry<int> BossHealthBarCornerRadius; public static ConfigEntry<bool> UseCustomTextures; public static ConfigEntry<int> CustomTextureScaleMode; public static Plugin Instance { get; private set; } private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) logger = ((BaseUnityPlugin)this).Logger; Instance = this; InitializeConfig(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Initializing Healthbar&DamageShow v2.0.0"); new Harmony("com.Xiaohai.HealthbarAndDamageShow").PatchAll(); InitializeConfigGUI(); CustomTextureManager.Initialize(); } private void InitializeConfigGUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("HealthBarConfigGUI"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<ConfigGUI>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"配置GUI已初始化,按{ConfigGUI_Hotkey.Value}键打开/关闭配置面板"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("初始化配置GUI失败: " + ex.Message)); } } private void InitializeConfig() { ShowEnemyHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowEnemyHealthBar", true, "是否显示普通敌人血条 / Whether to show normal enemy health bars"); ShowBossHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowBossHealthBar", true, "是否显示BOSS血条 / Whether to show boss health bars"); ShowDamageText = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowDamageText", true, "是否显示伤害文本 / Whether to show damage text"); ConfigGUI_Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Display", "ConfigGUI_Hotkey", (KeyCode)278, "配置面板热键 / Hotkey to toggle config GUI"); DamageTextDuration = ((BaseUnityPlugin)this).Config.Bind<float>("DamageText", "Duration", 2f, "伤害文本显示持续时间(秒) / Damage text display duration (seconds)"); DamageTextFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("DamageText", "FontSize", 55, "伤害文本字体大小 / Damage text font size"); DamageTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("DamageText", "DamageColor", "#0e0404ff", "伤害文本颜色(十六进制格式,如#FF0000为红色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Damage text color (hex format, e.g. #FF0000 for red)"); DamageTextUseSign = ((BaseUnityPlugin)this).Config.Bind<bool>("DamageText", "UseSign", true, "伤害文本是否显示符号?(Plus:+, Minus:-) / Whether to show signs in damage text (Plus:+, Minus:-)"); HealthBarFillColor = ((BaseUnityPlugin)this).Config.Bind<string>("HealthBar", "FillColor", "#beb8b8ff", "血条填充颜色(十六进制格式,如#FF0000为红色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Health bar fill color (hex format, e.g. #FF0000 for red)"); HealthBarBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("HealthBar", "BackgroundColor", "#00000085", "血条背景颜色(十六进制格式,如#000000为黑色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Health bar background color (hex format, e.g. #000000 for black)"); HealthBarWidth = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "Width", 135f, "血条宽度(像素) / Health bar width (pixels)"); HealthBarHeight = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "Height", 25f, "血条高度(像素) / Health bar height (pixels)"); ShowHealthBarNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("HealthBar", "ShowNumbers", true, "是否在血条上方显示具体数值(当前生命值/最大生命值) / Whether to show health numbers above health bar (current HP / max HP)"); HealthBarNumbersFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("HealthBar", "NumbersFontSize", 32, "血量数值文本字体大小 / Health numbers text font size"); HealthBarNumbersColor = ((BaseUnityPlugin)this).Config.Bind<string>("HealthBar", "NumbersColor", "#0e0404ff", "血量数值文本颜色(十六进制格式,如#FFFFFF为白色) / Health numbers text color (hex format, e.g. #FFFFFF for white)"); HealthBarHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "HideDelay", 1.5f, "血条/血量数值无变化后自动隐藏的延迟时间(秒) / Auto-hide delay for health bar/numbers after no changes (seconds)"); HealthBarNumbersVerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "NumbersVerticalOffset", 0.3f, "血量数值文本相对于血条的上下偏移值(正值向上,负值向下) / Vertical offset of health numbers relative to health bar (positive up, negative down)"); HealthBarNumbersInsideBar = ((BaseUnityPlugin)this).Config.Bind<bool>("HealthBar", "NumbersInsideBar", false, "是否将血量数值显示在血条内部(启用时忽略垂直偏移值) / Whether to display health numbers inside the health bar (ignores vertical offset when enabled)"); HealthBarNumbersAutoWhiteOnLowHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("HealthBar", "NumbersAutoWhiteOnLowHealth", true, "当血量低于49%时,血量文本颜色自动变为白色(确保在黑色背景下可见) / Automatically change health numbers color to white when health is below 49% (ensures visibility on dark backgrounds)"); HealthBarFillMarginTop = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "FillMarginTop", 2f, "血条填充物距离背景上边框的距离(像素) / Distance between health bar fill and top border of background (pixels)"); HealthBarFillMarginBottom = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBar", "FillMarginBottom", 2f, "血条填充物距离背景下边框的距离(像素) / Distance between health bar fill and bottom border of background (pixels)"); BossHealthThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("BossHealthBar", "HealthThreshold", 105, "BOSS血量阈值(血量大于此值时显示BOSS血条而非普通血条) / Boss health threshold (show boss health bar instead of normal health bar when HP exceeds this value)"); BossHealthBarFillColor = ((BaseUnityPlugin)this).Config.Bind<string>("BossHealthBar", "FillColor", "#beb8b8ff", "BOSS血条填充颜色(十六进制格式,如#FF0000为红色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Boss health bar fill color (hex format, e.g. #FF0000 for red)"); BossHealthBarBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("BossHealthBar", "BackgroundColor", "#000000ff", "BOSS血条背景颜色(十六进制格式,如#000000为黑色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Boss health bar background color (hex format, e.g. #000000 for black)"); BossHealthBarWidth = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "Width", 900f, "BOSS血条宽度(像素) / Boss health bar width (pixels)"); BossHealthBarHeight = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "Height", 25f, "BOSS血条高度(像素) / Boss health bar height (pixels)"); BossHealthBarBottomPosition = ((BaseUnityPlugin)this).Config.Bind<bool>("BossHealthBar", "BottomPosition", true, "BOSS血条位置(true=屏幕下方中间,false=屏幕上方中间) / Boss health bar position (true=bottom center of screen, false=top center of screen)"); BossHealthBarNameColor = ((BaseUnityPlugin)this).Config.Bind<string>("BossHealthBar", "NameColor", "#0e0404ff", "BOSS名字文本颜色(十六进制格式,如#FFFFFF为白色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Boss name text color (hex format, e.g. #FFFFFF for white)"); ShowBossHealthBarNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("BossHealthBar", "ShowNumbers", true, "是否显示BOSS血量数字(当前HP/最大HP) / Whether to show boss health numbers (current HP / max HP)"); BossMaxHealth = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "BossMaxHealth", 3000f, "显示BOSS最大生命值(用于修复将未知的巨大生命值的物体显示为BOSS血条) / Boss maximum health Used to fix the issue where unknown non-boss objects with extremely high health values are displayed as boss health bars.)"); BossHealthBarNumbersColor = ((BaseUnityPlugin)this).Config.Bind<string>("BossHealthBar", "NumbersColor", "#0e0404ff", "BOSS血量数值文本颜色(十六进制格式,如#FFFFFF为白色)颜色十六进制代码转换:http://pauli.cn/tool/color.htm / Boss health numbers text color (hex format, e.g. #FFFFFF for white)"); BossHealthBarFillMarginTop = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "FillMarginTop", 2f, "BOSS血条填充物距离背景上边框的距离(像素) / Distance between boss health bar fill and top border of background (pixels)"); BossHealthBarFillMarginBottom = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "FillMarginBottom", 2f, "BOSS血条填充物距离背景下边框的距离(像素) / Distance between boss health bar fill and bottom border of background (pixels)"); BossHealthBarFillMarginLeft = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "FillMarginLeft", 2f, "BOSS血条填充物距离背景左边框的距离(像素) / Distance between boss health bar fill and left border of background (pixels)"); BossHealthBarFillMarginRight = ((BaseUnityPlugin)this).Config.Bind<float>("BossHealthBar", "FillMarginRight", 2f, "BOSS血条填充物距离背景右边框的距离(像素) / Distance between boss health bar fill and right border of background (pixels)"); HealthBarShape = ((BaseUnityPlugin)this).Config.Bind<int>("HealthBar", "Shape", 1, "敌人血条形状(1=长方形,2=圆角) / Enemy health bar shape (1=Rectangle, 2=Rounded)"); BossHealthBarShape = ((BaseUnityPlugin)this).Config.Bind<int>("BossHealthBar", "Shape", 1, "BOSS血条形状(1=长方形,2=圆角) / Boss health bar shape (1=Rectangle, 2=Rounded)"); HealthBarCornerRadius = ((BaseUnityPlugin)this).Config.Bind<int>("HealthBar", "CornerRadius", 30, "敌人血条圆角半径(像素) / Enemy health bar corner radius (pixels)"); BossHealthBarCornerRadius = ((BaseUnityPlugin)this).Config.Bind<int>("BossHealthBar", "CornerRadius", 30, "BOSS血条圆角半径(像素) / Boss health bar corner radius (pixels)"); UseCustomTextures = ((BaseUnityPlugin)this).Config.Bind<bool>("CustomTexture", "Enabled", false, "是否启用自定义血条材质(从DLL目录/Texture/文件夹加载) / Enable custom health bar textures (load from DLL directory/Texture/ folder)"); CustomTextureScaleMode = ((BaseUnityPlugin)this).Config.Bind<int>("CustomTexture", "ScaleMode", 1, "自定义材质缩放模式(1=拉伸适应,2=保持比例) / Custom texture scale mode (1=Stretch to fit, 2=Keep aspect ratio)"); if (HealthBarNumbersInsideBar.Value) { HealthBarNumbersVerticalOffset.Value = -0.03f; } } } [HarmonyPatch] public static class Patch { [HarmonyPatch(typeof(HealthManager))] public static class HealthManager_Patch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake_Postfix(HealthManager __instance) { if ((float)__instance.initHp > Plugin.BossMaxHealth.Value || (float)__instance.hp > Plugin.BossMaxHealth.Value) { return; } if (__instance.hp > Plugin.BossHealthThreshold.Value) { if (Plugin.ShowBossHealthBar.Value && (Object)(object)((Component)__instance).gameObject.GetComponent<BossHealthBar>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<BossHealthBar>(); } } else if (Plugin.ShowEnemyHealthBar.Value && (Object)(object)((Component)__instance).gameObject.GetComponent<EnemyHealthBar>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<EnemyHealthBar>(); } } [HarmonyPatch("TakeDamage")] [HarmonyPrefix] public static void TakeDamage_Prefix(HealthManager __instance) { if (!((float)__instance.initHp > Plugin.BossMaxHealth.Value) && !((float)__instance.hp > Plugin.BossMaxHealth.Value)) { HealthTracker healthTracker = ((Component)__instance).GetComponent<HealthTracker>(); if ((Object)(object)healthTracker == (Object)null) { healthTracker = ((Component)__instance).gameObject.AddComponent<HealthTracker>(); } healthTracker.lastHp = __instance.hp; EnemyHealthBar component = ((Component)__instance).gameObject.GetComponent<EnemyHealthBar>(); if ((Object)(object)component != (Object)null) { component.RecordMaxHealth(__instance.hp); } BossHealthBar component2 = ((Component)__instance).gameObject.GetComponent<BossHealthBar>(); if ((Object)(object)component2 != (Object)null) { component2.RecordMaxHealth(__instance.hp); } } } [HarmonyPatch("TakeDamage")] [HarmonyPostfix] public static void TakeDamage_Postfix(HealthManager __instance) { //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) //IL_0078: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) if ((float)__instance.initHp > Plugin.BossMaxHealth.Value || (float)__instance.hp > Plugin.BossMaxHealth.Value) { return; } HeroController val = Object.FindFirstObjectByType<HeroController>(); if ((Object)(object)val == (Object)null) { return; } float num = Vector2.Distance(new Vector2(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y), new Vector2(val.transform.position.x, val.transform.position.y)); if (num > 35f) { return; } HealthTracker component = ((Component)__instance).GetComponent<HealthTracker>(); if ((Object)(object)component == (Object)null) { return; } int num2 = component.lastHp - __instance.hp; if (num2 == 0) { return; } if (__instance.initHp >= Plugin.BossHealthThreshold.Value) { if (!Plugin.ShowBossHealthBar.Value) { return; } BossHealthBar bossHealthBar = ((Component)__instance).gameObject.GetComponent<BossHealthBar>(); if ((Object)(object)bossHealthBar == (Object)null) { bossHealthBar = ((Component)__instance).gameObject.AddComponent<BossHealthBar>(); } if (num2 < 0) { bossHealthBar.RecordMaxHealth(__instance.hp); } if ((Object)(object)bossHealthBar != (Object)null) { bossHealthBar.OnDamageTaken(); } } else { if (!Plugin.ShowEnemyHealthBar.Value) { return; } EnemyHealthBar enemyHealthBar = ((Component)__instance).gameObject.GetComponent<EnemyHealthBar>(); if ((Object)(object)enemyHealthBar == (Object)null) { enemyHealthBar = ((Component)__instance).gameObject.AddComponent<EnemyHealthBar>(); } if (num2 < 0) { enemyHealthBar.RecordMaxHealth(__instance.hp); } if ((Object)(object)enemyHealthBar != (Object)null) { enemyHealthBar.OnDamageTaken(); } } if (Plugin.ShowDamageText.Value) { Vector3 position = ((Component)__instance).transform.position; DamageTextManager.Instance.ShowDamageText(Vector2.op_Implicit(position), num2); } } } } public class HealthTracker : MonoBehaviour { public int lastHp = 0; } public static class CustomTextureManager { private static Dictionary<string, Sprite> textureCache = new Dictionary<string, Sprite>(); private static string textureFolderPath; private const string ENEMY_TEXTURE_NAME = "HpBar.png"; private const string BOSS_TEXTURE_NAME = "HpBar_Boss.png"; private const string BORDER_TEXTURE_NAME = "BG.png"; public static void Initialize() { try { string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); textureFolderPath = Path.Combine(directoryName, "Texture"); if (Directory.Exists(textureFolderPath)) { } } catch (Exception ex) { Plugin.logger.LogError((object)("初始化自定义材质管理器失败: " + ex.Message)); } } public static Sprite GetEnemyHealthBarTexture() { if (!Plugin.UseCustomTextures.Value) { return null; } return LoadTexture("HpBar.png"); } public static Sprite GetBossHealthBarTexture() { if (!Plugin.UseCustomTextures.Value) { return null; } return LoadTexture("HpBar_Boss.png"); } private static Sprite LoadTexture(string fileName) { //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_006f: Expected O, but got Unknown try { if (textureCache.ContainsKey(fileName) && (Object)(object)textureCache[fileName] != (Object)null) { return textureCache[fileName]; } string text = Path.Combine(textureFolderPath, fileName); if (!File.Exists(text)) { return null; } byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); try { bool flag = false; try { Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule"); if (type != null) { MethodInfo method = type.GetMethod("LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }); if (method != null) { flag = (bool)method.Invoke(null, new object[2] { val, array }); } } } catch { flag = false; } if (!flag) { try { MethodInfo method2 = typeof(Texture2D).GetMethod("LoadImage", new Type[1] { typeof(byte[]) }); if (method2 != null) { flag = (bool)method2.Invoke(val, new object[1] { array }); } } catch { flag = false; } } if (!flag) { Plugin.logger.LogError((object)("无法加载图像文件: " + text + " - 当前Unity版本不支持图像加载方法")); Object.DestroyImmediate((Object)(object)val); return null; } } catch (Exception ex) { Plugin.logger.LogError((object)("加载图像时发生异常: " + ex.Message)); Object.DestroyImmediate((Object)(object)val); return null; } ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); textureCache[fileName] = val2; return val2; } catch (Exception ex2) { Plugin.logger.LogError((object)("加载自定义材质失败 " + fileName + ": " + ex2.Message)); return null; } } public static void ApplyCustomTexture(Image image, Sprite customSprite, Vector2 targetSize) { if ((Object)(object)image == (Object)null || (Object)(object)customSprite == (Object)null) { return; } try { image.sprite = customSprite; image.type = (Type)3; image.fillMethod = (FillMethod)0; switch (Plugin.CustomTextureScaleMode.Value) { case 1: image.preserveAspect = false; break; case 2: image.preserveAspect = true; break; default: image.preserveAspect = false; break; } } catch (Exception ex) { Plugin.logger.LogError((object)("应用自定义材质失败: " + ex.Message)); } } public static void ClearCache() { try { foreach (KeyValuePair<string, Sprite> item in textureCache) { if ((Object)(object)item.Value != (Object)null && (Object)(object)item.Value.texture != (Object)null) { Object.Destroy((Object)(object)item.Value.texture); Object.Destroy((Object)(object)item.Value); } } textureCache.Clear(); } catch (Exception ex) { Plugin.logger.LogError((object)("清理自定义材质缓存失败: " + ex.Message)); } } public static Sprite GetBorderTexture() { return LoadTexture("BG.png"); } public static void ReloadTextures() { ClearCache(); } } public class ConfigGUI : MonoBehaviour { private bool showGUI = false; private Rect windowRect = new Rect(20f, 20f, 400f, 600f); private Vector2 scrollPosition = Vector2.zero; private bool isEnglish = false; private Dictionary<string, string> texts = new Dictionary<string, string> { { "window_title_cn", "Silksong HealthBar 配置面板" }, { "window_title_en", "Silksong HealthBar Config Panel" }, { "display_settings_cn", "=== 显示开关配置 ===" }, { "display_settings_en", "=== Display Settings ===" }, { "damage_text_settings_cn", "=== 伤害文本配置 ===" }, { "damage_text_settings_en", "=== Damage Text Settings ===" }, { "healthbar_settings_cn", "=== 血条配置 ===" }, { "healthbar_settings_en", "=== Health Bar Settings ===" }, { "boss_settings_cn", "=== BOSS血条配置 ===" }, { "boss_settings_en", "=== Boss Health Bar Settings ===" }, { "show_enemy_healthbar_cn", "显示普通敌人血条" }, { "show_enemy_healthbar_en", "Show Normal Enemy Health Bars" }, { "show_boss_healthbar_cn", "显示BOSS血条" }, { "show_boss_healthbar_en", "Show Boss Health Bars" }, { "show_damage_text_cn", "显示伤害文本" }, { "show_damage_text_en", "Show Damage Text" }, { "damage_text_use_sign_cn", "显示+/-符号" }, { "damage_text_use_sign_en", "Show +/- Signs" }, { "damage_text_use_sign_label_cn", "伤害文本使用符号:" }, { "damage_text_use_sign_label_en", "Damage Text Use Signs:" }, { "damage_text_duration_cn", "伤害文本持续时间" }, { "damage_text_duration_en", "Damage Text Duration" }, { "damage_text_fontsize_cn", "伤害文本字体大小" }, { "damage_text_fontsize_en", "Damage Text Font Size" }, { "damage_text_color_cn", "伤害文本颜色 (十六进制):" }, { "damage_text_color_en", "Damage Text Color (Hex):" }, { "healthbar_fill_color_cn", "血条填充颜色 (十六进制):" }, { "healthbar_fill_color_en", "Health Bar Fill Color (Hex):" }, { "healthbar_background_color_cn", "血条背景颜色 (十六进制):" }, { "healthbar_background_color_en", "Health Bar Background Color (Hex):" }, { "healthbar_width_cn", "血条宽度" }, { "healthbar_width_en", "Health Bar Width" }, { "healthbar_height_cn", "血条高度" }, { "healthbar_height_en", "Health Bar Height" }, { "show_healthbar_numbers_cn", "显示血量数字" }, { "show_healthbar_numbers_en", "Show Health Numbers" }, { "healthbar_numbers_fontsize_cn", "血量数字字体大小" }, { "healthbar_numbers_fontsize_en", "Health Numbers Font Size" }, { "healthbar_numbers_color_cn", "血量数字颜色 (十六进制):" }, { "healthbar_numbers_color_en", "Health Numbers Color (Hex):" }, { "healthbar_hide_delay_cn", "血条隐藏延迟" }, { "healthbar_hide_delay_en", "Health Bar Hide Delay" }, { "healthbar_numbers_vertical_offset_cn", "血量数字垂直偏移" }, { "healthbar_numbers_vertical_offset_en", "Health Numbers Vertical Offset" }, { "healthbar_numbers_inside_bar_cn", "血量数字显示在血条内部" }, { "healthbar_numbers_inside_bar_en", "Show Health Numbers Inside Bar" }, { "healthbar_numbers_auto_white_cn", "血量低于49%时自动变白" }, { "healthbar_numbers_auto_white_en", "Auto White on Low Health (49%)" }, { "healthbar_fill_margin_top_cn", "血条填充物上边距" }, { "healthbar_fill_margin_top_en", "Health Bar Fill Top Margin" }, { "healthbar_fill_margin_bottom_cn", "血条填充物下边距" }, { "healthbar_fill_margin_bottom_en", "Health Bar Fill Bottom Margin" }, { "boss_health_threshold_cn", "BOSS血量阈值" }, { "boss_health_threshold_en", "Boss Health Threshold" }, { "boss_healthbar_fill_color_cn", "BOSS血条填充颜色 (十六进制):" }, { "boss_healthbar_fill_color_en", "Boss Health Bar Fill Color (Hex):" }, { "boss_healthbar_background_color_cn", "BOSS血条背景颜色 (十六进制):" }, { "boss_healthbar_background_color_en", "Boss Health Bar Background Color (Hex):" }, { "boss_healthbar_width_cn", "BOSS血条宽度" }, { "boss_healthbar_width_en", "Boss Health Bar Width" }, { "boss_healthbar_height_cn", "BOSS血条高度" }, { "boss_healthbar_height_en", "Boss Health Bar Height" }, { "boss_healthbar_bottom_position_cn", "BOSS血条显示在底部" }, { "boss_healthbar_bottom_position_en", "Show Boss Health Bar at Bottom" }, { "boss_healthbar_name_color_cn", "BOSS名字颜色 (十六进制):" }, { "boss_healthbar_name_color_en", "Boss Name Color (Hex):" }, { "show_boss_healthbar_numbers_cn", "显示BOSS血量数字" }, { "show_boss_healthbar_numbers_en", "Show Boss Health Numbers" }, { "boss_healthbar_numbers_color_cn", "BOSS血量数字颜色 (十六进制):" }, { "boss_healthbar_numbers_color_en", "Boss Health Numbers Color (Hex):" }, { "boss_healthbar_fill_margin_top_cn", "BOSS血条填充物上边距" }, { "boss_healthbar_fill_margin_top_en", "Boss Health Bar Fill Top Margin" }, { "boss_healthbar_fill_margin_bottom_cn", "BOSS血条填充物下边距" }, { "boss_healthbar_fill_margin_bottom_en", "Boss Health Bar Fill Bottom Margin" }, { "boss_healthbar_fill_margin_left_cn", "BOSS血条填充物左边距" }, { "boss_healthbar_fill_margin_left_en", "Boss Health Bar Fill Left Margin" }, { "boss_healthbar_fill_margin_right_cn", "BOSS血条填充物右边距" }, { "boss_healthbar_fill_margin_right_en", "Boss Health Bar Fill Right Margin" }, { "healthbar_shape_cn", "敌人血条形状" }, { "healthbar_shape_en", "Enemy Health Bar Shape" }, { "boss_healthbar_shape_cn", "BOSS血条形状" }, { "boss_healthbar_shape_en", "Boss Health Bar Shape" }, { "shape_rectangle_cn", "长方形" }, { "shape_rectangle_en", "Rectangle" }, { "shape_rounded_cn", "圆角" }, { "shape_rounded_en", "Rounded" }, { "corner_radius_cn", "圆角半径" }, { "corner_radius_en", "Corner Radius" }, { "boss_corner_radius_cn", "BOSS血条圆角半径" }, { "boss_corner_radius_en", "Boss Health Bar Corner Radius" }, { "custom_texture_settings_cn", "=== 自定义材质配置 ===" }, { "custom_texture_settings_en", "=== Custom Texture Settings ===" }, { "use_custom_textures_cn", "启用自定义血条材质" }, { "use_custom_textures_en", "Enable Custom Health Bar Textures" }, { "custom_texture_scale_mode_cn", "材质缩放模式" }, { "custom_texture_scale_mode_en", "Texture Scale Mode" }, { "scale_mode_stretch_cn", "拉伸适应" }, { "scale_mode_stretch_en", "Stretch to Fit" }, { "scale_mode_aspect_cn", "保持比例" }, { "scale_mode_aspect_en", "Keep Aspect Ratio" }, { "reload_textures_cn", "重新加载材质" }, { "reload_textures_en", "Reload Textures" }, { "texture_path_info_cn", "材质路径: DLL目录/Texture/\nHpBar.png (敌人) | HpBar_Boss.png (BOSS)" }, { "texture_path_info_en", "Texture Path: DLL Directory/Texture/\nHpBar.png (Enemy) | HpBar_Boss.png (Boss)" }, { "performance_settings_cn", "=== 性能优化配置 ===" }, { "performance_settings_en", "=== Performance Settings ===" }, { "use_simplified_corners_cn", "使用简化圆角算法(推荐)" }, { "use_simplified_corners_en", "Use Simplified Corner Algorithm (Recommended)" }, { "save_config_cn", "保存配置" }, { "save_config_en", "Save Config" }, { "reset_defaults_cn", "恢复默认值" }, { "reset_defaults_en", "Reset to Defaults" }, { "close_panel_cn", "关闭面板" }, { "close_panel_en", "Close Panel" }, { "seconds_cn", "秒" }, { "seconds_en", "s" } }; private string GetText(string key) { string text = (isEnglish ? "_en" : "_cn"); return texts.ContainsKey(key + text) ? texts[key + text] : key; } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(Plugin.ConfigGUI_Hotkey.Value)) { showGUI = !showGUI; } } private void OnGUI() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_002f: 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) if (showGUI) { windowRect = GUI.Window(0, windowRect, new WindowFunction(ConfigWindow), GetText("window_title")); } } private void ConfigWindow(int windowID) { //IL_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("中文", isEnglish ? GUI.skin.button : GUI.skin.box, Array.Empty<GUILayoutOption>())) { isEnglish = false; } if (GUILayout.Button("ENGLISH", isEnglish ? GUI.skin.box : GUI.skin.button, Array.Empty<GUILayoutOption>())) { isEnglish = true; } GUILayout.EndHorizontal(); GUILayout.Space(5f); scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("display_settings"), GUI.skin.box, Array.Empty<GUILayoutOption>()); Plugin.ShowEnemyHealthBar.Value = GUILayout.Toggle(Plugin.ShowEnemyHealthBar.Value, GetText("show_enemy_healthbar"), Array.Empty<GUILayoutOption>()); Plugin.ShowBossHealthBar.Value = GUILayout.Toggle(Plugin.ShowBossHealthBar.Value, GetText("show_boss_healthbar"), Array.Empty<GUILayoutOption>()); Plugin.ShowDamageText.Value = GUILayout.Toggle(Plugin.ShowDamageText.Value, GetText("show_damage_text"), Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("damage_text_use_sign_label"), Array.Empty<GUILayoutOption>()); Plugin.DamageTextUseSign.Value = GUILayout.Toggle(Plugin.DamageTextUseSign.Value, GetText("damage_text_use_sign"), Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label(GetText("damage_text_settings"), GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}{2}", GetText("damage_text_duration"), Plugin.DamageTextDuration.Value, GetText("seconds")), Array.Empty<GUILayoutOption>()); Plugin.DamageTextDuration.Value = GUILayout.HorizontalSlider(Plugin.DamageTextDuration.Value, 0.5f, 5f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1}", GetText("damage_text_fontsize"), Plugin.DamageTextFontSize.Value), Array.Empty<GUILayoutOption>()); Plugin.DamageTextFontSize.Value = (int)GUILayout.HorizontalSlider((float)Plugin.DamageTextFontSize.Value, 10f, 100f, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("damage_text_color"), Array.Empty<GUILayoutOption>()); Plugin.DamageTextColor.Value = GUILayout.TextField(Plugin.DamageTextColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label(GetText("healthbar_settings"), GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("healthbar_fill_color"), Array.Empty<GUILayoutOption>()); Plugin.HealthBarFillColor.Value = GUILayout.TextField(Plugin.HealthBarFillColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("healthbar_background_color"), Array.Empty<GUILayoutOption>()); Plugin.HealthBarBackgroundColor.Value = GUILayout.TextField(Plugin.HealthBarBackgroundColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F0}", GetText("healthbar_width"), Plugin.HealthBarWidth.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarWidth.Value = GUILayout.HorizontalSlider(Plugin.HealthBarWidth.Value, 50f, 500f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F0}", GetText("healthbar_height"), Plugin.HealthBarHeight.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarHeight.Value = GUILayout.HorizontalSlider(Plugin.HealthBarHeight.Value, 10f, 100f, Array.Empty<GUILayoutOption>()); Plugin.ShowHealthBarNumbers.Value = GUILayout.Toggle(Plugin.ShowHealthBarNumbers.Value, GetText("show_healthbar_numbers"), Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1}", GetText("healthbar_numbers_fontsize"), Plugin.HealthBarNumbersFontSize.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarNumbersFontSize.Value = (int)GUILayout.HorizontalSlider((float)Plugin.HealthBarNumbersFontSize.Value, 1f, 100f, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("healthbar_numbers_color"), Array.Empty<GUILayoutOption>()); Plugin.HealthBarNumbersColor.Value = GUILayout.TextField(Plugin.HealthBarNumbersColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}{2}", GetText("healthbar_hide_delay"), Plugin.HealthBarHideDelay.Value, GetText("seconds")), Array.Empty<GUILayoutOption>()); Plugin.HealthBarHideDelay.Value = GUILayout.HorizontalSlider(Plugin.HealthBarHideDelay.Value, 0.5f, 5f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F2}", GetText("healthbar_numbers_vertical_offset"), Plugin.HealthBarNumbersVerticalOffset.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarNumbersVerticalOffset.Value = GUILayout.HorizontalSlider(Plugin.HealthBarNumbersVerticalOffset.Value, -5f, 5f, Array.Empty<GUILayoutOption>()); Plugin.HealthBarNumbersInsideBar.Value = GUILayout.Toggle(Plugin.HealthBarNumbersInsideBar.Value, GetText("healthbar_numbers_inside_bar"), Array.Empty<GUILayoutOption>()); Plugin.HealthBarNumbersAutoWhiteOnLowHealth.Value = GUILayout.Toggle(Plugin.HealthBarNumbersAutoWhiteOnLowHealth.Value, GetText("healthbar_numbers_auto_white"), Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("healthbar_fill_margin_top"), Plugin.HealthBarFillMarginTop.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarFillMarginTop.Value = GUILayout.HorizontalSlider(Plugin.HealthBarFillMarginTop.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("healthbar_fill_margin_bottom"), Plugin.HealthBarFillMarginBottom.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarFillMarginBottom.Value = GUILayout.HorizontalSlider(Plugin.HealthBarFillMarginBottom.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("healthbar_shape"), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Toggle(Plugin.HealthBarShape.Value == 1, GetText("shape_rectangle"), Array.Empty<GUILayoutOption>())) { Plugin.HealthBarShape.Value = 1; } if (GUILayout.Toggle(Plugin.HealthBarShape.Value == 2, GetText("shape_rounded"), Array.Empty<GUILayoutOption>())) { Plugin.HealthBarShape.Value = 2; } GUILayout.EndHorizontal(); if (Plugin.HealthBarShape.Value == 2) { GUILayout.Label(string.Format("{0}: {1}", GetText("corner_radius"), Plugin.HealthBarCornerRadius.Value), Array.Empty<GUILayoutOption>()); Plugin.HealthBarCornerRadius.Value = (int)GUILayout.HorizontalSlider((float)Plugin.HealthBarCornerRadius.Value, 5f, 50f, Array.Empty<GUILayoutOption>()); } GUILayout.Space(10f); GUILayout.Label(GetText("boss_settings"), GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1}", GetText("boss_health_threshold"), Plugin.BossHealthThreshold.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthThreshold.Value = (int)GUILayout.HorizontalSlider((float)Plugin.BossHealthThreshold.Value, 50f, 1000f, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("boss_healthbar_fill_color"), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarFillColor.Value = GUILayout.TextField(Plugin.BossHealthBarFillColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("boss_healthbar_background_color"), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarBackgroundColor.Value = GUILayout.TextField(Plugin.BossHealthBarBackgroundColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F0}", GetText("boss_healthbar_width"), Plugin.BossHealthBarWidth.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarWidth.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarWidth.Value, 500f, 1200f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F0}", GetText("boss_healthbar_height"), Plugin.BossHealthBarHeight.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarHeight.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarHeight.Value, 10f, 50f, Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarBottomPosition.Value = GUILayout.Toggle(Plugin.BossHealthBarBottomPosition.Value, GetText("boss_healthbar_bottom_position"), Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("boss_healthbar_name_color"), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarNameColor.Value = GUILayout.TextField(Plugin.BossHealthBarNameColor.Value, Array.Empty<GUILayoutOption>()); Plugin.ShowBossHealthBarNumbers.Value = GUILayout.Toggle(Plugin.ShowBossHealthBarNumbers.Value, GetText("show_boss_healthbar_numbers"), Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("boss_healthbar_numbers_color"), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarNumbersColor.Value = GUILayout.TextField(Plugin.BossHealthBarNumbersColor.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("boss_healthbar_fill_margin_top"), Plugin.BossHealthBarFillMarginTop.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarFillMarginTop.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarFillMarginTop.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("boss_healthbar_fill_margin_bottom"), Plugin.BossHealthBarFillMarginBottom.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarFillMarginBottom.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarFillMarginBottom.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("boss_healthbar_fill_margin_left"), Plugin.BossHealthBarFillMarginLeft.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarFillMarginLeft.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarFillMarginLeft.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.Format("{0}: {1:F1}", GetText("boss_healthbar_fill_margin_right"), Plugin.BossHealthBarFillMarginRight.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarFillMarginRight.Value = GUILayout.HorizontalSlider(Plugin.BossHealthBarFillMarginRight.Value, 0f, 10f, Array.Empty<GUILayoutOption>()); GUILayout.Label(GetText("boss_healthbar_shape"), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Toggle(Plugin.BossHealthBarShape.Value == 1, GetText("shape_rectangle"), Array.Empty<GUILayoutOption>())) { Plugin.BossHealthBarShape.Value = 1; } if (GUILayout.Toggle(Plugin.BossHealthBarShape.Value == 2, GetText("shape_rounded"), Array.Empty<GUILayoutOption>())) { Plugin.BossHealthBarShape.Value = 2; } GUILayout.EndHorizontal(); if (Plugin.BossHealthBarShape.Value == 2) { GUILayout.Label(string.Format("{0}: {1}", GetText("boss_corner_radius"), Plugin.BossHealthBarCornerRadius.Value), Array.Empty<GUILayoutOption>()); Plugin.BossHealthBarCornerRadius.Value = (int)GUILayout.HorizontalSlider((float)Plugin.BossHealthBarCornerRadius.Value, 5f, 50f, Array.Empty<GUILayoutOption>()); } GUILayout.Space(10f); GUILayout.Label(GetText("custom_texture_settings"), GUI.skin.box, Array.Empty<GUILayoutOption>()); Plugin.UseCustomTextures.Value = GUILayout.Toggle(Plugin.UseCustomTextures.Value, GetText("use_custom_textures"), Array.Empty<GUILayoutOption>()); if (Plugin.UseCustomTextures.Value) { GUILayout.Label(GetText("custom_texture_scale_mode"), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Toggle(Plugin.CustomTextureScaleMode.Value == 1, GetText("scale_mode_stretch"), Array.Empty<GUILayoutOption>())) { Plugin.CustomTextureScaleMode.Value = 1; } if (GUILayout.Toggle(Plugin.CustomTextureScaleMode.Value == 2, GetText("scale_mode_aspect"), Array.Empty<GUILayoutOption>())) { Plugin.CustomTextureScaleMode.Value = 2; } GUILayout.EndHorizontal(); if (GUILayout.Button(GetText("reload_textures"), Array.Empty<GUILayoutOption>())) { CustomTextureManager.ReloadTextures(); RecreateAllHealthBars(); } GUILayout.Label(GetText("texture_path_info"), GUI.skin.textArea, Array.Empty<GUILayoutOption>()); } GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(GetText("save_config"), Array.Empty<GUILayoutOption>())) { ((BaseUnityPlugin)Plugin.Instance).Config.Save(); if (Plugin.HealthBarNumbersInsideBar.Value) { Plugin.HealthBarNumbersVerticalOffset.Value = -0.03f; } RecreateAllHealthBars(); } if (GUILayout.Button(GetText("reset_defaults"), Array.Empty<GUILayoutOption>())) { ResetToDefaults(); } GUILayout.EndHorizontal(); if (GUILayout.Button(GetText("close_panel"), Array.Empty<GUILayoutOption>())) { showGUI = false; } GUI.DragWindow(); } private void RecreateAllHealthBars() { try { if ((Object)(object)DamageTextManager.Instance != (Object)null) { DamageTextManager.Instance.ClearAllDamageTexts(); } BossHealthBar[] array = Object.FindObjectsByType<BossHealthBar>((FindObjectsSortMode)0); BossHealthBar[] array2 = array; foreach (BossHealthBar bossHealthBar in array2) { if ((Object)(object)bossHealthBar != (Object)null) { bossHealthBar.RecreateHealthBar(); } } EnemyHealthBar[] array3 = Object.FindObjectsByType<EnemyHealthBar>((FindObjectsSortMode)0); EnemyHealthBar[] array4 = array3; foreach (EnemyHealthBar enemyHealthBar in array4) { if ((Object)(object)enemyHealthBar != (Object)null) { enemyHealthBar.RecreateHealthBar(); } } } catch (Exception ex) { Plugin.logger.LogError((object)("重新创建血条时发生错误: " + ex.Message)); } } private void ResetToDefaults() { try { Plugin.ShowEnemyHealthBar.Value = true; Plugin.ShowBossHealthBar.Value = true; Plugin.ShowDamageText.Value = true; Plugin.ConfigGUI_Hotkey.Value = (KeyCode)278; Plugin.DamageTextDuration.Value = 2f; Plugin.DamageTextFontSize.Value = 55; Plugin.DamageTextColor.Value = "#DC143CFF"; Plugin.DamageTextUseSign.Value = true; Plugin.HealthBarFillColor.Value = "#beb8b8ff"; Plugin.HealthBarWidth.Value = 135f; Plugin.HealthBarHeight.Value = 25f; Plugin.ShowHealthBarNumbers.Value = true; Plugin.HealthBarNumbersFontSize.Value = 32; Plugin.HealthBarNumbersColor.Value = "#0e0404ff"; Plugin.HealthBarHideDelay.Value = 1.5f; Plugin.HealthBarNumbersVerticalOffset.Value = 0.3f; Plugin.HealthBarNumbersInsideBar.Value = false; Plugin.HealthBarNumbersAutoWhiteOnLowHealth.Value = true; Plugin.HealthBarFillMarginTop.Value = 2f; Plugin.HealthBarFillMarginBottom.Value = 2f; Plugin.HealthBarBackgroundColor.Value = "#00000085"; Plugin.BossHealthThreshold.Value = 105; Plugin.BossHealthBarFillColor.Value = "#beb8b8ff"; Plugin.BossHealthBarBackgroundColor.Value = "#000000ff"; Plugin.BossHealthBarWidth.Value = 900f; Plugin.BossHealthBarHeight.Value = 25f; Plugin.BossHealthBarBottomPosition.Value = true; Plugin.BossHealthBarNameColor.Value = "#0e0404ff"; Plugin.ShowBossHealthBarNumbers.Value = true; Plugin.BossMaxHealth.Value = 3000f; Plugin.BossHealthBarNumbersColor.Value = "#0e0404ff"; Plugin.BossHealthBarFillMarginTop.Value = 2f; Plugin.BossHealthBarFillMarginBottom.Value = 2f; Plugin.BossHealthBarFillMarginLeft.Value = 2f; Plugin.BossHealthBarFillMarginRight.Value = 2f; Plugin.HealthBarShape.Value = 1; Plugin.BossHealthBarShape.Value = 1; Plugin.HealthBarCornerRadius.Value = 30; Plugin.BossHealthBarCornerRadius.Value = 30; Plugin.UseCustomTextures.Value = false; Plugin.CustomTextureScaleMode.Value = 1; if (Plugin.HealthBarNumbersInsideBar.Value) { Plugin.HealthBarNumbersVerticalOffset.Value = -0.03f; } ((BaseUnityPlugin)Plugin.Instance).Config.Save(); RecreateAllHealthBars(); } catch (Exception ex) { Plugin.logger.LogError((object)("恢复默认配置时发生错误: " + ex.Message)); } } } public class EnemyHealthBar : MonoBehaviour { public Color healthBarColor = Color.red; public Color healthBarBackgroundColor = Color.black; public Color healthBarNumbersColor = Color.white; public Vector2 healthBarSize = new Vector2(135f, 25f); public Vector2 healthBarOffset = new Vector2(0f, 2f); private float maxDisplayDistance = 50f; private HeroController player; private HealthManager healthManager; private Canvas worldCanvas; private GameObject healthBarUI; private Slider healthBarSlider; private Text healthNumbersText; private GameObject healthNumbersCanvas; private int maxHpEverReached; private int currentHp; private bool maxHpRecorded = false; private bool healthBarActivated = false; private float lastHealthChangeTime; private int lastRecordedHp; private Collider2D cachedCollider2D; private static Dictionary<string, Texture2D> textureCache = new Dictionary<string, Texture2D>(); private static bool allowCacheClear = false; private void Start() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0059: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarFillColor.Value, ref val)) { healthBarColor = val; } Color val2 = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarBackgroundColor.Value, ref val2)) { healthBarBackgroundColor = val2; } Color val3 = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarNumbersColor.Value, ref val3)) { healthBarNumbersColor = val3; } player = Object.FindFirstObjectByType<HeroController>(); healthManager = ((Component)this).GetComponent<HealthManager>(); if ((Object)(object)healthManager == (Object)null) { Plugin.logger.LogError((object)("EnemyHealthBar: 未找到HealthManager组件在 " + ((Object)((Component)this).gameObject).name)); Object.Destroy((Object)(object)this); return; } currentHp = healthManager.hp; maxHpEverReached = currentHp; lastRecordedHp = currentHp; lastHealthChangeTime = Time.time; cachedCollider2D = ((Component)this).GetComponent<Collider2D>(); CreateHealthBarUI(); if ((Object)(object)healthBarUI != (Object)null) { healthBarUI.SetActive(false); } if (Plugin.ShowHealthBarNumbers.Value) { CreateHealthNumbersText(); if ((Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(false); } } } private void CreateHealthNumbersText() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)healthNumbersCanvas != (Object)null)) { healthNumbersCanvas = new GameObject("HealthNumbersCanvas"); Canvas val = healthNumbersCanvas.AddComponent<Canvas>(); val.renderMode = (RenderMode)2; val.sortingOrder = 101; int value = Plugin.HealthBarNumbersFontSize.Value; float num = Mathf.Max(100, value * 6); float num2 = Mathf.Max(30f, (float)value * 1.5f); RectTransform component = healthNumbersCanvas.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(num, num2); ((Transform)component).localScale = Vector3.one * 0.01f; Vector3 position = ((Component)this).transform.position + new Vector3(healthBarOffset.x, healthBarOffset.y + 0.3f, 0f); healthNumbersCanvas.transform.position = position; healthNumbersCanvas.transform.rotation = Quaternion.identity; GameObject val2 = new GameObject("HealthNumbers"); val2.transform.SetParent(healthNumbersCanvas.transform, false); healthNumbersText = val2.AddComponent<Text>(); if ((Object)(object)DamageTextManager.SharedFont != (Object)null) { healthNumbersText.font = DamageTextManager.SharedFont; } else { healthNumbersText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } healthNumbersText.fontSize = value; ((Graphic)healthNumbersText).color = healthBarNumbersColor; healthNumbersText.alignment = (TextAnchor)4; healthNumbersText.fontStyle = (FontStyle)1; healthNumbersText.text = $"{currentHp}/{maxHpEverReached}"; RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; ((Object)healthNumbersCanvas).name = "HealthNumbersCanvas_" + ((Object)((Component)this).gameObject).GetInstanceID(); } } catch (Exception ex) { Plugin.logger.LogError((object)("EnemyHealthBar: 创建血量数值文本失败: " + ex.Message)); healthNumbersText = null; } } private void Update() { //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthManager == (Object)null || (Object)(object)player == (Object)null) { HideHealthBar(); return; } if (healthManager.hp <= 0) { HideHealthBar(); return; } if (healthBarActivated && (Object)(object)cachedCollider2D != (Object)null && !((Behaviour)cachedCollider2D).enabled) { HideHealthBar(); return; } if (currentHp != healthManager.hp) { int num = currentHp; currentHp = healthManager.hp; lastHealthChangeTime = Time.time; lastRecordedHp = currentHp; if (num <= 0 && currentHp > 0) { if (healthBarActivated && (Object)(object)healthBarUI != (Object)null) { healthBarUI.SetActive(true); } if (healthBarActivated && Plugin.ShowHealthBarNumbers.Value && (Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(true); } } if (currentHp > num && (float)(currentHp - num) > (float)maxHpEverReached * 0.5f) { if ((float)currentHp <= Plugin.BossMaxHealth.Value) { maxHpEverReached = currentHp; } } else if (currentHp > maxHpEverReached && (float)currentHp <= Plugin.BossMaxHealth.Value) { maxHpEverReached = currentHp; } if (!healthBarActivated) { healthBarActivated = true; if ((Object)(object)healthBarUI != (Object)null) { healthBarUI.SetActive(true); } if (Plugin.ShowHealthBarNumbers.Value && (Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(true); } } UpdateHealthBarDisplay(); } if (healthBarActivated && (Object)(object)healthBarUI != (Object)null && currentHp > 0) { float num2 = Time.time - lastHealthChangeTime; if (num2 >= Plugin.HealthBarHideDelay.Value) { healthBarUI.SetActive(false); if ((Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(false); } healthBarActivated = false; return; } } if (!healthBarActivated || !((Object)(object)healthBarUI != (Object)null)) { return; } Vector3 position = ((Component)this).transform.position + new Vector3(healthBarOffset.x, healthBarOffset.y, 0f); healthBarUI.transform.position = position; healthBarUI.transform.rotation = Quaternion.identity; if ((Object)(object)healthNumbersText != (Object)null && (Object)(object)healthNumbersCanvas != (Object)null) { float value = Plugin.HealthBarNumbersVerticalOffset.Value; Vector3 position2 = ((Component)this).transform.position + new Vector3(healthBarOffset.x, healthBarOffset.y + value, 0f); healthNumbersCanvas.transform.position = position2; healthNumbersCanvas.transform.rotation = Quaternion.identity; } Vector3 val = ((Component)this).transform.position - player.transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= maxDisplayDistance * maxDisplayDistance && currentHp > 0) { if (!healthBarUI.activeSelf) { healthBarUI.SetActive(true); } if ((Object)(object)healthNumbersText != (Object)null && (Object)(object)healthNumbersCanvas != (Object)null && Plugin.ShowHealthBarNumbers.Value && !healthNumbersCanvas.activeSelf) { healthNumbersCanvas.SetActive(true); } } else { if (healthBarUI.activeSelf) { healthBarUI.SetActive(false); } if ((Object)(object)healthNumbersText != (Object)null && (Object)(object)healthNumbersCanvas != (Object)null && healthNumbersCanvas.activeSelf) { healthNumbersCanvas.SetActive(false); } } } private void OnDisable() { try { if ((Object)(object)healthBarUI != (Object)null) { HideHealthBar(); } } catch (Exception ex) { Plugin.logger.LogError((object)("[EnemyHealthBar] Error in OnDisable: " + ex.Message)); } } private void CreateHealthBarUI() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthBarUI != (Object)null) { return; } try { healthBarUI = new GameObject("HealthBarCanvas"); worldCanvas = healthBarUI.AddComponent<Canvas>(); worldCanvas.renderMode = (RenderMode)2; worldCanvas.sortingOrder = 100; healthBarUI.AddComponent<GraphicRaycaster>(); RectTransform component = healthBarUI.GetComponent<RectTransform>(); Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(Plugin.HealthBarWidth.Value, Plugin.HealthBarHeight.Value); component.sizeDelta = sizeDelta; ((Transform)component).localScale = Vector3.one * 0.01f; Vector3 position = ((Component)this).transform.position + new Vector3(healthBarOffset.x, healthBarOffset.y, 0f); healthBarUI.transform.position = position; healthBarUI.transform.rotation = Quaternion.identity; GameObject val = new GameObject("Background"); val.transform.SetParent(healthBarUI.transform, false); val.AddComponent<CanvasRenderer>(); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = healthBarBackgroundColor; RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; GameObject val3 = new GameObject("HealthBarSlider"); val3.transform.SetParent(val.transform, false); healthBarSlider = val3.AddComponent<Slider>(); healthBarSlider.minValue = 0f; healthBarSlider.maxValue = 1f; healthBarSlider.value = 1f; ((Selectable)healthBarSlider).interactable = false; RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; ((Selectable)healthBarSlider).targetGraphic = (Graphic)(object)val2; GameObject val4 = new GameObject("Fill Area"); RectTransform val5 = val4.AddComponent<RectTransform>(); val4.transform.SetParent(val3.transform, false); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = new Vector2(0f, Plugin.HealthBarFillMarginBottom.Value); val5.offsetMax = new Vector2(0f, 0f - Plugin.HealthBarFillMarginTop.Value); GameObject val6 = new GameObject("Fill"); RectTransform val7 = val6.AddComponent<RectTransform>(); val6.transform.SetParent(val4.transform, false); val6.AddComponent<CanvasRenderer>(); Image val8 = val6.AddComponent<Image>(); ((Graphic)val8).color = healthBarColor; val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; healthBarSlider.fillRect = val7; ApplyHealthBarShape(val2, val8); if (Plugin.ShowHealthBarNumbers.Value) { CreateHealthNumbersText(); } UpdateHealthBarDisplay(); } catch (Exception ex) { Plugin.logger.LogError((object)("EnemyHealthBar: 创建血条UI失败: " + ex.Message)); if ((Object)(object)healthBarUI != (Object)null) { Object.DestroyImmediate((Object)(object)healthBarUI); healthBarUI = null; worldCanvas = null; healthBarSlider = null; } } } private void UpdateHealthBarDisplay() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthBarSlider == (Object)null) { return; } float num = ((maxHpEverReached > 0) ? ((float)currentHp / (float)maxHpEverReached) : 0f); healthBarSlider.value = num; if ((Object)(object)healthBarSlider.fillRect != (Object)null) { Image component = ((Component)healthBarSlider.fillRect).GetComponent<Image>(); if ((Object)(object)component != (Object)null && (int)component.type == 3) { component.fillAmount = num; } } if ((Object)(object)healthNumbersText != (Object)null && Plugin.ShowHealthBarNumbers.Value) { healthNumbersText.text = $"{currentHp}/{maxHpEverReached}"; Color color = default(Color); if (Plugin.HealthBarNumbersAutoWhiteOnLowHealth.Value) { if (num < 0.49f) { ((Graphic)healthNumbersText).color = Color.white; } else { ((Graphic)healthNumbersText).color = healthBarNumbersColor; } } else if (ColorUtility.TryParseHtmlString(Plugin.HealthBarNumbersColor.Value, ref color)) { ((Graphic)healthNumbersText).color = color; } else { ((Graphic)healthNumbersText).color = Color.white; } } Canvas.ForceUpdateCanvases(); } public void RecordMaxHealth(int hp) { if (!((float)hp > Plugin.BossMaxHealth.Value)) { if (!maxHpRecorded || hp > maxHpEverReached) { maxHpEverReached = hp; maxHpRecorded = true; } else if ((float)currentHp < (float)maxHpEverReached * 0.3f && (float)hp > (float)maxHpEverReached * 0.8f) { maxHpEverReached = hp; } } } public void OnDamageTaken() { lastHealthChangeTime = Time.time; lastRecordedHp = healthManager.hp; if (!healthBarActivated) { healthBarActivated = true; } } private void HideHealthBar() { if ((Object)(object)healthBarUI != (Object)null) { healthBarUI.SetActive(false); } if ((Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(false); } } private void DestroyHealthBar() { if ((Object)(object)healthBarUI != (Object)null) { Object.Destroy((Object)(object)healthBarUI); healthBarUI = null; worldCanvas = null; healthBarSlider = null; } if ((Object)(object)healthNumbersCanvas != (Object)null) { Object.Destroy((Object)(object)healthNumbersCanvas); healthNumbersCanvas = null; healthNumbersText = null; } healthBarActivated = false; } public void RecreateHealthBar() { //IL_0062: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) bool flag = healthBarActivated; bool active = (Object)(object)healthBarUI != (Object)null && healthBarUI.activeSelf; bool active2 = (Object)(object)healthNumbersCanvas != (Object)null && healthNumbersCanvas.activeSelf; DestroyHealthBar(); Color val = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarFillColor.Value, ref val)) { healthBarColor = val; } Color val2 = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarBackgroundColor.Value, ref val2)) { healthBarBackgroundColor = val2; } Color val3 = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.HealthBarNumbersColor.Value, ref val3)) { healthBarNumbersColor = val3; } if (!((Object)(object)healthManager != (Object)null) || healthManager.hp <= 0) { return; } CreateHealthBarUI(); if ((Object)(object)healthBarUI != (Object)null) { healthBarUI.SetActive(active); } if (Plugin.ShowHealthBarNumbers.Value) { CreateHealthNumbersText(); if ((Object)(object)healthNumbersCanvas != (Object)null) { healthNumbersCanvas.SetActive(active2); } } healthBarActivated = flag; } private void OnDestroy() { DestroyHealthBar(); } private void ApplyHealthBarShape(Image backgroundImage, Image fillImage) { switch (Plugin.HealthBarShape.Value) { case 1: ApplyDefaultShape(backgroundImage, fillImage); break; case 2: ApplyRoundedShape(backgroundImage, fillImage); break; default: ApplyDefaultShape(backgroundImage, fillImage); break; } } private void ApplyDefaultShape(Image backgroundImage, Image fillImage) { //IL_0027: 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_007b: 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_0093: Unknown result type (might be due to invalid IL or missing references) try { backgroundImage.sprite = null; backgroundImage.type = (Type)0; Sprite enemyHealthBarTexture = CustomTextureManager.GetEnemyHealthBarTexture(); if ((Object)(object)enemyHealthBarTexture != (Object)null) { CustomTextureManager.ApplyCustomTexture(fillImage, enemyHealthBarTexture, healthBarSize); } else { fillImage.sprite = null; fillImage.type = (Type)0; } RectTransform component = ((Component)fillImage).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; } } catch (Exception ex) { Plugin.logger.LogError((object)("EnemyHealthBar: 应用默认形状失败: " + ex.Message)); } } private void ApplyRoundedShape(Image backgroundImage, Image fillImage) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) try { Sprite enemyHealthBarTexture = CustomTextureManager.GetEnemyHealthBarTexture(); if ((Object)(object)enemyHealthBarTexture != (Object)null) { int num = Mathf.RoundToInt(healthBarSize.x); int num2 = Mathf.RoundToInt(healthBarSize.y); Texture2D val = CreateRoundedTexture(num, num2, Plugin.HealthBarCornerRadius.Value); Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f)); backgroundImage.sprite = sprite; backgroundImage.type = (Type)0; Mask val2 = ((Component)backgroundImage).GetComponent<Mask>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)backgroundImage).gameObject.AddComponent<Mask>(); } val2.showMaskGraphic = true; CustomTextureManager.ApplyCustomTexture(fillImage, enemyHealthBarTexture, healthBarSize); } else { int num3 = Mathf.RoundToInt(healthBarSize.x); int num4 = Mathf.RoundToInt(healthBarSize.y); Texture2D val3 = CreateRoundedTexture(num3, num4, Plugin.HealthBarCornerRadius.Value); Sprite sprite2 = Sprite.Create(val3, new Rect(0f, 0f, (float)num3, (float)num4), new Vector2(0.5f, 0.5f)); Texture2D val4 = CreatePureFillTexture(num3, num4, Plugin.HealthBarCornerRadius.Value); Sprite sprite3 = Sprite.Create(val4, new Rect(0f, 0f, (float)num3, (float)num4), new Vector2(0.5f, 0.5f)); backgroundImage.sprite = sprite2; backgroundImage.type = (Type)0; Mask component = ((Component)backgroundImage).GetComponent<Mask>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } fillImage.sprite = sprite3; fillImage.type = (Type)3; fillImage.fillMethod = (FillMethod)0; } RectTransform component2 = ((Component)fillImage).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; } } catch (Exception ex) { Plugin.logger.LogError((object)("EnemyHealthBar: 应用圆角形状失败: " + ex.Message)); } } private Texture2D CreatePureFillTexture(int width, int height, int cornerRadius) { string text = $"fill_{width}_{height}_{cornerRadius}"; if (textureCache.ContainsKey(text) && (Object)(object)textureCache[text] != (Object)null) { return textureCache[text]; } return CreateSimpleFillTexture(width, height, cornerRadius, text); } private Texture2D CreateSimpleFillTexture(int width, int height, int cornerRadius, string cacheKey) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[width * height]; float num = cornerRadius; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = true; if ((j < cornerRadius && i < cornerRadius) || (j >= width - cornerRadius && i < cornerRadius) || (j < cornerRadius && i >= height - cornerRadius) || (j >= width - cornerRadius && i >= height - cornerRadius)) { float num2; float num3; if (j < cornerRadius && i < cornerRadius) { num2 = cornerRadius; num3 = cornerRadius; } else if (j >= width - cornerRadius && i < cornerRadius) { num2 = width - cornerRadius; num3 = cornerRadius; } else if (j < cornerRadius && i >= height - cornerRadius) { num2 = cornerRadius; num3 = height - cornerRadius; } else { num2 = width - cornerRadius; num3 = height - cornerRadius; } float num4 = Mathf.Sqrt(((float)j - num2) * ((float)j - num2) + ((float)i - num3) * ((float)i - num3)); if (num4 > num) { flag = false; } } if (flag) { array[i * width + j] = Color.white; } else { array[i * width + j] = Color.clear; } } } val.SetPixels(array); val.Apply(); textureCache[cacheKey] = val; return val; } public static void ClearTextureCache() { if (!allowCacheClear) { Plugin.logger.LogWarning((object)"[EnemyHealthBar] 尝试清理纹理缓存被阻止,避免影响其他血条显示"); } else { if (textureCache == null) { return; } foreach (Texture2D value in textureCache.Values) { if ((Object)(object)value != (Object)null) { Object.DestroyImmediate((Object)(object)value); } } textureCache.Clear(); Plugin.logger.LogInfo((object)"[EnemyHealthBar] 纹理缓存已清理"); } } public static void AllowCacheClear() { allowCacheClear = true; } private Texture2D CreateRoundedTexture(int width, int height, int cornerRadius) { string text = $"rounded_{width}_{height}_{cornerRadius}"; if (textureCache != null && textureCache.ContainsKey(text) && (Object)(object)textureCache[text] != (Object)null) { return textureCache[text]; } if (textureCache == null) { textureCache = new Dictionary<string, Texture2D>(); Plugin.logger.LogWarning((object)"[EnemyHealthBar] 纹理缓存被意外清理,已重新初始化"); } return CreateSimpleRoundedTexture(width, height, cornerRadius, text); } private Texture2D CreateSimpleRoundedTexture(int width, int height, int cornerRadius, string cacheKey) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[width * height]; float num = cornerRadius; int num2 = 2; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = true; bool flag2 = false; if ((j < cornerRadius && i < cornerRadius) || (j >= width - cornerRadius && i < cornerRadius) || (j < cornerRadius && i >= height - cornerRadius) || (j >= width - cornerRadius && i >= height - cornerRadius)) { float num3; float num4; if (j < cornerRadius && i < cornerRadius) { num3 = cornerRadius; num4 = cornerRadius; } else if (j >= width - cornerRadius && i < cornerRadius) { num3 = width - cornerRadius; num4 = cornerRadius; } else if (j < cornerRadius && i >= height - cornerRadius) { num3 = cornerRadius; num4 = height - cornerRadius; } else { num3 = width - cornerRadius; num4 = height - cornerRadius; } float num5 = Mathf.Sqrt(((float)j - num3) * ((float)j - num3) + ((float)i - num4) * ((float)i - num4)); if (num5 > num) { flag = false; } else if (num5 > num - (float)num2) { flag2 = true; } } else if (j < num2 || j >= width - num2 || i < num2 || i >= height - num2) { flag2 = true; } if (!flag) { array[i * width + j] = Color.clear; } else if (flag2) { array[i * width + j] = Color.black; } else { array[i * width + j] = Color.white; } } } val.SetPixels(array); val.Apply(); textureCache[cacheKey] = val; return val; } } public class BossHealthBar : MonoBehaviour { private HealthManager healthManager; private HeroController player; private GameObject bossHealthBarUI; private Slider healthBarSlider; private Text bossNameText; private Text healthNumbersText; private Canvas screenCanvas; private RectTransform backgroundRect; private int currentHp; private int maxHpEverReached; private int lastRecordedHp; private int previousHp; private float lastHealthChangeTime; private bool healthBarActivated = false; private Color bossHealthBarColor = Color.red; private Color bossBackgroundColor = new Color(0f, 0f, 0f, 0.5f); private Vector2 bossHealthBarSize; public float Debug_triangleWidth = 5f; private void Start() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0036: 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) Color val = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.BossHealthBarFillColor.Value, ref val)) { bossHealthBarColor = val; } Color val2 = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.BossHealthBarBackgroundColor.Value, ref val2)) { bossBackgroundColor = val2; } bossHealthBarSize = new Vector2(Plugin.BossHealthBarWidth.Value, Plugin.BossHealthBarHeight.Value); player = Object.FindFirstObjectByType<HeroController>(); healthManager = ((Component)this).GetComponent<HealthManager>(); if ((Object)(object)healthManager == (Object)null) { Plugin.logger.LogWarning((object)("BossHealthBar: 未找到HealthManager组件在 " + ((Object)((Component)this).gameObject).name)); Object.Destroy((Object)(object)this); return; } currentHp = healthManager.hp; maxHpEverReached = currentHp; lastRecordedHp = currentHp; lastHealthChangeTime = Time.time; previousHp = currentHp; CreateBossHealthBarUI(); if ((Object)(object)bossHealthBarUI != (Object)null) { bossHealthBarUI.SetActive(false); } } private void OnDisable() { try { if ((Object)(object)bossHealthBarUI != (Object)null) { HideBossHealthBar(); } } catch (Exception ex) { Plugin.logger.LogError((object)("[BossHealthBar] Error in OnDisable: " + ex.Message)); } } private void Update() { //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthManager == (Object)null) { HideBossHealthBar(); } else { if ((Object)(object)player == (Object)null) { return; } if (currentHp != healthManager.hp) { int num = currentHp; currentHp = healthManager.hp; lastHealthChangeTime = Time.time; lastRecordedHp = currentHp; if (num <= 0 && currentHp > 0 && healthBarActivated && (Object)(object)bossHealthBarUI != (Object)null) { bossHealthBarUI.SetActive(true); } if (currentHp > num && (float)(currentHp - num) > (float)maxHpEverReached * 0.5f) { if ((float)currentHp <= Plugin.BossMaxHealth.Value) { maxHpEverReached = currentHp; } } else if (currentHp > maxHpEverReached && (float)currentHp <= Plugin.BossMaxHealth.Value) { maxHpEverReached = currentHp; } UpdateBossHealthBarDisplay(); } if (!healthBarActivated && currentHp != previousHp && currentHp < previousHp) { healthBarActivated = true; if ((Object)(object)bossHealthBarUI != (Object)null) { bossHealthBarUI.SetActive(true); } } previousHp = currentHp; if (currentHp <= 0 || !healthBarActivated || !((Object)(object)bossHealthBarUI != (Object)null)) { return; } Vector3 val = ((Component)this).transform.position - player.transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= 400f) { if (!bossHealthBarUI.activeSelf) { bossHealthBarUI.SetActive(true); } } else if (bossHealthBarUI.activeSelf) { bossHealthBarUI.SetActive(false); } } } private void CreateBossHealthBarUI() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e0: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Expected O, but got Unknown //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: 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_04bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bossHealthBarUI != (Object)null) { return; } try { bossHealthBarUI = new GameObject("BossHealthBarCanvas"); screenCanvas = bossHealthBarUI.AddComponent<Canvas>(); screenCanvas.renderMode = (RenderMode)0; screenCanvas.sortingOrder = 200; CanvasScaler val = bossHealthBarUI.AddComponent<CanvasScaler>(); val.uiScaleMode = (ScaleMode)1; val.referenceResolution = new Vector2(1920f, 1080f); bossHealthBarUI.AddComponent<GraphicRaycaster>(); RectTransform component = bossHealthBarUI.GetComponent<RectTransform>(); component.sizeDelta = Vector2.zero; component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; GameObject val2 = new GameObject("BossHealthBarBackground"); val2.transform.SetParent(bossHealthBarUI.transform, false); Image val3 = val2.AddComponent<Image>(); if ((Object)(object)val3 == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法添加背景Image组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } ((Graphic)val3).color = bossBackgroundColor; backgroundRect = val2.GetComponent<RectTransform>(); if ((Object)(object)backgroundRect == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法获取背景的RectTransform组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } BossHealthBarManager.RegisterBossHealthBar(this); if (Plugin.BossHealthBarBottomPosition.Value) { backgroundRect.anchorMin = new Vector2(0.5f, 0f); backgroundRect.anchorMax = new Vector2(0.5f, 0f); } else { backgroundRect.anchorMin = new Vector2(0.5f, 1f); backgroundRect.anchorMax = new Vector2(0.5f, 1f); } float yOffsetForBossHealthBar = BossHealthBarManager.GetYOffsetForBossHealthBar(this); backgroundRect.anchoredPosition = new Vector2(0f, yOffsetForBossHealthBar); backgroundRect.sizeDelta = bossHealthBarSize; GameObject val4 = new GameObject("BossHealthBarSlider"); val4.transform.SetParent(val2.transform, false); healthBarSlider = val4.AddComponent<Slider>(); if ((Object)(object)healthBarSlider == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法添加Slider组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } healthBarSlider.minValue = 0f; healthBarSlider.maxValue = 1f; healthBarSlider.value = 1f; RectTransform component2 = val4.GetComponent<RectTransform>(); if ((Object)(object)component2 == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法获取Slider的RectTransform组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; GameObject val5 = new GameObject("FillArea"); val5.transform.SetParent(val4.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); if ((Object)(object)val6 == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法添加FillArea的RectTransform组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = new Vector2(Plugin.BossHealthBarFillMarginLeft.Value, Plugin.BossHealthBarFillMarginBottom.Value); val6.offsetMax = new Vector2(0f - Plugin.BossHealthBarFillMarginRight.Value, 0f - Plugin.BossHealthBarFillMarginTop.Value); GameObject val7 = new GameObject("Fill"); val7.transform.SetParent(val5.transform, false); RectTransform val8 = val7.AddComponent<RectTransform>(); if ((Object)(object)val8 == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法添加Fill的RectTransform组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } Image val9 = val7.AddComponent<Image>(); if ((Object)(object)val9 == (Object)null) { Plugin.logger.LogError((object)"BossHealthBar: 无法添加Fill的Image组件"); Object.Destroy((Object)(object)bossHealthBarUI); return; } ((Graphic)val9).color = bossHealthBarColor; val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.offsetMin = Vector2.zero; val8.offsetMax = Vector2.zero; healthBarSlider.fillRect = val8; ApplyHealthBarShape(val3, val9); CreateBossNameText(val2); if (Plugin.ShowBossHealthBarNumbers.Value) { CreateBossHealthNumbersText(val4); } UpdateBossHealthBarDisplay(); } catch (Exception ex) { Plugin.logger.LogError((object)("BossHealthBar: 创建BOSS血条UI失败: " + ex.Message)); if ((Object)(object)bossHealthBarUI != (Object)null) { Object.Destroy((Object)(object)bossHealthBarUI); bossHealthBarUI = null; } } } private void CreateBossNameText(GameObject parent) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)bossNameText != (Object)null) { return; } GameObject val = new GameObject("BossNameText"); val.transform.SetParent(((Component)screenCanvas).transform, false); bossNameText = val.AddComponent<Text>(); string text = ((Object)((Component)healthManager).gameObject).name; try { EnemyDeathEffects component = ((Component)healthManager).gameObject.GetComponent<EnemyDeathEffects>(); if ((Object)(object)component != (Object)null && (Object)(object)component.journalRecord != (Object)null) { LocalisedString displayName = component.journalRecord.displayName; if (!string.IsNullOrEmpty(LocalisedString.op_Implicit(displayName))) { text = LocalisedString.op_Implicit(displayName); } } if (text == ((Object)((Component)healthManager).gameObject).name) { string name = ((Object)((Component)healthManager).gameObject).name; int num = name.IndexOf('('); if (num >= 0) { text = name.Substring(0, num).Trim(); } } } catch { string name2 = ((Object)((Component)healthManager).gameObject).name; int num2 = name2.IndexOf('('); if (num2 >= 0) { text = name2.Substring(0, num2).Trim(); } } bossNameText.text = text; bossNameText.fontSize = 24; Color color = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.BossHealthBarNameColor.Value, ref color)) { ((Graphic)bossNameText).color = color; } else { ((Graphic)bossNameText).color = Color.white; } bossNameText.alignment = (TextAnchor)4; bossNameText.fontStyle = (FontStyle)1; if ((Object)(object)DamageTextManager.SharedFont != (Object)null) { bossNameText.font = DamageTextManager.SharedFont; } else { bossNameText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, Plugin.BossHealthBarBottomPosition.Value ? 0f : 1f); component2.anchorMax = new Vector2(0.5f, Plugin.BossHealthBarBottomPosition.Value ? 0f : 1f); float nameTextYOffsetForBossHealthBar = BossHealthBarManager.GetNameTextYOffsetForBossHealthBar(this); component2.anchoredPosition = new Vector2(0f, nameTextYOffsetForBossHealthBar); component2.sizeDelta = new Vector2(400f, 30f); } catch (Exception ex) { Plugin.logger.LogError((object)("BossHealthBar: 创建BOSS名称文本失败: " + ex.Message)); } } private void CreateBossHealthNumbersText(GameObject parent) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0086: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)healthNumbersText != (Object)null)) { GameObject val = new GameObject("BossHealthNumbersText"); val.transform.SetParent(((Component)screenCanvas).transform, false); healthNumbersText = val.AddComponent<Text>(); healthNumbersText.fontSize = 18; Color color = default(Color); if (ColorUtility.TryParseHtmlString(Plugin.BossHealthBarNumbersColor.Value, ref color)) { ((Graphic)healthNumbersText).color = color; } else { ((Graphic)healthNumbersText).color = Color.white; } healthNumbersText.alignment = (TextAnchor)4; healthNumbersText.fontStyle = (FontStyle)1; if ((Object)(object)DamageTextManager.SharedFont != (Object)null) { healthNumbersText.font = DamageTextManager.SharedFont; } else { healthNumbersText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, Plugin.BossHealthBarBottomPosition.Value ? 0f : 1f); component.anchorMax = new Vector2(0.5f, Plugin.BossHealthBarBottomPosition.Value ? 0f : 1f); float healthNumbersYOffsetForBossHealthBar = BossHealthBarManager.GetHealthNumbersYOffsetForBossHealthBar(this); component.anchoredPosition = new Vector2(0f, healthNumbersYOffsetForBossHealthBar); component.sizeDelta = new Vector2(200f, 20f); } } catch (Exception ex) { Plugin.logger.LogError((object)("BossHealthBar: 创建BOSS血量数值文本失败: " + ex.Message)); healthNumbersText = null; } } private void UpdateBossHealthBarDisplay() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Invalid comparison between Unknown and I4 //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthBarSlider == (Object)null) { return; } try { Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Plugin.BossHealthBarWidth.Value, Plugin.BossHealthBarHeight.Value); if (bossHealthBarSize != val) { bossHealthBarSize = val; if ((Object)(object)healthBarSlider != (Object)null) { RectTransform component = ((Component)healthBarSlider).GetComponent<RectTransform>(); if