perf: 自动战斗-自动编队存储编队信息 (#8542)

This commit is contained in:
status102
2024-03-14 11:24:18 +08:00
committed by GitHub
parent a4e5c595d3
commit 7cc1e7b551
5 changed files with 37 additions and 14 deletions

View File

@@ -84,16 +84,31 @@ void asst::BattleProcessTask::set_wait_until_end(bool wait_until_end)
m_need_to_wait_until_end = wait_until_end;
}
void asst::BattleProcessTask::set_formation_task_ptr(std::shared_ptr<std::unordered_map<std::string, std::string>> value)
{
m_formation_ptr = value;
}
bool asst::BattleProcessTask::to_group()
{
std::unordered_map<std::string, std::vector<std::string>> groups;
// 从编队任务中获取<干员-组名>映射
if (m_formation_ptr != nullptr) {
for (const auto& [group, oper] : *m_formation_ptr) {
groups.emplace(oper, std::vector<std::string> { group });
}
}
// 补充剩余的干员
for (const auto& [group_name, oper_list] : get_combat_data().groups) {
if (groups.contains(group_name)) {
continue;
}
std::vector<std::string> oper_name_list;
ranges::transform(oper_list, std::back_inserter(oper_name_list), [](const auto& oper) { return oper.name; });
groups.emplace(group_name, std::move(oper_name_list));
}
std::unordered_set<std::string> char_set;
std::unordered_set<std::string> char_set; // 干员集合
for (const auto& oper : m_cur_deployment_opers) {
char_set.emplace(oper.name);
}