// ChildHood Project - 玩家角色(v1.1 Effect/Action 架构适配) // 变更:移除 UInteractionManager,改用 UInteractionPromptComponent // 交互操作通过 ASystemDriver 访问 FInteractionManager + FEffectManager // Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "Logging/LogMacros.h" #include "ChildHoodCharacter.generated.h" class USpringArmComponent; class UCameraComponent; class UInputAction; class UInteractionPromptComponent; class UCollectionHUDComponent; class ASystemDriver; struct FInputActionValue; DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All); /** * A simple player-controllable third person character * Implements a controllable orbiting camera * * v1.1 架构变更: * - 交互操作通过 ASystemDriver 全局单例访问 FInteractionManager / FEffectManager * - 身上挂载 UInteractionPromptComponent 负责 Free 状态下的 Prompt UI 追踪 */ UCLASS(abstract) class AChildHoodCharacter : public ACharacter { GENERATED_BODY() /** Camera boom positioning the camera behind the character */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) USpringArmComponent* CameraBoom; /** Follow camera */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UCameraComponent* FollowCamera; protected: /** Move Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* MoveAction; /** Look Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* LookAction; /** Mouse Look Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* MouseLookAction; /** Interact Input Action (E key) — delegates to interaction system */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* InteractAction; /** Cancel Input Action (ESC key) — delegates to interaction system */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* CancelAction; /** Switch Interact Target Input Action (Tab / Mouse Wheel) — delegates to interaction system */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* SwitchInteractAction; /** 交互提示 UI 组件 — Free 状态下追踪选中交互物并显示 Prompt */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Interaction", meta = (AllowPrivateAccess = "true")) UInteractionPromptComponent* PromptComponent; /** 收集系统 HUD 组件 — 表现层,只读 CollectionManager 缓存驱动收集 UI */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Collection", meta = (AllowPrivateAccess = "true")) UCollectionHUDComponent* CollectionHUDComponent; /** Whether the character is currently in an interaction */ bool bIsInteracting = false; virtual void BeginPlay() override; public: /** Constructor */ AChildHoodCharacter(); /** 获取交互提示组件 */ UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Interaction") UInteractionPromptComponent* GetPromptComponent() const; /** 获取收集系统 HUD 组件 */ UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Collection") UCollectionHUDComponent* GetCollectionHUDComponent() const; /** Set interaction state — called by interaction system */ UFUNCTION(BlueprintCallable, Category = "Interaction") void SetInteracting(bool bValue); /** Query: is the character currently interacting? */ UFUNCTION(BlueprintCallable, BlueprintPure, Category="Interaction") bool IsInteracting() const; /** Query: is the character currently running (moving on ground)? */ UFUNCTION(BlueprintCallable, BlueprintPure, Category="Interaction") bool IsRunning() const; protected: /** Initialize input action bindings */ virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; /** Called for movement input */ void Move(const FInputActionValue& Value); /** Called for looking input */ void Look(const FInputActionValue& Value); /** Called for interact input (E) — delegates to ASystemDriver */ void OnInteract(const FInputActionValue& Value); /** Called for cancel input (ESC) — delegates to ASystemDriver */ void OnCancel(const FInputActionValue& Value); /** Called for switch interact target input (Tab/Wheel) — delegates to ASystemDriver */ void OnSwitchInteract(const FInputActionValue& Value); public: /** Handles move inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoMove(float Right, float Forward); /** Handles look inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoLook(float Yaw, float Pitch); public: /** Returns CameraBoom subobject **/ FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } /** Returns FollowCamera subobject **/ FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } };