fix(map): 修复英雄位置变更时的节点绑定逻辑

根据英雄的lane和lane_index重新计算期望的节点索引,当实际节点不匹配时将英雄卡片转移到正确的节点上,隐藏旧节点并激活新节点绑定最新数据
This commit is contained in:
panw
2026-05-13 17:21:07 +08:00
parent 254b7f3e9e
commit 8f65282af7

View File

@@ -965,6 +965,27 @@ export class MissionCardComp extends CCComp {
removeKeys.push(eid);
return;
}
// 检查英雄是否改变了位置 (lane 或 lane_index 发生了变化)
const laneOrder = item.model.lane === 0 ? 0 : (item.model.lane === 1 ? 1 : 2);
const expectedNodeIndex = item.model.lane_index * 3 + laneOrder + 1;
if (item.comp.node_index !== expectedNodeIndex) {
// 如果位置变了,需要转移到新的节点上
const newComp = this.cachedHInfoComps.get(expectedNodeIndex);
if (newComp) {
// 隐藏旧节点
item.node.active = false;
// 转移到新节点
item.comp = newComp;
item.node = newComp.node;
item.node.active = true;
item.comp.bindData(eid, item.model);
item.comp.setBattlePhase(this.isBattlePhase);
}
}
this.updateHeroInfoPanel(item);
});
for (let i = 0; i < removeKeys.length; i++) {