Decompiled source of GameAdjustments v1.3.8
GameAdjustments/Core.dll
Decompiled a month 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using AdvancedConfigSystem; using BepInEx; using Core; using Core.Collider2DViewer; using Core.Components; using Core.Localization; using Core.PatchFunction.RandomSystemV2; using Core.UI; using Core.UI.CreativeInventory; using GameAdjustments.Components; using GlobalEnums; using GlobalSettings; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using InControl; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PimDeWitte.UnityMainThreadDispatcher; using TeamCherry.Localization; using TeamCherry.SharedUtils; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Core")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Core")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7460c7cb-08f9-41d4-8b32-544f743c4ff0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } internal class HealthBarSystem { public class HealthBarConfigManager { private static HealthBarConfigManager _instance; public const float DEFAULT_TEXT_TO_BAR_GAP = 8f; public const float DEFAULT_SMOOTH_ANIMATION_SPEED = 8f; public const float DAMAGE_FLASH_DURATION = 0.15f; public const float HEAL_FLASH_DURATION = 0.2f; public const float DEFAULT_HEALTH_BAR_HEIGHT = 36f; public const float DEFAULT_HEALTH_BAR_WIDTH = 200f; public const float DEFAULT_BORDER_THICKNESS = 3f; public const float DEFAULT_CORNER_RADIUS = 6f; public const float DEFAULT_INNER_PADDING = 1f; public const float DEFAULT_BOSS_HEALTH_BAR_WIDTH = 250f; public const float DEFAULT_BOSS_HEALTH_BAR_HEIGHT = 40f; public const int DEFAULT_MAX_DAMAGE_DISPLAYS = 9; public const float DEFAULT_DAMAGE_DISPLAY_DURATION = 2.5f; public const float DEFAULT_DAMAGE_FADE_OUT_DURATION = 1.5f; public const float DEFAULT_DAMAGE_DISPLAY_SPACING_Y = 40f; public const int DEFAULT_DAMAGE_TEXT_FONT_SIZE = 32; public const int DEFAULT_TEXT_SIZE = 20; public readonly Color32 BORDER_COLOR = new Color32((byte)179, (byte)179, (byte)204, (byte)191); public readonly Color32 BORDER_GLOW_COLOR = new Color32((byte)153, (byte)153, (byte)179, (byte)115); public readonly Color32 BACKGROUND_COLOR = new Color32((byte)26, (byte)26, (byte)26, (byte)217); public readonly Color32 HEALTH_HIGH_COLOR = new Color32((byte)204, (byte)41, (byte)41, (byte)242); public readonly Color32 HEALTH_MID_COLOR = new Color32((byte)204, (byte)41, (byte)41, (byte)242); public readonly Color32 HEALTH_LOW_COLOR = new Color32((byte)204, (byte)41, (byte)41, (byte)242); public readonly Color32 BOSS_HEALTH_HIGH_COLOR = new Color32((byte)191, (byte)31, (byte)31, (byte)242); public readonly Color32 BOSS_HEALTH_MID_COLOR = new Color32((byte)191, (byte)31, (byte)31, (byte)242); public readonly Color32 BOSS_HEALTH_LOW_COLOR = new Color32((byte)191, (byte)31, (byte)31, (byte)242); public readonly Color32 BOSS_BORDER_COLOR = new Color32((byte)212, (byte)56, (byte)56, (byte)230); private string _style; private float _width; private float _height; private float _bossWidth; private float _bossHeight; private float _borderThickness; private float _cornerRadius; private float _innerPadding; private float _textGap; private int _textSize; private int _maxDamageDisplays; private float _damageSpacingY; private float _damageDuration; private float _damageFadeOut; private int _damageFontSize; private float _smoothAnimSpeed; private float _jitterX; private float _jitterY; private float _posSmooth; private float _autoHideDelay; private bool _bossUniqueBarEnabled; private bool _enabled; private float _edgeMarginTop; private float _edgeMarginBottom; private float _edgeMarginSide; private bool _noiseEnabled; private float _noiseSpeed; private float _noiseScale; private float _noiseOpacity; private float _damageFlashDuration; private float _healFlashDuration; private float _offscreenDestroyMargin; private float _offscreenDestroyDelay; public static HealthBarConfigManager Instance { get { if (_instance == null) { _instance = new HealthBarConfigManager(); } return _instance; } } public float BorderThickness => _borderThickness; public float CornerRadius => _cornerRadius; public float InnerPadding => _innerPadding; public float TextGap => _textGap; public int TextSize => _textSize; public int MaxDamageDisplays => _maxDamageDisplays; public float DamageSpacingY => _damageSpacingY; public float DamageDuration => _damageDuration; public float DamageFadeOut => _damageFadeOut; public int DamageFontSize => _damageFontSize; public float SmoothAnimSpeed => _smoothAnimSpeed; public float JitterX => _jitterX; public float JitterY => _jitterY; public float PosSmooth => _posSmooth; public float AutoHideDelay => _autoHideDelay; public bool BossUniqueBarEnabled => _bossUniqueBarEnabled; public bool Enabled => _enabled; public float EdgeMarginTop => _edgeMarginTop; public float EdgeMarginBottom => _edgeMarginBottom; public float EdgeMarginSide => _edgeMarginSide; public bool NoiseEnabled => _noiseEnabled; public float NoiseSpeed => _noiseSpeed; public float NoiseScale => _noiseScale; public float NoiseOpacity => _noiseOpacity; public float DamageFlashDuration => _damageFlashDuration; public float HealFlashDuration => _healFlashDuration; public float OffscreenDestroyMargin => _offscreenDestroyMargin; public float OffscreenDestroyDelay => _offscreenDestroyDelay; private HealthBarConfigManager() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) RefreshConfig(); } public void RefreshConfig() { MyGameConfig.HealthBarSettings healthBarSettings = Plugin.Instance?._config?.HealthBar; _style = healthBarSettings?.Style ?? "Normal"; _width = healthBarSettings?.Width ?? 200f; _height = healthBarSettings?.Height ?? 36f; _bossWidth = healthBarSettings?.BossWidth ?? 250f; _bossHeight = healthBarSettings?.BossHeight ?? 40f; _borderThickness = healthBarSettings?.BorderThickness ?? 3f; _cornerRadius = healthBarSettings?.CornerRadius ?? 6f; _innerPadding = healthBarSettings?.InnerPadding ?? 1f; _textGap = healthBarSettings?.TextGap ?? 8f; _textSize = healthBarSettings?.TextSize ?? 22; _maxDamageDisplays = healthBarSettings?.MaxDamageDisplays ?? 9; _damageSpacingY = healthBarSettings?.DamageSpacingY ?? 40f; _damageDuration = healthBarSettings?.DamageDuration ?? 2.5f; _damageFadeOut = healthBarSettings?.DamageFadeOut ?? 1.5f; _damageFontSize = healthBarSettings?.DamageFontSize ?? 32; _smoothAnimSpeed = healthBarSettings?.SmoothAnimSpeed ?? 8f; _jitterX = healthBarSettings?.JitterThresholdX ?? 0.03f; _jitterY = healthBarSettings?.JitterThresholdY ?? 0.03f; _posSmooth = healthBarSettings?.PositionSmoothSpeed ?? 15f; _autoHideDelay = healthBarSettings?.AutoHideDelay ?? 10f; _bossUniqueBarEnabled = healthBarSettings?.BossUniqueBarEnabled ?? true; _enabled = healthBarSettings?.Enabled ?? true; _edgeMarginTop = healthBarSettings?.EdgeMarginTop ?? 0.2f; _edgeMarginBottom = healthBarSettings?.EdgeMarginBottom ?? 0.1f; _edgeMarginSide = healthBarSettings?.EdgeMarginSide ?? 0.05f; _noiseEnabled = healthBarSettings?.NoiseEnabled ?? true; _noiseSpeed = healthBarSettings?.NoiseSpeed ?? 0.5f; _noiseScale = healthBarSettings?.NoiseScale ?? 2f; _noiseOpacity = healthBarSettings?.NoiseOpacity ?? 0.15f; _damageFlashDuration = healthBarSettings?.DamageFlashDuration ?? 0.15f; _healFlashDuration = healthBarSettings?.HealFlashDuration ?? 0.2f; _offscreenDestroyMargin = healthBarSettings?.OffscreenDestroyMargin ?? 0.2f; _offscreenDestroyDelay = healthBarSettings?.OffscreenDestroyDelay ?? 3f; } public string GetStyle(bool isBoss = false) { if (!isBoss || !_bossUniqueBarEnabled) { return _style; } return "Normal"; } public float GetWidth(bool isBoss = false) { if (!isBoss || !_bossUniqueBarEnabled) { return _width; } return _bossWidth; } public float GetHeight(bool isBoss = false) { if (!isBoss || !_bossUniqueBarEnabled) { return _height; } return _bossHeight; } public Color32 GetBorderColor(bool isBoss = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!isBoss || !_bossUniqueBarEnabled) { return BORDER_COLOR; } return BOSS_BORDER_COLOR; } public Color32 GetHealthHighColor(bool isBoss = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!isBoss || !_bossUniqueBarEnabled) { return HEALTH_HIGH_COLOR; } return BOSS_HEALTH_HIGH_COLOR; } public Color32 GetHealthMidColor(bool isBoss = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!isBoss || !_bossUniqueBarEnabled) { return HEALTH_MID_COLOR; } return BOSS_HEALTH_MID_COLOR; } public Color32 GetHealthLowColor(bool isBoss = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!isBoss || !_bossUniqueBarEnabled) { return HEALTH_LOW_COLOR; } return BOSS_HEALTH_LOW_COLOR; } public int GetSortingOrder(bool isBoss = false) { if (!isBoss || !_bossUniqueBarEnabled) { return 100; } return 110; } public float GetScale(bool isBoss = false) { if (!isBoss || !_bossUniqueBarEnabled) { return 0.01f; } return 0.011f; } } public class WorldDamageTextController : MonoBehaviour { private CanvasGroup canvasGroup; private float duration = 2f; private float elapsed; private Vector3 startPos; private Vector3 endPos; private void Start() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0033: 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_003d: Unknown result type (might be due to invalid IL or missing references) canvasGroup = ((Component)this).GetComponent<CanvasGroup>(); startPos = ((Component)this).transform.position; endPos = startPos + new Vector3(0f, 1.5f, 0f); } private void Update() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (elapsed >= duration) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } elapsed += Time.deltaTime; float num = elapsed / duration; ((Component)this).transform.position = Vector3.Lerp(startPos, endPos, num); if ((Object)(object)canvasGroup != (Object)null && num > 0.5f) { canvasGroup.alpha = Mathf.Lerp(1f, 0f, (num - 0.5f) * 2f); } } } public class EnemyHealthBar : MonoBehaviour { private class DamageDisplay { public GameObject gameObject; public Text textComponent; public CanvasGroup canvasGroup; public float displayTime; public float fadeOutTime; public bool isActive; public Vector3 targetLocalPosition; public Vector3 originalScale; public float moveSpeed = 5f; } [CompilerGenerated] private sealed class <BorderFlashCoroutine>d__64 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EnemyHealthBar <>4__this; private Color <originalColor>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BorderFlashCoroutine>d__64(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0079: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; EnemyHealthBar enemyHealthBar = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)enemyHealthBar.borderImage == (Object)null) { return false; } <originalColor>5__2 = ((Graphic)enemyHealthBar.borderImage).color; ((Graphic)enemyHealthBar.borderImage).color = new Color(1f, 0.2f, 0.2f, <originalColor>5__2.a); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; ((Graphic)enemyHealthBar.borderImage).color = <originalColor>5__2; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DamagePulseAnimationCoroutine>d__62 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EnemyHealthBar <>4__this; public int previousHp; private float <previousPercent>5__2; private float <currentPercent>5__3; private RectTransform <rectTransform>5__4; private float <duration>5__5; private float <elapsed>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DamagePulseAnimationCoroutine>d__62(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <rectTransform>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; EnemyHealthBar enemyHealthBar = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)enemyHealthBar.damagePulseBar == (Object)null || (Object)(object)enemyHealthBar.damagePulseImage == (Object)null) { return false; } <previousPercent>5__2 = (float)previousHp / (float)enemyHealthBar.maxHp; <currentPercent>5__3 = (float)enemyHealthBar.currentHp / (float)enemyHealthBar.maxHp; enemyHealthBar.damagePulseBar.SetActive(true); <rectTransform>5__4 = enemyHealthBar.damagePulseBar.GetComponent<RectTransform>(); <rectTransform>5__4.anchorMin = new Vector2(0f, 0f); <rectTransform>5__4.anchorMax = new Vector2(<previousPercent>5__2, 1f); <rectTransform>5__4.offsetMin = Vector2.zero; <rectTransform>5__4.offsetMax = Vector2.zero; <duration>5__5 = 0.3f; <elapsed>5__6 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__6 < <duration>5__5) { <elapsed>5__6 += Time.deltaTime; float num2 = <elapsed>5__6 / <duration>5__5; float num3 = Mathf.Lerp(<previousPercent>5__2, <currentPercent>5__3, num2); <rectTransform>5__4.anchorMax = new Vector2(num3, 1f); Color color = ((Graphic)enemyHealthBar.damagePulseImage).color; color.a = Mathf.Lerp(0.8f, 0f, num2); ((Graphic)enemyHealthBar.damagePulseImage).color = color; <>2__current = null; <>1__state = 1; return true; } enemyHealthBar.damagePulseBar.SetActive(false); Color color2 = ((Graphic)enemyHealthBar.damagePulseImage).color; color2.a = 0.8f; ((Graphic)enemyHealthBar.damagePulseImage).color = color2; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <FadeImage>d__114 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Image image; public float fromAlpha; public float toAlpha; public float duration; private float <elapsed>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeImage>d__114(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <elapsed>5__2 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__2 < duration) { if ((Object)(object)image == (Object)null) { return false; } <elapsed>5__2 += Time.deltaTime; float a = Mathf.Lerp(fromAlpha, toAlpha, <elapsed>5__2 / duration); Color color = ((Graphic)image).color; color.a = a; ((Graphic)image).color = color; <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <FlashEffectCoroutine>d__113 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GameObject flashObject; public EnemyHealthBar <>4__this; public float duration; private Image <flashImage>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FlashEffectCoroutine>d__113(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <flashImage>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; EnemyHealthBar enemyHealthBar = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)flashObject == (Object)null || !flashObject.activeInHierarchy) { return false; } <flashImage>5__2 = flashObject.GetComponent<Image>(); if ((Object)(object)<flashImage>5__2 == (Object)null) { flashObject.SetActive(false); return false; } flashObject.SetActive(true); <>2__current = enemyHealthBar.FadeImage(<flashImage>5__2, 0f, 0.7f, duration / 2f); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = enemyHealthBar.FadeImage(<flashImage>5__2, 0.7f, 0f, duration / 2f); <>1__state = 2; return true; case 2: { <>1__state = -1; GameObject obj = flashObject; if (obj != null) { obj.SetActive(false); } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private GameObject damagePulseBar; private Image damagePulseImage; private Coroutine damagePulseCoroutine; private Coroutine borderFlashCoroutine; private HealthManager healthManager; private tk2dSprite Tk2dSprite; private Collider2D collider2D; private GameObject healthBarUI; private Slider healthBarSlider; private Image fillImage; private Text healthText; private Text healthNumberText; private GameObject healthTextCanvas; private Image borderImage; private Image backgroundImage; private GameObject damageFlashEffect; private GameObject healFlashEffect; private readonly List<DamageDisplay> damageDisplays = new List<DamageDisplay>(); private readonly Queue<DamageDisplay> availableDisplays = new Queue<DamageDisplay>(); private GameObject damageDisplayContainer; private int currentHp; private int maxHp; private int lastHpSnapshot; private bool deltaHandledThisFrame; private bool isActive; private bool isBoss; private string enemyName; private float lastHealthChangeTime; private float targetHealthPercent = 1f; private float currentDisplayPercent = 1f; private Material healthBarMaterial; private Texture2D noiseTexture; private readonly Gradient healthGradient = new Gradient(); private Coroutine flashCoroutine; private float lastDebugTime; private const float DEBUG_INTERVAL = 1f; private float offscreenExitAt = -1f; private Vector3 lastTargetWorldPosition; private void Start() { InitializeComponents(); InitializeGradient(); CreateNoiseTexture(); if ((Object)(object)healthManager == (Object)null) { Object.Destroy((Object)(object)this); return; } InitializeGetEnemyData(InitGetHP: true); HealthBarConfigManager.Instance.RefreshConfig(); CreateHealthBarUI(); CreateDamagePulseBar(); if (HealthBarConfigManager.Instance.GetStyle(isBoss) != "Simple") { CreateDamageDisplayContainer(); PreCreateDamageDisplays(); } healthBarUI.SetActive(false); currentDisplayPercent = (targetHealthPercent = (float)currentHp / (float)maxHp); lastHpSnapshot = currentHp; } private void Update() { if (IsValid() && ((Component)this).gameObject.activeInHierarchy && ((Behaviour)this).isActiveAndEnabled && HealthBarConfigManager.Instance.Enabled && (Object)(object)healthBarUI != (Object)null && (Object)(object)healthBarUI.gameObject != (Object)null) { if (Time.time - lastDebugTime >= 1f) { CheckFillImageAlpha(); lastDebugTime = Time.time; } UpdateHealthBarPosition(); UpdateHealthAnimation(); CheckHealthChanges(); UpdateDamageDisplays(); UpdateHealthBarMaterial(); CheckHideHealthBar(); CheckOffscreenDestroy(); MonitorUntrackedHpChange(); lastHpSnapshot = (((Object)(object)healthManager != (Object)null) ? healthManager.hp : lastHpSnapshot); deltaHandledThisFrame = false; } else { HideOnlyBarVisuals(); UpdateDamageDisplays(); if (damageDisplays.Count == 0 && availableDisplays.Count >= HealthBarConfigManager.Instance.MaxDamageDisplays) { CleanupResources(); Object.Destroy((Object)(object)this); } } } private void OnDestroy() { CleanupResources(); } private void OnDisable() { try { HideHealthBar(); CleanupResources(); } catch { } } private void InitializeComponents() { healthManager = ((Component)this).GetComponent<HealthManager>(); Tk2dSprite = ((Component)this).GetComponent<tk2dSprite>(); collider2D = ((Component)this).GetComponent<Collider2D>(); } private void InitializeGetEnemyData(bool InitGetHP) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (InitGetHP) { currentHp = healthManager.hp; try { maxHp = Traverse.Create((object)healthManager).Field("initHp").GetValue<int>(); if (maxHp <= 0) { maxHp = healthManager.hp; } } catch { maxHp = healthManager.hp; } } string name = GetData.CleanUnityCloneSuffixes(((Object)healthManager).name); EnemyJournalRecord val = GetData.ObjToName(((Component)healthManager).gameObject, name); if ((Object)(object)val == (Object)null) { enemyName = name; isBoss = false; } else { enemyName = LocalisedString.op_Implicit(val.DisplayName); isBoss = val.KillsRequired < 5; } } private bool IsValid() { if ((Object)(object)healthManager != (Object)null) { return healthManager.hp > 0; } return false; } private void CreateHealthBarUI() { try { CreateHealthBarCanvas(); CreateRoundedBorder(); CreateBackground(); CreateHealthSlider(); CreateHealthNumberTextInternal(healthBarUI.transform); SetBaseComponentsActive(active: true); if (HealthBarConfigManager.Instance.GetStyle(isBoss) != "Simple") { CreateHealthBarDetails(); } CreateFlashEffects(); if (HealthBarConfigManager.Instance.GetStyle(isBoss) != "Simple") { CreateHealthText(); } EnsureNumberOnTop(); EnsureNumberSortingOrder(); UpdateHealthBarPosition(); } catch (Exception ex) { DebugLog.LogDebug("创建血条UI失败: " + ex.Message); } } private void CreateDamagePulseBar() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0057: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) try { damagePulseBar = new GameObject("DamagePulseBar"); damagePulseBar.transform.SetParent(healthBarUI.transform, false); damagePulseImage = damagePulseBar.AddComponent<Image>(); ((Graphic)damagePulseImage).color = new Color(1f, 1f, 1f, 0.8f); ((Graphic)damagePulseImage).raycastTarget = false; Material val = CreateRoundedCornersMaterial(); if ((Object)(object)val != (Object)null) { ((Graphic)damagePulseImage).material = val; } RectTransform component = damagePulseBar.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; float borderThickness = HealthBarConfigManager.Instance.BorderThickness; float innerPadding = HealthBarConfigManager.Instance.InnerPadding; component.offsetMin = new Vector2(borderThickness + innerPadding, borderThickness + innerPadding); component.offsetMax = new Vector2(0f - (borderThickness + innerPadding), 0f - (borderThickness + innerPadding)); damagePulseBar.SetActive(false); damagePulseBar.transform.SetSiblingIndex(((Component)healthBarSlider).transform.GetSiblingIndex() + 1); } catch (Exception ex) { DebugLog.LogDebug("创建受伤脉冲血条失败: " + ex.Message); } } private void SetBaseComponentsActive(bool active) { if ((Object)(object)borderImage != (Object)null && (Object)(object)((Component)borderImage).gameObject != (Object)null) { ((Component)borderImage).gameObject.SetActive(active); } if ((Object)(object)backgroundImage != (Object)null && (Object)(object)((Component)backgroundImage).gameObject != (Object)null) { ((Component)backgroundImage).gameObject.SetActive(active); } if ((Object)(object)healthBarSlider != (Object)null && (Object)(object)((Component)healthBarSlider).gameObject != (Object)null) { ((Component)healthBarSlider).gameObject.SetActive(active); } if ((Object)(object)fillImage != (Object)null && (Object)(object)((Component)fillImage).gameObject != (Object)null) { ((Component)fillImage).gameObject.SetActive(active); } } private void UpdateHealthAnimation() { if (!((Object)(object)healthBarUI == (Object)null) && Mathf.Abs(currentDisplayPercent - targetHealthPercent) > 0.001f) { currentDisplayPercent = Mathf.Lerp(currentDisplayPercent, targetHealthPercent, Time.deltaTime * HealthBarConfigManager.Instance.SmoothAnimSpeed); UpdateHealthBarVisuals(); } } private void CreateDivider(int index) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!(HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple")) { GameObject val = new GameObject($"Divider_{index}"); val.transform.SetParent(healthBarUI.transform, false); if ((Object)(object)healthBarSlider != (Object)null) { int siblingIndex = ((Component)healthBarSlider).transform.GetSiblingIndex(); val.transform.SetSiblingIndex(siblingIndex + 1); } Image obj = val.AddComponent<Image>(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.6f); ((Graphic)obj).raycastTarget = false; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2((float)index * 0.25f, 0f); component.anchorMax = new Vector2((float)index * 0.25f, 1f); component.pivot = new Vector2(0.5f, 0.5f); float borderThickness = HealthBarConfigManager.Instance.BorderThickness; component.sizeDelta = new Vector2(2f, 0f); component.offsetMin = new Vector2(-1f, borderThickness + 2f); component.offsetMax = new Vector2(1f, 0f - (borderThickness + 2f)); } } private void CreateHealthBarCanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) healthBarUI = new GameObject("HealthBarCanvas"); Canvas obj = healthBarUI.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.sortingOrder = HealthBarConfigManager.Instance.GetSortingOrder(isBoss); RectTransform component = healthBarUI.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(HealthBarConfigManager.Instance.GetWidth(isBoss), HealthBarConfigManager.Instance.GetHeight(isBoss)); ((Transform)component).localScale = Vector3.one * HealthBarConfigManager.Instance.GetScale(isBoss); component.pivot = new Vector2(0.5f, 0f); } private void CreateHealthNumberTextInternal(Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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) try { GameObject val = new GameObject("HealthNumberText"); val.transform.SetParent(parent, false); Canvas component = ((Component)parent).GetComponent<Canvas>(); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.overrideSorting = true; obj.sortingOrder = ((component != null) ? component.sortingOrder : 100) + 1; healthNumberText = val.AddComponent<Text>(); healthNumberText.text = $"{currentHp}/{maxHp}"; healthNumberText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); healthNumberText.alignment = (TextAnchor)4; ((Graphic)healthNumberText).raycastTarget = false; ((Graphic)healthNumberText).color = GetHealthTextColor(); RectTransform component2 = val.GetComponent<RectTransform>(); float borderThickness = HealthBarConfigManager.Instance.BorderThickness; float num = HealthBarConfigManager.Instance.GetHeight(isBoss) - borderThickness * 2f; float num2 = Mathf.Ceil(22.5f); float num3 = num2 + borderThickness * 2f; if (num < num2 && (Object)(object)healthBarUI != (Object)null) { RectTransform component3 = healthBarUI.GetComponent<RectTransform>(); component3.sizeDelta = new Vector2(component3.sizeDelta.x, Mathf.Max(component3.sizeDelta.y, num3)); num = component3.sizeDelta.y - borderThickness * 2f; } int fontSize = Mathf.Max(18, Mathf.Min(HealthBarConfigManager.Instance.TextSize + 2, Mathf.FloorToInt(num * 0.8f))); healthNumberText.fontSize = fontSize; healthNumberText.fontStyle = (FontStyle)1; component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = new Vector2(borderThickness, borderThickness); component2.offsetMax = new Vector2(0f - borderThickness, 0f - borderThickness); Shadow obj2 = val.AddComponent<Shadow>(); obj2.effectColor = new Color(0f, 0f, 0f, 0.85f); obj2.effectDistance = new Vector2(1.2f, -1.2f); Outline obj3 = val.AddComponent<Outline>(); ((Shadow)obj3).effectColor = new Color(0f, 0f, 0f, 0.6f); ((Shadow)obj3).effectDistance = new Vector2(1f, -1f); val.transform.SetAsLastSibling(); } catch (Exception ex) { DebugLog.LogDebug("创建血量数字文本失败: " + ex.Message); } } private void CreateHealthSlider() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HealthSlider"); val.transform.SetParent(healthBarUI.transform, false); healthBarSlider = val.AddComponent<Slider>(); healthBarSlider.minValue = 0f; healthBarSlider.maxValue = 1f; healthBarSlider.value = 1f; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; float borderThickness = HealthBarConfigManager.Instance.BorderThickness; component.offsetMin = new Vector2(borderThickness, borderThickness); component.offsetMax = new Vector2(0f - borderThickness, 0f - borderThickness); CreateFillArea(val); } private void CreateFillArea(GameObject sliderObj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0082: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("FillArea"); val.transform.SetParent(sliderObj.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; GameObject val2 = new GameObject("ColorLayer"); val2.transform.SetParent(val.transform, false); fillImage = val2.AddComponent<Image>(); Color color = Color32.op_Implicit(HealthBarConfigManager.Instance.GetHealthHighColor(isBoss)); color.a = 0.6f; ((Graphic)fillImage).color = color; ((Graphic)fillImage).raycastTarget = false; RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; GameObject val3 = new GameObject("NoiseLayer"); val3.transform.SetParent(val.transform, false); Image obj2 = val3.AddComponent<Image>(); Material val4 = new Material(Shader.Find("UI/Default")); val4.mainTexture = (Texture)(object)noiseTexture; val4.color = new Color(1f, 1f, 1f, 0.3f); ((Graphic)obj2).material = val4; ((Graphic)obj2).raycastTarget = false; ((Graphic)obj2).material.SetInt("_SrcBlend", 2); ((Graphic)obj2).material.SetInt("_DstBlend", 0); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; val2.transform.SetAsFirstSibling(); healthBarSlider.fillRect = component; healthBarMaterial = val4; } private void CheckHealthChanges() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00ae: 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) if (currentHp == healthManager.hp) { return; } if (healthManager.hp > maxHp) { maxHp = healthManager.hp; UpdateHealthBarSize(); } int num = currentHp; currentHp = healthManager.hp; int num2 = num - currentHp; if (!deltaHandledThisFrame) { if (num2 > 0) { Color damageColor = GetDamageColor(new HitInstance { AttackType = (AttackTypes)1 }); if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldDamageText(num2, damageColor); } else { ShowDamageNumber(num2, damageColor); } PlayBorderFlash(); } else if (num2 < 0) { int amount = -num2; ShowHeal(amount); } deltaHandledThisFrame = true; } HandleHealthChange(num, num2); lastHpSnapshot = currentHp; } private void MonitorUntrackedHpChange() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthManager == (Object)null || deltaHandledThisFrame) { return; } int hp = healthManager.hp; if (hp == lastHpSnapshot) { return; } int num = hp - lastHpSnapshot; if (num > 0) { ShowHeal(num); } else { Color damageColor = GetDamageColor(new HitInstance { AttackType = (AttackTypes)1 }); if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldDamageText(-num, damageColor); } else { ShowDamageNumber(-num, damageColor); } PlayBorderFlash(); } lastHpSnapshot = hp; } private void UpdateHealthBarSize() { //IL_0052: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthBarUI == (Object)null) { return; } try { Slider obj = healthBarSlider; float value = ((obj != null) ? obj.value : 1f); healthBarUI.GetComponent<RectTransform>().sizeDelta = new Vector2(HealthBarConfigManager.Instance.GetWidth(isBoss), HealthBarConfigManager.Instance.GetHeight(isBoss)); UpdateNoiseAndColorLayers(); if ((Object)(object)healthBarSlider != (Object)null) { healthBarSlider.value = value; } if ((Object)(object)backgroundImage != (Object)null) { RectTransform component = ((Component)backgroundImage).GetComponent<RectTransform>(); float borderThickness = HealthBarConfigManager.Instance.BorderThickness; component.offsetMin = new Vector2(borderThickness, borderThickness); component.offsetMax = new Vector2(0f - borderThickness, 0f - borderThickness); } if ((Object)(object)healthBarSlider != (Object)null && (Object)(object)healthBarSlider.fillRect != (Object)null) { RectTransform fillRect = healthBarSlider.fillRect; fillRect.offsetMin = Vector2.zero; fillRect.offsetMax = Vector2.zero; } UpdateLayerSize("FillArea/NoiseLayer"); UpdateLayerSize("FillArea/ColorLayer"); if ((Object)(object)healthNumberText != (Object)null) { RectTransform component2 = ((Component)healthNumberText).GetComponent<RectTransform>(); float borderThickness2 = HealthBarConfigManager.Instance.BorderThickness; component2.offsetMin = new Vector2(borderThickness2, borderThickness2); component2.offsetMax = new Vector2(0f - borderThickness2, 0f - borderThickness2); RectTransform component3 = healthBarUI.GetComponent<RectTransform>(); float num = component3.sizeDelta.y - borderThickness2 * 2f; float num2 = Mathf.Ceil(22.5f); float num3 = num2 + borderThickness2 * 2f; if (num < num2) { component3.sizeDelta = new Vector2(component3.sizeDelta.x, Mathf.Max(component3.sizeDelta.y, num3)); num = component3.sizeDelta.y - borderThickness2 * 2f; } int fontSize = Mathf.Max(18, Mathf.Min(HealthBarConfigManager.Instance.TextSize + 2, Mathf.FloorToInt(num * 0.8f))); healthNumberText.fontSize = fontSize; } if ((Object)(object)healthTextCanvas != (Object)null) { healthTextCanvas.GetComponent<RectTransform>().sizeDelta = new Vector2(HealthBarConfigManager.Instance.GetWidth(isBoss), HealthBarConfigManager.Instance.GetHeight(isBoss)); } } catch (Exception ex) { DebugLog.LogError("更新血条尺寸失败: " + ex.Message); } } private void UpdateLayerSize(string path) { //IL_002c: 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) Transform val = healthBarUI.transform.Find(path); if ((Object)(object)val != (Object)null) { RectTransform component = ((Component)val).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; } } } private void UpdateNoiseAndColorLayers() { Transform val = healthBarUI.transform.Find("HealthSlider"); if (!((Object)(object)val == (Object)null)) { Transform val2 = val.Find("FillArea"); if (!((Object)(object)val2 == (Object)null)) { UpdateLayerRect(val2.Find("NoiseLayer"), "噪声层"); UpdateLayerRect(val2.Find("ColorLayer"), "颜色层"); } } } private void UpdateLayerRect(Transform layer, string layerName) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)layer != (Object)null) { RectTransform component = ((Component)layer).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; } } else { DebugLog.LogDebug("未找到" + layerName); } } private void HandleHealthChange(int previousHp, int damageTaken) { targetHealthPercent = (float)currentHp / (float)maxHp; lastHealthChangeTime = Time.time; UpdateHealthBarSize(); ShowHealthBar(); } private void PlayDamagePulseAnimation(int previousHp) { if (damagePulseCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(damagePulseCoroutine); } damagePulseCoroutine = ((MonoBehaviour)this).StartCoroutine(DamagePulseAnimationCoroutine(previousHp)); } [IteratorStateMachine(typeof(<DamagePulseAnimationCoroutine>d__62))] private IEnumerator DamagePulseAnimationCoroutine(int previousHp) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DamagePulseAnimationCoroutine>d__62(0) { <>4__this = this, previousHp = previousHp }; } private void PlayBorderFlash() { if (borderFlashCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(borderFlashCoroutine); } borderFlashCoroutine = ((MonoBehaviour)this).StartCoroutine(BorderFlashCoroutine()); } [IteratorStateMachine(typeof(<BorderFlashCoroutine>d__64))] private IEnumerator BorderFlashCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BorderFlashCoroutine>d__64(0) { <>4__this = this }; } private void CheckHideHealthBar() { if (isActive && Time.time - lastHealthChangeTime > HealthBarConfigManager.Instance.AutoHideDelay) { HideHealthBar(); } } private void CreateNoiseTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) int num = 32; noiseTexture = new Texture2D(num, num, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; float noiseScale = HealthBarConfigManager.Instance.NoiseScale; for (int i = 0; i < ((Texture)noiseTexture).height; i++) { for (int j = 0; j < ((Texture)noiseTexture).width; j++) { float num2 = Mathf.PerlinNoise((float)j * (0.15f / noiseScale), (float)i * (0.15f / noiseScale)); float num3 = ((num2 > 0.6f) ? 0.8f : ((num2 < 0.4f) ? 0.2f : Mathf.Lerp(0.2f, 0.8f, (num2 - 0.4f) / 0.2f))); noiseTexture.SetPixel(j, i, new Color(0f, 0f, 0f, num3)); } } noiseTexture.Apply(); } private void UpdateHealthBarMaterial() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthBarMaterial != (Object)null && (Object)(object)noiseTexture != (Object)null && HealthBarConfigManager.Instance.NoiseEnabled) { float num = Time.time * HealthBarConfigManager.Instance.NoiseSpeed; healthBarMaterial.mainTextureOffset = new Vector2(num, num * 0.5f); } } private void InitializeGradient() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006e: Unknown result type (might be due to invalid IL or missing references) Color val = Color32.op_Implicit(HealthBarConfigManager.Instance.GetHealthHighColor(isBoss)); GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(val, 0f), new GradientColorKey(val, 1f) }; GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }; healthGradient.SetKeys(array, array2); } private void UpdateHealthBarVisuals() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) UpdateHealthSlider(); UpdateHealthText(); UpdateHealthNumberText(); UpdateNoiseTextureOffset(); if ((Object)(object)healthText != (Object)null) { ((Graphic)healthText).color = GetHealthTextColor(); } if ((Object)(object)healthBarUI != (Object)null && HealthBarConfigManager.Instance.GetStyle(isBoss) != "Simple") { UpdateDividersVisibility(); } } private void UpdateNoiseTextureOffset() { //IL_005f: 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) if ((Object)(object)healthBarMaterial != (Object)null && (Object)(object)noiseTexture != (Object)null && HealthBarConfigManager.Instance.NoiseEnabled) { float num = 0.4f; float num2 = Time.time * num; float num3 = Mathf.Sin(Time.time * num * 0.3f) * 0.1f; healthBarMaterial.mainTextureOffset = new Vector2(num2, num3); float num4 = 0.3f + (1f - currentDisplayPercent) * 0.15f; healthBarMaterial.color = new Color(1f, 1f, 1f, num4); } } private void UpdateHealthSlider() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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) //IL_003d: 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) if ((Object)(object)healthBarSlider != (Object)null) { healthBarSlider.value = currentDisplayPercent; Color color = Color32.op_Implicit(HealthBarConfigManager.Instance.GetHealthHighColor(isBoss)); color.a = ((Graphic)fillImage).color.a; ((Graphic)fillImage).color = color; UpdateNoiseTextureOffset(); EnsureNumberOnTop(); } } private void UpdateHealthText() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthText != (Object)null) { ((Graphic)healthText).color = GetHealthTextColor(); } } private void UpdateHealthNumberText() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)healthNumberText != (Object)null) { healthNumberText.text = $"{currentHp}/{maxHp}"; ((Graphic)healthNumberText).color = GetHealthTextColor(); } } private void EnsureNumberOnTop() { Text obj = healthNumberText; if (obj != null) { ((Component)obj).transform.SetAsLastSibling(); } } private void EnsureNumberSortingOrder() { if ((Object)(object)healthNumberText == (Object)null) { return; } Canvas component = ((Component)healthNumberText).GetComponent<Canvas>(); if (!((Object)(object)component == (Object)null)) { GameObject obj = healthBarUI; int? obj2; if (obj == null) { obj2 = null; } else { Canvas component2 = obj.GetComponent<Canvas>(); obj2 = ((component2 != null) ? new int?(component2.sortingOrder) : null); } int? num = obj2; int valueOrDefault = num.GetValueOrDefault(); GameObject obj3 = healthTextCanvas; int? obj4; if (obj3 == null) { obj4 = null; } else { Canvas component3 = obj3.GetComponent<Canvas>(); obj4 = ((component3 != null) ? new int?(component3.sortingOrder) : null); } num = obj4; int valueOrDefault2 = num.GetValueOrDefault(); int sortingOrder = Mathf.Max(valueOrDefault + 2, valueOrDefault2 + 1); component.renderMode = (RenderMode)2; component.overrideSorting = true; component.sortingOrder = sortingOrder; } } private Color GetHealthTextColor() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (currentDisplayPercent > 0.7f) { return Color.white; } if (currentDisplayPercent > 0.4f) { return new Color(1f, 0.8f, 0.8f, 1f); } if (currentDisplayPercent > 0.2f) { return new Color(1f, 0.6f, 0.6f, 1f); } return new Color(1f, 0.4f, 0.4f, 1f); } private void CreateDamageDisplayContainer() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) damageDisplayContainer = new GameObject("DamageDisplayContainer"); damageDisplayContainer.transform.SetParent(healthBarUI.transform, false); RectTransform obj = damageDisplayContainer.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(1f, 0.5f); obj.anchorMax = new Vector2(1f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = new Vector2(20f, 0f); obj.sizeDelta = new Vector2(100f, 100f); if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { damageDisplayContainer.SetActive(true); } } private void PreCreateDamageDisplays() { if (!(HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple")) { for (int i = 0; i < HealthBarConfigManager.Instance.MaxDamageDisplays; i++) { CreateDamageDisplayObject(); } } } private void SpawnWorldDamageText(int damage, Color color, bool isCritical = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)Camera.main == (Object)null)) { GameObject val = new GameObject("WorldDamageText"); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.sortingOrder = HealthBarConfigManager.Instance.GetSortingOrder(isBoss) + 10; val.AddComponent<CanvasGroup>(); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(200f, 100f); ((Transform)component).localScale = Vector3.one * 0.015f; Vector3 position = ((Component)this).transform.position + new Vector3(0f, 1.5f, 0f); val.transform.position = position; GameObject val2 = new GameObject("Text"); val2.transform.SetParent(val.transform, false); Text obj2 = val2.AddComponent<Text>(); obj2.text = (isCritical ? $"-{damage}!" : $"-{damage}"); obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); obj2.fontStyle = (FontStyle)1; obj2.alignment = (TextAnchor)4; ((Graphic)obj2).color = color; obj2.fontSize = 36; RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; Shadow obj3 = val2.AddComponent<Shadow>(); obj3.effectColor = new Color(color.r * 0.4f, color.g * 0.4f, color.b * 0.4f, 0.8f); obj3.effectDistance = new Vector2(2f, -2f); val.AddComponent<WorldDamageTextController>(); } } catch (Exception ex) { DebugLog.LogDebug("SpawnWorldDamageText error: " + ex.Message); } } private void SpawnWorldHealText(int healAmount) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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) try { if (!((Object)(object)Camera.main == (Object)null)) { GameObject val = new GameObject("WorldHealText"); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.sortingOrder = HealthBarConfigManager.Instance.GetSortingOrder(isBoss) + 10; val.AddComponent<CanvasGroup>(); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(200f, 100f); ((Transform)component).localScale = Vector3.one * 0.015f; Vector3 position = ((Component)this).transform.position + new Vector3(0f, 1.5f, 0f); val.transform.position = position; GameObject val2 = new GameObject("Text"); val2.transform.SetParent(val.transform, false); Text obj2 = val2.AddComponent<Text>(); obj2.text = $"+{healAmount}"; obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); obj2.fontStyle = (FontStyle)1; obj2.alignment = (TextAnchor)4; ((Graphic)obj2).color = new Color(0.3f, 1f, 0.3f, 1f); obj2.fontSize = 36; RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; Shadow obj3 = val2.AddComponent<Shadow>(); obj3.effectColor = new Color(0f, 0.2f, 0f, 0.8f); obj3.effectDistance = new Vector2(2f, -2f); val.AddComponent<WorldDamageTextController>(); } } catch (Exception ex) { DebugLog.LogDebug("SpawnWorldHealText error: " + ex.Message); } } private void CreateDamageDisplayObject() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("DamageDisplay"); val.transform.SetParent(damageDisplayContainer.transform, false); val.SetActive(false); Canvas obj = val.AddComponent<Canvas>(); obj.overrideSorting = true; obj.sortingOrder = 102; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0.5f); component.anchorMax = new Vector2(0f, 0.5f); component.pivot = new Vector2(0f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = new Vector2(160f, 60f); ((Transform)component).localScale = Vector3.one * 1.4f; Text textComponent = CreateDamageText(val); CanvasGroup canvasGroup = val.AddComponent<CanvasGroup>(); DamageDisplay damageDisplay = new DamageDisplay { gameObject = val, textComponent = textComponent, canvasGroup = canvasGroup, originalScale = ((Transform)component).localScale, isActive = false, displayTime = 0f, fadeOutTime = 0f, moveSpeed = 5f, targetLocalPosition = Vector2.op_Implicit(Vector2.zero) }; if ((Object)(object)damageDisplay.textComponent == (Object)null || (Object)(object)damageDisplay.canvasGroup == (Object)null) { DebugLog.LogError("DamageDisplay组件创建失败"); Object.Destroy((Object)(object)val); } else { availableDisplays.Enqueue(damageDisplay); } } catch (Exception ex) { DebugLog.LogError("创建DamageDisplayObject失败: " + ex.Message); } } private Text CreateDamageText(GameObject parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0096: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DamageText"); val.transform.SetParent(parent.transform, false); Text val2 = val.AddComponent<Text>(); val2.fontSize = HealthBarConfigManager.Instance.DamageFontSize; ((Graphic)val2).color = new Color(1f, 0.6f, 0.6f, 1f); val2.alignment = (TextAnchor)3; val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val2.fontStyle = (FontStyle)1; val2.text = "-0"; Shadow obj = val.AddComponent<Shadow>(); obj.effectColor = new Color(0.3f, 0f, 0f, 0.8f); obj.effectDistance = new Vector2(2f, -2f); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; return val2; } private void ShowDamageNumber(int damage, Color color, bool isCritical = false) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldDamageText(damage, color, isCritical); return; } if (availableDisplays.Count == 0 && damageDisplays.Count > 0) { ReuseOldestDamageDisplay(); } if (availableDisplays.Count != 0) { DamageDisplay damageDisplay = availableDisplays.Dequeue(); SetupDamageDisplay(damageDisplay, damage, color, isCritical); damageDisplays.Add(damageDisplay); RearrangeDamageDisplays(); } } private void ShowHealNumber(int healAmount) { if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldHealText(healAmount); return; } DamageDisplay damageDisplay = null; if (availableDisplays.Count > 0) { damageDisplay = availableDisplays.Dequeue(); } if (damageDisplay == null && damageDisplays.Count > 0) { for (int i = 0; i < damageDisplays.Count; i++) { DamageDisplay damageDisplay2 = damageDisplays[i]; if (damageDisplay2 != null && (Object)(object)damageDisplay2.gameObject != (Object)null && damageDisplay2.isActive) { damageDisplay = damageDisplay2; damageDisplays.RemoveAt(i); break; } } } if (damageDisplay == null) { CreateDamageDisplayObject(); if (availableDisplays.Count > 0) { damageDisplay = availableDisplays.Dequeue(); } } if (damageDisplay == null || (Object)(object)damageDisplay.gameObject == (Object)null) { DebugLog.LogDebug("无法获取有效的伤害显示对象,跳过治疗显示"); return; } SetupHealDisplay(damageDisplay, healAmount); damageDisplays.Add(damageDisplay); RearrangeDamageDisplays(); } private void ReuseOldestDamageDisplay() { if (damageDisplays.Count == 0) { return; } DamageDisplay damageDisplay = null; int num = -1; for (int i = 0; i < damageDisplays.Count; i++) { DamageDisplay damageDisplay2 = damageDisplays[i]; if (damageDisplay2 != null && (Object)(object)damageDisplay2.gameObject != (Object)null) { damageDisplay = damageDisplay2; num = i; break; } } if (damageDisplay != null && num >= 0) { damageDisplays.RemoveAt(num); if (damageDisplay.gameObject.activeSelf) { damageDisplay.gameObject.SetActive(false); } damageDisplay.isActive = false; damageDisplay.displayTime = 0f; damageDisplay.fadeOutTime = 0f; if ((Object)(object)damageDisplay.canvasGroup != (Object)null) { damageDisplay.canvasGroup.alpha = 1f; } availableDisplays.Enqueue(damageDisplay); } } private void SetupDamageDisplay(DamageDisplay display, int damage, Color color, bool isCritical = false) { //IL_0046: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)display.textComponent == (Object)null)) { display.textComponent.text = (isCritical ? $"-{damage}" : $"-{damage}"); ((Graphic)display.textComponent).color = color; display.textComponent.fontSize = HealthBarConfigManager.Instance.DamageFontSize; Shadow component = ((Component)display.textComponent).GetComponent<Shadow>(); if ((Object)(object)component != (Object)null) { component.effectColor = new Color(color.r * 0.4f, color.g * 0.4f, color.b * 0.4f, 0.8f); component.effectDistance = new Vector2(2f, -2f); } RectTransform component2 = display.gameObject.GetComponent<RectTransform>(); component2.anchoredPosition = Vector2.zero; ((Transform)component2).localScale = display.originalScale; display.canvasGroup.alpha = 1f; display.displayTime = HealthBarConfigManager.Instance.DamageDuration; display.fadeOutTime = HealthBarConfigManager.Instance.DamageFadeOut; display.isActive = true; display.targetLocalPosition = Vector2.op_Implicit(Vector2.zero); display.gameObject.SetActive(true); } } private void SetupHealDisplay(DamageDisplay display, int healAmount) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (display == null) { DebugLog.LogError("HealDisplay: display is null!"); return; } if ((Object)(object)display.gameObject == (Object)null) { DebugLog.LogError("HealDisplay: display.gameObject is null!"); return; } if ((Object)(object)display.textComponent == (Object)null) { DebugLog.LogDebug("HealDisplay textComponent is null, attempting to recreate..."); display.textComponent = display.gameObject.GetComponentInChildren<Text>(); if ((Object)(object)display.textComponent == (Object)null) { display.textComponent = CreateDamageText(display.gameObject); } } if ((Object)(object)display.textComponent == (Object)null) { DebugLog.LogError("HealDisplay: Failed to get or create textComponent!"); return; } if ((Object)(object)display.canvasGroup == (Object)null) { display.canvasGroup = display.gameObject.GetComponent<CanvasGroup>(); if ((Object)(object)display.canvasGroup == (Object)null) { display.canvasGroup = display.gameObject.AddComponent<CanvasGroup>(); } } display.textComponent.text = $"+{healAmount}"; ((Graphic)display.textComponent).color = new Color(0.3f, 1f, 0.3f, 1f); Shadow component = ((Component)display.textComponent).GetComponent<Shadow>(); if ((Object)(object)component != (Object)null) { component.effectColor = new Color(0f, 0.4f, 0f, 0.8f); } RectTransform component2 = display.gameObject.GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.anchoredPosition = Vector2.zero; } display.canvasGroup.alpha = 1f; display.gameObject.transform.localScale = display.originalScale; display.displayTime = HealthBarConfigManager.Instance.DamageDuration; display.fadeOutTime = HealthBarConfigManager.Instance.DamageFadeOut; display.isActive = true; display.targetLocalPosition = Vector2.op_Implicit(Vector2.zero); display.gameObject.SetActive(true); } private void UpdateDamageDisplays() { if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { return; } for (int num = damageDisplays.Count - 1; num >= 0; num--) { DamageDisplay damageDisplay = damageDisplays[num]; if (damageDisplay == null || (Object)(object)damageDisplay.gameObject == (Object)null || !damageDisplay.isActive) { damageDisplays.RemoveAt(num); } else { UpdateDamageDisplayPosition(damageDisplay); UpdateDamageDisplayTiming(damageDisplay, num); } } if (damageDisplays.Count > 0) { RearrangeDamageDisplays(); } } public void ShowDamage(HitInstance hit) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (hit.DamageDealt > 0) { int damageDealt = hit.DamageDealt; Color damageColor = GetDamageColor(hit); if (hit.CriticalHit) { ((Color)(ref damageColor))..ctor(1f, 0.85f, 0.3f, 1f); } if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldDamageText(damageDealt, damageColor, hit.CriticalHit); } else { ShowDamageNumber(damageDealt, damageColor, hit.CriticalHit); } PlayBorderFlash(); deltaHandledThisFrame = true; lastHpSnapshot = (((Object)(object)healthManager != (Object)null) ? healthManager.hp : (lastHpSnapshot - damageDealt)); } } public void ShowHeal(int amount) { if (amount <= 0) { return; } if ((Object)(object)healthManager == (Object)null) { DebugLog.LogDebug("HealthManager为空,跳过治疗显示"); return; } try { if (HealthBarConfigManager.Instance.GetStyle(isBoss) == "Simple") { SpawnWorldHealText(amount); } else { ShowHealNumber(amount); } PlayHealFlash(); deltaHandledThisFrame = true; if ((Object)(object)healthManager != (Object)null) { lastHpSnapshot = healthManager.hp; } else { lastHpSnapshot += amount; } } catch (Exception ex) { DebugLog.LogError("ShowHeal出错: " + ex.Message); } } private Color GetDamageColor(HitInstance hit) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected I4, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) AttackTypes attackType = hit.AttackType; DebugLog.LogDebug($"[HealthBar] GetDamageColor type={attackType}"); switch (attackType - 1) { case 1: return new Color(0.8f, 0.5f, 1f, 1f); case 2: case 3: case 4: return new Color(0.4f, 1f, 0.4f, 1f); case 7: case 10: case 18: return new Color(1f, 0.55f, 0.25f, 1f); case 8: return new Color(0.4f, 0.7f, 1f, 1f); case 5: case 9: return new Color(0.6f, 0.35f, 0.9f, 1f); case 6: return new Color(0.5f, 0.85f, 1f, 1f); case 15: return Color.white; case 0: return Color.gray; default: return new Color(1f, 0.6f, 0.6f, 1f); } } private void UpdateDamageDisplayPosition(DamageDisplay display) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (display != null && !((Object)(object)display.gameObject == (Object)null)) { RectTransform component = display.gameObject.GetComponent<RectTransform>(); if (!((Object)(object)component == (Object)null)) { component.anchoredPosition = Vector2.Lerp(component.anchoredPosition, Vector2.op_Implicit(display.targetLocalPosition), Time.deltaTime * display.moveSpeed); } } } private void UpdateDamageDisplayTiming(DamageDisplay display, int index) { if (display == null || (Object)(object)display.gameObject == (Object)null || !display.gameObject.activeSelf) { RemoveDamageDisplay(display, index); return; } display.displayTime -= Time.deltaTime; if (display.displayTime <= 0f) { display.fadeOutTime -= Time.deltaTime; if (display.fadeOutTime <= 0f) { RemoveDamageDisplay(display, index); } else { display.canvasGroup.alpha = Mathf.Clamp01(display.fadeOutTime / HealthBarConfigManager.Instance.DamageFadeOut); } } } private void RemoveDamageDisplay(DamageDisplay display, int index) { if ((Object)(object)display.gameObject != (Object)null) { display.gameObject.SetActive(false); display.isActive = false; if ((Object)(object)display.textComponent != (Object)null) { display.textComponent.text = ""; } if ((Object)(object)display.canvasGroup != (Object)null) { display.canvasGroup.alpha = 1f; } } if (index >= 0 && index < damageDisplays.Count) { damageDisplays.RemoveAt(index); } availableDisplays.Enqueue(display); } private void RearrangeDamageDisplays() { //IL_005e: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_007a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < damageDisplays.Count; i++) { DamageDisplay damageDisplay = damageDisplays[i]; if (damageDisplay.isActive) { int num = damageDisplays.Count - 1 - i; float num2 = (float)num * HealthBarConfigManager.Instance.DamageSpacingY; float num3 = Mathf.Max(0.7f, 1f - (float)num * 0.05f); damageDisplay.targetLocalPosition = Vector2.op_Implicit(new Vector2(0f, num2)); Vector3 val = damageDisplay.originalScale * num3; damageDisplay.gameObject.transform.localScale = Vector3.Lerp(damageDisplay.gameObject.transform.localScale, val, Time.deltaTime * 5f); } } } private void UpdateHealthBarPosition() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)healthBarUI == (Object)null) && !((Object)(object)healthManager == (Object)null)) { Vector3 val = CalculatePosition(); if (val != Vector3.zero) { ApplyPosition(val); } } } private Vector3 CalculatePosition() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = Vector3.zero; bool flag = false; if ((Object)(object)Tk2dSprite != (Object)null) { flag = TryGetTk2dSpritePosition(ref position); } if (!flag && (Object)(object)collider2D != (Object)null) { flag = TryGetColliderPosition(ref position); } if (!flag) { return Vector3.zero; } return position; } private bool TryGetTk2dSpritePosition(ref Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) try { Bounds bounds = ((tk2dBaseSprite)Tk2dSprite).GetBounds(); ((Component)this).transform.TransformPoint(((Bounds)(ref bounds)).min); Vector3 val = ((Component)this).transform.TransformPoint(((Bounds)(ref bounds)).max); position = new Vector3(((Component)this).transform.position.x, val.y, ((Component)this).transform.position.z); return true; } catch (Exception ex) { DebugLog.LogDebug("tk2dSprite 边界计算失败: " + ex.Message); return false; } } private bool TryGetColliderPosition(ref Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = collider2D.bounds; float y = ((Bounds)(ref bounds)).max.y; position = new Vector3(((Component)this).transform.position.x, y + 0.2f, ((Component)this).transform.position.z); return true; } private void ApplyPosition(Vector3 targetPosition) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b4: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)healthBarUI == (Object)null)) { Vector3 position = healthBarUI.transform.position; Vector3 val = CalculateClampedPosition(targetPosition); float num = val.x - position.x; float num2 = val.y - position.y; if (Mathf.Abs(num) < HealthBarConfigManager.Instance.JitterX) { val.x = position.x; } if (Mathf.Abs(num2) < HealthBarConfigManager.Instance.JitterY) { val.y = position.y; } Vector3 val2 = Vector3.Lerp(position, val, Time.deltaTime * HealthBarConfigManager.Instance.PosSmooth); healthBarUI.transform.position = val2; healthBarUI.transform.rotation = Quaternion.identity; if ((Object)(object)healthTextCanvas != (Object)null) { float num3 = CalculateHealthBarWorldHeight() + HealthBarConfigManager.Instance.TextGap * healthBarUI.transform.localScale.y; healthTextCanvas.transform.position = val2 + new Vector3(0f, num3, 0f); healthTextCanvas.transform.rotation = Quaternion.identity; } } } private float CalculateHealthBarWorldHeight() { if ((Object)(object)healthBarUI == (Object)null) { return 0f; } float height = HealthBarConfigManager.Instance.GetHeight(isBoss); float scale = HealthBarConfigManager.Instance.GetScale(isBoss); return height * scale; } private Vector3 CalculateClampedPosition(Vector3 targetPosition) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_005e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Camera.main == (Object)null) { return targetPosition; } try { Vector3 val = Camera.main.WorldToViewportPoint(targetPosition); float edgeMarginTop = HealthBarConfigManager.Instance.EdgeMarginTop; float edgeMarginBottom = HealthBarConfigManager.Instance.EdgeMarginBottom; float edgeMarginSide = HealthBarConfigManager.Instance.EdgeMarginSide; if (val.x < edgeMarginSide || val.x > 1f - edgeMarginSide || val.y < edgeMarginBottom || val.y > 1f - edgeMarginTop) { val.x = Mathf.Clamp(val.x, edgeMarginSide, 1f - edgeMarginSide); val.y = Mathf.Clamp(val.y, edgeMarginBottom, 1f - edgeMarginTop); Vector3 result = Camera.main.ViewportToWorldPoint(val); float num = CalculateHealthBarWorldHeight(); result.y += num * 0.5f; return result; } return targetPosition; } catch (Exception ex) { DebugLog.LogError("屏幕边界检测失败: " + ex.Message); return targetPosition; } } private void CheckOffscreenDestroy() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (m