From ed4312ff529fd56bad20ef15eeeb1a7e45051ae3 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 04 六月 2026 18:04:26 +0800
Subject: [PATCH] 花鬘复活卡死问题修复
---
Main/System/Battle/Motion/MotionBase.cs | 69 +++++++++
Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs | 266 +++++++++++++++++++++++++++++++++++++
Main/System/Battle/BattleObject/HeroBattleObject.cs | 30 ++++
Main/System/Battle/Skill/SkillBase.Finish.cs | 28 ++--
Main/System/Battle/Skill/SkillBase.Cast.cs | 16 +-
5 files changed, 376 insertions(+), 33 deletions(-)
diff --git a/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
index 772fa97..6a544c5 100644
--- a/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
+++ b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
@@ -24,6 +24,12 @@
private SkillRecordAction playSkillRecordAction = null;
+#if UNITY_EDITOR
+ private int deathDebugNotFinishedCount = 0;
+ private const int DeathDebugFirstDumpCount = 120;
+ private const int DeathDebugRepeatDumpCount = 180;
+#endif
+
public DeathRecordAction(BattleField _battleField, List<BattleDeadPack> _deadPackList, SkillRecordAction _parentSkillAction = null, SkillRecordAction _playSkillRecordAction = null)
: base(RecordActionType.Death, _battleField, null)
{
@@ -68,6 +74,10 @@
{
isRunOnce = true;
+#if UNITY_EDITOR
+ // DumpDeathDebugState("棣栨Run");
+#endif
+
SkillRecordAction waitingAnimeAction = playSkillRecordAction;
foreach (var battleDeadPack in deadPackList)
@@ -78,6 +88,10 @@
if (null != skillAction)
{
deathActionDict.Add(battleDeadPack, skillAction);
+
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒涘缓姝讳骸瑙﹀彂鎶�鑳� {FormatDeadPackForDebug(battleDeadPack)} -> {FormatSkillActionForDebug(skillAction)} waitingAnimeAction={(waitingAnimeAction == null ? "null" : FormatSkillActionForDebug(waitingAnimeAction))}");
+#endif
// 銆愪娇鐢� BattleField.recordPlayer銆�
// 鍘熷洜锛氭浜¤Е鍙戞妧鑳芥槸椤跺眰鐨凴ecordAction锛屼笉鏄湪鏌愪釜RecordAction鍐呴儴浜х敓鐨�
@@ -99,9 +113,18 @@
waitingAnimeAction = skillAction;
}
}
+#if UNITY_EDITOR
+ else
+ {
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸瑙﹀彂鎶�鑳藉垱寤哄け璐� {FormatDeadPackForDebug(battleDeadPack)}");
+ }
+#endif
}
else
{
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒涘缓鏅�氭浜$姸鎬� {FormatDeadPackForDebug(battleDeadPack)}");
+#endif
deadActionStatesDict.Add(battleDeadPack, CreateDeadActionState(battleDeadPack));
}
}
@@ -149,6 +172,10 @@
}
}
+#if UNITY_EDITOR
+ // ReportDeathNotFinishedIfNeeded(completeNum);
+#endif
+
if (completeNum == deadPackList.Count)
{
// 姝讳骸澶勭悊瀹屾垚鍚庯紝鍒嗗彂姝讳骸鍚庣殑鍖�
@@ -177,12 +204,46 @@
BattleObject deadObj = battleField.battleObjMgr.GetBattleObject((int)deadPack.deadPack.ObjID);
if (null == deadObj)
{
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸瀵硅薄涓嶅瓨鍦紝鐩存帴瑙嗕负瀹屾垚 {FormatDeadPackForDebug(deadPack)}");
+#endif
return () => true;
}
+
+ if (deadObj.IsReborning())
+ {
+ #if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒涘缓姝讳骸鐘舵�佹椂瀵硅薄宸插湪澶嶆椿娴佺▼锛岀洿鎺ヨ涓哄畬鎴� {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+ #endif
+ return () => true;
+ }
+
+ if (deadObj.GetCurHp() > 0)
+ {
+ #if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒涘缓姝讳骸鐘舵�佹椂瀵硅薄琛�閲忓凡鍥炴锛岀洿鎺ヨ涓哄畬鎴� {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+ #endif
+ return () => true;
+ }
+
+ if (deadObj.IsDead())
+ {
+ #if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒涘缓姝讳骸鐘舵�佹椂瀵硅薄宸叉浜★紝鐩存帴瑙嗕负瀹屾垚 {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+ #endif
+ return () => true;
+ }
bool playDeath = false;
bool isComplete = false;
+
+#if UNITY_EDITOR
+ bool loggedWaitingCanStartDeath = false;
+ bool loggedReborningComplete = false;
+ bool loggedHpRestoredComplete = false;
+ bool loggedAlreadyDeadComplete = false;
+#endif
// 濡傛灉娌℃湁閲婃斁鎶�鑳� 鍒欑洿鎺ユ浜�
if (deadObj.CanStartDeath())
@@ -191,10 +252,23 @@
deadObj.OnDeath(() => {
isComplete = true;
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸鍔ㄧ敾鍥炶皟瀹屾垚 {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+#endif
}, withoutAnime);
playDeath = true;
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 寮�濮嬫挱鏀炬浜¤〃鐜� {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+#endif
}
+#if UNITY_EDITOR
+ else
+ {
+ loggedWaitingCanStartDeath = true;
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鏆備笉鑳芥挱鏀炬浜¤〃鐜帮紝绛夊緟 CanStartDeath {FormatDeadPackForDebug(deadPack)} deadObj.CanStartDeath={deadObj.CanStartDeath()} isReborning={deadObj.IsReborning()} isDead={deadObj.IsDead()}");
+ }
+#endif
@@ -207,14 +281,58 @@
deadObj.OnDeath(() => {
isComplete = true;
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 寤惰繜姝讳骸鍔ㄧ敾鍥炶皟瀹屾垚 {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+#endif
}, withoutAnime);
playDeath = true;
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 寤惰繜寮�濮嬫挱鏀炬浜¤〃鐜� {FormatDeadPackForDebug(deadPack)} withoutAnime={withoutAnime}");
+#endif
}
+#if UNITY_EDITOR
+ else if (!playDeath && !loggedWaitingCanStartDeath)
+ {
+ loggedWaitingCanStartDeath = true;
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 浠嶄笉鑳芥挱鏀炬浜¤〃鐜帮紝绛夊緟 CanStartDeath {FormatDeadPackForDebug(deadPack)} deadObj.CanStartDeath={deadObj.CanStartDeath()} isReborning={deadObj.IsReborning()} isDead={deadObj.IsDead()}");
+ }
+#endif
if (deadObj.IsReborning())
{
isComplete = true;
+#if UNITY_EDITOR
+ if (!loggedReborningComplete)
+ {
+ loggedReborningComplete = true;
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸瀵硅薄宸茶繘鍏ュ娲绘祦绋嬶紝姝讳骸鐘舵�佽涓哄畬鎴� {FormatDeadPackForDebug(deadPack)}");
+ }
+#endif
+ }
+
+ if (!isComplete && deadObj.GetCurHp() > 0)
+ {
+ isComplete = true;
+#if UNITY_EDITOR
+ if (!loggedHpRestoredComplete)
+ {
+ loggedHpRestoredComplete = true;
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸瀵硅薄琛�閲忓凡鍥炴锛屾浜$姸鎬佽涓哄畬鎴� {FormatDeadPackForDebug(deadPack)}");
+ }
+#endif
+ }
+
+ if (!isComplete && deadObj.IsDead())
+ {
+ isComplete = true;
+#if UNITY_EDITOR
+ if (!loggedAlreadyDeadComplete)
+ {
+ loggedAlreadyDeadComplete = true;
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 姝讳骸瀵硅薄宸插浜庢浜$姸鎬侊紝姝讳骸鐘舵�佽涓哄畬鎴� {FormatDeadPackForDebug(deadPack)}");
+ }
+#endif
}
return isComplete;
@@ -284,18 +402,19 @@
// 閬嶅巻鎵�鏈夋浜″寘锛屽垎鍙戝畠浠殑 packListAfterDeath
foreach (var deadPack in deadPackList)
{
+#if UNITY_EDITOR
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍑嗗鍒嗗彂姝讳骸鍚庡寘 {FormatDeadPackForDebug(deadPack)} afterDeathCount={deadPack.packListAfterDeath?.Count ?? 0}");
+#endif
if (deadPack.packListAfterDeath != null && deadPack.packListAfterDeath.Count > 0)
{
foreach (var pack in deadPack.packListAfterDeath)
{
// 鑾峰彇鍖呯殑绫诲瀷鍜孶ID鐢ㄤ簬璋冭瘯
+#if UNITY_EDITOR
string packType = pack.GetType().Name;
- ulong packUID = 0;
- var packUIDField = pack.GetType().GetField("packUID");
- if (packUIDField != null)
- {
- packUID = (ulong)packUIDField.GetValue(pack);
- }
+ ulong packUID = GetPackUIDForDebug(pack);
+ // BattleDebug.LogError($"[DeathRecordAction璇婃柇] 鍒嗗彂姝讳骸鍚庡寘 objId={GetDeadObjIdForDebug(deadPack)} packType={packType} packUID={packUID} playSkillRecordAction={(playSkillRecordAction == null ? "null" : FormatSkillActionForDebug(playSkillRecordAction))}");
+#endif
// 鐗规畩澶勭悊 CustomHB426CombinePack锛氫娇鐢ㄥ叾鑷繁鐨� Distribute 鏂规硶
@@ -379,6 +498,141 @@
}
#if UNITY_EDITOR
+ private void ReportDeathNotFinishedIfNeeded(int completeNum)
+ {
+ if (isFinish || isActionCompleted)
+ {
+ deathDebugNotFinishedCount = 0;
+ return;
+ }
+
+ deathDebugNotFinishedCount++;
+ bool firstDump = deathDebugNotFinishedCount == DeathDebugFirstDumpCount;
+ bool repeatDump = deathDebugNotFinishedCount > DeathDebugFirstDumpCount
+ && (deathDebugNotFinishedCount - DeathDebugFirstDumpCount) % DeathDebugRepeatDumpCount == 0;
+ if (!firstDump && !repeatDump)
+ {
+ return;
+ }
+
+ DumpDeathDebugState($"鏈畬鎴� completeNum={completeNum}/{deadPackList.Count} checkCount={deathDebugNotFinishedCount}");
+ }
+
+ private void DumpDeathDebugState(string reason)
+ {
+ var sb = new System.Text.StringBuilder();
+ sb.Append($"[DeathRecordAction璇婃柇] {reason} actionID={actionID} ");
+ sb.Append($"deadPackList.Count={deadPackList?.Count ?? 0} ");
+ sb.Append($"deathActionDict.Count={deathActionDict.Count} ");
+ sb.Append($"deadActionStatesDict.Count={deadActionStatesDict.Count} ");
+ sb.Append($"hasDeathTriggerSkill={hasDeathTriggerSkill} ");
+ sb.Append($"hasDistributedPacksAfterDeath={hasDistributedPacksAfterDeath} ");
+ sb.Append($"parentSkillAction={(parentSkillAction == null ? "null" : FormatSkillActionForDebug(parentSkillAction))} ");
+ sb.Append($"playSkillRecordAction={(playSkillRecordAction == null ? "null" : FormatSkillActionForDebug(playSkillRecordAction))}");
+
+ if (deadPackList != null)
+ {
+ for (int i = 0; i < deadPackList.Count; i++)
+ {
+ BattleDeadPack deadPack = deadPackList[i];
+ sb.Append("\n [").Append(i).Append("] ").Append(FormatDeadPackForDebug(deadPack));
+ if (deathActionDict.TryGetValue(deadPack, out var skillAction))
+ {
+ sb.Append(" deathSkill=").Append(FormatSkillActionForDebug(skillAction));
+ }
+ sb.Append(" hasState=").Append(deadActionStatesDict.ContainsKey(deadPack));
+ }
+ }
+
+ // BattleDebug.LogError(sb.ToString());
+ }
+
+ private string FormatDeadPackForDebug(BattleDeadPack deadPack)
+ {
+ ulong objId = GetDeadObjIdForDebug(deadPack);
+ BattleObject deadObj = null;
+ if (battleField != null && battleField.battleObjMgr != null && objId > 0)
+ {
+ deadObj = battleField.battleObjMgr.GetBattleObject((int)objId);
+ }
+
+ string objName = deadObj?.GetName() ?? "null";
+ bool canStartDeath = deadObj != null && deadObj.CanStartDeath();
+ bool isReborning = deadObj != null && deadObj.IsReborning();
+ bool isDead = deadObj != null && deadObj.IsDead();
+ long curHp = deadObj != null ? deadObj.GetCurHp() : 0;
+ int afterDeathCount = deadPack?.packListAfterDeath?.Count ?? 0;
+ string triggerTag = deadPack?.deadTriggerSkill?.startTag?.Tag ?? "null";
+
+ return $"objId={objId} name={objName} hp={curHp} isDead={isDead} canStartDeath={canStartDeath} isReborning={isReborning} hasDeadTriggerSkill={deadPack?.deadTriggerSkill != null} triggerTag={triggerTag} isPlaySkill={deadPack?.isPlaySkill ?? false} afterDeathCount={afterDeathCount}";
+ }
+
+ private ulong GetDeadObjIdForDebug(BattleDeadPack deadPack)
+ {
+ if (deadPack == null || deadPack.deadPack == null)
+ {
+ return 0;
+ }
+ return deadPack.deadPack.ObjID;
+ }
+
+ private string FormatSkillActionForDebug(SkillRecordAction skillAction)
+ {
+ if (skillAction == null)
+ {
+ return "null";
+ }
+
+ SkillBase skillBase = skillAction.skillBase;
+ if (skillBase == null)
+ {
+ return $"SkillRecordAction(actionID={skillAction.actionID}, skillBase=null)";
+ }
+
+ int skillId = skillBase.skillConfig != null ? skillBase.skillConfig.SkillID : 0;
+ ulong casterId = skillBase.tagUseSkillAttack != null ? skillBase.tagUseSkillAttack.ObjID : 0;
+ return $"SkillRecordAction(actionID={skillAction.actionID}, skillId={skillId}, caster={casterId}, StateFlags={skillBase.StateFlagsForDebug}, IsActionCompleted={skillAction.IsActionCompleted()})";
+ }
+
+ private ulong GetPackUIDForDebug(GameNetPackBasic pack)
+ {
+ if (pack == null)
+ {
+ return 0;
+ }
+
+ if (pack is HB422_tagMCTurnFightObjDead deadPack)
+ {
+ return deadPack.packUID;
+ }
+
+ if (pack is CustomHB426CombinePack combinePack)
+ {
+ return combinePack.packUID;
+ }
+
+ var packUIDField = pack.GetType().GetField("packUID");
+ if (packUIDField == null)
+ {
+ return 0;
+ }
+
+ object value = packUIDField.GetValue(pack);
+ if (value is ulong ulongValue)
+ {
+ return ulongValue;
+ }
+ if (value is uint uintValue)
+ {
+ return uintValue;
+ }
+ if (value is int intValue)
+ {
+ return (ulong)intValue;
+ }
+ return 0;
+ }
+
/// <summary>
/// 棣栨杩愯鏃舵墦鍗版棩蹇楋紙浠呯紪杈戝櫒锛�
/// 鎵撳嵃姝讳骸瀵硅薄鐨勫悕瀛�
diff --git a/Main/System/Battle/BattleObject/HeroBattleObject.cs b/Main/System/Battle/BattleObject/HeroBattleObject.cs
index feceba8..c02b288 100644
--- a/Main/System/Battle/BattleObject/HeroBattleObject.cs
+++ b/Main/System/Battle/BattleObject/HeroBattleObject.cs
@@ -476,6 +476,12 @@
public override void OnDeath(Action _onDeathAnimationComplete, bool withoutAnime = false)
{
+#if UNITY_EDITOR
+ if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
+ {
+ // BattleDebug.LogError($"[HeroBattleObject姝讳骸璇婃柇] OnDeath objId={ObjID} name={GetName()} hp={GetCurHp()} isDead={IsDead()} isReborning={IsReborning()} withoutAnime={withoutAnime} motionHash={motionBase?.GetHashCode() ?? 0}");
+ }
+#endif
buffMgr.RemoveAllBuff();
battleField.soundManager.PlayEffectSound(teamHero.heroConfig.DeathSFX, false);
if (withoutAnime)
@@ -487,6 +493,12 @@
{
motionBase.PlayDeadAnimation(() =>
{
+#if UNITY_EDITOR
+ if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
+ {
+ // BattleDebug.LogError($"[HeroBattleObject姝讳骸璇婃柇] 姝讳骸鍔ㄧ敾鍥炶皟 objId={ObjID} name={GetName()} hp={GetCurHp()} isDead={IsDead()} isReborning={IsReborning()} motionHash={motionBase?.GetHashCode() ?? 0}");
+ }
+#endif
SetDeath();
_onDeathAnimationComplete?.Invoke();
});
@@ -511,6 +523,12 @@
// 閲婃斁鑰呭氨鏄娲昏�呮椂璋冪敤
public override void PreReborn(bool reviveSelf = false)
{
+#if UNITY_EDITOR
+ if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
+ {
+ // BattleDebug.LogError($"[HeroBattleObject姝讳骸璇婃柇] PreReborn objId={ObjID} name={GetName()} hp={GetCurHp()} isDead={IsDead()} isReborning={IsReborning()} reviveSelf={reviveSelf} motionHash={motionBase?.GetHashCode() ?? 0}");
+ }
+#endif
heroGo.SetActive(true);
motionBase.skeletonAnim.skeleton.A = 0f;
motionBase.skeletonAnim.LateUpdate();
@@ -521,6 +539,12 @@
// 澶嶆椿action
public override void OnReborn(HB427_tagSCUseSkill.tagSCUseSkillHurt vNetData, bool reviveSelf = false, RecordAction parentAction = null)
{
+#if UNITY_EDITOR
+ if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
+ {
+ // BattleDebug.LogError($"[HeroBattleObject姝讳骸璇婃柇] OnReborn objId={ObjID} name={GetName()} hp={GetCurHp()} isDead={IsDead()} isReborning={IsReborning()} reviveSelf={reviveSelf} motionHash={motionBase?.GetHashCode() ?? 0}");
+ }
+#endif
isReborning = true;
heroGo.SetActive(true);
motionBase.ResetForReborn(reviveSelf);
@@ -531,6 +555,12 @@
public override void AfterReborn()
{
+#if UNITY_EDITOR
+ if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
+ {
+ // BattleDebug.LogError($"[HeroBattleObject姝讳骸璇婃柇] AfterReborn objId={ObjID} name={GetName()} hp={GetCurHp()} isDead={IsDead()} isReborning={IsReborning()} motionHash={motionBase?.GetHashCode() ?? 0}");
+ }
+#endif
// 娓呯┖鎵�鏈�
motionBase.ResetForReborn(false);
isReborning = false;
diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index 1a1c31d..94e5564 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -63,8 +63,8 @@
{
string owner = skeletonAnim != null && skeletonAnim.gameObject != null ? skeletonAnim.gameObject.name : "(no-skel)";
// 姣忔鍙樻洿鎵撳嵃鏍堬紝瀹氫綅鍒板簳鏄皝鎶� playingSkillWithAnim 璁� true 浜嗐�佽皝娓�/涓嶆竻
- BattleDebug.LogError($"[MotionBase owner={owner} hash={GetHashCode()}] playingSkillWithAnim {_playingSkillWithAnim} -> {value}\n"
- + UnityEngine.StackTraceUtility.ExtractStackTrace());
+ // BattleDebug.LogError($"[MotionBase owner={owner} hash={GetHashCode()}] playingSkillWithAnim {_playingSkillWithAnim} -> {value}\n"
+ // + UnityEngine.StackTraceUtility.ExtractStackTrace());
}
// [鍗℃璇婃柇] 缁存姢閿佺殑鎸佹湁鑰呬俊鎭紙涓婁竴杞殑瀛楁琚洖婊氫簡锛岃繖閲屾槸鏈�灏忓繀瑕侀泦鍚堬級
if (value && !_playingSkillWithAnim)
@@ -161,7 +161,14 @@
public virtual Spine.TrackEntry PlayDeadAnimation(Action onComplete = null)
{
- if (animState == null) return null;
+ if (animState == null)
+ {
+#if UNITY_EDITOR
+ LogDeathTrackDebug("PlayDeadAnimation animState=null锛岀洿鎺ュ畬鎴愭浜″洖璋�", null, false);
+#endif
+ onComplete?.Invoke();
+ return null;
+ }
// 浣跨敤杞ㄩ亾9浣滀负姝讳骸鍔ㄧ敾涓撶敤杞ㄩ亾锛堢嫭绔嬩簬涓昏建閬�0鍜屽瓙鎶�鑳借建閬�1-8锛�
@@ -169,7 +176,12 @@
if (activeSkillTracks.TryGetValue(DeathTrackIndex, out var oldDeathTrack))
{
if (trackEntryCallbacks.ContainsKey(oldDeathTrack))
+ {
+#if UNITY_EDITOR
+ LogDeathTrackDebug("PlayDeadAnimation 鏇挎崲鏃ф浜¤建閬擄紝绉婚櫎鏃у洖璋�", oldDeathTrack, true);
+#endif
trackEntryCallbacks.Remove(oldDeathTrack);
+ }
}
Spine.Animation deadAnim = FindAnim(MotionName.dead.ToString());
@@ -189,9 +201,42 @@
if (onComplete != null)
trackEntryCallbacks[deathTrack] = onComplete;
}
+#if UNITY_EDITOR
+ LogDeathTrackDebug("PlayDeadAnimation 鍒涘缓姝讳骸杞ㄩ亾", deathTrack, onComplete != null && deathTrack != null);
+#endif
+
+ if (deathTrack == null)
+ {
+ onComplete?.Invoke();
+ }
return deathTrack;
}
+
+#if UNITY_EDITOR
+ private void LogDeathTrackDebug(string reason, Spine.TrackEntry trackEntry, bool hasCallback)
+ {
+ if (Launch.Instance == null || !Launch.Instance.isOpenBattleDebug)
+ {
+ return;
+ }
+
+ string owner = skeletonAnim != null && skeletonAnim.gameObject != null ? skeletonAnim.gameObject.name : "(no-skel)";
+ // BattleDebug.LogError($"[MotionBase姝讳骸璇婃柇] {reason} owner={owner} hash={GetHashCode()} track={FormatTrackForDebug(trackEntry)} hasCallback={hasCallback} callbacks={trackEntryCallbacks.Count} activeSkillTracks={activeSkillTracks.Count}");
+ }
+
+ private string FormatTrackForDebug(Spine.TrackEntry trackEntry)
+ {
+ if (trackEntry == null)
+ {
+ return "null";
+ }
+
+ string animName = trackEntry.Animation != null ? trackEntry.Animation.Name : "(null)";
+ float duration = trackEntry.Animation != null ? trackEntry.Animation.Duration : -1f;
+ return $"hash={trackEntry.GetHashCode()} anim={animName} TrackTime={trackEntry.TrackTime:F3} duration={duration:F3} isComplete={trackEntry.IsComplete} timeScale={trackEntry.TimeScale}";
+ }
+#endif
private void AddAction(Action action) => runningActions.Add(action);
private void RemoveAction(Action action) => runningActions.Remove(action);
@@ -636,6 +681,13 @@
string animName = trackEntry.Animation.Name.ToLower();
+#if UNITY_EDITOR
+ if (animName == MotionName.dead.ToString().ToLower())
+ {
+ LogDeathTrackDebug("OnAnimationComplete 鏀跺埌姝讳骸鍔ㄧ敾瀹屾垚", trackEntry, trackEntryCallbacks.ContainsKey(trackEntry));
+ }
+#endif
+
if (AttackMotionList.Contains(animName))
{
OnAttackAnimationComplete?.Invoke();
@@ -734,7 +786,7 @@
if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
{
string owner = skeletonAnim != null && skeletonAnim.gameObject != null ? skeletonAnim.gameObject.name : "(no-skel)";
- BattleDebug.LogError($"[MotionBase.HaveRest owner={owner} hash={GetHashCode()}] 璋冪敤鏍堬細\n{UnityEngine.StackTraceUtility.ExtractStackTrace()}");
+ // BattleDebug.LogError($"[MotionBase.HaveRest owner={owner} hash={GetHashCode()}] 璋冪敤鏍堬細\n{UnityEngine.StackTraceUtility.ExtractStackTrace()}");
}
#endif
// 鍏堝己鍒剁粨鏉熸墍鏈夋鍦ㄨ繍琛岀殑 skillBase锛岄伩鍏嶆竻瀛楀吀鍚庤繖浜� skillBase 鐨� frameHandler 琚垹浣嗚嚜韬� StateFlags 姘歌繙鍋滃湪 Started
@@ -789,7 +841,14 @@
if (Launch.Instance != null && Launch.Instance.isOpenBattleDebug)
{
string owner = skeletonAnim != null && skeletonAnim.gameObject != null ? skeletonAnim.gameObject.name : "(no-skel)";
- BattleDebug.LogError($"[MotionBase.ResetForReborn owner={owner} hash={GetHashCode()}] reviveSelf={reviveSelf} 璋冪敤鏍堬細\n{UnityEngine.StackTraceUtility.ExtractStackTrace()}");
+ // BattleDebug.LogError($"[MotionBase.ResetForReborn owner={owner} hash={GetHashCode()}] reviveSelf={reviveSelf} 璋冪敤鏍堬細\n{UnityEngine.StackTraceUtility.ExtractStackTrace()}");
+ Spine.TrackEntry deathTrack = null;
+ bool hasDeathTrack = activeSkillTracks.TryGetValue(DeathTrackIndex, out deathTrack);
+ bool hasDeathCallback = hasDeathTrack && deathTrack != null && trackEntryCallbacks.ContainsKey(deathTrack);
+ if (hasDeathTrack || hasDeathCallback || trackEntryCallbacks.Count > 0)
+ {
+ // BattleDebug.LogError($"[MotionBase姝讳骸璇婃柇] ResetForReborn 鍗冲皢娓呯悊杞ㄩ亾 owner={owner} hash={GetHashCode()} reviveSelf={reviveSelf} hasDeathTrack={hasDeathTrack} hasDeathCallback={hasDeathCallback} callbacks={trackEntryCallbacks.Count} activeSkillTracks={activeSkillTracks.Count} deathTrack={FormatTrackForDebug(deathTrack)}");
+ }
}
#endif
// 璺� HaveRest 鍚岀悊锛氬厛寮哄埗缁撴潫鎵�鏈夋鍦ㄨ繍琛岀殑 skillBase锛�
diff --git a/Main/System/Battle/Skill/SkillBase.Cast.cs b/Main/System/Battle/Skill/SkillBase.Cast.cs
index 8d3ef90..c20f544 100644
--- a/Main/System/Battle/Skill/SkillBase.Cast.cs
+++ b/Main/System/Battle/Skill/SkillBase.Cast.cs
@@ -18,7 +18,7 @@
? caster.GetRectTransform().anchoredPosition : Vector2.zero;
bool casterTweening = caster != null && caster.GetRectTransform() != null
&& DG.Tweening.DOTween.IsTweening(caster.GetRectTransform());
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] Cast 鍏ュ彛 skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} castMode={skillSkinConfig?.castMode} anchoredPos={castEntryPos} casterTweening={casterTweening}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] Cast 鍏ュ彛 skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} castMode={skillSkinConfig?.castMode} anchoredPos={castEntryPos} casterTweening={casterTweening}");
}
#endif
// 骞挎挱鎶�鑳介噴鏀句簨浠�
@@ -175,13 +175,13 @@
private void ExecuteMoveAndCastSequence(RectTransform target, Action onReturnComplete)
{
#if UNITY_EDITOR
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] ExecuteMoveAndCastSequence 寮�濮� skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} CastDistance={skillSkinConfig?.CastDistance} castMode={skillSkinConfig?.castMode}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] ExecuteMoveAndCastSequence 寮�濮� skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} CastDistance={skillSkinConfig?.CastDistance} castMode={skillSkinConfig?.castMode}");
#endif
ShadowIllutionCreate(true);
MoveToTarget(target, new Vector2(skillSkinConfig.CastDistance, 0), () =>
{
#if UNITY_EDITOR
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] 鍓嶅啿瀹屾垚 skillId={skillConfig?.SkillID} caster={caster?.ObjID} 鍑嗗 CastImpl");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] 鍓嶅啿瀹屾垚 skillId={skillConfig?.SkillID} caster={caster?.ObjID} 鍑嗗 CastImpl");
#endif
if (skillSkinConfig.CastDistance < 9999 && skillSkinConfig.SkinllSFX2 != 0)
{
@@ -220,12 +220,12 @@
? caster.GetRectTransform().anchoredPosition : Vector2.zero;
bool mttTweening = caster != null && caster.GetRectTransform() != null
&& DG.Tweening.DOTween.IsTweening(caster.GetRectTransform());
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] MoveToTarget 鍏ュ彛 skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} CastDistance={skillSkinConfig?.CastDistance} offset={offset} speed={speed} fromPos={fromPos} casterTweening={mttTweening}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] MoveToTarget 鍏ュ彛 skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} CastDistance={skillSkinConfig?.CastDistance} offset={offset} speed={speed} fromPos={fromPos} casterTweening={mttTweening}");
#endif
if (skillSkinConfig.CastDistance >= 9999)
{
#if UNITY_EDITOR
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] CastDistance>=9999 鐩存帴璺宠繃绉诲姩 skillId={skillConfig?.SkillID} caster={caster?.ObjID}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] CastDistance>=9999 鐩存帴璺宠繃绉诲姩 skillId={skillConfig?.SkillID} caster={caster?.ObjID}");
#endif
_onComplete?.Invoke();
return;
@@ -238,14 +238,14 @@
Vector3 targetWorld = target != null ? target.position : Vector3.zero;
Vector3 targetLossyScale = target != null ? (Vector3)target.lossyScale : Vector3.one;
Vector2 targetAnchored = target != null ? target.anchoredPosition : Vector2.zero;
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] target淇℃伅 skillId={skillConfig?.SkillID} caster={caster?.ObjID} casterCamp={caster?.Camp} target.name={targetName} target.anchoredPos={targetAnchored} target.worldPos={targetWorld} target.lossyScale={targetLossyScale}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] target淇℃伅 skillId={skillConfig?.SkillID} caster={caster?.ObjID} casterCamp={caster?.Camp} target.name={targetName} target.anchoredPos={targetAnchored} target.worldPos={targetWorld} target.lossyScale={targetLossyScale}");
#endif
var tweener = BattleUtility.MoveToTarget(caster.GetRectTransform(), target, offset, () =>
{
#if UNITY_EDITOR
Vector2 toPos = caster != null && caster.GetRectTransform() != null
? caster.GetRectTransform().anchoredPosition : Vector2.zero;
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] MoveToTarget 瀹屾垚 skillId={skillConfig?.SkillID} caster={caster?.ObjID} toPos={toPos}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] MoveToTarget 瀹屾垚 skillId={skillConfig?.SkillID} caster={caster?.ObjID} toPos={toPos}");
#endif
// tween 瀹屾垚鏃舵竻闄� caster 涓婄殑 activeMoveTween 鍙ユ焺锛屾斁寮� CanCastSkillAnimation 鐨勯椄闂ㄣ��
if (caster != null)
@@ -283,7 +283,7 @@
? caster.GetRectTransform().anchoredPosition : Vector2.zero;
bool finTweening = caster != null && caster.GetRectTransform() != null
&& DG.Tweening.DOTween.IsTweening(caster.GetRectTransform());
- BattleDebug.LogError($"[鍓嶅啿璇婃柇] OnAttackFinish skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} anchoredPos={finPos} casterTweening={finTweening}");
+ // BattleDebug.LogError($"[鍓嶅啿璇婃柇] OnAttackFinish skillId={skillConfig?.SkillID} caster={caster?.ObjID} battleType={tagUseSkillAttack?.BattleType} anchoredPos={finPos} casterTweening={finTweening}");
}
#endif
TurnBack(null, 1f);
diff --git a/Main/System/Battle/Skill/SkillBase.Finish.cs b/Main/System/Battle/Skill/SkillBase.Finish.cs
index b8758c4..c73f850 100644
--- a/Main/System/Battle/Skill/SkillBase.Finish.cs
+++ b/Main/System/Battle/Skill/SkillBase.Finish.cs
@@ -131,7 +131,7 @@
/// </summary>
private void ReportStuckIfNeeded(string reason)
{
-#if UNITY_EDITOR
+#if false && UNITY_EDITOR
_stuckCheckCount++;
// 闃诲鍘熷洜鍒囨崲浜� 鈫� 绔嬪埢鎵撲竴娆★紝骞堕噸缃鏁�
@@ -210,19 +210,19 @@
string skinInfo = $" skillSkinConfig.SkillMotionName={(skillSkinConfig == null ? "null" : (string.IsNullOrEmpty(skillSkinConfig.SkillMotionName) ? "(绌�)" : skillSkinConfig.SkillMotionName))}";
string skillEffectDump = skillEffect == null ? " skillEffect=null" : $" skillEffect: {skillEffect.DumpState()}";
- BattleDebug.LogError(
- "SkillBase.IsFinished 鐤戜技鍗℃ (鎸佺画 " + _stuckCheckCount + " 娆℃湭瀹屾垚)\n" +
- $" skillId={skillId} caster={casterId} 鍘熷洜: {reason}\n" +
- $" StateFlags={_stateFlags}\n" +
- $"{skillEffectDump}\n" +
- $"{skinInfo}\n" +
- $"{casterAnim}\n" +
- $" currentWaitingSkill.Count={currentWaitingSkill.Count}\n{subSkillDump}\n" +
- $" packList.Count={(packList?.Count ?? 0)}\n{packListDump}\n" +
- $" innerRecordPlayer.IsPlaying={innerPlaying}\n" +
- $"{innerPlayerDump}\n" +
- $" tempDeadPackList.Count={tempDeadPackList.Count}\n" +
- $" buffPackCollections.Count={buffPackCollections.Count}");
+ // BattleDebug.LogError(
+ // "SkillBase.IsFinished 鐤戜技鍗℃ (鎸佺画 " + _stuckCheckCount + " 娆℃湭瀹屾垚)\n" +
+ // $" skillId={skillId} caster={casterId} 鍘熷洜: {reason}\n" +
+ // $" StateFlags={_stateFlags}\n" +
+ // $"{skillEffectDump}\n" +
+ // $"{skinInfo}\n" +
+ // $"{casterAnim}\n" +
+ // $" currentWaitingSkill.Count={currentWaitingSkill.Count}\n{subSkillDump}\n" +
+ // $" packList.Count={(packList?.Count ?? 0)}\n{packListDump}\n" +
+ // $" innerRecordPlayer.IsPlaying={innerPlaying}\n" +
+ // $"{innerPlayerDump}\n" +
+ // $" tempDeadPackList.Count={tempDeadPackList.Count}\n" +
+ // $" buffPackCollections.Count={buffPackCollections.Count}");
#endif
}
--
Gitblit v1.8.0