Keep input system on player character
This commit is contained in:
@@ -41,8 +41,6 @@ APHYPlayerController::APHYPlayerController(const FObjectInitializer& ObjectIniti
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
PlayerCameraManagerClass = APHYPlayerCameraManager::StaticClass();
|
||||
|
||||
InputSystemComponent = CreateDefaultSubobject<UGIPS_InputSystemComponent>(TEXT("InputSystemComponent"));
|
||||
}
|
||||
|
||||
void APHYPlayerController::BeginPlay()
|
||||
@@ -68,13 +66,10 @@ UGIPS_InputSystemComponent* APHYPlayerController::GetInputSystemComponent() cons
|
||||
{
|
||||
if (const APHYPlayerCharacter* PHYCharacter = GetPHYPlayerCharacter())
|
||||
{
|
||||
if (UGIPS_InputSystemComponent* CharacterInputSystemComponent = PHYCharacter->GetInputSystemComponent())
|
||||
{
|
||||
return CharacterInputSystemComponent;
|
||||
}
|
||||
return PHYCharacter->GetInputSystemComponent();
|
||||
}
|
||||
|
||||
return InputSystemComponent;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void APHYPlayerController::BindInputEvents()
|
||||
|
||||
@@ -13,7 +13,8 @@ class UGIPS_InputSystemComponent;
|
||||
/**
|
||||
* @brief PHY 玩家控制器。
|
||||
*
|
||||
* 控制器优先绑定当前玩家角色的 GenericInputSystem 组件,并将 Input GameplayTag 路由到角色、ASC、移动和相机输入缓存。
|
||||
* 控制器不持有 GenericInputSystem 组件,只绑定当前玩家角色身上的输入组件,
|
||||
* 并把 Input GameplayTag 路由到角色、ASC、移动和相机输入缓存。
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class PHY_API APHYPlayerController : public APlayerController
|
||||
@@ -21,7 +22,7 @@ class PHY_API APHYPlayerController : public APlayerController
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/** @brief 构造输入组件并设置 UGC 相机管理器。 */
|
||||
/** @brief 构造控制器并设置 UGC 相机管理器。 */
|
||||
APHYPlayerController(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
/** @brief 初始化输入委托。 */
|
||||
@@ -30,14 +31,10 @@ public:
|
||||
/** @brief 接管 Pawn 时刷新输入委托。 */
|
||||
virtual void OnPossess(APawn* InPawn) override;
|
||||
|
||||
/** @brief 获取当前实际绑定的 GenericInputSystem 组件,优先返回玩家角色上的组件。 */
|
||||
/** @brief 获取当前玩家角色身上的 GenericInputSystem 组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
||||
UGIPS_InputSystemComponent* GetInputSystemComponent() const;
|
||||
|
||||
/** @brief 获取控制器自身保留的 GenericInputSystem 组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
||||
UGIPS_InputSystemComponent* GetControllerInputSystemComponent() const { return InputSystemComponent; }
|
||||
|
||||
/** @brief 获取当前 PHY 玩家角色。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Input")
|
||||
APHYPlayerCharacter* GetPHYPlayerCharacter() const;
|
||||
@@ -53,17 +50,17 @@ public:
|
||||
/** @brief 从输入处理器或控制器 fallback 路由移动输入。 */
|
||||
bool RouteMoveInput(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
||||
|
||||
/** @brief 从 GenericInputSystem 处理器路由移动输入,并阻止同一事件被广播 fallback 重复执行。 */
|
||||
/** @brief 从 GenericInputSystem 处理器路由移动输入,并阻止同一事件被 fallback 重复执行。 */
|
||||
bool RouteMoveInputFromProcessor(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
||||
|
||||
/** @brief 从输入处理器或控制器 fallback 路由视角输入。 */
|
||||
bool RouteLookInput(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
||||
|
||||
/** @brief 从 GenericInputSystem 处理器路由视角输入,并阻止同一事件被广播 fallback 重复执行。 */
|
||||
/** @brief 从 GenericInputSystem 处理器路由视角输入,并阻止同一事件被 fallback 重复执行。 */
|
||||
bool RouteLookInputFromProcessor(const FInputActionInstance& ActionData, ETriggerEvent TriggerEvent);
|
||||
|
||||
protected:
|
||||
/** @brief 绑定 GenericInputSystem 输入委托。 */
|
||||
/** @brief 绑定玩家角色身上的 GenericInputSystem 输入委托。 */
|
||||
virtual void BindInputEvents();
|
||||
|
||||
/** @brief 处理 GenericInputSystem 发出的输入事件。 */
|
||||
@@ -82,11 +79,7 @@ protected:
|
||||
/** @brief 查询并消费视角处理器留下的重复执行保护。 */
|
||||
virtual bool ConsumeLookProcessorGuard(ETriggerEvent TriggerEvent);
|
||||
|
||||
/** @brief GenericInputSystem 路由组件。 */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Input")
|
||||
TObjectPtr<UGIPS_InputSystemComponent> InputSystemComponent;
|
||||
|
||||
/** @brief 当前已经绑定输入委托的组件。 */
|
||||
/** @brief 当前已经绑定输入委托的角色输入组件。 */
|
||||
UPROPERTY(Transient)
|
||||
TObjectPtr<UGIPS_InputSystemComponent> BoundInputSystemComponent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user