dd
This commit is contained in:
18
assets/script/game/core/EntityFactory.ts
Normal file
18
assets/script/game/core/EntityFactory.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export class EntityFactory {
|
||||
static createHero(config: HeroConfig): ecs.Entity {
|
||||
const hero = ecs.Entity.create();
|
||||
|
||||
// 基础组件
|
||||
hero.add(HeroModel).init(config);
|
||||
hero.add(HeroView).loadModel(config.prefabPath);
|
||||
hero.add(Movement).init(config.speed);
|
||||
hero.add(Combat).init(config.baseAttack, config.attackRange);
|
||||
|
||||
// 技能系统
|
||||
config.skills.forEach(skill => {
|
||||
hero.add(Skill).registerSkill(skill);
|
||||
});
|
||||
|
||||
return hero;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user