From 9c21ab748e82676c666b66725a51c87e0fc44dbb Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 15 Mar 2026 23:02:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(skill):=20=E4=BC=98=E5=8C=96=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E7=A2=B0=E6=92=9E=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B9=B6=E6=B7=BB=E5=8A=A0=E7=A7=BB=E5=8A=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 StimeDataComp 组件用于存储技能移动相关数据 - 修改 SMoveSystem 中距离结束和碰撞结束时的销毁逻辑,增加关闭碰撞体操作 - 重构 SkillView 的碰撞检测启用逻辑,提取为 enable_collider_safely 方法确保安全性 - 修复攻击帧事件中碰撞检测的启用条件,避免无效操作 --- assets/script/game/skill/SMoveSystem.ts | 8 +++++-- assets/script/game/skill/STimeComp.ts | 25 ++++++++++++++++++++++ assets/script/game/skill/STimeComp.ts.meta | 1 + assets/script/game/skill/SkillView.ts | 17 ++++++++++----- 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 assets/script/game/skill/STimeComp.ts create mode 100644 assets/script/game/skill/STimeComp.ts.meta diff --git a/assets/script/game/skill/SMoveSystem.ts b/assets/script/game/skill/SMoveSystem.ts index 2ce2f406..dcf3ba2b 100644 --- a/assets/script/game/skill/SMoveSystem.ts +++ b/assets/script/game/skill/SMoveSystem.ts @@ -136,7 +136,11 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate // 检查移动完成 if (moveComp.isCompleted && moveComp.autoDestroy) { // 根据结束类型决定是否销毁 - if (moveComp.endType === EType.timeEnd || moveComp.endType === EType.collision) { + if ( + moveComp.endType === EType.distanceEnd || + moveComp.endType === EType.collision + ) { + skillView.close_collider(); entity.destroy(); } } @@ -229,4 +233,4 @@ export class SMoveHelper { moveComp.stopMove(); } } -} \ No newline at end of file +} diff --git a/assets/script/game/skill/STimeComp.ts b/assets/script/game/skill/STimeComp.ts new file mode 100644 index 00000000..71c49183 --- /dev/null +++ b/assets/script/game/skill/STimeComp.ts @@ -0,0 +1,25 @@ +import { Vec3, v3, Node } from "cc"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { RType, EType, SkillSet } from "../common/config/SkillSet"; +import { BoxSet } from "../common/config/GameSet"; +import { SkillView } from "./SkillView"; +import { smc } from "../common/SingletonModuleComp"; + +/** + * ==================== 技能移动数据组件 ==================== + * + * 用途: + * - 存储技能实体的移动相关数据 + * - 管理移动状态和参数 + * - 支持多种移动类型(线性、贝塞尔、固定位置等) + */ +@ecs.register('StimeDataComp') +export class StimeDataComp extends ecs.Comp { + /** 技能UUID */ + s_uuid: number = 0; + reset() { + + } + +} + diff --git a/assets/script/game/skill/STimeComp.ts.meta b/assets/script/game/skill/STimeComp.ts.meta new file mode 100644 index 00000000..f7598bb7 --- /dev/null +++ b/assets/script/game/skill/STimeComp.ts.meta @@ -0,0 +1 @@ +{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"f39d7998-2039-4411-9dd2-77db452d0a6d","files":[],"subMetas":{},"userData":{}} diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index edea13ce..6e342272 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -103,11 +103,7 @@ export class SkillView extends CCComp { // //动画帧事件 atk 触发 public atk(args:any){ this.attackFrameCount++; - - // 开启碰撞检测 - if(this.collider) { - this.pendingDisableCollider = false; - this.collider.enabled = true; + if (this.enable_collider_safely()) { mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`); } @@ -175,6 +171,17 @@ export class SkillView extends CCComp { this.isDisposing = true; this.close_collider(); } + private enable_collider_safely(): boolean { + if (!this.collider || !this.collider.isValid) return false; + if (this.isDisposing) return false; + if (!this.node || !this.node.isValid || !this.node.activeInHierarchy) return false; + this.pendingDisableCollider = false; + this.collider.group = this.group; + this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); + this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); + this.collider.enabled = true; + return true; + } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { // 清理碰撞体事件监听