mirror of
https://github.com/Jous99/F4MP.git
synced 2026-01-12 23:20:53 +01:00
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#include "BehaviorVarsMap.h"
|
|
|
|
const uint32_t BehaviorVarsMap::find(const uint64_t acBehaviorVarsKey, const TiltedPhoques::String acName)
|
|
{
|
|
auto map = m_map.find(acBehaviorVarsKey);
|
|
|
|
if (map != m_map.end())
|
|
{
|
|
auto map2 = map->second.m_nameMap.find(acName);
|
|
|
|
if (map2 != map->second.m_nameMap.end())
|
|
return map2->second;
|
|
}
|
|
|
|
return UINT32_MAX;
|
|
}
|
|
|
|
const TiltedPhoques::String BehaviorVarsMap::find(const uint64_t acBehaviorVarsKey, const uint32_t acValue)
|
|
{
|
|
const TiltedPhoques::String empty;
|
|
|
|
auto map = m_map.find(acBehaviorVarsKey);
|
|
if (map != m_map.end())
|
|
{
|
|
auto map2 = map->second.m_valueMap.find(acValue);
|
|
|
|
if (map2 != map->second.m_valueMap.end())
|
|
return map2->second;
|
|
}
|
|
|
|
return empty;
|
|
}
|
|
|
|
void BehaviorVarsMap::Register(const BehaviorVars aMap)
|
|
{
|
|
m_map.insert_or_assign(aMap.m_key, aMap);
|
|
}
|
|
|
|
BehaviorVarsMap& BehaviorVarsMap::getInstance()
|
|
{
|
|
// The only instance. Guaranteed lazy initiated
|
|
// Guaranteed that it will be destroyed correctly
|
|
static BehaviorVarsMap instance;
|
|
|
|
return instance;
|
|
}
|