Files
ChildHood/Source/ChildHood/SystemDriver.h
T
starmen1265 4bf678b937 feat(interaction): 交互系统v1.1 Effect/Action架构实现
新增:
- 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>
2026-06-11 23:21:38 +08:00

82 lines
2.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ChildHood Project - 系统驱动器(v1.1 Effect/Action 架构)
// 对应技术方案: docs/technical/交互系统-技术方案.md 第3节(类设计)
// 职责:全局唯一的 World 级驱动器,持有所有 Manager(FInteractionManager, FEffectManager),
// 负责初始化、Tick 驱动、跨 Manager 协调。
// 架构:AInfo 子类(不渲染、不占场景空间),每关只有一个实例。
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Info.h"
#include "Interaction/InteractionManager.h"
#include "SystemDriver.generated.h"
// FEffectManager 由另一个子代理并行创建,此处只前向声明
class FEffectManager;
/**
* ASystemDriver
*
* 全局唯一的 World 级系统驱动器。持有 FInteractionManager 和 FEffectManager,
* 负责它们的初始化、Tick 驱动和跨 Manager 协调。
*
* 访问方式:ASystemDriver::Get(WorldContextObject) 静态方法。
*
* 数据流:
* InteractableComponent 碰撞回调 → Get() → GetInteractionManager().Register/Unregister
* Character 输入回调 → Get() → GetInteractionManager().BeginInteract/Cancel/Switch
* EffectManager 完成 → OnEffectComplete → GetInteractionManager().OnInteractionFinished
*/
UCLASS()
class ASystemDriver : public AInfo
{
GENERATED_BODY()
public:
ASystemDriver();
// === 生命周期 ===
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;
// === 全局访问 ===
/**
* 获取当前 World 中的 ASystemDriver 实例。
* WorldContextObject 用于获取 World 上下文(通常传 this 或 GetWorld())。
*/
UFUNCTION(BlueprintPure, Category = "System", meta = (WorldContext = "WorldContextObject"))
static ASystemDriver* Get(const UObject* WorldContextObject);
// === Manager 访问 ===
/** 获取交互管理器(值引用) */
FInteractionManager& GetInteractionManager() { return InteractionManager; }
const FInteractionManager& GetInteractionManager() const { return InteractionManager; }
/**
* 获取效果管理器(值引用)。
* FEffectManager 尚未创建时调用会触发链接错误,仅在 EffectManager.h 存在时使用。
*/
FEffectManager& GetEffectManager();
private:
/** 交互管理器 — 普通 C++ 值持有 */
FInteractionManager InteractionManager;
/**
* 效果管理器 — 普通 C++ 值持有。
* FEffectManager 定义在 Interaction/EffectManager.h 中(由另一个子代理创建)。
* 使用 unique_ptr 延迟构造,避免头文件中需要完整定义。
*/
TUniquePtr<FEffectManager> EffectManagerPtr;
// === Effect 完成回调连线 ===
/** EffectManager 的 OnEffectComplete 回调目标 */
void OnEffectComplete();
};