第一次提交

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,16 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "DefaultMovementSet/Modes/FlyingMode.h"
#include "GMS_FlyingMode.generated.h"
/**
*
*/
UCLASS()
class GENERICMOVEMENTSYSTEM_API UGMS_FlyingMode : public UFlyingMode
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,18 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "MovementMode.h"
#include "UObject/Object.h"
#include "GMS_MoverSettingObjectLibrary.generated.h"
/**
* CommonLegacyMovementSettings: collection of settings that are shared between several of the legacy movement modes
*/
UCLASS(BlueprintType)
class GENERICMOVEMENTSYSTEM_API UGMS_MoverGroundedMovementSettings : public UObject
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,159 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "MoverTypes.h"
#include "GMS_MoverStructLibrary.generated.h"
/**
* Data block containing extended movement actions inputs used by Generic Movement System.
* 包含GMS所用到的运动行为输入定义的数据块。
*/
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_MoverActionInputs : public FMoverDataStructBase
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadWrite, Category = Mover)
bool bIsDashJustPressed = false;
UPROPERTY(BlueprintReadWrite, Category = Mover)
bool bIsAimPressed = false;
UPROPERTY(BlueprintReadWrite, Category = Mover)
bool bIsVaultJustPressed = false;
UPROPERTY(BlueprintReadWrite, Category = Mover)
bool bWantsToStartZiplining = false;
UPROPERTY(BlueprintReadWrite, Category = Mover)
bool bWantsToBeCrouched = false;
// @return newly allocated copy of this FGMS_MoverActionInputs. Must be overridden by child classes
virtual FMoverDataStructBase* Clone() const override
{
// TODO: ensure that this memory allocation jives with deletion method
FGMS_MoverActionInputs* CopyPtr = new FGMS_MoverActionInputs(*this);
return CopyPtr;
}
virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override
{
Super::NetSerialize(Ar, Map, bOutSuccess);
Ar.SerializeBits(&bIsDashJustPressed, 1);
Ar.SerializeBits(&bIsAimPressed, 1);
Ar.SerializeBits(&bIsVaultJustPressed, 1);
Ar.SerializeBits(&bWantsToStartZiplining, 1);
Ar.SerializeBits(&bWantsToBeCrouched, 1);
bOutSuccess = true;
return true;
}
virtual UScriptStruct* GetScriptStruct() const override { return StaticStruct(); }
virtual void ToString(FAnsiStringBuilderBase& Out) const override
{
Super::ToString(Out);
Out.Appendf("bIsDashJustPressed: %i\n", bIsDashJustPressed);
Out.Appendf("bIsAimPressed: %i\n", bIsAimPressed);
Out.Appendf("bIsVaultJustPressed: %i\n", bIsVaultJustPressed);
Out.Appendf("bWantsToStartZiplining: %i\n", bWantsToStartZiplining);
Out.Appendf("bWantsToBeCrouched: %i\n", bWantsToBeCrouched);
}
virtual void AddReferencedObjects(FReferenceCollector& Collector) override { Super::AddReferencedObjects(Collector); }
};
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_MoverTagInputs : public FMoverDataStructBase
{
GENERATED_USTRUCT_BODY()
/**
* A container which you can query tag to indicate a input is requested.
*/
UPROPERTY(BlueprintReadWrite, Category = Mover)
FGameplayTagContainer Tags;
// @return newly allocated copy of this FGMS_MoverActionInputs. Must be overridden by child classes
virtual FMoverDataStructBase* Clone() const override
{
// TODO: ensure that this memory allocation jives with deletion method
FGMS_MoverTagInputs* CopyPtr = new FGMS_MoverTagInputs(*this);
return CopyPtr;
}
virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override
{
bool bSuccess = Super::NetSerialize(Ar, Map, bOutSuccess);
Tags.NetSerialize(Ar, Map, bSuccess);
return bSuccess;
}
virtual UScriptStruct* GetScriptStruct() const override { return StaticStruct(); }
virtual void ToString(FAnsiStringBuilderBase& Out) const override
{
Super::ToString(Out);
Out.Appendf("MoverTagInputs Tags[%s] \n", *Tags.ToString());
}
virtual void AddReferencedObjects(FReferenceCollector& Collector) override { Super::AddReferencedObjects(Collector); }
};
USTRUCT(BlueprintType)
struct GENERICMOVEMENTSYSTEM_API FGMS_MoverMovementControlInputs : public FMoverDataStructBase
{
GENERATED_USTRUCT_BODY()
/**
* 当前是什么运动集?影响角色动画表现方式。
*/
UPROPERTY(BlueprintReadWrite, Category = Mover)
FGameplayTag DesiredMovementSet;
/**
* 想以什么状态移动?影响角色移动参数
*/
UPROPERTY(BlueprintReadWrite, Category = Mover)
FGameplayTag DesiredMovementState;
/**
* 想以什么方式旋转?影响角色的朝向方式。
*/
UPROPERTY(BlueprintReadWrite, Category = Mover)
FGameplayTag DesiredRotationMode;
// @return newly allocated copy of this FGMS_MoverActionInputs. Must be overridden by child classes
virtual FMoverDataStructBase* Clone() const override
{
// TODO: ensure that this memory allocation jives with deletion method
FGMS_MoverMovementControlInputs* CopyPtr = new FGMS_MoverMovementControlInputs(*this);
return CopyPtr;
}
virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override
{
bool bSuccess = Super::NetSerialize(Ar, Map, bOutSuccess);
DesiredMovementSet.NetSerialize(Ar, Map, bSuccess);
DesiredMovementState.NetSerialize(Ar, Map, bSuccess);
DesiredRotationMode.NetSerialize(Ar, Map, bSuccess);
return bSuccess;
}
virtual UScriptStruct* GetScriptStruct() const override { return StaticStruct(); }
virtual void ToString(FAnsiStringBuilderBase& Out) const override
{
Super::ToString(Out);
Out.Appendf("DesiredMovementSet [%s] \n", *DesiredMovementSet.ToString());
Out.Appendf("DesiredMovementState [%s] \n", *DesiredMovementState.ToString());
Out.Appendf("DesiredRotationMode [%s] \n", *DesiredRotationMode.ToString());
}
virtual void AddReferencedObjects(FReferenceCollector& Collector) override { Super::AddReferencedObjects(Collector); }
};

View File

@@ -0,0 +1,84 @@
// // Copyright 2025 https://yuewu.dev/en All Rights Reserved.
//
// #pragma once
//
// #include "CoreMinimal.h"
// #include "MovementModifier.h"
// #include "UObject/Object.h"
// #include "GMS_MovementStateModifer.generated.h"
//
//
// USTRUCT(BlueprintType)
// struct FGMS_MovementStateModifierEntry
// {
// GENERATED_BODY()
//
// /** Maximum speed in the movement plane */
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="General", meta = (ClampMin = "0", UIMin = "0", ForceUnits = "cm/s"))
// float MaxSpeed = 800.f;
//
// /** Default max linear rate of deceleration when there is no controlled input */
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="General", meta = (ClampMin = "0", UIMin = "0", ForceUnits = "cm/s^2"))
// float Deceleration = 4000.f;
//
// /** Default max linear rate of acceleration for controlled input. May be scaled based on magnitude of input. */
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="General", meta = (ClampMin = "0", UIMin = "0", ForceUnits = "cm/s^2"))
// float Acceleration = 4000.f;
//
// /** Maximum rate of turning rotation (degrees per second). Negative numbers indicate instant rotation and should cause rotation to snap instantly to desired direction. */
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="General", meta = (ClampMin = "-1", UIMin = "0", ForceUnits = "degrees/s"))
// float TurningRate = 500.f;
//
// /** Speeds velocity direction changes while turning, to reduce sliding */
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="General", meta = (ClampMin = "0", UIMin = "0", ForceUnits = "Multiplier"))
// float TurningBoost = 8.f;
// };
//
//
// /**
// * States: Applies settings to the actor to make them go into different states like walk or jog, sprint, affects actor speed and acceleration/deceleration, turn etc,
// */
// USTRUCT(BlueprintType)
// struct MOVER_API FGMS_MovementStateModifier : public FMovementModifierBase
// {
// GENERATED_BODY()
//
// FGMS_MovementStateModifier();
//
// virtual ~FGMS_MovementStateModifier() override
// {
// }
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Modifer")
// bool bRevertMovementSettingsOnEnd{false};
//
// /** Fired when this modifier is activated. */
// virtual void OnStart(UMoverComponent* MoverComp, const FMoverTimeStep& TimeStep, const FMoverSyncState& SyncState, const FMoverAuxStateContext& AuxState) override;
//
// /** Fired when this modifier is deactivated. */
// virtual void OnEnd(UMoverComponent* MoverComp, const FMoverTimeStep& TimeStep, const FMoverSyncState& SyncState, const FMoverAuxStateContext& AuxState) override;
//
// /** Fired just before a Substep */
// virtual void OnPreMovement(UMoverComponent* MoverComp, const FMoverTimeStep& TimeStep) override;
//
// /** Fired after a Substep */
// virtual void OnPostMovement(UMoverComponent* MoverComp, const FMoverTimeStep& TimeStep, const FMoverSyncState& SyncState, const FMoverAuxStateContext& AuxState) override;
//
// // @return newly allocated copy of this FMovementModifier. Must be overridden by child classes
// virtual FMovementModifierBase* Clone() const override;
//
// virtual void NetSerialize(FArchive& Ar) override;
//
// virtual UScriptStruct* GetScriptStruct() const override;
//
// virtual FString ToSimpleString() const override;
//
// virtual void AddReferencedObjects(class FReferenceCollector& Collector) override;
//
// protected:
// // Applies any movement settings like acceleration or max speed changes
// void ApplyMovementSettings(UMoverComponent* MoverComp);
//
// // Reverts any movement settings like acceleration or max speed changes
// void RevertMovementSettings(UMoverComponent* MoverComp);
// };

View File

@@ -0,0 +1,20 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "DefaultMovementSet/Modes/WalkingMode.h"
#include "GMS_WalkingMode.generated.h"
class UGMS_MoverGroundedMovementSettings;
/**
*
*/
UCLASS()
class GENERICMOVEMENTSYSTEM_API UGMS_WalkingMode : public UWalkingMode
{
GENERATED_BODY()
public:
UGMS_WalkingMode(const FObjectInitializer& ObjectInitializer);
};

View File

@@ -0,0 +1,30 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "GMS_ZiplineInterface.generated.h"
// This class does not need to be modified.
UINTERFACE()
class GENERICMOVEMENTSYSTEM_API UGMS_ZiplineInterface : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class GENERICMOVEMENTSYSTEM_API IGMS_ZiplineInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Zipline")
USceneComponent* GetStartComponent();
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Zipline")
USceneComponent* GetEndComponent();
};

View File

@@ -0,0 +1,51 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Runtime/Launch/Resources/Version.h"
#include "GMS_ZipliningMode.h"
#include "MovementModeTransition.h"
#include "GMS_ZiplineModeTransition.generated.h"
/**
* Transition that handles starting ziplining based on input. Character must be airborne to catch the
* zipline, regardless of input.
*/
UCLASS(Blueprintable, BlueprintType)
class UGMS_ZiplineStartTransition : public UBaseMovementModeTransition
{
GENERATED_UCLASS_BODY()
#if ENGINE_MINOR_VERSION >= 6
virtual FTransitionEvalResult Evaluate_Implementation(const FSimulationTickParams& Params) const override;
#else
virtual FTransitionEvalResult OnEvaluate(const FSimulationTickParams& Params) const override;
#endif
UPROPERTY(EditAnywhere, Category = "Ziplining")
FName ZipliningModeName = ExtendedModeNames::Ziplining;
UPROPERTY(EditAnywhere, Category = "Ziplining")
FGameplayTag ZipliningInputTag;
};
/**
* Transition that handles exiting ziplining based on input
*/
UCLASS(Blueprintable, BlueprintType)
class UGMS_ZiplineEndTransition : public UBaseMovementModeTransition
{
GENERATED_UCLASS_BODY()
#if ENGINE_MINOR_VERSION >= 6
virtual FTransitionEvalResult Evaluate_Implementation(const FSimulationTickParams& Params) const override;
virtual void Trigger_Implementation(const FSimulationTickParams& Params) override;
#else
virtual FTransitionEvalResult OnEvaluate(const FSimulationTickParams& Params) const override;
virtual void OnTrigger(const FSimulationTickParams& Params) override;
#endif
// Mode to enter when exiting the zipline
UPROPERTY(EditAnywhere, Category = "Ziplining")
FName AutoExitToMode = DefaultModeNames::Falling;
};

View File

@@ -0,0 +1,55 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Runtime/Launch/Resources/Version.h"
#include "MovementMode.h"
#include "GMS_ZipliningMode.generated.h"
namespace ExtendedModeNames
{
const FName Ziplining = TEXT("Ziplining");
}
// ZipliningMode: movement mode that traverses an actor implementing the IZipline interface
UCLASS(Blueprintable, BlueprintType)
class UGMS_ZipliningMode : public UBaseMovementMode
{
GENERATED_UCLASS_BODY()
#if ENGINE_MINOR_VERSION >=6
virtual void GenerateMove_Implementation(const FMoverTickStartData& StartState, const FMoverTimeStep& TimeStep, FProposedMove& OutProposedMove) const override;
virtual void SimulationTick_Implementation(const FSimulationTickParams& Params, FMoverTickEndData& OutputState) override;
#else
virtual void OnGenerateMove(const FMoverTickStartData& StartState, const FMoverTimeStep& TimeStep, FProposedMove& OutProposedMove) const override;
virtual void OnSimulationTick(const FSimulationTickParams& Params, FMoverTickEndData& OutputState) override;
#endif
// Maximum speed
UPROPERTY(EditAnywhere, Category = "Ziplining", meta = (ClampMin = "1", UIMin = "1", ForceUnits = "cm/s"))
float MaxSpeed = 1000.0f;
};
// Data block containing ziplining state info, used while ZipliningMode is active
USTRUCT()
struct FGMS_ZipliningState : public FMoverDataStructBase
{
GENERATED_USTRUCT_BODY()
TObjectPtr<AActor> ZiplineActor;
bool bIsMovingAtoB;
FGMS_ZipliningState()
: bIsMovingAtoB(true)
{
}
virtual FMoverDataStructBase* Clone() const override;
virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override;
virtual UScriptStruct* GetScriptStruct() const override { return StaticStruct(); }
virtual void ToString(FAnsiStringBuilderBase& Out) const override;
virtual bool ShouldReconcile(const FMoverDataStructBase& AuthorityState) const override;
virtual void Interpolate(const FMoverDataStructBase& From, const FMoverDataStructBase& To, float Pct) override;
};