From e059c97670f55c2431c2138c226806c778f24ef7 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 18 Mar 2026 10:22:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(skill):=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84caster=E5=BC=95=E7=94=A8=E4=BB=A5?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=8A=80=E8=83=BD=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 清理SDataCom中未使用的caster属性及相关代码,减少内存占用并提升代码清晰度。技能逻辑仅依赖casterEid进行实体识别,移除冗余引用可避免潜在循环引用问题。 --- assets/script/game/skill/SDataCom.ts | 3 --- assets/script/game/skill/Skill.ts | 1 - assets/script/game/skill/SkillView.ts | 6 ++---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/assets/script/game/skill/SDataCom.ts b/assets/script/game/skill/SDataCom.ts index 7ac61a54..8249a632 100644 --- a/assets/script/game/skill/SDataCom.ts +++ b/assets/script/game/skill/SDataCom.ts @@ -1,6 +1,5 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { BoxSet } from "../common/config/GameSet"; -import { HeroViewComp } from "../hero/HeroViewComp"; /** 业务层对象 */ //技能数据 @@ -8,7 +7,6 @@ import { HeroViewComp } from "../hero/HeroViewComp"; export class SDataCom extends ecs.Comp { /** 业务层组件移除时,重置所有数据为默认值 */ Attrs:any=null - caster:HeroViewComp=null casterEid: number = -1; // 施法者实体ID,用于安全校验 group:BoxSet=BoxSet.HERO fac: number = 0; // 0:hero 1:monster @@ -22,7 +20,6 @@ export class SDataCom extends ecs.Comp { this.group=BoxSet.HERO this.fac=0 this.s_uuid=0 - this.caster=null this.casterEid = -1; this.hit_count=0 this.max_hit_count=0 diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 85b97768..103c2af4 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -190,7 +190,6 @@ export class Skill extends ecs.Entity { } sDataCom.reset(); sDataCom.group=caster.box_group - sDataCom.caster=caster sDataCom.casterEid=caster.ent.eid sDataCom.Attrs = {}; const addCrt = config.crt ?? 0; diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index 02e23c76..eb02a365 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -67,11 +67,10 @@ export class SkillView extends CCComp { if (!this.node || !this.node.activeInHierarchy) return; const targetView = oCol.getComponent(HeroViewComp); if (this.debugMode) { - const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? '未知施法者'; const casterEid = this.sData.casterEid; const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象'; const targetEid = targetView?.ent?.eid ?? '未知EID'; - mLogger.log(this.debugMode, 'SkillView', `[skillView] 碰撞1 [${this.sData.caster.box_group}][${casterName}][${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[ ${targetName}][${targetEid}]`); + mLogger.log(this.debugMode, 'SkillView', `[skillView] 碰撞1 [${this.sData.group}][eid:${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[${targetName}][${targetEid}]`); } if (oCol.group === seCol.group) return; if (this.pendingDisableCollider) return; @@ -130,9 +129,8 @@ export class SkillView extends CCComp { if (!this.sData) return; if (!this.SConf) return; if (this.debugMode) { - const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者"; const targetName = target.ent.get(HeroAttrsComp)?.hero_name ?? "未知目标"; - mLogger.log(this.debugMode, 'SkillView', `[skillView] 伤害 [${this.group}][${casterName}][${this.sData.casterEid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${targetName}][${target.ent.eid}]`); + mLogger.log(this.debugMode, 'SkillView', `[skillView] 伤害 [${this.group}][eid:${this.sData.casterEid}]的 [${this.SConf.name}]对 [${target.box_group}][${targetName}][${target.ent.eid}]`); } // 使用伤害队列系统处理伤害 DamageQueueHelper.addDamageToEntity(