refactor(hero): 移除SkillConComp并添加ECS系统注册装饰器
- 删除废弃的SkillConComp组件及其meta文件 - 为HeroAtkSystem、HeroAttrSystem等系统添加@ecs.register装饰器 - 在生命周期系统中添加空安全检查 - 移除SkillConComp相关引用及调试日志 - 在移动系统中添加节点有效性检查
This commit is contained in:
@@ -114,6 +114,7 @@ export class Hero extends ecs.Entity {
|
||||
|
||||
}
|
||||
|
||||
@ecs.register('HeroLifecycleSystem')
|
||||
export class HeroLifecycleSystem extends ecs.ComblockSystem
|
||||
implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem {
|
||||
|
||||
@@ -123,11 +124,21 @@ export class HeroLifecycleSystem extends ecs.ComblockSystem
|
||||
|
||||
entityEnter(e: ecs.Entity): void {
|
||||
// 英雄实体创建时的特殊处理
|
||||
console.log(`英雄进入世界: ${e.get(HeroAttrsComp).hero_name}`);
|
||||
const heroAttrs = e.get(HeroAttrsComp);
|
||||
if (heroAttrs) {
|
||||
console.log(`英雄进入世界: ${heroAttrs.hero_name}`);
|
||||
} else {
|
||||
console.log(`英雄进入世界: 实体ID ${e.eid}`);
|
||||
}
|
||||
}
|
||||
|
||||
entityRemove(e: ecs.Entity): void {
|
||||
// 英雄实体销毁时的清理工作
|
||||
console.log(`英雄离开世界: ${e.get(HeroAttrsComp).hero_name}`);
|
||||
const heroAttrs = e.get(HeroAttrsComp);
|
||||
if (heroAttrs) {
|
||||
console.log(`英雄离开世界: ${heroAttrs.hero_name}`);
|
||||
} else {
|
||||
console.log(`英雄离开世界: 实体ID ${e.eid}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user