Add SLS integration component

This commit is contained in:
2026-04-26 14:35:32 +08:00
parent 2ed2e91381
commit a2a2e16c93
6 changed files with 64 additions and 7 deletions

View File

@@ -27,7 +27,7 @@
- 相机专家向总架构汇报。主责 `AuroraDevs_UGC`、战斗锁定/瞄准/移动相机状态;不得主动引入 `GenericCameraSystem``SLSCameraModeSystem` 作为玩法层依赖。 - 相机专家向总架构汇报。主责 `AuroraDevs_UGC`、战斗锁定/瞄准/移动相机状态;不得主动引入 `GenericCameraSystem``SLSCameraModeSystem` 作为玩法层依赖。
- 战斗/GAS 专家向总架构汇报。主责 ASC、Ability、Attribute、GameplayTag、GameplayCue、伤害、复制、预测。 - 战斗/GAS 专家向总架构汇报。主责 ASC、Ability、Attribute、GameplayTag、GameplayCue、伤害、复制、预测。
- 输入专家向总架构汇报。主责 `GenericInputSystem``EnhancedInput`、输入到 GAS/UGC/运动/UI 的路由。 - 输入专家向总架构汇报。主责 `GenericInputSystem``EnhancedInput`、输入到 GAS/UGC/运动/UI 的路由。
- 运动专家向总架构汇报。主责 `SmoothLocomotionSystem``SLSCore``TraversalSystem``SLSIntegration``FootStepSystem`;运动状态只通过项目接口通知相机。 - 运动专家向总架构汇报。主责 `SmoothLocomotionSystem``SLSCore``TraversalSystem``SLSIntegration``FootStepSystem``USLSIntegrationComponent` 允许由运动专家集中接入,禁止其它系统散落依赖;运动状态只通过项目接口通知相机。
- UI 专家向总架构汇报。主责 `GenericUISystem``CommonUI`、UMG、HUD、输入模式切换。 - UI 专家向总架构汇报。主责 `GenericUISystem``CommonUI`、UMG、HUD、输入模式切换。
- 背包专家向总架构汇报。主责 `GenericInventorySystem`、物品、装备、拾取、战斗/UI 联动。 - 背包专家向总架构汇报。主责 `GenericInventorySystem`、物品、装备、拾取、战斗/UI 联动。
- 交互/效果专家向总架构汇报。主责 `GenericGameSystem``GenericEffectsSystem``SmartObjects``TargetingSystem`、Niagara。 - 交互/效果专家向总架构汇报。主责 `GenericGameSystem``GenericEffectsSystem``SmartObjects``TargetingSystem`、Niagara。
@@ -48,6 +48,7 @@
## 相机规则 ## 相机规则
- 项目相机主入口统一使用 Ultimate Gameplay Camera`AuroraDevs_UGC` - 项目相机主入口统一使用 Ultimate Gameplay Camera`AuroraDevs_UGC`
- `GenericCameraSystem``SLSCameraModeSystem` 只允许作为插件内部依赖、示例资产参考或薄适配层依赖;项目玩法层尽可能不用。 - `GenericCameraSystem``SLSCameraModeSystem` 只允许作为插件内部依赖、示例资产参考或薄适配层依赖;项目玩法层尽可能不用。
- `USLSIntegrationComponent` 由运动层集中持有和暴露,不等于允许业务层直接依赖 `SLSCameraModeSystem`
- 相机状态由项目级接口接收输入、运动和战斗状态,不允许业务代码到处直接耦合多个相机系统。 - 相机状态由项目级接口接收输入、运动和战斗状态,不允许业务代码到处直接耦合多个相机系统。
## C++ 和配置规则 ## C++ 和配置规则

View File

@@ -24,7 +24,9 @@ public class PHY : ModuleRules
"GenericInputSystem", "GenericInputSystem",
"GenericGameSystem", "GenericGameSystem",
"GenericEffectsSystem", "GenericEffectsSystem",
"SLSCore",
"SmoothLocomotionSystem", "SmoothLocomotionSystem",
"SLSIntegration",
"AuroraDevs_UGC", "AuroraDevs_UGC",
"IKRig", "IKRig",
"AIModule" "AIModule"

View File

@@ -22,6 +22,8 @@
#include "PHYGameplayTags.h" #include "PHYGameplayTags.h"
#include "Ragdoll/GGS_RagdollComponent.h" #include "Ragdoll/GGS_RagdollComponent.h"
#include "Components/SLSCharacterMovementComponent.h" #include "Components/SLSCharacterMovementComponent.h"
#include "SLSIntegrationComponent.h"
#include "SLSIntegrationDataAsset.h"
#include "Targeting/GCS_TargetingSystemComponent.h" #include "Targeting/GCS_TargetingSystemComponent.h"
#include "Team/GCS_CombatTeamAgentComponent.h" #include "Team/GCS_CombatTeamAgentComponent.h"
@@ -39,6 +41,32 @@ APHYCharacterBase::APHYCharacterBase(const FObjectInitializer& ObjectInitializer
ContextEffectComponent = CreateDefaultSubobject<UGES_ContextEffectComponent>(TEXT("ContextEffectComponent")); ContextEffectComponent = CreateDefaultSubobject<UGES_ContextEffectComponent>(TEXT("ContextEffectComponent"));
MeshBridgeComponent = CreateDefaultSubobject<UPHYCharacterMeshBridgeComponent>(TEXT("MeshBridgeComponent")); MeshBridgeComponent = CreateDefaultSubobject<UPHYCharacterMeshBridgeComponent>(TEXT("MeshBridgeComponent"));
SLSMovementBridgeComponent = CreateDefaultSubobject<UPHYSLSMovementBridgeComponent>(TEXT("SLSMovementBridgeComponent")); 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"))) if (UClass* GenericIntegrationClass = FindObject<UClass>(nullptr, TEXT("/Script/GenericGameSystem.GenericIntegrationComponent")))
{ {
@@ -86,7 +114,7 @@ void APHYCharacterBase::BeginPlay()
if (SLSMovementBridgeComponent) if (SLSMovementBridgeComponent)
{ {
SLSMovementBridgeComponent->InitializeSLSMovementBridge(this, GenericIntegrationComponent); SLSMovementBridgeComponent->InitializeSLSMovementBridge(this, GenericIntegrationComponent, SLSIntegrationComponent);
} }
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady); UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);

View File

@@ -8,6 +8,7 @@
#include "Components/SLSCharacterMovementComponent.h" #include "Components/SLSCharacterMovementComponent.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "PHYConfigSettings.h" #include "PHYConfigSettings.h"
#include "SLSIntegrationComponent.h"
UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent() UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent()
{ {
@@ -15,11 +16,12 @@ UPHYSLSMovementBridgeComponent::UPHYSLSMovementBridgeComponent()
SetIsReplicatedByDefault(false); SetIsReplicatedByDefault(false);
} }
bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent) bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent)
{ {
bInitialized = false; bInitialized = false;
OwnerCharacter = InCharacter; OwnerCharacter = InCharacter;
GenericIntegrationComponent = InGenericIntegrationComponent; GenericIntegrationComponent = InGenericIntegrationComponent;
SLSIntegrationComponent = InSLSIntegrationComponent;
SLSCharacterMovementComponent = nullptr; SLSCharacterMovementComponent = nullptr;
const UPHYLocomotionSettings* LocomotionSettings = GetDefault<UPHYLocomotionSettings>(); const UPHYLocomotionSettings* LocomotionSettings = GetDefault<UPHYLocomotionSettings>();
@@ -34,9 +36,14 @@ bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InC
return false; return false;
} }
if (!SLSIntegrationComponent)
{
SLSIntegrationComponent = OwnerCharacter->FindComponentByClass<USLSIntegrationComponent>();
}
const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>(); const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>();
// 首期由项目侧显式初始化,避免依赖 SLSIntegrationComponent 的总装逻辑 // 项目侧保留显式初始化SLSIntegrationComponent 只作为运动层集中集成入口
SLSCharacterMovementComponent->Config.InitComponentType = ESLSComponentInitType::ManualInit; SLSCharacterMovementComponent->Config.InitComponentType = ESLSComponentInitType::ManualInit;
SLSCharacterMovementComponent->Config.MovementType = ESLSMovementType::Jog; SLSCharacterMovementComponent->Config.MovementType = ESLSMovementType::Jog;
SLSCharacterMovementComponent->Config.RotationMode = ESLSRotationMode::VelocityDirection; SLSCharacterMovementComponent->Config.RotationMode = ESLSRotationMode::VelocityDirection;

View File

@@ -22,6 +22,7 @@ class UPHYCharacterStateComponent;
class UPHYSLSMovementBridgeComponent; class UPHYSLSMovementBridgeComponent;
class USkeletalMeshComponent; class USkeletalMeshComponent;
class USLSCharacterMovementComponent; class USLSCharacterMovementComponent;
class USLSIntegrationComponent;
/** /**
* @brief PHY 玩家和 AI 共用角色基类。 * @brief PHY 玩家和 AI 共用角色基类。
@@ -134,6 +135,10 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion") UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const; USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const;
/** @brief 获取 SLS 集成入口组件。 */
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
USLSIntegrationComponent* GetSLSIntegrationComponent() const { return SLSIntegrationComponent; }
/** @brief 获取 GenericGameSystem 可选集成入口组件。 */ /** @brief 获取 GenericGameSystem 可选集成入口组件。 */
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion") UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Character|Locomotion")
UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; } UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; }
@@ -266,6 +271,10 @@ protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion") UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
TObjectPtr<UPHYSLSMovementBridgeComponent> SLSMovementBridgeComponent; TObjectPtr<UPHYSLSMovementBridgeComponent> SLSMovementBridgeComponent;
/** @brief SLS 插件集成入口组件,由运动层集中接入。 */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
TObjectPtr<USLSIntegrationComponent> SLSIntegrationComponent;
/** @brief GenericGameSystem 可选集成入口组件。 */ /** @brief GenericGameSystem 可选集成入口组件。 */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion") UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="PHY|Character|Locomotion")
TObjectPtr<UActorComponent> GenericIntegrationComponent; TObjectPtr<UActorComponent> GenericIntegrationComponent;

View File

@@ -8,12 +8,13 @@
class ACharacter; class ACharacter;
class USLSCharacterMovementComponent; class USLSCharacterMovementComponent;
class USLSIntegrationComponent;
/** /**
* @brief PHY 对 Smooth Locomotion System 的首期运动桥接组件。 * @brief PHY 对 Smooth Locomotion System 的首期运动桥接组件。
* *
* 该组件缓存并初始化明确接入的 SLS 运动组件,不使用 SLSIntegrationComponent * 该组件缓存并初始化明确接入的 SLS 运动组件 SLSIntegrationComponent
* 不承担相机系统职责。 * 不承担相机系统职责。
*/ */
UCLASS(BlueprintType, Blueprintable) UCLASS(BlueprintType, Blueprintable)
class PHY_API UPHYSLSMovementBridgeComponent : public UActorComponent class PHY_API UPHYSLSMovementBridgeComponent : public UActorComponent
@@ -28,10 +29,11 @@ public:
* @brief 初始化 SLS 运动桥接。 * @brief 初始化 SLS 运动桥接。
* @param InCharacter 拥有该桥接组件的角色。 * @param InCharacter 拥有该桥接组件的角色。
* @param InGenericIntegrationComponent 可选的 Generic 集成入口组件。 * @param InGenericIntegrationComponent 可选的 Generic 集成入口组件。
* @param InSLSIntegrationComponent SLS 插件集成入口组件。
* @return 初始化是否成功。 * @return 初始化是否成功。
*/ */
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS") UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS")
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent); bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent = nullptr);
/** @brief 获取桥接到的角色。 */ /** @brief 获取桥接到的角色。 */
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS") UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
@@ -41,6 +43,10 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS") UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const { return SLSCharacterMovementComponent; } USLSCharacterMovementComponent* GetSLSCharacterMovementComponent() const { return SLSCharacterMovementComponent; }
/** @brief 获取 SLS 插件集成入口组件。 */
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
USLSIntegrationComponent* GetSLSIntegrationComponent() const { return SLSIntegrationComponent; }
/** @brief 获取可选的 Generic 集成入口组件。 */ /** @brief 获取可选的 Generic 集成入口组件。 */
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS") UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; } UActorComponent* GetGenericIntegrationComponent() const { return GenericIntegrationComponent; }
@@ -58,6 +64,10 @@ protected:
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS") UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
TObjectPtr<USLSCharacterMovementComponent> SLSCharacterMovementComponent; TObjectPtr<USLSCharacterMovementComponent> SLSCharacterMovementComponent;
/** @brief SLS 插件集成入口组件。 */
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
TObjectPtr<USLSIntegrationComponent> SLSIntegrationComponent;
/** @brief GenericGameSystem 提供的可选集成入口。 */ /** @brief GenericGameSystem 提供的可选集成入口。 */
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS") UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
TObjectPtr<UActorComponent> GenericIntegrationComponent; TObjectPtr<UActorComponent> GenericIntegrationComponent;