79 lines
2.8 KiB
C++
79 lines
2.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/PlayerController.h"
|
|
#include "GIPS_InputTypes.h"
|
|
#include "PHYPlayerController.generated.h"
|
|
|
|
class APHYPlayerCharacter;
|
|
class UGIPS_InputSystemComponent;
|
|
|
|
/**
|
|
* @brief PHY 玩家控制器。
|
|
*
|
|
* 控制器持有 GenericInputSystem 组件,并将 Input GameplayTag 路由到当前玩家角色、ASC、移动和相机输入缓存。
|
|
*/
|
|
UCLASS(BlueprintType, Blueprintable)
|
|
class PHY_API APHYPlayerController : public APlayerController
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** @brief 构造输入组件并设置 UGC 相机管理器。 */
|
|
APHYPlayerController(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
|
|
|
/** @brief 初始化输入委托。 */
|
|
virtual void BeginPlay() override;
|
|
|
|
/** @brief 接管 Pawn 时刷新输入委托。 */
|
|
virtual void OnPossess(APawn* InPawn) override;
|
|
|
|
/** @brief 获取 GenericInputSystem 组件。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
|
UGIPS_InputSystemComponent* GetInputSystemComponent() const { return InputSystemComponent; }
|
|
|
|
/** @brief 获取当前 PHY 玩家角色。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
|
APHYPlayerCharacter* GetPHYPlayerCharacter() const;
|
|
|
|
/** @brief 获取相机使用的旋转输入缓存。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
|
FRotator GetCachedRotationInput() const { return CachedRotationInput; }
|
|
|
|
/** @brief 获取相机使用的移动控制输入缓存。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
|
FVector GetCachedMovementControlInput() const { return FVector(CachedMovementInput.X, CachedMovementInput.Y, 0.0f); }
|
|
|
|
protected:
|
|
/** @brief 绑定 GenericInputSystem 输入委托。 */
|
|
virtual void BindInputEvents();
|
|
|
|
/** @brief 处理 GenericInputSystem 发出的输入事件。 */
|
|
UFUNCTION()
|
|
void OnReceivedInput(const FInputActionInstance& ActionData, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent);
|
|
|
|
/** @brief 处理移动输入。 */
|
|
virtual bool HandleMoveInput(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
|
|
|
/** @brief 处理视角输入。 */
|
|
virtual bool HandleLookInput(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
|
|
|
/** @brief GenericInputSystem 路由组件。 */
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Input")
|
|
TObjectPtr<UGIPS_InputSystemComponent> InputSystemComponent;
|
|
|
|
/** @brief 本地移动输入缓存。 */
|
|
UPROPERTY(Transient)
|
|
FVector2D CachedMovementInput = FVector2D::ZeroVector;
|
|
|
|
/** @brief 本地视角输入缓存。 */
|
|
UPROPERTY(Transient)
|
|
FVector2D CachedLookInput = FVector2D::ZeroVector;
|
|
|
|
/** @brief UGC 相机管理器读取的旋转输入缓存。 */
|
|
UPROPERTY(Transient)
|
|
FRotator CachedRotationInput = FRotator::ZeroRotator;
|
|
};
|