Files
heros/assets/script/game/skill/SMoveComp.ts
2025-11-01 11:15:11 +08:00

68 lines
2.2 KiB
TypeScript

import { Vec3, v3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { BezierMove } from "../BezierMove/BezierMove";
import { RType, SkillSet } from "../common/config/SkillSet";
import { BoxSet } from "../common/config/BoxSet";
import { ECSEntity } from "db://oops-framework/libs/ecs/ECSEntity";
import { SkillView } from "./SkillView";
/**
* 技能移动数据组件
* 存储技能实体的移动相关数据
*/
@ecs.register('SMoveDataComp')
export class SMoveDataComp extends ecs.Comp {
/** 起始位置 */
startPos: Vec3 = null;
/** 目标位置 */
targetPos: Vec3 = null;
/** 移动速度 */
speed: number = 500;
/** 移动持续时间 */
duration: number = 0;
/** 移动方向 */
scale: number = 1;
/** 是否自动销毁(到达目标后) */
autoDestroy: boolean = true;
s_uuid:number=0;
reset() {
this.startPos.set(0, 0, 0);
this.targetPos.set(0, 0, 0);
this.speed = 500;
this.duration = 0;
this.scale=1;
this.autoDestroy = true;
}
rePos(originalStart:Vec3){
if(!originalStart){
return
}
console.log("[SMoveDataComp]rePos",originalStart,this.targetPos)
// 计算延长后的目标点坐标
const originalTarget = v3(this.targetPos.x, this.targetPos.y + BoxSet.ATK_Y);
const direction = new Vec3();
Vec3.subtract(direction, originalTarget, originalStart);
const distance = direction.length();
direction.normalize();
const extendedTarget = new Vec3();
Vec3.scaleAndAdd(extendedTarget, originalTarget, direction, 720);
this.startPos.set(originalStart);
this.targetPos.set(extendedTarget);
}
}
/** 业务层业务逻辑处理对象 */
export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
filter(): ecs.IMatcher {
return ecs.allOf(SMoveDataComp,SkillView);
}
entityEnter(e: ecs.Entity): void {
// 注:自定义业务逻辑
let s_uuid=e.get(SMoveDataComp).s_uuid
let SConf=SkillSet[s_uuid]
}
update(entity: ECSEntity): void {
}
}