Add SLS integration component
This commit is contained in:
@@ -24,7 +24,9 @@ public class PHY : ModuleRules
|
||||
"GenericInputSystem",
|
||||
"GenericGameSystem",
|
||||
"GenericEffectsSystem",
|
||||
"SLSCore",
|
||||
"SmoothLocomotionSystem",
|
||||
"SLSIntegration",
|
||||
"AuroraDevs_UGC",
|
||||
"IKRig",
|
||||
"AIModule"
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "PHYGameplayTags.h"
|
||||
#include "Ragdoll/GGS_RagdollComponent.h"
|
||||
#include "Components/SLSCharacterMovementComponent.h"
|
||||
#include "SLSIntegrationComponent.h"
|
||||
#include "SLSIntegrationDataAsset.h"
|
||||
#include "Targeting/GCS_TargetingSystemComponent.h"
|
||||
#include "Team/GCS_CombatTeamAgentComponent.h"
|
||||
|
||||
@@ -39,6 +41,32 @@ APHYCharacterBase::APHYCharacterBase(const FObjectInitializer& ObjectInitializer
|
||||
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"));
|
||||
if (SLSIntegrationComponent && SLSIntegrationRuntimeDataAsset)
|
||||
{
|
||||
FSLSBaseCharacterMovementSettingsOp* MovementSettingsOp = SLSIntegrationRuntimeDataAsset->GetFirstSLSDataOpOfType<FSLSBaseCharacterMovementSettingsOp>();
|
||||
if (!MovementSettingsOp)
|
||||
{
|
||||
MovementSettingsOp = SLSIntegrationRuntimeDataAsset->AddAndGetSLSDataOp<FSLSBaseCharacterMovementSettingsOp>();
|
||||
}
|
||||
|
||||
if (MovementSettingsOp)
|
||||
{
|
||||
if (FSLSBaseCharacterMovementSettings* MovementSettings = static_cast<FSLSBaseCharacterMovementSettings*>(MovementSettingsOp->GetSettings()))
|
||||
{
|
||||
MovementSettings->bAddSkeletalBoneSyncComponent = false;
|
||||
MovementSettings->Config.InitComponentType = ESLSComponentInitType::ManualInit;
|
||||
MovementSettings->Config.MovementType = ESLSMovementType::Jog;
|
||||
MovementSettings->Config.RotationMode = ESLSRotationMode::VelocityDirection;
|
||||
MovementSettings->Config.bEnableSprintInLookingDirectionRotationMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
SLSIntegrationRuntimeDataAsset->InitializeData();
|
||||
SLSIntegrationComponent->SLSIntegrationDataAsset = SLSIntegrationRuntimeDataAsset;
|
||||
}
|
||||
|
||||
if (UClass* GenericIntegrationClass = FindObject<UClass>(nullptr, TEXT("/Script/GenericGameSystem.GenericIntegrationComponent")))
|
||||
{
|
||||
@@ -86,7 +114,7 @@ void APHYCharacterBase::BeginPlay()
|
||||
|
||||
if (SLSMovementBridgeComponent)
|
||||
{
|
||||
SLSMovementBridgeComponent->InitializeSLSMovementBridge(this, GenericIntegrationComponent);
|
||||
SLSMovementBridgeComponent->InitializeSLSMovementBridge(this, GenericIntegrationComponent, SLSIntegrationComponent);
|
||||
}
|
||||
|
||||
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Components/SLSCharacterMovementComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "PHYConfigSettings.h"
|
||||
#include "SLSIntegrationComponent.h"
|
||||
|
||||
UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent()
|
||||
{
|
||||
@@ -15,11 +16,12 @@ UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent()
|
||||
SetIsReplicatedByDefault(false);
|
||||
}
|
||||
|
||||
bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent)
|
||||
bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent)
|
||||
{
|
||||
bInitialized = false;
|
||||
OwnerCharacter = InCharacter;
|
||||
GenericIntegrationComponent = InGenericIntegrationComponent;
|
||||
SLSIntegrationComponent = InSLSIntegrationComponent;
|
||||
SLSCharacterMovementComponent = nullptr;
|
||||
|
||||
const UPHYLocomotionSettings* LocomotionSettings = GetDefault<UPHYLocomotionSettings>();
|
||||
@@ -34,9 +36,14 @@ bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InC
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SLSIntegrationComponent)
|
||||
{
|
||||
SLSIntegrationComponent = OwnerCharacter->FindComponentByClass<USLSIntegrationComponent>();
|
||||
}
|
||||
|
||||
const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>();
|
||||
|
||||
// 首期由项目侧显式初始化,避免依赖 SLSIntegrationComponent 的总装逻辑。
|
||||
// 项目侧保留显式初始化,SLSIntegrationComponent 只作为运动层集中集成入口。
|
||||
SLSCharacterMovementComponent->Config.InitComponentType = ESLSComponentInitType::ManualInit;
|
||||
SLSCharacterMovementComponent->Config.MovementType = ESLSMovementType::Jog;
|
||||
SLSCharacterMovementComponent->Config.RotationMode = ESLSRotationMode::VelocityDirection;
|
||||
|
||||
@@ -22,6 +22,7 @@ class UPHYCharacterStateComponent;
|
||||
class UPHYSLSMovementBridgeComponent;
|
||||
class USkeletalMeshComponent;
|
||||
class USLSCharacterMovementComponent;
|
||||
class USLSIntegrationComponent;
|
||||
|
||||
/**
|
||||
* @brief PHY 玩家和 AI 共用角色基类。
|
||||
@@ -134,6 +135,10 @@ public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
|
||||
USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const;
|
||||
|
||||
/** @brief 获取 SLS 集成入口组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
|
||||
USLSIntegrationComponent* GetSLSIntegrationComponent() const { return SLSIntegrationComponent; }
|
||||
|
||||
/** @brief 获取 GenericGameSystem 可选集成入口组件。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
|
||||
UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; }
|
||||
@@ -266,6 +271,10 @@ protected:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
|
||||
TObjectPtr<UPHYSLSMovementBridgeComponent> SLSMovementBridgeComponent;
|
||||
|
||||
/** @brief SLS 插件集成入口组件,由运动层集中接入。 */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
|
||||
TObjectPtr<USLSIntegrationComponent> SLSIntegrationComponent;
|
||||
|
||||
/** @brief GenericGameSystem 可选集成入口组件。 */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
|
||||
TObjectPtr<UActorComponent> GenericIntegrationComponent;
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
|
||||
class ACharacter;
|
||||
class USLSCharacterMovementComponent;
|
||||
class USLSIntegrationComponent;
|
||||
|
||||
/**
|
||||
* @brief PHY 对 Smooth Locomotion System 的首期运动桥接组件。
|
||||
*
|
||||
* 该组件只缓存并初始化明确接入的 SLS 运动组件,不使用 SLSIntegrationComponent,
|
||||
* 也不承担相机系统职责。
|
||||
* 该组件缓存并初始化明确接入的 SLS 运动组件和 SLSIntegrationComponent,
|
||||
* 但不承担相机系统职责。
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class PHY_API UPHYSLSMovementBridgeComponent : public UActorComponent
|
||||
@@ -28,10 +29,11 @@ public:
|
||||
* @brief 初始化 SLS 运动桥接。
|
||||
* @param InCharacter 拥有该桥接组件的角色。
|
||||
* @param InGenericIntegrationComponent 可选的 Generic 集成入口组件。
|
||||
* @param InSLSIntegrationComponent SLS 插件集成入口组件。
|
||||
* @return 初始化是否成功。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS")
|
||||
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent);
|
||||
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent = nullptr);
|
||||
|
||||
/** @brief 获取桥接到的角色。 */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||
@@ -41,6 +43,10 @@ public:
|
||||
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; }
|
||||
@@ -58,6 +64,10 @@ protected:
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user