Add CDBaseCombatAIComponentTable with LoadValuesFromDefaults support

Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-31 21:58:26 +00:00
parent 6bb8040221
commit dac47cc240
5 changed files with 107 additions and 22 deletions

View File

@@ -13,6 +13,7 @@
#include "CDClientDatabase.h"
#include "CDClientManager.h"
#include "CDBaseCombatAIComponentTable.h"
#include "DestroyableComponent.h"
#include <algorithm>
@@ -41,31 +42,20 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
m_ForcedTetherTime = 0.0f;
//Grab the aggro information from BaseCombatAI:
auto componentQuery = CDClientDatabase::CreatePreppedStmt(
"SELECT aggroRadius, tetherSpeed, pursuitSpeed, softTetherRadius, hardTetherRadius FROM BaseCombatAIComponent WHERE id = ?;");
componentQuery.bind(1, static_cast<int>(id));
auto* componentTable = CDClientManager::GetTable<CDBaseCombatAIComponentTable>();
auto componentEntries = componentTable->Query([id](CDBaseCombatAIComponent entry) {
return entry.id == static_cast<int32_t>(id);
});
auto componentResult = componentQuery.execQuery();
if (!componentResult.eof()) {
if (!componentResult.fieldIsNull("aggroRadius"))
m_AggroRadius = componentResult.getFloatField("aggroRadius");
if (!componentResult.fieldIsNull("tetherSpeed"))
m_TetherSpeed = componentResult.getFloatField("tetherSpeed");
if (!componentResult.fieldIsNull("pursuitSpeed"))
m_PursuitSpeed = componentResult.getFloatField("pursuitSpeed");
if (!componentResult.fieldIsNull("softTetherRadius"))
m_SoftTetherRadius = componentResult.getFloatField("softTetherRadius");
if (!componentResult.fieldIsNull("hardTetherRadius"))
m_HardTetherRadius = componentResult.getFloatField("hardTetherRadius");
if (!componentEntries.empty()) {
const auto& component = componentEntries[0];
m_AggroRadius = component.aggroRadius;
m_TetherSpeed = component.tetherSpeed;
m_PursuitSpeed = component.pursuitSpeed;
m_SoftTetherRadius = component.softTetherRadius;
m_HardTetherRadius = component.hardTetherRadius;
}
componentResult.finalize();
// Get aggro and tether radius from settings and use this if it is present. Only overwrite the
// radii if it is greater than the one in the database.
if (m_Parent) {