Remove redundant SLS movement bridge
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Interaction/GGS_InteractionSystemComponent.h"
|
||||
#include "Locomotion/PHYSLSMovementBridgeComponent.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
#include "PHYConfigSettings.h"
|
||||
#include "PHYGameplayTags.h"
|
||||
#include "Ragdoll/GGS_RagdollComponent.h"
|
||||
#include "Components/SLSCharacterMovementComponent.h"
|
||||
@@ -47,7 +47,6 @@ APHYCharacterBase::APHYCharacterBase(const FObjectInitializer& ObjectInitializer
|
||||
RagdollComponent = CreateDefaultSubobject<UGGS_RagdollComponent>(TEXT("RagdollComponent"));
|
||||
ContextEffectComponent = CreateDefaultSubobject<UGES_ContextEffectComponent>(TEXT("ContextEffectComponent"));
|
||||
MeshBridgeComponent = CreateDefaultSubobject<UPHYCharacterMeshBridgeComponent>(TEXT("MeshBridgeComponent"));
|
||||
SLSMovementBridgeComponent = CreateDefaultSubobject<UPHYSLSMovementBridgeComponent>(TEXT("SLSMovementBridgeComponent"));
|
||||
SLSIntegrationComponent = CreateDefaultSubobject<USLSIntegrationComponent>(TEXT("SLSIntegrationComponent"));
|
||||
|
||||
USLSIntegrationDataAsset* SLSIntegrationRuntimeDataAsset = CreateDefaultSubobject<USLSIntegrationDataAsset>(TEXT("SLSIntegrationRuntimeDataAsset"));
|
||||
@@ -126,9 +125,15 @@ void APHYCharacterBase::BeginPlay()
|
||||
ContextEffectComponent->SetGameplayTagsProvider(this);
|
||||
}
|
||||
|
||||
if (SLSMovementBridgeComponent)
|
||||
if (const UPHYLocomotionSettings* LocomotionSettings = GetDefault<UPHYLocomotionSettings>(); LocomotionSettings && LocomotionSettings->bUseSmoothLocomotionSystem)
|
||||
{
|
||||
SLSMovementBridgeComponent->InitializeSLSMovementBridge(this, GenericIntegrationComponent, SLSIntegrationComponent);
|
||||
if (USLSCharacterMovementComponent* SLSMovementComponent = GetSLSCharacterMovementComponent())
|
||||
{
|
||||
const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>();
|
||||
SLSMovementComponent->ApplyBaseSLSCharacterMovementSettings();
|
||||
SLSMovementComponent->MaxWalkSpeed = CharacterSettings ? CharacterSettings->DefaultMaxWalkSpeed : SLSMovementComponent->MaxWalkSpeed;
|
||||
SLSMovementComponent->MaxAcceleration = CharacterSettings ? CharacterSettings->DefaultMaxAcceleration : SLSMovementComponent->MaxAcceleration;
|
||||
}
|
||||
}
|
||||
|
||||
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "Locomotion/PHYSLSMovementBridgeComponent.h"
|
||||
|
||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYSLSMovementBridgeComponent)
|
||||
|
||||
#include "Characters/PHYCharacterBase.h"
|
||||
#include "Characters/PHYCharacterSettings.h"
|
||||
#include "Components/SLSCharacterMovementComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "PHYConfigSettings.h"
|
||||
#include "SLSIntegrationComponent.h"
|
||||
|
||||
UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
SetIsReplicatedByDefault(false);
|
||||
}
|
||||
|
||||
bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent)
|
||||
{
|
||||
bInitialized = false;
|
||||
OwnerCharacter = InCharacter;
|
||||
GenericIntegrationComponent = InGenericIntegrationComponent;
|
||||
SLSIntegrationComponent = InSLSIntegrationComponent;
|
||||
SLSCharacterMovementComponent = nullptr;
|
||||
|
||||
const UPHYLocomotionSettings* LocomotionSettings = GetDefault<UPHYLocomotionSettings>();
|
||||
if (!LocomotionSettings || !LocomotionSettings->bUseSmoothLocomotionSystem || !OwnerCharacter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SLSCharacterMovementComponent = Cast<USLSCharacterMovementComponent>(OwnerCharacter->GetCharacterMovement());
|
||||
if (!SLSCharacterMovementComponent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SLSIntegrationComponent)
|
||||
{
|
||||
SLSIntegrationComponent = OwnerCharacter->FindComponentByClass<USLSIntegrationComponent>();
|
||||
}
|
||||
|
||||
const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>();
|
||||
|
||||
// 项目侧保留显式初始化,SLSIntegrationComponent 只作为运动层集中集成入口。
|
||||
SLSCharacterMovementComponent->Config.InitComponentType = ESLSComponentInitType::ManualInit;
|
||||
SLSCharacterMovementComponent->Config.MovementType = ESLSMovementType::Jog;
|
||||
SLSCharacterMovementComponent->Config.RotationMode = ESLSRotationMode::VelocityDirection;
|
||||
SLSCharacterMovementComponent->Config.bEnableSprintInLookingDirectionRotationMode = true;
|
||||
|
||||
SLSCharacterMovementComponent->ApplyBaseSLSCharacterMovementSettings();
|
||||
|
||||
if (CharacterSettings)
|
||||
{
|
||||
SLSCharacterMovementComponent->MaxWalkSpeed = CharacterSettings->DefaultMaxWalkSpeed;
|
||||
SLSCharacterMovementComponent->MaxAcceleration = CharacterSettings->DefaultMaxAcceleration;
|
||||
}
|
||||
|
||||
SLSCharacterMovementComponent->InitializeMovementComponent(SLSCharacterMovementComponent->Config);
|
||||
bInitialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UPHYSLSMovementBridgeComponent::HandleMoveInput(const FVector2D MoveInput)
|
||||
{
|
||||
if (!EnsureSLSMovementBridgeReady())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FRotator YawRotation(0.0f, OwnerCharacter->GetControlRotation().Yaw, 0.0f);
|
||||
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
|
||||
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
|
||||
const FVector WorldIntent = (ForwardDirection * MoveInput.Y) + (RightDirection * MoveInput.X);
|
||||
|
||||
if (APHYCharacterBase* PHYCharacter = Cast<APHYCharacterBase>(OwnerCharacter))
|
||||
{
|
||||
PHYCharacter->SetMovementIntent(WorldIntent);
|
||||
}
|
||||
|
||||
SLSCharacterMovementComponent->Input_OnMove(MoveInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UPHYSLSMovementBridgeComponent::HandleLookInput(const FVector2D LookInput)
|
||||
{
|
||||
if (!EnsureSLSMovementBridgeReady())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SLSCharacterMovementComponent->Input_OnLook(LookInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UPHYSLSMovementBridgeComponent::EnsureSLSMovementBridgeReady()
|
||||
{
|
||||
if (bInitialized && OwnerCharacter && SLSCharacterMovementComponent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ACharacter* Character = OwnerCharacter ? OwnerCharacter.Get() : Cast<ACharacter>(GetOwner());
|
||||
return InitializeSLSMovementBridge(Character, GenericIntegrationComponent, SLSIntegrationComponent);
|
||||
}
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "Characters/PHYPlayerCharacter.h"
|
||||
#include "Characters/PHYCharacterSettings.h"
|
||||
#include "Components/SLSCharacterMovementComponent.h"
|
||||
#include "GIPS_InputSystemComponent.h"
|
||||
#include "InputActionValue.h"
|
||||
#include "Locomotion/PHYSLSMovementBridgeComponent.h"
|
||||
#include "PHYGameplayTags.h"
|
||||
|
||||
namespace
|
||||
@@ -156,8 +156,19 @@ bool APHYPlayerController::HandleMoveInput(const FInputActionInstance& ActionDat
|
||||
|
||||
CachedMovementInput = IsInputReleased(TriggerEvent) ? FVector2D::ZeroVector : ExtractAxis2D(ActionData.GetValue());
|
||||
|
||||
UPHYSLSMovementBridgeComponent* SLSMovementBridge = PHYCharacter->GetSLSMovementBridgeComponent();
|
||||
return SLSMovementBridge ? SLSMovementBridge->HandleMoveInput(CachedMovementInput) : false;
|
||||
const FRotator YawRotation(0.0f, PHYCharacter->GetControlRotation().Yaw, 0.0f);
|
||||
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
|
||||
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
|
||||
const FVector WorldIntent = (ForwardDirection * CachedMovementInput.Y) + (RightDirection * CachedMovementInput.X);
|
||||
PHYCharacter->SetMovementIntent(WorldIntent);
|
||||
|
||||
if (USLSCharacterMovementComponent* SLSMovementComponent = PHYCharacter->GetSLSCharacterMovementComponent())
|
||||
{
|
||||
SLSMovementComponent->Input_OnMove(CachedMovementInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool APHYPlayerController::ConsumeMoveProcessorGuard(const ETriggerEvent TriggerEvent)
|
||||
@@ -199,6 +210,11 @@ bool APHYPlayerController::HandleLookInput(const FInputActionInstance& ActionDat
|
||||
return false;
|
||||
}
|
||||
|
||||
UPHYSLSMovementBridgeComponent* SLSMovementBridge = PHYCharacter->GetSLSMovementBridgeComponent();
|
||||
return SLSMovementBridge ? SLSMovementBridge->HandleLookInput(CachedLookInput) : false;
|
||||
if (USLSCharacterMovementComponent* SLSMovementComponent = PHYCharacter->GetSLSCharacterMovementComponent())
|
||||
{
|
||||
SLSMovementComponent->Input_OnLook(CachedLookInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ class UGGS_InteractionSystemComponent;
|
||||
class UGGS_RagdollComponent;
|
||||
class UPHYCharacterMeshBridgeComponent;
|
||||
class UPHYCharacterStateComponent;
|
||||
class UPHYSLSMovementBridgeComponent;
|
||||
class USkeletalMeshComponent;
|
||||
class USLSCharacterMovementComponent;
|
||||
class USLSIntegrationComponent;
|
||||
@@ -130,10 +129,6 @@ public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Animation")
|
||||
UPHYCharacterMeshBridgeComponent* GetMeshBridgeComponent() const { return MeshBridgeComponent; }
|
||||
|
||||
/** @brief 获取 PHY SLS 运动桥接组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
|
||||
UPHYSLSMovementBridgeComponent* GetSLSMovementBridgeComponent() const { return SLSMovementBridgeComponent; }
|
||||
|
||||
/** @brief 获取 SLS 角色运动组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
|
||||
USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const;
|
||||
@@ -270,10 +265,6 @@ protected:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Animation")
|
||||
TObjectPtr<UPHYCharacterMeshBridgeComponent> MeshBridgeComponent;
|
||||
|
||||
/** @brief PHY 对 SLS 运动系统的桥接组件。 */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
|
||||
TObjectPtr<UPHYSLSMovementBridgeComponent> SLSMovementBridgeComponent;
|
||||
|
||||
/** @brief SLS 插件集成入口组件,由运动层集中接入。 */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
|
||||
TObjectPtr<USLSIntegrationComponent> SLSIntegrationComponent;
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "PHYSLSMovementBridgeComponent.generated.h"
|
||||
|
||||
class ACharacter;
|
||||
class USLSCharacterMovementComponent;
|
||||
class USLSIntegrationComponent;
|
||||
|
||||
/**
|
||||
* @brief PHY 对 Smooth Locomotion System 的首期运动桥接组件。
|
||||
*
|
||||
* 该组件缓存并初始化明确接入的 SLS 运动组件和 SLSIntegrationComponent,
|
||||
* 但不承担相机系统职责。
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class PHY_API UPHYSLSMovementBridgeComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/** @brief 创建运动桥接组件。 */
|
||||
UPHYSLSMovementBridgeComponent();
|
||||
|
||||
/**
|
||||
* @brief 初始化 SLS 运动桥接。
|
||||
* @param InCharacter 拥有该桥接组件的角色。
|
||||
* @param InGenericIntegrationComponent 可选的 Generic 集成入口组件。
|
||||
* @param InSLSIntegrationComponent SLS 插件集成入口组件。
|
||||
* @return 初始化是否成功。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS")
|
||||
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief 通过 SLS 原生移动输入接口处理二维移动输入。
|
||||
* @param MoveInput X 为右移输入,Y 为前进输入。
|
||||
* @return 成功路由到 SLS 运动组件时返回 true。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS|Input")
|
||||
bool HandleMoveInput(FVector2D MoveInput);
|
||||
|
||||
/**
|
||||
* @brief 通过 SLS 原生视角输入接口处理二维视角输入。
|
||||
* @param LookInput X 为 Yaw 输入,Y 为 Pitch 输入。
|
||||
* @return 成功路由到 SLS 运动组件时返回 true。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS|Input")
|
||||
bool HandleLookInput(FVector2D LookInput);
|
||||
|
||||
/** @brief 获取桥接到的角色。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
ACharacter* GetOwnerCharacter() const { return OwnerCharacter; }
|
||||
|
||||
/** @brief 获取 SLS 角色运动组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const { return SLSCharacterMovementComponent; }
|
||||
|
||||
/** @brief 获取 SLS 插件集成入口组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
USLSIntegrationComponent* GetSLSIntegrationComponent() const { return SLSIntegrationComponent; }
|
||||
|
||||
/** @brief 获取可选的 Generic 集成入口组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; }
|
||||
|
||||
/** @brief 查询桥接是否已完成初始化。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
bool IsSLSMovementBridgeInitialized() const { return bInitialized; }
|
||||
|
||||
protected:
|
||||
/** @brief 确保桥接组件已经缓存角色和 SLS 运动组件。 */
|
||||
bool EnsureSLSMovementBridgeReady();
|
||||
|
||||
/** @brief 拥有 SLS 运动能力的角色。 */
|
||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||
TObjectPtr<ACharacter> OwnerCharacter;
|
||||
|
||||
/** @brief SLS 核心角色运动组件。 */
|
||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||
TObjectPtr<USLSCharacterMovementComponent> SLSCharacterMovementComponent;
|
||||
|
||||
/** @brief SLS 插件集成入口组件。 */
|
||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||
TObjectPtr<USLSIntegrationComponent> SLSIntegrationComponent;
|
||||
|
||||
/** @brief GenericGameSystem 提供的可选集成入口。 */
|
||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||
TObjectPtr<UActorComponent> GenericIntegrationComponent;
|
||||
|
||||
/** @brief 桥接初始化状态。 */
|
||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||
bool bInitialized = false;
|
||||
};
|
||||
Reference in New Issue
Block a user