2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Character/CTransitionDatabaseGame.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Character/CHalfTransition.hpp"
|
|
|
|
#include "Runtime/Character/CTransition.hpp"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <utility>
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-13 06:07:23 +00:00
|
|
|
|
|
|
|
CTransitionDatabaseGame::CTransitionDatabaseGame(const std::vector<CTransition>& transitions,
|
|
|
|
const std::vector<CHalfTransition>& halfTransitions,
|
2020-03-09 15:48:14 +00:00
|
|
|
std::shared_ptr<IMetaTrans> defaultTrans)
|
|
|
|
: x10_defaultTrans(std::move(defaultTrans)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_transitions.reserve(transitions.size());
|
|
|
|
for (const CTransition& trans : transitions)
|
|
|
|
x14_transitions.emplace_back(trans.GetAnimPair(), trans.GetMetaTrans());
|
2019-03-09 08:58:27 +00:00
|
|
|
std::sort(x14_transitions.begin(), x14_transitions.end(),
|
|
|
|
[](const auto& a, const auto& b) { return a.first < b.first; });
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x24_halfTransitions.reserve(halfTransitions.size());
|
|
|
|
for (const CHalfTransition& trans : halfTransitions)
|
|
|
|
x24_halfTransitions.emplace_back(trans.GetId(), trans.GetMetaTrans());
|
2019-03-09 08:58:27 +00:00
|
|
|
std::sort(x24_halfTransitions.begin(), x24_halfTransitions.end(),
|
|
|
|
[](const auto& a, const auto& b) { return a.first < b.first; });
|
2016-04-13 06:07:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const std::shared_ptr<IMetaTrans>& CTransitionDatabaseGame::GetMetaTrans(u32 a, u32 b) const {
|
2020-04-11 03:51:16 +00:00
|
|
|
const auto it = rstl::binary_find(x14_transitions.cbegin(), x14_transitions.cend(), std::make_pair(a, b),
|
|
|
|
[](const auto& p) { return p.first; });
|
|
|
|
if (it != x14_transitions.cend()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return it->second;
|
2020-04-11 03:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto it2 = rstl::binary_find(x24_halfTransitions.cbegin(), x24_halfTransitions.cend(), b,
|
|
|
|
[](const auto& p) { return p.first; });
|
|
|
|
if (it2 != x24_halfTransitions.cend()) {
|
2019-03-05 08:34:43 +00:00
|
|
|
return it2->second;
|
2020-04-11 03:51:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return x10_defaultTrans;
|
2016-04-13 06:07:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|