feat(技能系统): 添加施法者实体ID字段用于安全校验
在SDataCom组件中添加casterEid字段,并在Skill和SkillView中使用该字段替代原有的链式访问,提高代码安全性和可读性
This commit is contained in:
@@ -9,6 +9,7 @@ export class SDataCom extends ecs.Comp {
|
|||||||
/** 业务层组件移除时,重置所有数据为默认值 */
|
/** 业务层组件移除时,重置所有数据为默认值 */
|
||||||
Attrs:any=null
|
Attrs:any=null
|
||||||
caster:HeroViewComp=null
|
caster:HeroViewComp=null
|
||||||
|
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
|
||||||
s_uuid:number=0
|
s_uuid:number=0
|
||||||
@@ -21,6 +22,7 @@ export class SDataCom extends ecs.Comp {
|
|||||||
this.fac=0
|
this.fac=0
|
||||||
this.s_uuid=0
|
this.s_uuid=0
|
||||||
this.caster=null
|
this.caster=null
|
||||||
|
this.casterEid = -1;
|
||||||
this.hit_count=0
|
this.hit_count=0
|
||||||
this.ext_dmg=0
|
this.ext_dmg=0
|
||||||
this.dmg_ratio=1
|
this.dmg_ratio=1
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export class Skill extends ecs.Entity {
|
|||||||
sDataCom.reset();
|
sDataCom.reset();
|
||||||
sDataCom.group=caster.box_group
|
sDataCom.group=caster.box_group
|
||||||
sDataCom.caster=caster
|
sDataCom.caster=caster
|
||||||
|
sDataCom.casterEid=caster.ent.eid
|
||||||
sDataCom.Attrs={...cAttrsComp.Attrs}
|
sDataCom.Attrs={...cAttrsComp.Attrs}
|
||||||
sDataCom.s_uuid=s_uuid
|
sDataCom.s_uuid=s_uuid
|
||||||
sDataCom.fac=cAttrsComp.fac
|
sDataCom.fac=cAttrsComp.fac
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class SkillView extends CCComp {
|
|||||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||||
// 安全获取双方信息用于日志
|
// 安全获取双方信息用于日志
|
||||||
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? '未知施法者';
|
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? '未知施法者';
|
||||||
const casterEid = this.sData.caster?.ent?.eid ?? '未知EID';
|
const casterEid = this.sData.casterEid;
|
||||||
const targetView = oCol.getComponent(HeroViewComp);
|
const targetView = oCol.getComponent(HeroViewComp);
|
||||||
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';
|
||||||
|
|||||||
Reference in New Issue
Block a user