refactor(hero): 优化英雄动画状态同步逻辑
移除测试用的英雄成长模拟数据,修复动画状态与实际表现不一致的问题 1. 重构HeroSpine的idle/move方法,新增返回值标记动画是否被拦截 2. 重构HeroViewComp的status_change逻辑,仅在动画切换成功时更新状态 3. 重构HeroAnmComp的动画播放逻辑,修复动画结束后默认播放的异常 4. 移除SingletonModuleComp中的测试用英雄成长数据 5. 简化MoveSystem中状态切换的冗余判断逻辑
This commit is contained in:
@@ -312,15 +312,24 @@ export class HeroViewComp extends CCComp {
|
||||
get isActive() {
|
||||
return this.ent.has(HeroViewComp) && this.node?.isValid;
|
||||
}
|
||||
/** 状态切换(动画) */
|
||||
/**
|
||||
* 状态切换(动画)。
|
||||
* Why 成功才记录:动画层在普攻/buff/大招播放期间会拦截 idle/move 切换,
|
||||
* 若先记录状态再播动画,会导致记录与实际动画永久脱钩(位置在动动画却卡死、
|
||||
* 或攻击结束回放过期动画)。只在切换成功时写入 status,被拦截时不写入,
|
||||
* 下一帧 MoveSystem 重试时去重条件不成立,会再次尝试直至成功。
|
||||
*/
|
||||
status_change(type: string) {
|
||||
if (this.status === type) return;
|
||||
this.status = type;
|
||||
if (this.model.is_dead || this.model.is_reviving) return
|
||||
if (this.model.is_dead || this.model.is_reviving) {
|
||||
// 死亡/复活中动画由对应流程接管,仅记录待恢复状态
|
||||
this.status = type;
|
||||
return;
|
||||
}
|
||||
if (type === "idle") {
|
||||
this.as.idle();
|
||||
if (this.as.idle()) this.status = type;
|
||||
} else if (type === "move") {
|
||||
this.as.move();
|
||||
if (this.as.move()) this.status = type;
|
||||
}
|
||||
}
|
||||
/** 护盾常驻特效节点,避免重复创建 */
|
||||
@@ -374,6 +383,9 @@ export class HeroViewComp extends CCComp {
|
||||
// 恢复UI
|
||||
this.topBar.show();
|
||||
|
||||
// 死亡期间 status 可能已被记录为 idle(死亡分支只记录不播动画),
|
||||
// 清空强制重同步,确保复活后动画真实切回待机
|
||||
this.status = "";
|
||||
this.status_change("idle");
|
||||
|
||||
// 【新增】仅英雄阵营派发复活成功事件,供卡牌技能(HeroCall 类型)监听
|
||||
|
||||
Reference in New Issue
Block a user