refactor: 合并英雄与怪物移动组件为通用 MoveComp

重构移动系统,将 HeroMoveComp 和 MonMoveComp 合并为通用的 MoveComp 组件,统一移动逻辑。
- 移除 HeroMasterComp 相关代码,简化实体查询
- 统一战斗范围计算和阵型回归逻辑
- 调整移动边界和撤退范围配置
- 优化敌人查找算法,提高性能
This commit is contained in:
walkpan
2026-03-13 15:54:12 +08:00
parent 5ab5a51752
commit b12b421823
7 changed files with 330 additions and 47 deletions

View File

@@ -9,7 +9,6 @@ import { CardType, FightSet, CardKind } from "../common/config/GameSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { HeroMasterComp } from "../hero/HeroMasterComp";
const { ccclass, property } = _decorator;
@@ -252,16 +251,7 @@ export class MissionCardComp extends CCComp {
*/
fetchCards(level: number, forcedType?: CardType){
// 获取主角已有的属性倾向 (已拥有的永久属性Buff)
let preferredAttrs: number[] = [];
// @ts-ignore
const entities = ecs.query(ecs.allOf(HeroMasterComp));
if (entities.length > 0) {
const role = entities[0];
const heroAttrs = role.get(HeroAttrsComp);
if (heroAttrs && heroAttrs.BUFFS) {
preferredAttrs = Object.keys(heroAttrs.BUFFS).map(Number);
}
}
// 使用 CardSet 的 getCardOptions 获取卡牌
// 这里我们要获取 4 张卡牌
@@ -441,13 +431,10 @@ export class MissionCardComp extends CCComp {
.to(0.1, { scale: new Vec3(1, 1, 1) })
.delay(0.5)
// .call(() => {
// // 使用 HeroMasterComp 查找主角实体
// // @ts-ignore
// const entities = ecs.query(ecs.allOf(HeroMasterComp));
// let role = entities.length > 0 ? entities[0] : null;
// if (!role) {
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 未找到挂载 HeroMasterComp 的主角实体`);
// } else {
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 成功定位主角实体: ${role.eid}`);
// }