From e1c3c19c9adbe985377f9c7d122cad9bcfdfed27 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 1 Oct 2026 08:37:42 -0500 Subject: [PATCH] refactor(component): the quickbuild reads its level config and spawns its activator in LoadConfigData Co-Authored-By: Claude Opus 5.5 --- dGame/dComponents/QuickBuildComponent.cpp | 8 ++++++-- dGame/dComponents/QuickBuildComponent.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index c7c357db3..3c29ddf57 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -33,7 +33,12 @@ QuickBuildComponent::QuickBuildComponent(Entity* const entity, const int32_t componentID) : Component{ entity, componentID } { RegisterMsg(&QuickBuildComponent::OnRequestUse); - std::u16string checkPreconditions = entity->GetVar(u"CheckPrecondition"); + RegisterMsg(&QuickBuildComponent::OnGetObjectReportInfo); +} + +// The level config: the precondition and the activator's position, then the activator +void QuickBuildComponent::LoadConfigData() { + std::u16string checkPreconditions = m_Parent->GetVar(u"CheckPrecondition"); if (!checkPreconditions.empty()) { m_Precondition = new PreconditionExpression(GeneralUtils::UTF16ToWTF8(checkPreconditions)); @@ -51,7 +56,6 @@ QuickBuildComponent::QuickBuildComponent(Entity* const entity, const int32_t com } SpawnActivator(); - RegisterMsg(&QuickBuildComponent::OnGetObjectReportInfo); } QuickBuildComponent::~QuickBuildComponent() { diff --git a/dGame/dComponents/QuickBuildComponent.h b/dGame/dComponents/QuickBuildComponent.h index b7cb7b12b..064260088 100644 --- a/dGame/dComponents/QuickBuildComponent.h +++ b/dGame/dComponents/QuickBuildComponent.h @@ -25,6 +25,8 @@ public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD; QuickBuildComponent(Entity* const entity, const int32_t componentID); + + void LoadConfigData() override; ~QuickBuildComponent() override; void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;