From 7309f98b5143f541a25443b95ee52c654fbd68af Mon Sep 17 00:00:00 2001 From: panw Date: Sun, 4 Jan 2026 16:42:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84):=20=E4=B8=BA=E4=B8=BB?= =?UTF-8?q?=E8=A7=92=E6=B7=BB=E5=8A=A0=E5=A4=A9=E8=B5=8B=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只有主角角色会初始化天赋组件,用于管理角色的天赋系统 --- assets/script/game/hero/Hero.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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);