refactor(skill): 移除旧技能组件和文档,优化技能配置结构 fix(skill): 修正技能预制体配置错误,统一技能运行类型字段 docs(skill): 删除过时的技能系统说明文档 perf(skill): 优化技能加载逻辑,减少资源消耗 style(skill): 调整代码格式,提高可读性
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
import { instantiate, Node, Prefab, v3, Vec3 } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { Hero } from "../hero/Hero";
|
|
import { Monster } from "../hero/Mon";
|
|
import { ECSEntity } from "db://oops-framework/libs/ecs/ECSEntity";
|
|
import { SkillSet } from "../common/config/SkillSet";
|
|
import { oops } from "db://oops-framework/core/Oops";
|
|
import { AtkConCom } from "./AtkConCom";
|
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
|
import { BoxSet, FacSet } from "../common/config/BoxSet";
|
|
import { HType } from "../common/config/heroSet";
|
|
import { SkillView } from "./SkillView";
|
|
import { SDataCom } from "./SDataCom";
|
|
import { Attrs } from "../common/config/HeroAttrs";
|
|
import { SMoveDataComp } from "../hero/SMoveComp";
|
|
|
|
/** Skill 模块 */
|
|
@ecs.register(`Skill`)
|
|
export class Skill extends ecs.Entity {
|
|
/** ---------- 数据层 ---------- */
|
|
SDataCom!: SDataCom;
|
|
SMoveCom!: SMoveDataComp
|
|
|
|
/** ---------- 业务层 ---------- */
|
|
// SkillBll!: SkillBllComp;
|
|
|
|
/** ---------- 视图层 ---------- */
|
|
SView!: SkillView;
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
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];
|
|
if (!config) {
|
|
console.error("[Skill] 技能配置不存在:", uuid);
|
|
return;
|
|
}
|
|
|
|
// 加载预制体
|
|
const path = `game/skill/atk/${config.sp_name}`;
|
|
const prefab:Prefab = oops.res.get(path, Prefab);
|
|
if (!prefab) {
|
|
console.error("[Skill] 预制体加载失败:", path);
|
|
return;
|
|
}
|
|
// console.log("load skill startPos",startPos)
|
|
const node: Node = instantiate(prefab);
|
|
console.log("load skill node",node)
|
|
node.parent = parent;
|
|
// 设置节点属性
|
|
node.setPosition(startPos);
|
|
|
|
if(fac==FacSet.MON){
|
|
node.scale=v3(node.scale.x*-1,1,1)
|
|
}else{
|
|
if(type==HType.warrior){
|
|
if(scale<0){
|
|
node.scale=v3(node.scale.x*-1,node.scale.y,1)
|
|
}
|
|
}
|
|
}
|
|
// 添加技能组件
|
|
const SView = node.getComponent(SkillView); // 初始化技能参数
|
|
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
|
|
// 核心标识
|
|
SView.s_uuid= uuid
|
|
SView.group= 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
|
|
sDataCom.attrs=casterAttrs
|
|
sDataCom.s_uuid=uuid
|
|
|
|
}
|
|
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
this.remove(SDataCom);
|
|
this.remove(SkillView)
|
|
super.destroy();
|
|
|
|
}
|
|
}
|
|
|
|
|