refactor(battle): 重构战斗目标查找与位置管理逻辑

新增全局位置网格系统,用于按索引存储敌我单位实体ID:
-  在SingletonModuleComp添加heroGrid与monGrid数组
-  为HeroAttrsComp新增posIndex字段记录位置索引并初始化

优化战斗核心流程:
-  重构MissionHeroComp的位置选择逻辑,拆分方法返回位置索引而非直接坐标,优化位置占用检测
-  重构SCastSystem的目标查找与收集逻辑,改用网格遍历替代全量实体查询,大幅提升性能
-  统一三路单位的查找优先级,简化代码提升可维护性
-  完善Hero与Monster的创建销毁流程,同步更新网格的单位注册与注销信息
This commit is contained in:
pan
2026-06-17 09:45:46 +08:00
parent 06a47842dd
commit b6b2dff986
7 changed files with 144 additions and 142 deletions

View File

@@ -76,6 +76,7 @@ export class HeroAttrsComp extends ecs.Comp {
minSkillDistance: number = 0; // 最近技能攻击距离缓存不受MP影响用于停止位置判断
// ==================== 阵型位置 ====================
posIndex: number = -1;
// ==================== 标记状态 ====================
is_dead: boolean = false;
@@ -408,6 +409,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.maxSkillDistance = 0;
this.minSkillDistance = 0;
this.posIndex = -1;
this.is_dead = false;
this.is_count_dead = false;