refactor(skill): 移除未使用的caster引用以简化技能数据
清理SDataCom中未使用的caster属性及相关代码,减少内存占用并提升代码清晰度。技能逻辑仅依赖casterEid进行实体识别,移除冗余引用可避免潜在循环引用问题。
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { BoxSet } from "../common/config/GameSet";
|
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 {
|
export class SDataCom extends ecs.Comp {
|
||||||
/** 业务层组件移除时,重置所有数据为默认值 */
|
/** 业务层组件移除时,重置所有数据为默认值 */
|
||||||
Attrs:any=null
|
Attrs:any=null
|
||||||
caster:HeroViewComp=null
|
|
||||||
casterEid: number = -1; // 施法者实体ID,用于安全校验
|
casterEid: number = -1; // 施法者实体ID,用于安全校验
|
||||||
group:BoxSet=BoxSet.HERO
|
group:BoxSet=BoxSet.HERO
|
||||||
fac: number = 0; // 0:hero 1:monster
|
fac: number = 0; // 0:hero 1:monster
|
||||||
@@ -22,7 +20,6 @@ export class SDataCom extends ecs.Comp {
|
|||||||
this.group=BoxSet.HERO
|
this.group=BoxSet.HERO
|
||||||
this.fac=0
|
this.fac=0
|
||||||
this.s_uuid=0
|
this.s_uuid=0
|
||||||
this.caster=null
|
|
||||||
this.casterEid = -1;
|
this.casterEid = -1;
|
||||||
this.hit_count=0
|
this.hit_count=0
|
||||||
this.max_hit_count=0
|
this.max_hit_count=0
|
||||||
|
|||||||
@@ -190,7 +190,6 @@ export class Skill extends ecs.Entity {
|
|||||||
}
|
}
|
||||||
sDataCom.reset();
|
sDataCom.reset();
|
||||||
sDataCom.group=caster.box_group
|
sDataCom.group=caster.box_group
|
||||||
sDataCom.caster=caster
|
|
||||||
sDataCom.casterEid=caster.ent.eid
|
sDataCom.casterEid=caster.ent.eid
|
||||||
sDataCom.Attrs = {};
|
sDataCom.Attrs = {};
|
||||||
const addCrt = config.crt ?? 0;
|
const addCrt = config.crt ?? 0;
|
||||||
|
|||||||
@@ -67,11 +67,10 @@ export class SkillView extends CCComp {
|
|||||||
if (!this.node || !this.node.activeInHierarchy) return;
|
if (!this.node || !this.node.activeInHierarchy) return;
|
||||||
const targetView = oCol.getComponent(HeroViewComp);
|
const targetView = oCol.getComponent(HeroViewComp);
|
||||||
if (this.debugMode) {
|
if (this.debugMode) {
|
||||||
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? '未知施法者';
|
|
||||||
const casterEid = this.sData.casterEid;
|
const casterEid = this.sData.casterEid;
|
||||||
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
|
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
|
||||||
const targetEid = targetView?.ent?.eid ?? '未知EID';
|
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 (oCol.group === seCol.group) return;
|
||||||
if (this.pendingDisableCollider) return;
|
if (this.pendingDisableCollider) return;
|
||||||
@@ -130,9 +129,8 @@ export class SkillView extends CCComp {
|
|||||||
if (!this.sData) return;
|
if (!this.sData) return;
|
||||||
if (!this.SConf) return;
|
if (!this.SConf) return;
|
||||||
if (this.debugMode) {
|
if (this.debugMode) {
|
||||||
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者";
|
|
||||||
const targetName = target.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(
|
DamageQueueHelper.addDamageToEntity(
|
||||||
|
|||||||
Reference in New Issue
Block a user