implement jetpack behavior and remove hardcoded jetpacks (#411)

This commit is contained in:
Avery
2022-01-24 14:02:56 -08:00
committed by GitHub
parent 1e01423a93
commit f6558aa31e
11 changed files with 91 additions and 47 deletions

View File

@@ -40,13 +40,13 @@ std::string CDBehaviorParameterTable::GetName(void) const {
return "BehaviorParameter";
}
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name)
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue)
{
size_t hash = 0;
GeneralUtils::hash_combine(hash, behaviorID);
GeneralUtils::hash_combine(hash, name);
// Search for specific perameter
// Search for specific parameter
const auto& it = m_Entries.find(hash);
if (it != m_Entries.end()) {
return it->second;
@@ -55,7 +55,7 @@ float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::s
// Check if this behavior has already been checked
const auto& itChecked = m_Entries.find(behaviorID);
if (itChecked != m_Entries.end()) {
return itChecked->second;
return defaultValue;
}
#ifndef CDCLIENT_CACHE_ALL
@@ -86,5 +86,5 @@ float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::s
}
#endif
return 0;
return defaultValue;
}

View File

@@ -35,5 +35,5 @@ public:
*/
std::string GetName(void) const override;
float GetEntry(const uint32_t behaviorID, const std::string& name);
float GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
};