第一次提交

This commit is contained in:
不明不惑
2026-03-03 01:23:02 +08:00
commit 3e434877e8
1053 changed files with 102411 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_LocomotionStructLibrary.h"
#include "Engine/DataAsset.h"
#include "Animation/AnimInstance.h"
#include "GMS_AnimLayer.generated.h"
class UGMS_MovementDefinition;
class UGMS_AnimLayer;
class UGMS_MovementSystemComponent;
class UGMS_MainAnimInstance;
class APawn;
/**
* Base class for animation layer settings.
* 动画层设置的基类。
*/
UCLASS(Abstract, BlueprintType, EditInlineNew, Const, CollapseCategories)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting : public UDataAsset
{
GENERATED_BODY()
public:
/**
* Gets the override animation layer class.
* 获取覆盖的动画层类。
* @param OutLayerClass The output animation layer class. 输出的动画层类。
* @return True if an override class is provided. 如果提供了覆盖类则返回true。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|AnimationLayer")
bool GetOverrideAnimLayerClass(TSubclassOf<UGMS_AnimLayer>& OutLayerClass) const;
/**
* Validates the data for this animation layer setting.
* 验证此动画层设置的数据。
* @param ErrorText The error message if validation fails. 如果验证失败的错误信息。
* @return True if data is valid. 如果数据有效则返回true。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|AnimationLayer", meta=(DisplayName="Is Data Valid"))
bool K2_IsDataValid(FText& ErrorText) const;
#if WITH_EDITOR
public:
/**
* Validates data in the editor.
* 在编辑器中验证数据。
* @param Context The validation context. 验证上下文。
* @return The validation result. 验证结果。
*/
virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override;
#endif
};
/**
* Base class for all animation layers.
* 所有动画层的基类。
* @note Classes inheriting from this must only be linked to GMS_MainAnimInstance (the main animation instance). 从该类继承的类只能链接到GMS_MainAnimInstance主动画实例
*/
UCLASS(BlueprintType, Abstract)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer : public UAnimInstance
{
GENERATED_BODY()
protected:
/**
* The owning pawn of this animation layer.
* 此动画层的拥有Pawn。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="State", Transient)
TObjectPtr<APawn> PawnOwner;
/**
* Reference to the movement system component.
* 运动系统组件的引用。
*/
UPROPERTY(Transient)
TObjectPtr<UGMS_MovementSystemComponent> MovementSystem;
private:
/**
* Weak reference to the parent main animation instance.
* 对父主动画实例的弱引用。
*/
UPROPERTY(VisibleAnywhere, Category="State", Transient)
TWeakObjectPtr<UGMS_MainAnimInstance> Parent;
public:
/**
* Constructor.
* 构造函数。
*/
UGMS_AnimLayer();
/**
* Gets the parent main animation instance.
* 获取父主动画实例。
* @return The parent main animation instance. 父主动画实例。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|AnimationLayer", Meta = (BlueprintThreadSafe, ReturnDisplayName = "Parent"))
UGMS_MainAnimInstance* GetParent() const;
/**
* Called when the animation layer is linked to the main animation instance.
* 当动画层链接到主动画实例时调用。
* @note Suitable for initialization tasks similar to BeginPlay. 适合执行类似BeginPlay的初始化任务。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|AnimationLayer")
void OnLinked();
virtual void OnLinked_Implementation();
/**
* Called when the animation layer is unlinked from the main animation instance.
* 当动画层从主动画实例取消链接时调用。
* @note Suitable for cleanup tasks similar to EndPlay. 适合执行类似EndPlay的清理任务。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|AnimationLayer")
void OnUnlinked();
virtual void OnUnlinked_Implementation();
/**
* Applies settings to the animation layer.
* 向动画层应用设置。
* @param Setting The setting object to apply, cast to the desired type. 要应用的设置对象,可转换为所需类型。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|AnimationLayer")
void ApplySetting(const UGMS_AnimLayerSetting* Setting);
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting);
/**
* Resets the settings of the animation layer.
* 重置动画层的设置。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|AnimationLayer")
void ResetSetting();
virtual void ResetSetting_Implementation();
/**
* Initializes the animation.
* 初始化动画。
*/
virtual void NativeInitializeAnimation() override;
/**
* Called when the game starts.
* 游戏开始时调用。
*/
virtual void NativeBeginPlay() override;
/**
* Maps animation state names to gameplay tags for checking node relevance.
* 将动画状态名称映射到游戏标签以检查节点相关性。
* @note Used to determine if an animation state node is active via NodeRelevantTags in the main animation instance. 用于通过主动画实例中的NodeRelevantTags确定动画状态节点是否活跃。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings", meta=(TitleProperty="Tag"))
TArray<FGMS_AnimStateNameToTag> AnimStateNameToTagMapping;
};

View File

@@ -0,0 +1,17 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "GMS_AnimLayer_Additive.generated.h"
/**
* Base class for additive animation layer settings.
* 附加动画层设置的基类。
*/
UCLASS(Abstract, Blueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Additive : public UGMS_AnimLayerSetting
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,81 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "Settings/GMS_SettingObjectLibrary.h"
#include "GMS_AnimLayer_Overlay.generated.h"
#pragma region Blend Data Structures
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_PoseBlendSetting
{
GENERATED_BODY()
virtual ~FGMS_AnimData_PoseBlendSetting() = default;
/**
* The overall adoption of the pose(0~1).
* 姿势的整体采用度0~11是开启0是关闭。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(ClampMin=0, ClampMax=1, DisplayPriority=0))
float BlendAmount{1.0f};
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_PoseBlendSetting_TwoParams : public FGMS_AnimData_PoseBlendSetting
{
GENERATED_BODY()
/**
* Overall adoption of Montage playing on this slot (0~1)
* 在此槽上播放的Montage的整体采用度0~1
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(ClampMin=0, ClampMax=1, DisplayPriority=2))
float SlotBlendAmount{1.0f};
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_PoseBlendSetting_ThreeParams : public FGMS_AnimData_PoseBlendSetting_TwoParams
{
GENERATED_BODY()
/**
* How much to blend the overlay pose with the underlying motion.
* 叠加姿势与底层运动的混合程度。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(ClampMin=0, ClampMax=1, DisplayPriority=1))
float AdditiveBlendAmount{0.0f};
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_PoseBlendSetting_FourParams : public FGMS_AnimData_PoseBlendSetting_ThreeParams
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(ClampMin=0, ClampMax=1, DisplayPriority=3))
bool bMeshSpace{true};
};
#pragma endregion
/**
* Base class for overlay animation layer settings.
* 叠加动画层设置的基类。
*/
UCLASS(Abstract, Blueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Overlay : public UGMS_AnimLayerSetting
{
GENERATED_BODY()
public:
/**
* Checks if the overlay mode is valid.
* 检查叠加模式是否有效。
* @param NewOverlayMode The overlay mode to check. 要检查的叠加模式。
* @return True if the overlay mode is valid, false otherwise. 如果叠加模式有效则返回true否则返回false。
*/
virtual bool IsValidForOverlayMode(const FGameplayTag& NewOverlayMode) const { return true; };
};

View File

@@ -0,0 +1,351 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "Animation/AnimExecutionContext.h"
#include "Animation/AnimNodeReference.h"
#include "GameplayTagContainer.h"
#include "GMS_AnimLayer_Overlay.h"
#include "GMS_AnimState.h"
#include "InstancedStruct.h"
#include "StructUtils/InstancedStruct.h"
#include "GMS_AnimLayer_Overlay_ParallelPoseStack.generated.h"
#pragma region Settings
/**
* The body mask type for human body.
* 针对人的身体遮罩。
* @attention The enum order also controls the override priority.枚举顺序同时控制了姿势覆盖的优先级。
*/
UENUM(BlueprintType)
enum class EGMS_BodyMask : uint8
{
Head,
ArmLeft,
ArmRight,
UpperBody,
LowerBody,
FullBody,
MAX UMETA(Hidden)
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose
{
GENERATED_BODY()
virtual ~FGMS_AnimData_BodyPose() = default;
/**
* Gameplay tag query against to main anim instance's relevance tags(the tags representing the relevant/active state of the anim state machine nodes).
* 针对主动画实例的相关性标签的查询,相关性标签指:用于标识动画状态机节点是否激活的标签。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.SM"))
FGameplayTagQuery RelevanceQuery;
/**
* Gameplay tag query against to the movement system's owned tags.
* 针对运动系统组件所拥有标签的查询。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FGameplayTagQuery TagQuery;
/**
* The pose sequence.
* 姿势。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> Pose{nullptr};
/**
* The pose time.
* 姿势的帧位置。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float PoseExplicitTime{0.0f};
UPROPERTY()
int32 Priority = 999;
virtual EGMS_BodyMask GetBodyPart() const { return EGMS_BodyMask::FullBody; }
virtual void Reset()
{
Pose = nullptr;
Priority = 999;
};
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const
{
};
bool IsValid() const { return Pose != nullptr; }
#if WITH_EDITORONLY_DATA
UPROPERTY(EditAnywhere, Category="GES", meta=(EditCondition=false, EditConditionHides))
FString EditorFriendlyName;
virtual void PreSave();
#endif
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_Full : public FGMS_AnimData_BodyPose
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_ThreeParams HeadBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_FourParams ArmLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_FourParams ArmRightBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting HandLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting HandRightBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_ThreeParams SpineBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_TwoParams PelvisBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_TwoParams LegsBlend;
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::FullBody; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_Upper : public FGMS_AnimData_BodyPose
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_ThreeParams HeadBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_FourParams ArmLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_FourParams ArmRightBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting HandLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting HandRightBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_ThreeParams SpineBlend;
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::UpperBody; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_Head : public FGMS_AnimData_BodyPose
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_ThreeParams Blend;
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::Head; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT(meta=(Hidden))
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_Arms : public FGMS_AnimData_BodyPose
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_FourParams Blend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting HandBlend;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_ArmLeft : public FGMS_AnimData_BodyPose_Arms
{
GENERATED_BODY()
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::ArmLeft; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_ArmRight : public FGMS_AnimData_BodyPose_Arms
{
GENERATED_BODY()
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::ArmRight; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData_BodyPose_Lower : public FGMS_AnimData_BodyPose
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_TwoParams PelvisBlend;
UPROPERTY(EditAnywhere, Category="GMS", meta=(DisplayAfter="PoseExplicitTime"))
FGMS_AnimData_PoseBlendSetting_TwoParams LegsBlend;
virtual EGMS_BodyMask GetBodyPart() const override { return EGMS_BodyMask::LowerBody; }
virtual void UpdateLayeringState(FGMS_AnimState_Layering& LayeringState) const override;
};
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_OverlayModeSetting_ParallelPoseStack
{
GENERATED_BODY()
virtual ~FGMS_OverlayModeSetting_ParallelPoseStack() = default;
/**
* Unique tag for this overlay mode.
* 此叠加模式的唯一标签。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.OverlayMode"))
FGameplayTag Tag;
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> BasePose = nullptr;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_Full>> FullBodyPoses;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_Upper>> UpperBodyPoses;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_Lower>> LowerBodyPoses;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_ArmLeft>> ArmLeftPoses;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_ArmRight>> ArmRightPoses;
UPROPERTY(EditAnywhere, Category="GMS")
TArray<TInstancedStruct<FGMS_AnimData_BodyPose_Head>> HeadPoses;
#if WITH_EDITORONLY_DATA
virtual void PreSave();
#endif
};
struct GENERICMOVEMENTSYSTEM_API FGMS_BodyPartOverridePolicy
{
FGMS_BodyPartOverridePolicy();
bool CanOverride(EGMS_BodyMask NewPart, EGMS_BodyMask ExistingPart, int32 NewPriority, int32 ExistingPriority) const;
void ApplyCoverage(EGMS_BodyMask BodyPart, TArray<TInstancedStruct<FGMS_AnimData_BodyPose>>& SelectedPoses, const TInstancedStruct<FGMS_AnimData_BodyPose>& NewPose, int32 NewPriority) const;
TMap<EGMS_BodyMask, TArray<EGMS_BodyMask>> FallbackChain;
};
/**
* Anim layer setting for ParallelPoseStack overlay system.
* 针对"并行姿势栈"的动画叠加系统设置。
* @details Similar to PoseStack, but allowing multiple body part has different overlay at the same time.与姿势栈相似,但允许同时让身体的不同部位有不同的姿势。
*/
UCLASS(NotBlueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Overlay_ParallelPoseStack final : public UGMS_AnimLayerSetting_Overlay
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category="Settings", meta=(EditCondition=false, EditConditionHides))
TMap<FGameplayTag, FGMS_OverlayModeSetting_ParallelPoseStack> AcceleratedOverlayModes;
protected:
UPROPERTY(EditAnywhere, Category="Settings", meta=(TitleProperty="Tag"))
TArray<FGMS_OverlayModeSetting_ParallelPoseStack> OverlayModes;
#if WITH_EDITORONLY_DATA
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};
#pragma endregion
/**
* Anim layer implementation for ParallelPoseStack overlay system.
* 针对"并行姿势栈"的动画叠加系统实现。
*/
UCLASS(Abstract)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer_Overlay_ParallelPoseStack : public UGMS_AnimLayer
{
GENERATED_BODY()
protected:
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting) override;
virtual void ResetSetting_Implementation() override;
virtual void NativeInitializeAnimation() override;
virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
const FGMS_OverlayModeSetting_ParallelPoseStack& GetOverlayModeSetting() const;
void UpdateAnim(const FAnimUpdateContext& Context, const FAnimNodeReference& Node, const EGMS_BodyMask& BodyMask, const FGMS_AnimData_BodyPose& BodyPose);
void SelectPoses(const FGameplayTagContainer& Tags, const FGameplayTagContainer& Nodes);
void UpdateLayeringState(float DeltaSeconds);
void UpdateLayeringSmoothState(float DeltaSeconds);
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
void BasePose_AnimUpdate(UPARAM(ref)
FAnimUpdateContext& Context, UPARAM(ref)
FAnimNodeReference& Node);
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
void BodyPart_AnimUpdate(UPARAM(ref)
FAnimUpdateContext& Context, UPARAM(ref)
FAnimNodeReference& Node, EGMS_BodyMask BodyMask);
UPROPERTY()
TArray<TInstancedStruct<FGMS_AnimData_BodyPose>> SelectedBodyPoses; // Indexed by EGMS_BodyPart
UPROPERTY()
TObjectPtr<const UGMS_AnimLayerSetting_Overlay_ParallelPoseStack> CurrentSetting = nullptr;
UPROPERTY(Transient)
FGameplayTag CurrentOverlayMode;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
TObjectPtr<UAnimSequence> BasePose = nullptr;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
bool bHasValidSetting = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_LayeringSmooth LayeringSmoothState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
bool bArmLeftMeshSpace{false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
bool bArmRightMeshSpace{false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Layering LayeringState;
FGMS_BodyPartOverridePolicy OverridePolicy;
};

View File

@@ -0,0 +1,381 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "GMS_AnimLayer_Overlay.h"
#include "Settings/GMS_SettingObjectLibrary.h"
#include "GMS_AnimLayer_Overlay_ParallelSequenceStack.generated.h"
struct FCachedAnimStateData;
/**
* Single entry within "GMS_ParallelSequenceStack".
* "GMS_ParallelSequenceStack"中的单个条目
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_ParallelSequenceStackEntry
{
GENERATED_BODY()
/**
* Gameplay tag query against to the movement system's owned tags.
* 针对运动系统组件所拥有标签的查询。
* @details This sequence will be considered if the tags matches this query.此序列会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
FGameplayTagQuery TagQuery;
/**
* Animation sequence for the overlay.
* 叠加的动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
TObjectPtr<UAnimSequenceBase> Sequence = nullptr;
/**
* Blend weight for the overlay.
* 叠加的混合权重。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMax=1, ClampMin=0))
float BlendWeight = 1.0f;
/**
* Whether to blend in mesh space.
* 是否在网格空间中混合。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
bool MeshSpaceBlend = true;
/**
* Play mode for the overlay animation.
* 叠加动画的播放模式。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
EGMS_OverlayPlayMode PlayMode{EGMS_OverlayPlayMode::SequenceEvaluator};
/**
* Start position for sequence player mode.
* 序列播放器模式的起始位置。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0, EditCondition="PlayMode == EGMS_OverlayPlayMode::SequencePlayer", EditConditionHides))
float StartPosition = 0.0f;
/**
* Explicit time for sequence evaluator mode.
* 序列评估器模式的明确时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0, EditCondition="PlayMode == EGMS_OverlayPlayMode::SequenceEvaluator", EditConditionHides))
float ExplicitTime = 0.0f;
/**
* Blend mode for the overlay animation.
* 叠加动画的混合模式。
* @attention Use branch filters for multiple skeletons to improve reusability. 如果项目中使用多个骨架,建议使用分支过滤器以提高复用性。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
EGMS_LayeredBoneBlendMode BlendMode{EGMS_LayeredBoneBlendMode::BlendMask};
/**
* Blend mask name for the overlay.
* 叠加的混合遮罩名称。
* @attention Must be defined in the skeleton first. 必须先在骨架中定义。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(EditCondition="BlendMode == EGMS_LayeredBoneBlendMode::BlendMask", EditConditionHides))
FName BlendMaskName;
/**
* Branch filters for the overlay.
* 叠加的分支过滤器。
* @attention Refer to documentation for usage details. 请参阅文档了解使用详情。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(EditCondition="BlendMode == EGMS_LayeredBoneBlendMode::BranchFilter", EditConditionHides))
FGMS_InputBlendPose BranchFilters;
/**
* Speed to blend to the specified blend weight.
* 混合到指定混合权重的速度。
* @attention Zero means instant blending. 为零表示立即混合。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
float BlendInSpeed = 10.f;
/**
* Speed to blend back to zero weight.
* 混合回零权重的速度。
* @attention Zero means instant return to zero. 为零表示立即归零。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
float BlendOutSpeed = 10.f;
/**
* Indicates if the overlay data is valid.
* 指示叠加数据是否有效。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
bool bValid{false};
/**
* Equality operator for overlay data.
* 叠加数据的相等比较运算符。
*/
friend bool operator==(const FGMS_ParallelSequenceStackEntry& Lhs, const FGMS_ParallelSequenceStackEntry& RHS)
{
return Lhs.Sequence == RHS.Sequence
&& Lhs.BlendMode == RHS.BlendMode
&& Lhs.MeshSpaceBlend == RHS.MeshSpaceBlend
&& Lhs.bValid == RHS.bValid;
}
/**
* Inequality operator for overlay data.
* 叠加数据的不相等比较运算符。
*/
friend bool operator!=(const FGMS_ParallelSequenceStackEntry& Lhs, const FGMS_ParallelSequenceStackEntry& RHS)
{
return !(Lhs == RHS);
}
#if WITH_EDITORONLY_DATA
/**
* Validates the overlay animation data.
* 验证叠加动画数据。
*/
void Validate();
/**
* Friendly message for displaying in the editor.
* 在编辑器中显示的友好消息。
*/
UPROPERTY(VisibleAnywhere, Category = "GMS", Meta = (EditCondition = False, EditConditionHides))
FString EditorMessage;
#endif
};
/**
* A single parallel sequence stack
* 堆叠叠加动画数据的结构体。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_ParallelSequenceStack
{
GENERATED_BODY()
/**
* Animation nodes that determine overlay relevance.
* 确定叠加相关性的动画节点。
* @attention Configure state-to-tag mapping in the main AnimInstance or derived GMS_AnimLayer. 在主AnimInstance或派生的GMS_AnimLayer中配置状态到标签的映射。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", meta=(Categories="GMS.SM"))
FGameplayTagContainer TargetAnimNodes;
/**
* List of potential overlays, with the first matching one selected.
* 潜在叠加列表,第一个匹配的将被选用。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", meta=(TitleProperty="EditorMessage"))
TArray<FGMS_ParallelSequenceStackEntry> Overlays;
#if WITH_EDITORONLY_DATA
/**
* Friendly name for displaying in the editor.
* 在编辑器中显示的友好名称。
*/
UPROPERTY(VisibleAnywhere, Category = "GMS", Meta = (EditCondition = False, EditConditionHides))
FString EditorFriendlyName;
#endif
};
/**
* Parallel Sequence Stacks for certain overlay mode.
* 针对特定叠加模式的并行Sequence栈
*/
USTRUCT(BlueprintType)
struct FGMS_OverlayModeSetting_ParallelSequenceStack
{
GENERATED_BODY()
/**
* Unique tag for this overlay mode.
* 此叠加模式的唯一标签。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.OverlayMode"))
FGameplayTag Tag;
/**
* List of parallel sequence stack
* 用于并行混合的动画序列栈列表。
* @attention Later stacks have higher priority; each stack selects one entry from multiple candidates. 越靠后的栈优先级越高;每个栈从多个候选动画中选择一个。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", meta=(TitleProperty="EditorFriendlyName"))
TArray<FGMS_ParallelSequenceStack> Stacks;
};
/**
* Struct for the state of a stacked overlay.
* 栈式叠加状态的结构体。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_ParallelSequenceStackState
{
GENERATED_BODY()
/**
* Indicates if the target animation nodes are relevant.
* 指示目标动画节点是否相关。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bRelevant{false};
/**
* Current blend weight of the overlay.
* 叠加的当前混合权重。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float BlendWeight{0.0f};
/**
* Speed to blend out the overlay.
* 叠加混合退出的速度。
*/
float BlendOutSpeed{0.0f};
/**
* Overlay animation data.
* 叠加动画数据。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FGMS_ParallelSequenceStackEntry Overlay;
};
/**
* Anim layer setting for ParallelSequenceStack overlay system.
* 针对"并行序列栈"的动画叠加系统设置。
* @attention Its more recommended to use SequenceStack instead of this one.通常你应该使用序列栈,而不是这个。
*/
UCLASS(NotBlueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Overlay_ParallelSequenceStack final : public UGMS_AnimLayerSetting_Overlay
{
GENERATED_BODY()
public:
/**
* Map of accelerated overlay modes.
* 加速叠加模式的映射。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(EditCondition=false, EditConditionHides))
TMap<FGameplayTag, FGMS_OverlayModeSetting_ParallelSequenceStack> AcceleratedOverlayModes;
protected:
/**
* List of overlay mode settings.
* 叠加模式设置列表。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings", meta=(TitleProperty="Tag"))
TArray<FGMS_OverlayModeSetting_ParallelSequenceStack> OverlayModes;
#if WITH_EDITORONLY_DATA
/**
* Called before saving the object.
* 在保存对象之前调用。
* @param SaveContext The save context. 保存上下文。
*/
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};
/**
* Anim layer implementation for ParallelSequenceStack overlay system.
* 针对"并行序列栈"的动画叠加系统实现。
*/
UCLASS(Abstract)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer_Overlay_ParallelSequenceStack : public UGMS_AnimLayer
{
GENERATED_BODY()
friend UGMS_AnimLayerSetting_Overlay_ParallelSequenceStack;
public:
/**
* Called when the component begins play.
* 组件开始播放时调用。
*/
virtual void NativeBeginPlay() override;
/**
* Updates the animation.
* 更新动画。
* @param DeltaSeconds Time since the last update. 自上次更新以来的时间。
*/
virtual void NativeUpdateAnimation(float DeltaSeconds) override;
/**
* Updates the animation in a thread-safe manner.
* 以线程安全的方式更新动画。
* @param DeltaSeconds Time since the last update. 自上次更新以来的时间。
*/
virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
/**
* Applies the specified animation layer setting.
* 应用指定的动画层设置。
* @param Setting The animation layer setting to apply. 要应用的动画层设置。
*/
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting) override;
/**
* Resets the animation layer setting.
* 重置动画层设置。
*/
virtual void ResetSetting_Implementation() override;
protected:
/**
* Refreshes the relevance of the overlay stacks.
* 刷新叠加堆栈的相关性。
*/
virtual void RefreshRelevance();
/**
* Refreshes the blending of the overlay stacks.
* 刷新叠加堆栈的混合。
* @param DeltaSeconds Time since the last update. 自上次更新以来的时间。
*/
virtual void RefreshBlend(float DeltaSeconds);
/**
* Previous overlay setting.
* 前一个叠加设置。
*/
UPROPERTY()
TObjectPtr<const UGMS_AnimLayerSetting_Overlay_ParallelSequenceStack> PrevSetting{nullptr};
/**
* Previous overlay mode tag.
* 前一个叠加模式标签。
*/
UPROPERTY()
FGameplayTag PrevOverlayMode;
/**
* List of overlay stacks.
* 叠加堆栈列表。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings", meta=(TitleProperty="EditorFriendlyName"))
TArray<FGMS_ParallelSequenceStack> OverlayStacks;
/**
* List of overlay stack states.
* 叠加堆栈状态列表。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
TArray<FGMS_ParallelSequenceStackState> OverlayStackStates;
/**
* Maximum number of overlay layers.
* 最大叠加层数。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State", meta=(ClampMin=4))
int32 MaxLayers{10};
};

View File

@@ -0,0 +1,439 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "GMS_AnimLayer_Overlay.h"
#include "GMS_AnimState.h"
#include "Settings/GMS_SettingObjectLibrary.h"
#include "GMS_AnimLayer_Overlay_PoseStack.generated.h"
#pragma region Deprecated
/**
* Enum for pose overlay setting types.
* 姿势叠加设置类型的枚举。
*/
UENUM(BlueprintType)
enum class EGMS_PoseOverlaySettingType: uint8
{
Simple,
Layered
};
/**
* Struct for simple pose overlay animation data.
* 简单姿势叠加动画数据的结构体。
*/
USTRUCT()
struct FGMS_AnimData_PoseOverlay_Simple
{
GENERATED_BODY()
/**
* Idle pose animation sequence.
* 空闲姿势动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> IdlePose{nullptr};
/**
* Explicit time for the idle pose.
* 空闲姿势的明确时间。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
float IdlePoseExplicitTime{0};
/**
* Moving pose animation sequence.
* 移动姿势动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> MovingPose{nullptr};
/**
* Explicit time for the moving pose.
* 移动姿势的明确时间。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
float MovingPoseExplicitTime{0};
/**
* Aiming sweep pose animation sequence.
* 瞄准扫动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> AimingSweepPose{nullptr};
};
/**
* Struct for layered pose overlay anim data.
* 分层姿势叠加动画数据的结构体。
*/
USTRUCT()
struct FGMS_AnimData_PoseOverlay_Layered
{
GENERATED_BODY()
/**
* Gameplay tag query for layered pose.
* 分层姿势的游戏标签查询。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
FGameplayTagQuery TagQuery;
/**
* Idle pose animation sequence for layered pose.
* 分层姿势的空闲姿势动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> IdlePose{nullptr};
/**
* Explicit time for the idle pose in layered pose.
* 分层姿势中空闲姿势的明确时间。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
float IdlePoseExplicitTime{0};
/**
* Moving pose animation sequence for layered pose.
* 分层姿势的移动姿势动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> MovingPose{nullptr};
/**
* Explicit time for the moving pose in layered pose.
* 分层姿势中移动姿势的明确时间。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
float MovingPoseExplicitTime{0};
/**
* Aiming sweep pose animation sequence for layered pose.
* 分层姿势的瞄准扫动画序列。
*/
UPROPERTY(EditAnywhere, Category = "GMS")
TObjectPtr<UAnimSequence> AimingSweepPose{nullptr};
};
#pragma endregion
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_PerBodyPoseBlendSetting
{
GENERATED_BODY()
virtual ~FGMS_PerBodyPoseBlendSetting() = default;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_ThreeParams HeadBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_FourParams ArmLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_FourParams ArmRightBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting HandLeftBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting HandRightBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_ThreeParams SpineBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_TwoParams PelvisBlend;
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_AnimData_PoseBlendSetting_TwoParams LegsBlend;
//Read layering setting from sequence curves.
void ApplyFromSequence(const UAnimSequence* InSequence, float ExplicitTime);
//Set blend setting to layering state.
virtual void ApplyToLayeringState(FGMS_AnimState_Layering& InLayeringState) const;
//Read setting from layering state.
virtual void ApplyFromLayeringState(const FGMS_AnimState_Layering& InLayeringState);
};
/**
* Single entry within GMS_OverlayModeSetting_PoseStack
* GMS_OverlayModeSetting_PoseStack中的单个条目。
*
*/
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_PoseStackEntry
{
GENERATED_BODY()
/**
* Gameplay tag query against to main anim instance's relevance tags(the tags representing the relevant/active state of the anim state machine nodes).
* 针对主动画实例的相关性标签的查询,相关性标签指:用于标识动画状态机节点是否激活的标签。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.SM"))
FGameplayTagQuery RelevanceQuery;
/**
* Gameplay tag query against to the movement system's owned tags.
* 针对运动系统组件所拥有标签的查询。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FGameplayTagQuery TagQuery;
/**
* The sequence for this pose.
* 此姿势的动画序列。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> Pose{nullptr};
/**
* Controls the blend weight for each body parts.
* 控制每一个身体部位的混合权重。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FGMS_PerBodyPoseBlendSetting PoseBlend;
/**
* Explicit time for the pose.
* 姿势的明确播放时间。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float ExplicitTime{0};
/**
* Aiming sweep pose animation sequence for layered pose.
* 分层姿势的瞄准扫动画序列。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> AimingSweepPose{nullptr};
#if WITH_EDITORONLY_DATA
UPROPERTY(EditAnywhere, Category = "GMS", meta = (EditCondition = false, EditConditionHides))
FString EditorFriendlyName;
#endif
};
/**
* Pose overlay setting for specific overlay mode.
* 针对特定动画叠加模式的姿势叠加设置。
*/
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_OverlayModeSetting_PoseStack
{
GENERATED_BODY()
/**
* Unique tag for this overlay mode.
* 此叠加模式的唯一标签。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.OverlayMode"))
FGameplayTag Tag;
/**
* Base pose animation sequence.
* 基础姿势动画序列。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> BasePose{nullptr};
/**
* Potential dynamic poses.
* 潜在的动态poses。
* @note To ensure smooth pose switching, Avoid using "multi frames sequence with different explicit time setup", favors "single frame sequence with 0 explicit time setup."
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(TitleProperty="EditorFriendlyName"))
TArray<FGMS_PoseStackEntry> Poses;
#if WITH_EDITORONLY_DATA
/**
* Type of pose overlay setting.
* 姿势叠加设置的类型。
*/
UE_DEPRECATED (1.5, "deprecated and will be removed in 1.6")
UPROPERTY(EditAnywhere, Category = "Deprecated", meta = (EditCondition = false, EditConditionHides))
EGMS_PoseOverlaySettingType PoseOverlaySettingType{EGMS_PoseOverlaySettingType::Simple};
/**
* Simple pose overlay settings.
* 简单姿势叠加设置。
*/
UE_DEPRECATED (1.5, "deprecated and will be removed in 1.6")
UPROPERTY(EditAnywhere, Category = "Deprecated", meta = (EditCondition = false, EditConditionHides))
FGMS_AnimData_PoseOverlay_Simple SimplePoseSetting;
/**
* Layered pose overlay settings.
* 分层姿势叠加设置。
*/
UE_DEPRECATED (1.5, "deprecated and will be removed in 1.6")
UPROPERTY(EditAnywhere, Category = "Deprecated", meta = (EditCondition = false, EditConditionHides))
TArray<FGMS_AnimData_PoseOverlay_Layered> LayeredPoseSetting;
#endif
};
/**
* Anim layer setting for PoseStack overlay system.
* 针对"姿势栈"的动画叠加系统设置。
* @details Similar to ALS's layering system, but more dynamic and easy to use. 类似于ALS的叠层系统但更动态且易于使用。
*/
UCLASS(NotBlueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Overlay_PoseStack : public UGMS_AnimLayerSetting_Overlay
{
GENERATED_BODY()
public:
/**
* Map of accelerated overlay modes.
* 加速叠加模式的映射。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(EditCondition=false, EditConditionHides))
TMap<FGameplayTag, FGMS_OverlayModeSetting_PoseStack> AcceleratedOverlayModes;
/**
* Checks if the overlay mode is valid.
* 检查叠加模式是否有效。
* @param NewOverlayMode The overlay mode to check. 要检查的叠加模式。
* @return True if the overlay mode is valid, false otherwise. 如果叠加模式有效则返回true否则返回false。
*/
virtual bool IsValidForOverlayMode(const FGameplayTag& NewOverlayMode) const override;
protected:
/**
* List of pose overlay settings.
* 姿势叠加设置列表。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(TitleProperty="Tag"))
TArray<FGMS_OverlayModeSetting_PoseStack> OverlayModes;
#if WITH_EDITOR
public:
UFUNCTION(BlueprintCallable, CallInEditor, Category = "GMS")
void RunDataMigration(bool bResetDeprecatedSettings = false);
UFUNCTION(BlueprintCallable, CallInEditor, Category = "GMS")
static void RunDataMigrationFromDefinition(UGMS_MovementDefinition* InDefinition, bool bResetDeprecatedSettings = false);
/**
* Called before saving the object.
* 在保存对象之前调用。
* @param SaveContext The save context. 保存上下文。
*/
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};
/**
* Anim layer implementation for PoseStack overlay system.
* 针对"姿势栈"的动画叠加系统实现。
*/
UCLASS(Abstract)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer_Overlay_PoseStack : public UGMS_AnimLayer
{
GENERATED_BODY()
public:
/**
* Applies the specified animation layer setting.
* 应用指定的动画层设置。
* @param Setting The animation layer setting to apply. 要应用的动画层设置。
*/
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting) override;
/**
* Resets the animation layer setting.
* 重置动画层设置。
*/
virtual void ResetSetting_Implementation() override;
bool SelectPose();
/**
* Updates the animation in a thread-safe manner.
* 以线程安全的方式更新动画。
* @param DeltaSeconds Time since the last update. 自上次更新以来的时间。
*/
virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
const FGMS_OverlayModeSetting_PoseStack& GetOverlayModeSetting() const;
virtual void UpdateLayeringSmoothState(float DeltaSeconds);
protected:
/**
* Base pose animation sequence.
* 基础姿势动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
TObjectPtr<UAnimSequence> BasePose{nullptr};
/**
* Current Selected Pose.
* 当前选择的Pose.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
TObjectPtr<UAnimSequence> Pose{nullptr};
UPROPERTY()
TObjectPtr<UAnimSequence> PrevPose{nullptr};
/**
* Explicit time for the current pose
* 当前姿势的明确时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
float ExplicitTime{0};
/**
* Aiming sweep pose animation sequence.
* 瞄准扫动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
TObjectPtr<UAnimSequence> AimingSweepPose{nullptr};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
bool bValidPose{false};
/**
* Indicates if the aiming pose is valid.
* 指示瞄准姿势是否有效。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
bool bValidAimingPose{false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
bool bHasValidSetting = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
float LayeringSmoothSpeed{2.0f};
/**
* Current layering state.
* 当前分层状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Layering LayeringState;
/**
* Current smoothed layering state.
* 当前的平滑分层状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_LayeringSmooth LayeringSmoothState;
/**
* Reference to the pose-based overlay settings.
* 基于姿势的叠加设置的引用。
*/
UPROPERTY(Transient)
TObjectPtr<const UGMS_AnimLayerSetting_Overlay_PoseStack> CurrentSetting;
UPROPERTY(Transient)
FGameplayTag CurrentOverlayMode;
};

View File

@@ -0,0 +1,276 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer_Overlay.h"
#include "GMS_AnimLayer_Overlay_SequenceStack.generated.h"
class UGMS_AnimLayerSetting_Overlay_ParallelSequenceStack;
/**
* Single entry within "GMS_OverlayModeSetting_SequenceStack".
* "GMS_OverlayModeSetting_SequenceStack"中的单个条目
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_SequenceStackEntry
{
GENERATED_BODY()
/**
* Gameplay tag query against to main anim instance's relevance tags(the tags representing the relevant/active state of the anim state machine nodes).
* 针对主动画实例的相关性标签的查询,相关性标签指:用于标识动画状态机节点是否激活的标签。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(Categories="GMS.SM"))
FGameplayTagQuery RelevanceQuery;
/**
* Gameplay tag query against to the movement system's owned tags.
* 针对运动系统组件所拥有标签的查询。
* @details This pose will be considered if the tags matches this query.此姿势会在标签匹配此查询时被考虑。
* @note Left empty will bypass this filter. 留空则不应用此过滤。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
FGameplayTagQuery TagQuery;
/**
* Animation sequence for the overlay.
* 叠加的动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
TObjectPtr<UAnimSequence> Sequence = nullptr;
/**
* Play mode for the overlay animation.
* 叠加动画的播放模式。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
EGMS_OverlayPlayMode PlayMode{EGMS_OverlayPlayMode::SequencePlayer};
/**
* Blend weight for the overlay.
* 叠加的混合权重。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMax=1, ClampMin=0))
float BlendWeight = 1.0f;
/**
* Speed to blend to the specified blend weight.
* 混合到指定混合权重的速度。
* @attention Zero means instant blending. 为零表示立即混合。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
float BlendInSpeed = 10.f;
/**
* Speed to blend back to zero weight.
* 混合回零权重的速度。
* @attention Zero means instant return to zero. 为零表示立即归零。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
float BlendOutSpeed = 10.f;
/**
* Whether to blend in mesh space.
* 是否在网格空间中混合。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
bool MeshSpaceBlend = true;
/**
* The start time of animation.
* 动画开始播放的事件。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
float AnimationTime = 0.0f;
/**
* Blend mode for the overlay animation.
* 叠加动画的混合模式。
* @attention Use branch filters for multiple skeletons to improve reusability. 如果项目中使用多个骨架,建议使用分支过滤器以提高复用性。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS")
EGMS_LayeredBoneBlendMode BlendMode{EGMS_LayeredBoneBlendMode::BlendMask};
/**
* Blend mask name for the overlay.
* 叠加的混合遮罩名称。
* @attention Must be defined in the skeleton first. 必须先在骨架中定义。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(EditCondition="BlendMode == EGMS_LayeredBoneBlendMode::BlendMask", EditConditionHides))
FName BlendMaskName;
/**
* Branch filters for the overlay.
* 叠加的分支过滤器。
* @attention Refer to documentation for usage details. 请参阅文档了解使用详情。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(EditCondition="BlendMode == EGMS_LayeredBoneBlendMode::BranchFilter", EditConditionHides))
FGMS_InputBlendPose BranchFilters;
/**
* Speed to blend to the specified blend weight.
* 混合到指定混合权重的速度。
* @attention Zero means instant blending. 为零表示立即混合。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
float BlendTime = 0.2f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(ClampMin=0))
FName BlendProfile = NAME_None;
friend bool operator==(const FGMS_SequenceStackEntry& Lhs, const FGMS_SequenceStackEntry& RHS)
{
return Lhs.Sequence == RHS.Sequence
&& Lhs.BlendMode == RHS.BlendMode
&& Lhs.MeshSpaceBlend == RHS.MeshSpaceBlend;
}
friend bool operator!=(const FGMS_SequenceStackEntry& Lhs, const FGMS_SequenceStackEntry& RHS)
{
return !(Lhs == RHS);
}
#if WITH_EDITORONLY_DATA
/**
* Friendly message for displaying in the editor.
* 在编辑器中显示的友好消息。
*/
UPROPERTY(VisibleAnywhere, Category = "GMS", Meta = (EditCondition = False, EditConditionHides))
FString EditorFriendlyName;
#endif
};
/**
* Pose overlay setting for specific overlay mode.
* 针对特定动画叠加模式的姿势叠加设置。
*/
USTRUCT()
struct GENERICMOVEMENTSYSTEM_API FGMS_OverlayModeSetting_SequenceStack
{
GENERATED_BODY()
/**
* Unique tag for this overlay mode.
* 此叠加模式的唯一标签。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(Categories="GMS.OverlayMode"))
FGameplayTag Tag;
/**
* Potential dynamic sequences.
* 潜在的动态sequences。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(TitleProperty="EditorFriendlyName"))
TArray<FGMS_SequenceStackEntry> Sequences;
};
/**
* Anim layer setting for SequenceStack overlay system.
* 针对序列栈的动画叠加系统设置。
* @details Dynamically stacking different anim sequence. 可动态叠加不同的动画序列。
*/
UCLASS(NotBlueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_Overlay_SequenceStack : public UGMS_AnimLayerSetting_Overlay
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category="GMS", meta=(EditCondition=false, EditConditionHides))
TMap<FGameplayTag, FGMS_OverlayModeSetting_SequenceStack> AcceleratedOverlayModes;
protected:
/**
* List of sequence overlay settings.
* 序列叠加设置列表。
*/
UPROPERTY(EditAnywhere, Category="GMS", meta=(TitleProperty="Tag"))
TArray<FGMS_OverlayModeSetting_SequenceStack> OverlayModes;
#if WITH_EDITOR
public:
UFUNCTION(BlueprintCallable, CallInEditor, Category = "GMS")
void ConvertToSequenceStack(const UGMS_AnimLayerSetting_Overlay_ParallelSequenceStack* Src);
UFUNCTION(BlueprintCallable, CallInEditor, Category = "GMS")
static void ConvertToSequenceStackFromDefinition(UGMS_MovementDefinition* InDefinition);
/**
* Called before saving the object.
* 在保存对象之前调用。
* @param SaveContext The save context. 保存上下文。
*/
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};
/**
*
*/
UCLASS()
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer_Overlay_SequenceStack : public UGMS_AnimLayer
{
GENERATED_BODY()
public:
/**
* Applies the specified animation layer setting.
* 应用指定的动画层设置。
* @param Setting The animation layer setting to apply. 要应用的动画层设置。
*/
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting) override;
/**
* Resets the animation layer setting.
* 重置动画层设置。
*/
virtual void ResetSetting_Implementation() override;
bool SelectSequence();
/**
* Updates the animation in a thread-safe manner.
* 以线程安全的方式更新动画。
* @param DeltaSeconds Time since the last update. 自上次更新以来的时间。
*/
virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
const FGMS_OverlayModeSetting_SequenceStack& GetOverlayModeSetting() const;
protected:
/**
* Current Selected Pose.
* 当前选择的Pose.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
FGMS_SequenceStackEntry Definition;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
bool bHasValidDefinition = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
float BlendWeight{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
float BlendOutSpeed{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
TObjectPtr<UBlendProfile> BlendProfile{nullptr};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings")
bool bHasValidSetting = false;
/**
* Reference to the pose-based overlay settings.
* 基于姿势的叠加设置的引用。
*/
UPROPERTY(Transient)
TObjectPtr<const UGMS_AnimLayerSetting_Overlay_SequenceStack> CurrentSetting;
UPROPERTY(Transient)
FGameplayTag CurrentOverlayMode;
};

View File

@@ -0,0 +1,17 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "GMS_AnimLayer_SkeletalControls.generated.h"
/**
* Base class for skeletal control animation layer settings.
* 骨骼控制动画层设置的基类。
*/
UCLASS(Abstract, Blueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_SkeletalControls : public UGMS_AnimLayerSetting
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,50 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "UObject/Object.h"
#include "Runtime/Launch/Resources/Version.h"
#if ENGINE_MINOR_VERSION < 5
#include "InstancedStruct.h"
#else
#include "StructUtils/InstancedStruct.h"
#endif
#include "Settings/GMS_SettingObjectLibrary.h"
#include "GMS_AnimLayer_States.generated.h"
/**
* Animation data for state-based animation layers.
* 状态动画层的数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimData
{
GENERATED_BODY()
virtual ~FGMS_AnimData() = default;
/**
* Validates the animation data.
* 验证动画数据。
*/
virtual void Validate();
/**
* Indicates if the animation data is valid.
* 指示动画数据是否有效。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GMS", meta=(EditCondition=false, EditConditionHides))
bool bValid{false};
};
/**
* Base class for state-based animation layer settings.
* 状态动画层设置的基类。
* @details Inherit this class to create custom state-based animation layer settings. 继承此类以创建自定义状态动画层设置。
*/
UCLASS(Abstract, Blueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_States : public UGMS_AnimLayerSetting
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,18 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "UObject/Object.h"
#include "GMS_AnimLayer_View.generated.h"
/**
* Base class for view animation layer settings.
* 视图动画层设置的基类。
*/
UCLASS(Abstract, Blueprintable)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayerSetting_View : public UGMS_AnimLayerSetting
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,109 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_AnimLayer.h"
#include "GMS_AnimLayer_View.h"
#include "GMS_AnimLayer_View_Default.generated.h"
class UAimOffsetBlendSpace;
/**
* Native implementation of default view animation layer settings.
* 默认视图动画层设置的原生实现。
*/
UCLASS(NotBlueprintable)
class UGMS_AnimLayerSetting_View_Default final : public UGMS_AnimLayerSetting_View
{
GENERATED_BODY()
public:
/**
* Blend space for the view animation.
* 视图动画的混合空间。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View")
TObjectPtr<UBlendSpace> BlendSpace;
/**
* Yaw angle offset for the view.
* 视图的偏航角偏移。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View")
float YawAngleOffset = 0.0f;
/**
* Additional smoothing speed for aim offset.
* 瞄准偏移的额外平滑速度。
* @attention Zero means no additional smoothing. 为零表示无额外平滑。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View", meta=(ClampMin=0))
float SmoothInterpSpeed = 5.0f;
/**
* Yaw angle limits for the view.
* 视图的偏航角限制。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View")
FVector2D YawAngleLimit{-90.0f, 90.0f};
};
/**
* Native implementation of default view animation layer.
* 默认视图动画层的原生实现。
*/
UCLASS(Abstract)
class GENERICMOVEMENTSYSTEM_API UGMS_AnimLayer_View_Default : public UGMS_AnimLayer
{
GENERATED_BODY()
public:
/**
* Applies the specified animation layer setting.
* 应用指定的动画层设置。
* @param Setting The animation layer setting to apply. 要应用的动画层设置。
*/
virtual void ApplySetting_Implementation(const UGMS_AnimLayerSetting* Setting) override;
/**
* Resets the animation layer setting.
* 重置动画层设置。
*/
virtual void ResetSetting_Implementation() override;
/**
* Blend space for the view animation.
* 视图动画的混合空间。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View")
TObjectPtr<UBlendSpace> BlendSpace;
/**
* Yaw angle offset for the view.
* 视图的偏航角偏移。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Anim View")
float YawAngleOffset = 0.0f;
/**
* Yaw angle limits for the view.
* 视图的偏航角限制。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Anim View")
FVector2D YawAngleLimit{ -90.0f, 90.0f };
/**
* Smoothing speed for the view animation.
* 视图动画的平滑速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Anim View", meta=(ClampMin=0))
float SmoothInterpSpeed = 0.0f;
/**
* Indicates if the blend space is valid.
* 指示混合空间是否有效。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Anim View")
bool bValidBlendSpace;
};

View File

@@ -0,0 +1,976 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GMS_LocomotionEnumLibrary.h"
#include "Animation/TrajectoryTypes.h"
#include "BoneControllers/AnimNode_OffsetRootBone.h"
#include "UObject/Object.h"
#include "GMS_AnimState.generated.h"
class UAnimSequenceBase;
class UAnimSequence;
/**
* Stores locomotion-related animation state data.
* 存储与运动相关的动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Locomotion
{
GENERATED_BODY()
/**
* World-space location of the character.
* 角色的世界空间位置。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector Location{ForceInit};
/**
* Displacement from the previous frame.
* 上一帧的位移。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float PreviousDisplacement{0.0f};
/**
* Speed of displacement (cm/s).
* 位移速度(厘米/秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float DisplacementSpeed{0.0f};
/**
* World-space rotation of the character.
* 角色的世界空间旋转。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FRotator Rotation{ForceInit};
/**
* Quaternion representation of the rotation.
* 旋转的四元数表示。
*/
UPROPERTY()
FQuat RotationQuaternion{ForceInit};
/**
* Current velocity vector.
* 当前速度向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector Velocity{ForceInit};
/**
* 2D local-space velocity vector.
* 2D本地空间速度向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector LocalVelocity2D{ForceInit};
/**
* Indicates if the character has velocity.
* 指示角色是否有速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bHasVelocity = false;
/**
* Current speed of the character (cm/s).
* 角色的当前速度(厘米/秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "cm/s"))
float Speed{0.0f};
/**
* Yaw angle of the local velocity (degrees).
* 本地速度的偏航角(度)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float LocalVelocityYawAngle{0.0f};
/**
* Yaw angle of the local velocity with offset (degrees).
* 带偏移的本地速度偏航角(度)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float LocalVelocityYawAngleWithOffset{0.0f};
/**
* Cardinal direction of the local velocity.
* 本地速度的主要方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EGMS_MovementDirection LocalVelocityDirection{EGMS_MovementDirection::Forward};
/**
* Cardinal direction of the local velocity without offset.
* 无偏移的本地速度主要方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EGMS_MovementDirection LocalVelocityDirectionNoOffset{EGMS_MovementDirection::Forward};
/**
* Octagonal direction of the local velocity.
* 本地速度的八方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EGMS_MovementDirection_8Way LocalVelocityOctagonalDirection{EGMS_MovementDirection_8Way::Forward};
/**
* Indicates if there is active input.
* 指示是否有活跃输入。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bHasInput{false};
/**
* Velocity acceleration vector.
* 速度加速度向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector VelocityAcceleration{ForceInit};
/**
* 2D local-space acceleration vector.
* 2D本地空间加速度向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector LocalAcceleration2D{ForceInit};
/**
* Indicates if the character is moving.
* 指示角色是否在移动。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bMoving{false};
/**
* Actor's rotation yaw speed.
* Actor的旋转偏航角变化速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float YawVelocity{0.0f};
/**
* Scale factor for animations.
* 动画的缩放因子。
*/
float Scale{1.0f};
/**
* Radius of the character's capsule.
* 角色胶囊体的半径。
*/
float CapsuleRadius{0.0f};
/**
* Half-height of the character's capsule.
* 角色胶囊体的一半高度。
*/
float CapsuleHalfHeight{0.0f};
/**
* Maximum acceleration of the character.
* 角色的最大加速度。
*/
float MaxAcceleration{0.0f};
/**
* Maximum braking deceleration of the character.
* 角色的最大制动减速度。
*/
float MaxBrakingDeceleration{0.0f};
/**
* Z value for walkable floor detection.
* 可行走地板检测的Z值。
*/
float WalkableFloorZ{0.0f};
};
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Trajectory
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FTransformTrajectory Trajectory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector PastVelocity{FVector::ZeroVector};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector CurrentVelocity{FVector::ZeroVector};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector FutureVelocity{FVector::ZeroVector};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float DesiredControllerYaw{0.0f};
};
/**
* Stores root bone animation state data.
* 存储根骨骼动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Root
{
GENERATED_BODY()
/**
* Translation mode for the root bone.
* 根骨骼的平移模式。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EOffsetRootBoneMode TranslationMode{EOffsetRootBoneMode::Release};
/**
* Rotation mode for the root bone.
* 根骨骼的旋转模式。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EOffsetRootBoneMode RotationMode{EOffsetRootBoneMode::Release};
/**
* Current world-space transform of the root bone.
* 根骨骼的当前世界空间变换。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FTransform RootTransform{FTransform::Identity};
/**
* Yaw offset relative to the actor's rotation (degrees; <0 left, >0 right).
* 相对于Actor旋转的偏航偏移<0左侧>0右侧
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
float YawOffset{0};
/**
* Maximum rotation error in degrees; values <0 disable the limit.
* 最大旋转误差(度);值<0禁用限制。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float MaxRotationError{-1.0f};
};
/**
* Stores turn-in-place animation state data.
* 存储原地转身动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_TurnInPlace
{
GENERATED_BODY()
/**
* Indicates if the state was updated this frame.
* 指示此帧是否更新了状态。
*/
UPROPERTY()
uint8 bUpdatedThisFrame : 1 {false};
/**
* Animation sequence for turn-in-place.
* 原地转身的动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequenceBase> Animation;
/**
* Indicates if the character should turn.
* 指示角色是否应该转身。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bShouldTurn : 1 {false};
/**
* Accumulated time for the animation.
* 动画的累计时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float AccumulatedTime{0};
/**
* Playback rate for the animation.
* 动画的播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "x"))
float PlayRate{1.0f};
/**
* Scaled playback rate for the animation.
* 动画的缩放播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "x"))
float ScaledPlayRate{1.0f};
/**
* Delay before activating the turn-in-place animation.
* 原地转身动画激活前的延迟。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ForceUnits = "s"))
float ActivationDelay{0.0f};
/**
* Angle that triggers the turn-in-place animation.
* 触发原地转身动画的角度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float TriggeredAngle{0.0f};
/**
* Indicates if the turn is 180 degrees.
* 指示是否为180度转身。
*/
bool b180{false};
};
/**
* Stores in-air animation state data.
* 存储空中动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_InAir
{
GENERATED_BODY()
/**
* Vertical speed of the character (cm/s).
* 角色的垂直速度(厘米/秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ForceUnits = "cm/s"))
float VerticalSpeed{0.0f};
/**
* Indicates if the character is jumping.
* 指示角色是否在跳跃。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bJumping{false};
/**
* Indicates if the character is falling.
* 指示角色是否在下落。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bFalling{false};
/**
* Playback rate for the jump animation.
* 跳跃动画的播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "x"))
float JumpPlayRate{1.0f};
/**
* Indicates if valid ground is detected.
* 指示是否检测到有效地面。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bValidGround{false};
/**
* Distance to the ground (cm).
* 到地面的距离(厘米)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", meta=(ForceUnits = "cm"))
float GroundDistance{0.0f};
/**
* Time to reach the jump apex (s).
* 到达跳跃顶点的时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1, ForceUnits = "s"))
float TimeToJumpApex{0.0f};
/**
* Time spent falling (s).
* 下落的时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1, ForceUnits = "s"))
float FallingTime{0.0f};
};
/**
* Stores idle animation state data.
* 存储空闲动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Idle
{
GENERATED_BODY()
/**
* Animation sequence for idle.
* 空闲动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Animation{nullptr};
/**
* Indicates if the idle animation is looped.
* 指示空闲动画是否循环。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bLoop{true};
/**
* Playback rate for the idle animation.
* 空闲动画的播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float PlayRate{1.0f};
/**
* Blend time for the idle animation.
* 空闲动画的混合时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float BlendTime{1.0f};
/**
* Blend profile for the idle animation.
* 空闲动画的混合配置文件。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UBlendProfile> BlendProfile{nullptr};
};
/**
* Stores runtime state for idle break animations.
* 存储空闲中断动画的运行时状态。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_IdleBreak
{
GENERATED_BODY()
/**
* Time until the next idle break animation (s).
* 到下一个空闲中断动画的时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float TimeUntilNextIdleBreak{0.0f};
/**
* Index of the current idle break animation.
* 当前空闲中断动画的索引。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
int32 CurrentIdleBreakIndex{0};
/**
* Delay between idle break animations (s).
* 空闲中断动画之间的延迟(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float IdleBreakDelayTime{0.0f};
};
/**
* Stores lean animation state data.
* 存储倾斜动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Lean
{
GENERATED_BODY()
/**
* Horizontal acceleration amount for leaning (clamped -1 to 1).
* 用于倾斜的水平加速度量(限制在-1到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -1, ClampMax = 1))
float RightAmount{0.0f};
/**
* Vertical acceleration amount for leaning (clamped -1 to 1).
* 用于倾斜的垂直加速度量(限制在-1到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -1, ClampMax = 1))
float ForwardAmount{0.0f};
};
/**
* Stores pivot animation state data.
* 存储枢轴动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Pivot
{
GENERATED_BODY()
/**
* Animation sequence for the pivot.
* 枢轴动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Animation;
/**
* Acceleration at the start of the pivot.
* 枢轴开始时的加速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector StartingAcceleration{ForceInit};
/**
* Accumulated time for the pivot animation.
* 枢轴动画的累计时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float AccumulatedTime{ForceInit};
/**
* Time at which the pivot stops for distance matching.
* 距离匹配时枢轴停止的时间。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float TimeAtPivotStop{ForceInit};
/**
* Alpha for stride warping during the pivot.
* 枢轴期间步幅适配的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float StrideWarpingAlpha{ForceInit};
/**
* Clamp for the playback rate (min, max).
* 播放速率的限制(最小,最大)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector2D PlayRateClamp{0.f, 0.f};
/**
* 2D direction of the pivot.
* 枢轴的2D方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FVector Direction2D{ForceInit};
/**
* Desired movement direction for the pivot.
* 枢轴的期望移动方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
EGMS_MovementDirection DesiredDirection{ForceInit};
/**
* Initial movement direction for the pivot.
* 枢轴的初始移动方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
EGMS_MovementDirection InitialDirection{ForceInit};
/**
* Remaining cooldown time for the pivot (s).
* 枢轴的剩余冷却时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
float RemainingCooldown{ForceInit};
/**
* Indicates if the pivot is moving perpendicular to the initial direction.
* 指示枢轴是否垂直于初始方向移动。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
bool bMovingPerpendicularToInitialDirection{ForceInit};
};
/**
* Stores start animation state data.
* 存储开始动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Start
{
GENERATED_BODY()
/**
* Animation sequence for the start movement.
* 开始移动的动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Animation{nullptr};
/**
* Smooth target rotation for the start movement.
* 开始移动的平滑目标旋转。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FRotator SmoothTargetRotation{ForceInit};
/**
* Yaw delta between acceleration direction and root direction at start (degrees).
* 开始时加速度方向与根方向的偏航差(度)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float YawDeltaToAcceleration{ForceInit};
/**
* Local velocity direction at the start.
* 开始时的本地速度方向。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
EGMS_MovementDirection LocalVelocityDirection{ForceInit};
/**
* Alpha for stride warping during the start.
* 开始期间步幅适配的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float StrideWarpingAlpha{ForceInit};
/**
* Clamp for the playback rate (min, max).
* 播放速率的限制(最小,最大)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector2D PlayRateClamp{ForceInit};
/**
* Alpha for orientation warping during the start.
* 开始期间朝向扭曲的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float OrientationAlpha{1.0f};
/**
* Time spent in the start state (s).
* 开始状态的持续时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float TimeInState{0.0f};
/**
* Blend profile for the start animation.
* 开始动画的混合配置文件。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UBlendProfile> BlendProfile{nullptr};
/**
* Remaining time for the start animation (s).
* 开始动画的剩余时间(秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float TimeRemaining{0.0f};
/**
* Playback rate for the start animation.
* 开始动画的播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float PlayRate{0.0f};
};
/**
* Stores cycle animation state data.
* 存储循环动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Cycle
{
GENERATED_BODY()
/**
* Animation sequence for the cycle.
* 循环动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Animation{nullptr};
/**
* Alpha for orientation warping during the cycle.
* 循环期间朝向扭曲的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float OrientationAlpha{ForceInit};
/**
* Alpha for stride warping during the cycle.
* 循环期间步幅适配的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float StrideWarpingAlpha{ForceInit};
/**
* Playback rate for the cycle animation.
* 循环动画的播放速率。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float PlayRate{1.0f};
/**
* Blend profile for the cycle animation.
* 循环动画的混合配置文件。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UBlendProfile> BlendProfile{nullptr};
};
/**
* Stores stop animation state data.
* 存储停止动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Stop
{
GENERATED_BODY()
/**
* Animation sequence for the stop.
* 停止动画序列。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Animation{nullptr};
/**
* Alpha for orientation warping during the stop.
* 停止期间朝向扭曲的Alpha值。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
float OrientationAlpha{1.0f};
};
/**
* Stores view-related animation state data.
* 存储与视图相关的动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_View
{
GENERATED_BODY()
/**
* Rotation of the view.
* 视图的旋转。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FRotator Rotation{ForceInit};
/**
* Yaw angle between the actor and camera (degrees).
* Actor与相机之间的偏航角
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float YawAngle{0.0f};
/**
* Speed of yaw angle change (degrees/s).
* 偏航角变化速度(度/秒)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "deg/s"))
float YawSpeed{0.0f};
/**
* Pitch angle of the view (degrees).
* 视图的俯仰角(度)。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -90, ClampMax = 90, ForceUnits = "deg"))
float PitchAngle{0.0f};
/**
* Amount of pitch applied (clamped 0 to 1).
* 应用的俯仰量限制在0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float PitchAmount{0.5f};
};
/**
* Stores layering animation state data for body parts.
* 存储身体部位的分层动画状态数据。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_Layering
{
GENERATED_BODY()
virtual ~FGMS_AnimState_Layering() = default;
/**
* Blend amount for the head (0 to 1).
* 头部混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HeadBlendAmount{0.0f};
/**
* Additive blend amount for the head (0 to 1).
* 头部附加混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HeadAdditiveBlendAmount{0.0f};
/**
* Slot blend amount for the head (0 to 1).
* 头部槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HeadSlotBlendAmount{1.0f};
/**
* Blend amount for the left arm (0 to 1).
* 左臂混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftBlendAmount{0.0f};
/**
* Additive blend amount for the left arm (0 to 1).
* 左臂附加混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftAdditiveBlendAmount{0.0f};
/**
* Slot blend amount for the left arm (0 to 1).
* 左臂槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftSlotBlendAmount{1.0f};
/**
* Local space blend amount for the left arm (0 to 1).
* 左臂本地空间混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftLocalSpaceBlendAmount{0.0f};
/**
* Mesh space blend amount for the left arm (0 to 1).
* 左臂网格空间混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftMeshSpaceBlendAmount{0.0f};
/**
* Blend amount for the right arm (0 to 1).
* 右臂混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightBlendAmount{0.0f};
/**
* Additive blend amount for the right arm (0 to 1).
* 右臂附加混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightAdditiveBlendAmount{0.0f};
/**
* Slot blend amount for the right arm (0 to 1).
* 右臂槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightSlotBlendAmount{1.0f};
/**
* Local space blend amount for the right arm (0 to 1).
* 右臂本地空间混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightLocalSpaceBlendAmount{0.0f};
/**
* Mesh space blend amount for the right arm (0 to 1).
* 右臂网格空间混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightMeshSpaceBlendAmount{0.0f};
/**
* Blend amount for the left hand (0 to 1).
* 左手混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HandLeftBlendAmount{0.0f};
/**
* Blend amount for the right hand (0 to 1).
* 右手混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HandRightBlendAmount{0.0f};
/**
* Blend amount for the spine (0 to 1).
* 脊椎混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float SpineBlendAmount{0.0f};
/**
* Additive blend amount for the spine (0 to 1).
* 脊椎附加混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float SpineAdditiveBlendAmount{0.0f};
/**
* Slot blend amount for the spine (0 to 1).
* 脊椎槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float SpineSlotBlendAmount{1.0f};
/**
* Blend amount for the pelvis (0 to 1).
* 骨盆混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float PelvisBlendAmount{0.0f};
/**
* Slot blend amount for the pelvis (0 to 1).
* 骨盆槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float PelvisSlotBlendAmount{1.0f};
/**
* Blend amount for the legs (0 to 1).
* 腿部混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float LegsBlendAmount{0.0f};
/**
* Slot blend amount for the legs (0 to 1).
* 腿部槽混合量0到1
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float LegsSlotBlendAmount{1.0f};
void ApplyValueFromSequence(const UAnimSequence* InSequence, float ExplicitTime);
virtual void ZeroOut();
};
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimState_LayeringSmooth
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float HeadBlendAmount{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmLeftBlendAmount{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float ArmRightBlendAmount{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float SpineBlendAmount{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float PelvisBlendAmount{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ClampMax = 1))
float LegsBlendAmount{0.0f};
};

View File

@@ -0,0 +1,37 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "GMS_LocomotionEnumLibrary.generated.h"
/**
* Defines four-directional movement directions.
* 定义四方向移动方向。
*/
UENUM(BlueprintType)
enum class EGMS_MovementDirection : uint8
{
Forward, // Forward movement. 前进移动。
Backward, // Backward movement. 后退移动。
Left, // Left movement. 左移。
Right // Right movement. 右移。
};
/**
* Defines eight-directional movement directions.
* 定义八方向移动方向。
*/
UENUM(BlueprintType)
enum class EGMS_MovementDirection_8Way : uint8
{
Forward, // Forward movement. 前进移动。
ForwardLeft, // Forward-left movement. 前左移动。
ForwardRight, // Forward-right movement. 前右移动。
Backward, // Backward movement. 后退移动。
BackwardLeft, // Backward-left movement. 后左移动。
BackwardRight, // Backward-right movement. 后右移动。
Left, // Left movement. 左移。
Right // Right movement. 右移。
};

View File

@@ -0,0 +1,601 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "Animation/CachedAnimData.h"
#include "UObject/Object.h"
#include "GMS_LocomotionStructLibrary.generated.h"
class UBlendSpace1D;
class UAnimSequenceBase;
class UAnimSequence;
/**
* Stores the locomotion state of a character.
* 存储角色的运动状态。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_LocomotionState
{
GENERATED_BODY()
/**
* Indicates if there is active input.
* 表示是否有活跃的输入。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bHasInput{false};
/**
* Input yaw angle in world space.
* 世界空间中的输入偏航角。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float InputYawAngle{0.0f};
/**
* Indicates if the character has speed.
* 表示角色是否有速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bHasVelocity{false};
/**
* Current speed of the character.
* 角色的当前速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "cm/s"))
float Speed{0.0f};
/**
* Current velocity vector.
* 当前速度向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector Velocity{ForceInit};
/**
* Yaw angle of the character's velocity.
* 角色速度的偏航角。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float VelocityYawAngle{0.0f};
/**
* Indicates if the character is moving.
* 表示角色是否在移动。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
bool bMoving{false};
/**
* Target yaw angle for the actor's rotation.
* Actor旋转的目标偏航角。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float TargetYawAngle{0.0f};
/**
* Smoothed target yaw angle for extra smooth rotation.
* 用于平滑旋转的平滑目标偏航角。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float SmoothTargetYawAngle{0.0f};
/**
* Angle between view yaw and target yaw.
* 视角偏航角与目标偏航角之间的角度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float ViewRelativeTargetYawAngle{0.0f};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bAimingLimitAppliedThisFrame : 1 {false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bResetAimingLimit : 1 {true};
/**
* Limit for the aiming yaw angle.
* 瞄准偏航角的限制。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float AimingYawAngleLimit{180.0f};
};
/**
* Stores the view state of a character.
* 存储角色的视图状态。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_ViewState
{
GENERATED_BODY()
/**
* Smoothed view rotation, set by replicated view rotation.
* 平滑的视角旋转,由复制的视角旋转设置。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FRotator Rotation{ForceInit};
/**
* Speed of camera rotation from left to right.
* 相机左右旋转的速度。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = 0, ForceUnits = "deg/s"))
float YawSpeed{0.0f};
/**
* View yaw angle from the previous frame.
* 上一帧的视角偏航角。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", Meta = (ClampMin = -180, ClampMax = 180, ForceUnits = "deg"))
float PreviousYawAngle{0.0f};
};
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_MovementBaseState
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, Category="GMS")
TObjectPtr<UPrimitiveComponent> Primitive;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FName BoneName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bBaseChanged : 1 {false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bHasRelativeLocation : 1 {false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
uint8 bHasRelativeRotation : 1 {false};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FVector Location{ForceInit};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FQuat Rotation{ForceInit};
/**
* 基础对象(例如移动平台)从上一帧到当前帧的旋转变化。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
FRotator DeltaRotation{ForceInit};
};
/**
* Parameters for predicting ground movement stop location.
* 预测地面运动停止位置的参数。
*/
USTRUCT()
struct FGMS_PredictGroundMovementStopLocationParams
{
GENERATED_BODY()
/**
* Current velocity vector.
* 当前速度向量。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FVector Velocity{ForceInit};
/**
* Whether to use separate braking friction.
* 是否使用单独的制动摩擦。
*/
UPROPERTY(EditAnywhere, Category="GMS")
bool bUseSeparateBrakingFriction{ForceInit};
/**
* Braking friction value.
* 制动摩擦值。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float BrakingFriction{ForceInit};
/**
* Ground friction value.
* 地面摩擦值。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float GroundFriction{ForceInit};
/**
* Braking friction factor.
* 制动摩擦因子。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float BrakingFrictionFactor{ForceInit};
/**
* Braking deceleration for walking.
* 行走时的制动减速度。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float BrakingDecelerationWalking{ForceInit};
};
/**
* Parameters for predicting ground movement pivot location.
* 预测地面运动枢轴位置的参数。
*/
USTRUCT()
struct FGMS_PredictGroundMovementPivotLocationParams
{
GENERATED_BODY()
/**
* Current acceleration vector.
* 当前加速度向量。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FVector Acceleration{ForceInit};
/**
* Current velocity vector.
* 当前速度向量。
*/
UPROPERTY(EditAnywhere, Category="GMS")
FVector Velocity{ForceInit};
/**
* Ground friction value.
* 地面摩擦值。
*/
UPROPERTY(EditAnywhere, Category="GMS")
float GroundFriction{0.0f};
};
/**
* Stores animations for four-directional movement.
* 存储四方向移动的动画。
*/
USTRUCT(BlueprintType)
struct FGMS_Animations_4Direction
{
GENERATED_BODY()
/**
* Animation for forward movement.
* 前进移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Forward = nullptr;
/**
* Animation for backward movement.
* 后退移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Backward = nullptr;
/**
* Animation for left movement.
* 左移移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Left = nullptr;
/**
* Animation for right movement.
* 右移移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Right = nullptr;
/**
* Checks if all animations are valid.
* 检查所有动画是否有效。
* @return True if all animations are set. 如果所有动画都设置返回true。
*/
bool ValidAnimations() const;
/**
* Checks if any animation has root motion.
* 检查是否有动画包含根运动。
* @return True if any animation has root motion. 如果有动画包含根运动返回true。
*/
bool HasRootMotion() const;
};
/**
* Stores animations for eight-directional movement.
* 存储八方向移动的动画。
*/
USTRUCT(BlueprintType)
struct FGMS_Animations_8Direction
{
GENERATED_BODY()
/**
* Animation for forward movement.
* 前进移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Forward = nullptr;
/**
* Animation for forward-left movement.
* 前左移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> ForwardLeft = nullptr;
/**
* Animation for forward-right movement.
* 前右移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> ForwardRight = nullptr;
/**
* Animation for backward movement.
* 后退移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Backward = nullptr;
/**
* Animation for backward-left movement.
* 后左移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> BackwardLeft = nullptr;
/**
* Animation for backward-right movement.
* 后右移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> BackwardRight = nullptr;
/**
* Animation for left movement.
* 左移移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Left = nullptr;
/**
* Animation for right movement.
* 右移移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> Right = nullptr;
/**
* Checks if all animations are valid.
* 检查所有动画是否有效。
* @return True if all animations are set. 如果所有动画都设置返回true。
*/
bool ValidAnimations() const;
/**
* Checks if any animation has root motion.
* 检查是否有动画包含根运动。
* @return True if any animation has root motion. 如果有动画包含根运动返回true。
*/
bool HasRootMotion() const;
};
/**
* Stores 1D blend space animations for forward and backward movement.
* 存储用于前后移动的1D混合空间动画。
*/
USTRUCT(BlueprintType)
struct FGMS_Animations_BS1D_FwdBwd
{
GENERATED_BODY()
/**
* Blend space for forward movement.
* 前进移动的混合空间。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UBlendSpace1D> Forward{nullptr};
/**
* Blend space for backward movement.
* 后退移动的混合空间。
*/
UPROPERTY(EditAnywhere, Category="GMS")
TObjectPtr<UBlendSpace1D> Backward{nullptr};
};
/**
* Stores animations for starting movement while facing forward.
* 存储面向前进时开始移动的动画。
*/
USTRUCT(BlueprintType)
struct FGMS_Animations_StartForwardFacing
{
GENERATED_BODY()
/**
* Animation for starting movement forward.
* 前进开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForward = nullptr;
/**
* Animation for starting movement forward with a 90-degree left turn.
* 前进并向左90度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardL90 = nullptr;
/**
* Animation for starting movement forward with a 90-degree right turn.
* 前进并向右90度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardR90 = nullptr;
/**
* Animation for starting movement forward with a 180-degree left turn.
* 前进并向左180度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardL180 = nullptr;
/**
* Animation for starting movement forward with a 180-degree right turn.
* 前进并向右180度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardR180 = nullptr;
};
/**
* Stores animations for starting movement while facing forward in eight directions.
* 存储面向前进时八方向开始移动的动画。
*/
USTRUCT(BlueprintType)
struct FGMS_Animations_StartForwardFacing_8Direction
{
GENERATED_BODY()
/**
* Animation for starting movement forward.
* 前进开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForward = nullptr;
/**
* Animation for starting movement forward with a 90-degree left turn.
* 前进并向左90度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardL90 = nullptr;
/**
* Animation for starting movement forward with a 90-degree right turn.
* 前进并向右90度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardR90 = nullptr;
/**
* Animation for starting movement forward with a 180-degree left turn.
* 前进并向左180度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardL180 = nullptr;
/**
* Animation for starting movement forward with a 180-degree right turn.
* 前进并向右180度开始移动的动画。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS")
TObjectPtr<UAnimSequence> StartForwardR180 = nullptr;
};
/**
* Stores an animation with an associated distance.
* 存储与距离关联的动画。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_AnimationWithDistance
{
GENERATED_BODY()
/**
* The animation sequence.
* 动画序列。
*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="GMS")
TObjectPtr<UAnimSequence> Animation = nullptr;
/**
* The distance associated with the animation.
* 与动画关联的距离。
*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="GMS", meta=(ClampMin=0))
float Distance{200};
#if WITH_EDITORONLY_DATA
/**
* Editor-friendly name for the animation.
* 动画的编辑器友好名称。
*/
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
FString EditorFriendlyName;
#endif
};
/**
* Maps animation state names to gameplay tags.
* 将动画状态名称映射到游戏标签。
*/
USTRUCT(BlueprintType)
struct FGMS_AnimStateNameToTag
{
GENERATED_BODY()
/**
* The gameplay tag for the animation state.
* 动画状态的游戏标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GMS", meta=(Categories="GMS.SM"))
FGameplayTag Tag;
/**
* The cached animation state data.
* 缓存的动画状态数据。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "GMS")
FCachedAnimStateData State;
/**
* Equality operator for comparing two animation state mappings.
* 比较两个动画状态映射的相等运算符。
* @param Lhs Left-hand side mapping. 左侧映射。
* @param RHS Right-hand side mapping. 右侧映射。
* @return True if mappings are equal. 如果映射相等返回true。
*/
friend bool operator==(const FGMS_AnimStateNameToTag& Lhs, const FGMS_AnimStateNameToTag& RHS)
{
return Lhs.Tag == RHS.Tag
&& Lhs.State.StateMachineName == RHS.State.StateMachineName && Lhs.State.StateName == RHS.State.StateName;
}
/**
* Inequality operator for comparing two animation state mappings.
* 比较两个动画状态映射的不等运算符。
* @param Lhs Left-hand side mapping. 左侧映射。
* @param RHS Right-hand side mapping. 右侧映射。
* @return True if mappings are not equal. 如果映射不相等返回true。
*/
friend bool operator!=(const FGMS_AnimStateNameToTag& Lhs, const FGMS_AnimStateNameToTag& RHS)
{
return !(Lhs == RHS);
}
};
/**
* Wrapper for a list of animation state to tag mappings.
* 动画状态到标签映射列表的包装器。
*/
USTRUCT()
struct FGMS_AnimStateNameToTagWrapper
{
GENERATED_BODY()
/**
* Array of animation state to tag mappings.
* 动画状态到标签映射的数组。
*/
UPROPERTY()
TArray<FGMS_AnimStateNameToTag> AnimStateNameToTagMapping;
};

View File

@@ -0,0 +1,651 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "GMS_LocomotionStructLibrary.h"
#include "Engine/TimerHandle.h"
#include "TimerManager.h"
#include "Animation/AnimExecutionContext.h"
#include "Animation/AnimInstance.h"
#include "Animation/AnimNodeReference.h"
#include "Engine/World.h"
#include "Settings/GMS_SettingStructLibrary.h"
#include "Locomotions/GMS_AnimState.h"
#include "Utility/GMS_Tags.h"
#include "GMS_MainAnimInstance.generated.h"
class IPoseSearchTrajectoryPredictorInterface;
class UGMS_AnimLayerSetting_Additive;
class UGMS_AnimLayer;
class UGMS_AnimLayerSetting;
class UGMS_AnimLayerSetting_View;
class UGMS_AnimLayerSetting_Overlay;
class UGMS_AnimLayerSetting_States;
class UGMS_MovementDefinition;
class UGMS_MovementSystemComponent;
/**
* Base animation template for the main animation instance.
* 主动画实例的动画模板基类。
*/
UCLASS(BlueprintType)
class GENERICMOVEMENTSYSTEM_API UGMS_MainAnimInstance : public UAnimInstance
{
GENERATED_BODY()
public:
/**
* Gets the movement system component.
* 获取运动系统组件。
* @return The movement system component. 运动系统组件。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
UGMS_MovementSystemComponent* GetMovementSystemComponent() const;
/**
* Constructor.
* 构造函数。
*/
UGMS_MainAnimInstance();
/**
* Initializes the animation.
* 初始化动画。
*/
virtual void NativeInitializeAnimation() override;
/**
* Uninitializes the animation.
* 取消初始化动画。
*/
virtual void NativeUninitializeAnimation() override;
/**
* Called when the game starts.
* 游戏开始时调用。
*/
virtual void NativeBeginPlay() override;
/**
* Updates the animation.
* 更新动画。
* @param DeltaTime Time since last update. 自上次更新以来的时间。
*/
virtual void NativeUpdateAnimation(float DeltaTime) override;
/**
* Thread-safe animation update.
* 线程安全的动画更新。
* @param DeltaTime Time since last update. 自上次更新以来的时间。
*/
virtual void NativeThreadSafeUpdateAnimation(float DeltaTime) override;
/**
* Applies an animation layer setting to an animation layer instance.
* 将动画层设置应用于动画层实例。
* @param LayerSetting The layer setting to apply. 要应用的层设置。
* @param LayerInstance The layer instance to apply the setting to. 要应用设置的层实例。
*/
virtual void SetAnimLayerBySetting(const UGMS_AnimLayerSetting* LayerSetting, TObjectPtr<UGMS_AnimLayer>& LayerInstance);
/**
* Registers animation state name to tag mappings for a given animation instance.
* 为给定的动画实例注册动画状态名称到标签的映射。
* @param SourceAnimInstance The animation instance to register mappings for. 要注册映射的动画实例。
* @param Mapping The state name to tag mappings. 状态名称到标签的映射。
*/
UFUNCTION(BlueprintCallable, Category="GMS|Animation")
virtual void RegisterStateNameToTagMapping(UAnimInstance* SourceAnimInstance, TArray<FGMS_AnimStateNameToTag> Mapping);
/**
* Unregisters animation state name to tag mappings for a given animation instance.
* 为给定的动画实例取消注册动画状态名称到标签的映射。
* @param SourceAnimInstance The animation instance to unregister mappings for. 要取消注册映射的动画实例。
*/
UFUNCTION(BlueprintCallable, Category="GMS|Animation")
virtual void UnregisterStateNameToTagMapping(UAnimInstance* SourceAnimInstance);
/**
* Refreshes layer settings when core state changes (e.g., movement set, locomotion mode).
* 当核心状态(如运动集、运动模式)更改时刷新层设置。
* @note Override if custom movement definitions include additional animation layer settings. 如果自定义运动定义包含额外的动画层设置,则需覆盖。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation")
void RefreshLayerSettings();
virtual void RefreshLayerSettings_Implementation();
/**
* Sets the offset root bone rotation mode.
* 设置偏移根骨骼旋转模式。
* @param NewRotationMode The new rotation mode. 新的旋转模式。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
void SetOffsetRootBoneRotationMode(EOffsetRootBoneMode NewRotationMode);
/**
* Gets the current offset root bone rotation mode.
* 获取当前偏移根骨骼旋转模式。
* @return The current rotation mode. 当前旋转模式。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
EOffsetRootBoneMode GetOffsetRootBoneRotationMode() const;
/**
* Gets the current offset root bone translation mode.
* 获取当前偏移根骨骼平移模式。
* @return The current translation mode. 当前平移模式。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
EOffsetRootBoneMode GetOffsetRootBoneTranslationMode() const;
/**
* Sets the offset root bone translation mode.
* 设置偏移根骨骼平移模式。
* @param NewTranslationMode The new translation mode. 新的平移模式。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
void SetOffsetRootBoneTranslationMode(EOffsetRootBoneMode NewTranslationMode);
protected:
/**
* Called when the locomotion mode changes.
* 运动模式更改时调用。
* @param Prev The previous locomotion mode. 之前的运动模式。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|Animation")
void OnLocomotionModeChanged(const FGameplayTag& Prev);
/**
* Called when the rotation mode changes.
* 旋转模式更改时调用。
* @param Prev The previous rotation mode. 之前的旋转模式。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|Animation")
void OnRotationModeChanged(const FGameplayTag& Prev);
/**
* Called when the movement set changes.
* 运动集更改时调用。
* @param Prev The previous movement set. 之前的运动集。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|Animation")
void OnMovementSetChanged(const FGameplayTag& Prev);
/**
* Called when the movement state changes.
* 运动状态更改时调用。
* @param Prev The previous movement state. 之前的运动状态。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|Animation")
void OnMovementStateChanged(const FGameplayTag& Prev);
/**
* Called when the overlay mode changes.
* 叠层模式更改时调用。
* @param Prev The previous overlay mode. 之前的叠层模式。
*/
UFUNCTION(BlueprintNativeEvent, Category="GMS|Animation")
void OnOverlayModeChanged(const FGameplayTag& Prev);
/**
* Refreshes Trajectory-related data.
* 刷新Trajectory相关数据。
* @param DeltaTime Time since last update. 自上次更新以来的时间。
*/
virtual void RefreshTrajectoryState(float DeltaTime);
/**
* Refreshes view-related data.
* 刷新视图相关数据。
* @param DeltaTime Time since last update. 自上次更新以来的时间。
*/
virtual void RefreshView(float DeltaTime);
/**
* Refreshes locomotion data.
* 刷新运动数据。
* @param DeltaTime Time since last update. 自上次更新以来的时间。
*/
virtual void RefreshLocomotion(const float DeltaTime);
/**
* Refreshes block state.
* 刷新阻塞状态。
*/
virtual void RefreshBlock();
/**
* Gather information from game world.
* 从游戏世界获取信息。
*/
virtual void RefreshStateOnGameThread();
/**
* Refreshes animation node relevance tags on the game thread.
* 在游戏线程上刷新动画节点相关性标签。
*/
virtual void RefreshRelevanceOnGameThread();
/**
* Refreshes grounded state data.
* 刷新地面状态数据。
*/
virtual void RefreshGrounded();
/**
* Refreshes lean data for grounded state.
* 刷新地面状态的倾斜数据。
*/
virtual void RefreshGroundedLean();
/**
* Gets the relative acceleration amount for leaning.
* 获取用于倾斜的相对加速度量。
* @return 2D vector of relative acceleration. 相对加速度的2D向量。
*/
virtual FVector2f GetRelativeAccelerationAmount() const;
/**
* Refreshes in-air state data.
* 刷新空中状态数据。
*/
virtual void RefreshInAir();
/**
* Refreshes ground prediction data.
* 刷新地面预测数据。
*/
virtual void RefreshGroundPrediction();
/**
* Refreshes lean data for in-air state.
* 刷新空中状态的倾斜数据。
*/
virtual void RefreshInAirLean();
/**
* Refreshes the offset root bone state.
* 刷新偏移根骨骼状态。
* @param Context Animation update context. 动画更新上下文。
* @param Node Animation node reference. 动画节点引用。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GMS|Animation", meta=(BlueprintThreadSafe))
void RefreshOffsetRootBone(UPARAM(ref)
FAnimUpdateContext& Context, UPARAM(ref)
FAnimNodeReference& Node);
public:
/**
* Gets the clamped curve value (0 to 1) for a given curve name.
* 获取给定曲线名称的限制曲线值0到1
* @param CurveName The name of the curve. 曲线名称。
* @return The clamped curve value. 限制的曲线值。
*/
float GetCurveValueClamped01(const FName& CurveName) const;
/**
* Gets the named blend profile.
* 获取命名的混合配置文件。
* @param BlendProfileName The name of the blend profile. 混合配置文件名称。
* @return The blend profile. 混合配置文件。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
UBlendProfile* GetNamedBlendProfile(const FName& BlendProfileName) const;
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
FGameplayTagContainer GetAggregatedTags() const;
/**
* Gets the yaw value for aim offset.
* 获取瞄准偏移的偏航值。
* @return The aim offset yaw value. 瞄准偏移偏航值。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
float GetAOYawValue() const;
/**
* Selects a cardinal direction based on an angle.
* 根据角度选择主要方向。
* @param Angle The angle to evaluate. 要评估的角度。
* @param DeadZone The dead zone for direction changes. 方向变化的死区。
* @param CurrentDirection The current direction. 当前方向。
* @param bUseCurrentDirection Whether to consider the current direction. 是否考虑当前方向。
* @return The selected cardinal direction. 选择的主要方向。
*/
EGMS_MovementDirection SelectCardinalDirectionFromAngle(float Angle, float DeadZone, EGMS_MovementDirection CurrentDirection, bool bUseCurrentDirection) const;
/**
* Selects an octagonal direction based on an angle.
* 根据角度选择八方向。
* @param Angle The angle to evaluate. 要评估的角度。
* @param DeadZone The dead zone for direction changes. 方向变化的死区。
* @param CurrentDirection The current direction. 当前方向。
* @param bUseCurrentDirection Whether to consider the current direction. 是否考虑当前方向。
* @return The selected octagonal direction. 选择的八方向。
*/
EGMS_MovementDirection_8Way SelectOctagonalDirectionFromAngle(float Angle, float DeadZone, EGMS_MovementDirection_8Way CurrentDirection, bool bUseCurrentDirection) const;
/**
* Gets the opposite cardinal direction.
* 获取相反的主要方向。
* @param CurrentDirection The current direction. 当前方向。
* @return The opposite cardinal direction. 相反的主要方向。
*/
EGMS_MovementDirection GetOppositeCardinalDirection(EGMS_MovementDirection CurrentDirection) const;
/**
* Checks if any core state has changed (movement set, state, locomotion, rotation, or overlay mode).
* 检查是否有核心状态更改(运动集、状态、运动、旋转或叠层模式)。
* @return True if any core state has changed. 如果任何核心状态更改则返回true。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
bool HasCoreStateChanges() const;
/**
* Checks if specified core states have changed.
* 检查指定的核心状态是否更改。
* @param bCheckLocomotionMode Check locomotion mode changes. 检查运动模式更改。
* @param bCheckMovementSet Check movement set changes. 检查运动集更改。
* @param bCheckRotationMode Check rotation mode changes. 检查旋转模式更改。
* @param bCheckMovementState Check movement state changes. 检查运动状态更改。
* @param bCheckOverlayMode Check overlay mode changes. 检查叠层模式更改。
* @return True if any specified state has changed. 如果任何指定状态更改则返回true。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GMS|Animation", meta=(BlueprintThreadSafe))
bool CheckCoreStateChanges(bool bCheckLocomotionMode, bool bCheckMovementSet, bool bCheckRotationMode, bool bCheckMovementState, bool bCheckOverlayMode) const;
/**
* Animation state name to gameplay tag mappings.
* 动画状态名称到游戏标签的映射。
* @note Used to check if a state node is active via NodeRelevantTags. 用于通过NodeRelevantTags检查状态节点是否活跃。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(TitleProperty="Tag"))
TArray<FGMS_AnimStateNameToTag> AnimStateNameToTagMapping;
/**
* Current locomotion mode.
* 当前运动模式。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.LocomotionMode"))
FGameplayTag LocomotionMode{GMS_MovementModeTags::Grounded};
/**
* Container for locomotion mode (for chooser only).
* 运动模式的容器(仅用于选择器)。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.LocomotionMode"))
FGameplayTagContainer LocomotionModeContainer;
/**
* Current rotation mode.
* 当前旋转模式。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.RotationMode"))
FGameplayTag RotationMode{GMS_RotationModeTags::ViewDirection};
/**
* Container for rotation mode (for chooser only).
* 旋转模式的容器(仅用于选择器)。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.RotationMode"))
FGameplayTagContainer RotationModeContainer;
/**
* Current movement state.
* 当前运动状态。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.MovementState"))
FGameplayTag MovementState{GMS_MovementStateTags::Jog};
/**
* Container for movement state (for chooser only).
* 运动状态的容器(仅用于选择器)。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.MovementState"))
FGameplayTagContainer MovementStateContainer;
/**
* Current movement set.
* 当前运动集。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.MovementSet"))
FGameplayTag MovementSet;
/**
* Container for movement set (for chooser only).
* 运动集的容器(仅用于选择器)。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.MovementSet"))
FGameplayTagContainer MovementSetContainer;
/**
* Current overlay mode.
* 当前叠层模式。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.OverlayMode"))
FGameplayTag OverlayMode{GMS_OverlayModeTags::Default};
/**
* Container for overlay mode (for chooser only).
* 叠层模式的容器(仅用于选择器)。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings", meta=(Categories="GMS.OverlayMode"))
FGameplayTagContainer OverlayModeContainer;
/**
* Enables ground prediction.
* 启用地面预测。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings")
bool bEnableGroundPrediction{false};
/**
* General animation settings.
* 通用动画设置。
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Settings")
FGMS_AnimDataSetting_General GeneralSetting;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings", meta=(BlueprintThreadSafe))
TObjectPtr<const UGMS_MovementControlSetting_Default> ControlSetting{nullptr};
UPROPERTY(Transient)
FGMS_MovementBaseState MovementBase;
/**
* Locomotion state for the game thread.
* 游戏线程的运动状态。
*/
UPROPERTY(Transient)
FGMS_LocomotionState GameLocomotionState;
/**
* Root bone animation state.
* 根骨骼动画状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Root RootState;
/**
* Locomotion animation state.
* 运动动画状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Locomotion LocomotionState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Trajectory TrajectoryState;
/**
* View-related animation state.
* 视图相关动画状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_View ViewState;
/**
* Lean animation state.
* 倾斜动画状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_Lean LeanState;
/**
* Movement intent vector.
* 运动意图向量。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State", meta=(DisplayName="Movement Intent"))
FVector MovementIntent;
/**
* In-air animation state.
* 空中动画状态。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="State")
FGMS_AnimState_InAir InAirState;
/**
* Tags owned by the animation instance.
* 动画实例拥有的标签。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
FGameplayTagContainer OwnedTags;
/**
* Tags indicating active animation nodes.
* 指示活跃动画节点的标签。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
FGameplayTagContainer NodeRelevanceTags;
/**
* Indicates if any montage is playing.
* 指示是否有蒙太奇在播放。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bAnyMontagePlaying{false};
/**
* Indicates if the movement state has changed.
* 指示运动状态是否更改。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bMovementStateChanged{false};
/**
* Indicates if the locomotion mode has changed.
* 指示运动模式是否更改。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bLocomotionModeChanged{false};
/**
* Indicates if the movement set has changed.
* 指示运动集是否更改。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bMovementSetChanged{false};
/**
* Indicates if the rotation mode has changed.
* 指示旋转模式是否更改。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bRotationModeChanged{false};
/**
* Indicates if the overlay mode has changed.
* 指示叠层模式是否更改。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bOverlayModeChanged{false};
/**
* Indicates if movement is blocked.
* 指示移动是否被阻塞。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State", meta=(DisplayName="Movement Blocked"))
bool bBlocked{false};
/**
* Indicates if the character has just landed.
* 指示角色是否刚刚着陆。
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="State")
bool bJustLanded{false};
/**
* Indicates if this is the first update.
* 指示这是否是第一次更新。
*/
bool bFirstUpdate = true;
UPROPERTY()
TScriptInterface<IPoseSearchTrajectoryPredictorInterface> TrajectoryPredictor;
protected:
/**
* Reference to the movement system component.
* 运动系统组件的引用。
*/
UPROPERTY()
TObjectPtr<UGMS_MovementSystemComponent> MovementSystem;
/**
* Reference to the owning pawn.
* 拥有Pawn的引用。
*/
UPROPERTY(Transient)
TObjectPtr<APawn> PawnOwner;
/**
* Runtime mappings of animation state names to tags.
* 动画状态名称到标签的运行时映射。
*/
UPROPERTY()
TMap<TObjectPtr<UAnimInstance>, FGMS_AnimStateNameToTagWrapper> RuntimeAnimStateNameToTagMappings;
/**
* Timer handle for initial updates.
* 初始更新的计时器句柄。
*/
FTimerHandle InitialTimerHandle;
/**
* Animation layer instance for states.
* 状态动画层实例。
*/
UPROPERTY(VisibleInstanceOnly, Category="AnimLayers", meta=(ShowInnerProperties))
TObjectPtr<UGMS_AnimLayer> StateLayerInstance;
/**
* Animation layer instance for overlays.
* 叠层动画层实例。
*/
UPROPERTY(VisibleInstanceOnly, Category="AnimLayers", meta=(ShowInnerProperties))
TObjectPtr<UGMS_AnimLayer> OverlayLayerInstance;
/**
* Animation layer instance for view.
* 视图动画层实例。
*/
UPROPERTY(VisibleInstanceOnly, Category="AnimLayers", meta=(ShowInnerProperties))
TObjectPtr<UGMS_AnimLayer> ViewLayerInstance;
/**
* Animation layer instance for additive animations.
* 附加动画层实例。
*/
UPROPERTY(VisibleInstanceOnly, Category="AnimLayers", meta=(ShowInnerProperties))
TObjectPtr<UGMS_AnimLayer> AdditiveLayerInstance;
/**
* Animation layer instance for skeletal controls.
* 骨骼控制动画层实例。
*/
UPROPERTY(VisibleInstanceOnly, Category="AnimLayers", meta=(ShowInnerProperties))
TObjectPtr<UGMS_AnimLayer> SkeletonControlsLayerInstance;
};