From 0713673af41f9661619588e2d5f1abd567a6458b Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 19 十一月 2025 15:21:30 +0800
Subject: [PATCH] 125 战斗 修复因为死亡动作被中断导致的战斗卡死

---
 Main/System/Battle/Motion/MotionBase.cs |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index 3a21f7c..9539668 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -105,6 +105,41 @@
         return currentTrack;
     }
 
+    public virtual Spine.TrackEntry PlayDeadAnimation(Action onComplete = null)
+    {
+        if (animState == null) return null;
+        
+        // 浣跨敤杞ㄩ亾9浣滀负姝讳骸鍔ㄧ敾涓撶敤杞ㄩ亾锛堢嫭绔嬩簬涓昏建閬�0鍜屽瓙鎶�鑳借建閬�1-8锛�
+        const int deathTrackIndex = 9;
+        
+        // 娓呴櫎姝讳骸杞ㄩ亾涓婄殑鍥炶皟
+        if (activeSkillTracks.TryGetValue(deathTrackIndex, out var oldDeathTrack))
+        {
+            if (trackEntryCallbacks.ContainsKey(oldDeathTrack))
+                trackEntryCallbacks.Remove(oldDeathTrack);
+        }
+        
+        Spine.Animation deadAnim = FindAnim(MotionName.dead.ToString());
+        if (deadAnim == null)
+        {
+            Debug.LogError("鎵句笉鍒版浜″姩鐢�");
+            onComplete?.Invoke();
+            return null;
+        }
+        
+        Spine.TrackEntry deathTrack = animState.SetAnimation(deathTrackIndex, deadAnim, false);
+        
+        if (deathTrack != null)
+        {
+            activeSkillTracks[deathTrackIndex] = deathTrack;
+            
+            if (onComplete != null)
+                trackEntryCallbacks[deathTrack] = onComplete;
+        }
+        
+        return deathTrack;
+    }
+
     private void AddAction(Action action) => runningActions.Add(action);
     private void RemoveAction(Action action) => runningActions.Remove(action);
 

--
Gitblit v1.8.0