refactor(技能系统): 重构技能系统以使用s_uuid作为主键并优化技能施放逻辑

- 将HeroSkillsComp中的技能数组改为以s_uuid为键的对象存储
- 修改CSRequestComp使用s_uuid替代skillIndex
- 优化SkillCastSystem和SACastSystem的施放逻辑
- 为SMoveDataComp添加rePos方法处理技能位置计算
- 移除未使用的SDataComSystem代码
This commit is contained in:
panw
2025-10-31 10:47:05 +08:00
parent b38e63e200
commit 2b3b80b308
11 changed files with 230 additions and 96 deletions

View File

@@ -13,6 +13,7 @@ import { SkillView } from "./SkillView";
import { SDataCom } from "./SDataCom";
import { Attrs } from "../common/config/HeroAttrs";
import { SMoveDataComp } from "../skill/SMoveComp";
import { HeroViewComp } from "../hero/HeroViewComp";
/** Skill 模块 */
@ecs.register(`Skill`)
@@ -32,10 +33,12 @@ export class Skill extends ecs.Entity {
this.addComponents<SDataCom>();
this.addComponents<SMoveDataComp>();
}
load(startPos: Vec3, parent: Node, uuid: number, targetPos: Vec3,casterAttrs:Attrs[]=[],scale:number=1,fac:FacSet=FacSet.MON,type:HType=HType.warrior,box_group:BoxSet=BoxSet.HERO) {
const config = SkillSet[uuid];
load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3,
caster:HeroViewComp) {
const config = SkillSet[s_uuid];
let casterAttrs=caster.ent.get(HeroAttrsComp).Attrs
if (!config) {
console.error("[Skill] 技能配置不存在:", uuid);
console.error("[Skill] 技能配置不存在:", s_uuid);
return;
}
@@ -53,32 +56,35 @@ export class Skill extends ecs.Entity {
// 设置节点属性
node.setPosition(startPos);
if(fac==FacSet.MON){
if(casterAttrs.fac==FacSet.MON){
node.scale=v3(node.scale.x*-1,1,1)
}else{
if(type==HType.warrior){
if(scale<0){
if(casterAttrs.type==HType.warrior){
if(casterAttrs.node.scale<0){
node.scale=v3(node.scale.x*-1,node.scale.y,1)
}
}
}
// 添加技能组件
const SView = node.getComponent(SkillView); // 初始化技能参数
// 初始视图
const SView = node.getComponent(SkillView);
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
// 核心标识
SView.s_uuid= uuid
SView.group= box_group
SView.s_uuid= s_uuid
SView.group= caster.box_group
this.add(SView);
const sDataCom = this.get(SDataCom);
// 初始化移动组件
const sMoveCom = this.get(SMoveDataComp);
sMoveCom.startPos=startPos
sMoveCom.targetPos=targetPos
sMoveCom.s_uuid=uuid
sDataCom.group=box_group
sMoveCom.s_uuid=s_uuid
// 初始化数据组件
const sDataCom = this.get(SDataCom);
sDataCom.group=caster.box_group
sDataCom.caster=caster
sDataCom.attrs=casterAttrs
sDataCom.s_uuid=uuid
sDataCom.s_uuid=s_uuid
}