refactor(component): proximity monitor and movement AI load their own rows

The ProximityMonitorComponent row's radii and the MovementAIComponent row
(with the level's wanderRadius over it) move out of Entity::Initialize into
each component's LoadDataFromTemplate / LoadConfigData. Same components and
bytes for every LOT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-01 15:47:10 -05:00
parent c710e1d3a9
commit 54adbcdce8
5 changed files with 52 additions and 41 deletions

View File

@@ -470,47 +470,14 @@ void Entity::Initialize() {
}
case eReplicaComponentType::PROXIMITY_MONITOR: {
const auto proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR);
if (proximityMonitorID > 0) {
auto* const proxCompTable = CDClientManager::GetTable<CDProximityMonitorComponentTable>();
const auto proxCompData = proxCompTable->Query([proximityMonitorID](const CDProximityMonitorComponent& entry) { return (entry.id == proximityMonitorID); });
if (proxCompData.size() > 0) {
// "small,large"; one value (LOT 9833: "4") is both
const auto radii = GeneralUtils::SplitString(proxCompData[0].Proximities, ',');
const auto small = radii.empty() ? std::nullopt : GeneralUtils::TryParse<int32_t>(radii[0]);
const auto large = radii.size() > 1 ? GeneralUtils::TryParse<int32_t>(radii[1]) : small;
if (small && large) AddComponent<ProximityMonitorComponent>(proximityMonitorID, *small, *large);
}
}
if (proximityMonitorID > 0) AddComponent<ProximityMonitorComponent>(proximityMonitorID);
break;
}
case eReplicaComponentType::MOVEMENT_AI: {
const int movementAIID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVEMENT_AI);
if (movementAIID > 0) {
CDMovementAIComponentTable* moveAITable = CDClientManager::GetTable<CDMovementAIComponentTable>();
std::vector<CDMovementAIComponent> moveAIComp = moveAITable->Query([=](CDMovementAIComponent entry) {return (entry.id == movementAIID); });
if (moveAIComp.size() > 0) {
MovementAIInfo moveInfo{
.movementType = moveAIComp[0].MovementType,
.wanderRadius = moveAIComp[0].WanderRadius,
.wanderSpeed = moveAIComp[0].WanderSpeed,
.wanderChance = moveAIComp[0].WanderChance,
.wanderDelayMin = moveAIComp[0].WanderDelayMin,
.wanderDelayMax = moveAIComp[0].WanderDelayMax,
};
const bool useWanderDB = GetVar<bool>(u"usewanderdb");
if (!useWanderDB) {
const auto wanderOverride = GetVarAs<float>(u"wanderRadius");
if (wanderOverride != 0.0f) {
moveInfo.wanderRadius = wanderOverride;
}
}
AddComponent<MovementAIComponent>(movementAIID, moveInfo);
}
// Its row and the level's wanderRadius load in the component
AddComponent<MovementAIComponent>(movementAIID, MovementAIInfo{});
} else if (petComponentID > 0 || combatAiID > 0 && BaseCombatAIComponent::TetherSpeedOf(combatAiID) > 0) {
MovementAIInfo moveInfo{
.movementType = "",