refactor(skill): 移除未使用的rePos方法并实现贝塞尔移动逻辑
- 删除SMoveDataComp中未使用的rePos方法以简化代码 - 在SMoveSystem中为贝塞尔移动类型实现完整的坐标计算逻辑 - 添加resolveBezierFinalXByHorizon方法计算水平线上的最终X坐标
This commit is contained in:
@@ -103,8 +103,22 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
node.setPosition(moveComp.targetPos.x > 360 ? 300 : moveComp.targetPos.x, node.position.y, 0);
|
||||
break;
|
||||
case RType.bezier:
|
||||
//
|
||||
return
|
||||
const bezierStartPos = v3(
|
||||
moveComp.startPos.x + moveComp.atk_x,
|
||||
moveComp.startPos.y + moveComp.atk_y,
|
||||
moveComp.startPos.z
|
||||
);
|
||||
const bezierTargetPos = v3(
|
||||
moveComp.targetPos.x + moveComp.atk_x,
|
||||
moveComp.targetPos.y + moveComp.atk_y,
|
||||
moveComp.targetPos.z
|
||||
);
|
||||
const horizonY = bezierStartPos.y;
|
||||
const finalX = this.resolveBezierFinalXByHorizon(bezierStartPos, bezierTargetPos, horizonY);
|
||||
moveComp.startPos.set(bezierStartPos);
|
||||
moveComp.targetPos.set(finalX, horizonY, bezierTargetPos.z);
|
||||
node.setPosition(bezierStartPos);
|
||||
break;
|
||||
default:
|
||||
// 其他类型(包括bezier):根据atk_x和atk_y调整起始位置
|
||||
if (moveComp.atk_x !== 0 || moveComp.atk_y !== 0) {
|
||||
@@ -119,6 +133,15 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private resolveBezierFinalXByHorizon(startPos: Vec3, targetPos: Vec3, horizonY: number): number {
|
||||
const deltaY = targetPos.y - startPos.y;
|
||||
if (Math.abs(deltaY) < 0.0001) {
|
||||
return targetPos.x;
|
||||
}
|
||||
const t = (horizonY - startPos.y) / deltaY;
|
||||
return startPos.x + (targetPos.x - startPos.x) * t;
|
||||
}
|
||||
|
||||
update(entity: ecs.Entity): void {
|
||||
if(!smc.mission.play ) return;
|
||||
|
||||
Reference in New Issue
Block a user