feat(skill): 优化技能碰撞检测逻辑并添加移动数据组件

- 新增 StimeDataComp 组件用于存储技能移动相关数据
- 修改 SMoveSystem 中距离结束和碰撞结束时的销毁逻辑,增加关闭碰撞体操作
- 重构 SkillView 的碰撞检测启用逻辑,提取为 enable_collider_safely 方法确保安全性
- 修复攻击帧事件中碰撞检测的启用条件,避免无效操作
This commit is contained in:
walkpan
2026-03-15 23:02:24 +08:00
parent ad9799d938
commit 9c21ab748e
4 changed files with 44 additions and 7 deletions

View File

@@ -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() {
// 清理碰撞体事件监听