4bf678b937
新增: - EffectManager: Effect Timeline调度 + Action执行分发 - SystemDriver: AInfo全局驱动器, 持有FInteractionManager/FEffectManager - InteractionPromptComponent: 独立Prompt UI组件(只读Manager缓存) - DoorActor/DoorInteractableComponent: 门派生类 修改: - InteractionManager: 从UActorComponent重写为普通C++ FInteractionManager - Character: 替换旧InteractionManager为PromptComponent, 通过Driver访问Manager - GameInstance: 空壳化, 持久数据迁移至PersistenceSubsystem - InteractableComponent: 碰撞回调接入ASystemDriver注册路径 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
// ChildHood Project - 交互提示追踪组件
|
||
// 对应技术方案: docs/technical/交互系统-技术方案.md 第6节(提示UI显示/隐藏)
|
||
// 职责:独立于 Effect 执行,只负责 Free 状态下的 Prompt UI 追踪
|
||
// 架构:UActorComponent,自有 Tick,只读 InteractionManager 缓存
|
||
// 挂载:Character 上,由 Character::BeginPlay 中调用 Initialize
|
||
|
||
#pragma once
|
||
|
||
#include "CoreMinimal.h"
|
||
#include "Components/ActorComponent.h"
|
||
#include "InteractionPromptComponent.generated.h"
|
||
|
||
class ASystemDriver;
|
||
class UInteractionPromptWidget;
|
||
|
||
/**
|
||
* UInteractionPromptComponent
|
||
*
|
||
* 交互提示追踪组件。每帧检查 InteractionManager 的缓存数据,
|
||
* 在 Free 状态且有选中交互物时显示 Prompt Widget,Executing 时隐藏。
|
||
*
|
||
* 数据流:
|
||
* InteractionManager 缓存 (CachedSelected) → 此组件 Tick 只读 → Prompt Widget 显示/隐藏
|
||
*
|
||
* 不直接访问任何 InteractableComponent,所有数据来自 Manager 缓存。
|
||
*/
|
||
UCLASS(ClassGroup=(Interaction), meta=(BlueprintSpawnableComponent))
|
||
class UInteractionPromptComponent : public UActorComponent
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
|
||
UInteractionPromptComponent();
|
||
|
||
/** 初始化(Character::BeginPlay 中调用) */
|
||
void Initialize(ASystemDriver* InDriver);
|
||
|
||
protected:
|
||
|
||
virtual void BeginPlay() override;
|
||
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
|
||
FActorComponentTickFunction* ThisTickFunction) override;
|
||
|
||
private:
|
||
|
||
/** 弱引用 Driver */
|
||
TWeakObjectPtr<ASystemDriver> Driver;
|
||
|
||
/** Prompt Widget 实例 */
|
||
UPROPERTY()
|
||
TObjectPtr<UInteractionPromptWidget> PromptWidget;
|
||
|
||
/** Prompt Widget 蓝图类(编辑器中指定 WBP_InteractionPrompt) */
|
||
UPROPERTY(EditAnywhere, Category = "Interaction|UI")
|
||
TSubclassOf<UInteractionPromptWidget> PromptWidgetClass;
|
||
|
||
/** 提示 UI 高度偏移(cm) */
|
||
UPROPERTY(EditAnywhere, Category = "Interaction|UI")
|
||
float PromptHeightOffset = 80.0f;
|
||
|
||
/** 上一次记录的状态(用于检测状态变化) */
|
||
bool bWasShowingPrompt = false;
|
||
|
||
/** 更新 Prompt 显示 */
|
||
void UpdatePrompt();
|
||
|
||
/** 隐藏 Prompt */
|
||
void HidePrompt();
|
||
};
|