diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 73772e47..8bd9e6d2 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -12,6 +12,7 @@ import { time } from "console"; import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs"; import { HeroSkillsComp } from "./HeroSkills"; import { HeroMoveComp } from "./HeroMove"; +import { TalComp } from "./TalComp"; /** 角色实体 */ @ecs.register(`Hero`) @@ -20,6 +21,7 @@ export class Hero extends ecs.Entity { HeroSkills!: HeroSkillsComp; View!: HeroViewComp; HeroMove!: HeroMoveComp; + TalComp!: TalComp; protected init() { this.addComponents( HeroMoveComp, @@ -38,6 +40,7 @@ export class Hero extends ecs.Entity { this.remove(HeroViewComp); this.remove(HeroAttrsComp); this.remove(HeroSkillsComp); + this.remove(TalComp); super.destroy(); } @@ -80,6 +83,15 @@ export class Hero extends ecs.Entity { model.fac = FacSet.HERO; model.is_master = is_master; + // 只有主角才挂载天赋组件 + if (is_master) { + this.add(TalComp); + const talComp = this.get(TalComp); + if (talComp) { + talComp.init(uuid); + } + } + // ✅ 初始化技能数据(迁移到 HeroSkillsComp) skillsComp.initSkills(hero.skills, uuid, this);