feat(collection): P-013收集系统三层架构解耦实现

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 05:13:28 +08:00
parent 2f0a2133a1
commit 4fc4a39aa6
21 changed files with 1286 additions and 7 deletions
+18
View File
@@ -17,6 +17,7 @@
#include "InputActionValue.h"
#include "ChildHood.h"
#include "Interaction/InteractionPromptComponent.h"
#include "Collection/CollectionHUDComponent.h"
#include "SystemDriver.h"
#include "Interaction/InteractionManager.h"
#include "Interaction/EffectManager.h"
@@ -67,6 +68,9 @@ AChildHoodCharacter::AChildHoodCharacter()
// 创建交互提示组件(替代旧 InteractionManager)
PromptComponent = CreateDefaultSubobject<UInteractionPromptComponent>(TEXT("PromptComponent"));
// 创建收集系统 HUD 组件(表现层,挂在角色上;Tick 兜底查找 Driver)
CollectionHUDComponent = CreateDefaultSubobject<UCollectionHUDComponent>(TEXT("CollectionHUDComponent"));
}
void AChildHoodCharacter::BeginPlay()
@@ -81,6 +85,15 @@ void AChildHoodCharacter::BeginPlay()
PromptComponent->Initialize(Driver);
}
}
// 初始化收集系统 HUD 组件(Driver 弱引用;Tick 会兜底查找,规避 BeginPlay 时序竞争)
if (CollectionHUDComponent)
{
if (ASystemDriver* Driver = ASystemDriver::Get(this))
{
CollectionHUDComponent->Initialize(Driver);
}
}
}
void AChildHoodCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
@@ -235,6 +248,11 @@ UInteractionPromptComponent* AChildHoodCharacter::GetPromptComponent() const
return PromptComponent;
}
UCollectionHUDComponent* AChildHoodCharacter::GetCollectionHUDComponent() const
{
return CollectionHUDComponent;
}
void AChildHoodCharacter::SetInteracting(bool bValue)
{
bIsInteracting = bValue;