feat(战斗系统): 实现伤害队列机制优化战斗处理

重构伤害处理逻辑,将直接伤害组件改为队列系统
- 新增DamageQueueComp组件管理伤害事件队列
- 添加DamageQueueHelper工具类处理伤害事件添加和查询
- 修改HeroAtkSystem改为处理伤害队列而非单个伤害
- 移除旧的DmgDataCom组件及相关引用
- 优化SkillView.apply_damage使用新队列系统
This commit is contained in:
walkpan
2025-10-31 20:08:43 +08:00
parent 8e0d09fc98
commit b8f48e09d6
7 changed files with 278 additions and 85 deletions

View File

@@ -5,12 +5,13 @@ import { HeroViewComp } from "../hero/HeroViewComp";
import { DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet";
import { BezierMove } from "../BezierMove/BezierMove";
import { BoxSet, FacSet } from "../common/config/BoxSet";
import { DmgDataCom, SDataCom } from "./SDataCom";
import { SDataCom } from "./SDataCom";
import { SMoveDataComp } from "./SMoveComp";
import { Attrs } from "../common/config/HeroAttrs";
import { MonMoveComp } from "../hero/MonMove";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { HeroMoveComp } from "../hero/HeroMove";
import { DamageQueueHelper } from "../hero/DamageQueueComp";
const { ccclass, property } = _decorator;
@@ -178,14 +179,21 @@ export class SkillView extends CCComp {
apply_damage(target:HeroViewComp,is_range:boolean=false){
if(target == null) return;
if (!this.SConf) return;
//伤害处理
target.ent.addComponents<DmgDataCom>(DmgDataCom)
let dmgData=target.ent.get(DmgDataCom)
dmgData.Attrs= this.sData.Attrs
dmgData.caster= this.sData.caster
dmgData.s_uuid= this.sData.s_uuid
// 使用伤害队列系统处理伤害
DamageQueueHelper.addDamageToEntity(
target.ent,
this.sData.Attrs,
this.sData.caster,
this.sData.s_uuid
);
// console.log(`[SkillCom]: ${this.sData.caster.ent.get(HeroAttrsComp).hero_name}[${this.sData.caster.ent.get(HeroAttrsComp).fac}:${ this.sData.fac}:${target.ent.get(HeroAttrsComp).fac}] 对 ${target.ent.get(HeroAttrsComp).hero_name} 释放技能 ${this.SConf.name}`)
this.sData.hit_count++
// 更新技能命中次数
this.sData.hit_count++
// 检查技能是否应该销毁
if( this.sData.hit_count>=(this.SConf.hit+ this.sData.Attrs[Attrs.PUNCTURE])&&(this.SConf.DTType!=DTType.range)&&(this.endType!=EType.animationEnd)&&(this.endType!=EType.timeEnd)) this.ent.destroy// 技能命中次数
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */