2021-06-17 08:58:34 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2021-06-22 04:50:11 -04:00
|
|
|
|
|
|
|
|
#include "Animation/AnimExecutionContext.h"
|
2021-06-17 08:58:34 -04:00
|
|
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
2021-06-21 07:54:03 -04:00
|
|
|
#include "Animation/AnimNodeReference.h"
|
2021-06-17 08:58:34 -04:00
|
|
|
#include "SequencePlayerLibrary.generated.h"
|
|
|
|
|
|
2021-06-21 07:54:03 -04:00
|
|
|
struct FAnimNode_SequencePlayer;
|
|
|
|
|
|
|
|
|
|
USTRUCT(BlueprintType)
|
|
|
|
|
struct FSequencePlayerReference : public FAnimNodeReference
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
typedef FAnimNode_SequencePlayer FInternalNodeType;
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-17 08:58:34 -04:00
|
|
|
// Exposes operations to be performed on a sequence player anim node
|
|
|
|
|
// Note: Experimental and subject to change!
|
|
|
|
|
UCLASS(Experimental)
|
|
|
|
|
class ANIMGRAPHRUNTIME_API USequencePlayerLibrary : public UBlueprintFunctionLibrary
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
2021-06-21 07:54:03 -04:00
|
|
|
public:
|
|
|
|
|
/** Get a sequence player context from an anim node context */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe, ExpandEnumAsExecs = "Result"))
|
2021-06-23 10:58:34 -04:00
|
|
|
static FSequencePlayerReference ConvertToSequencePlayer(const FAnimNodeReference& Node, EAnimNodeReferenceConversionResult& Result);
|
|
|
|
|
|
|
|
|
|
/** Get a sequence player context from an anim node context (pure) */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe, DisplayName = "Convert to Sequence Player"))
|
2021-06-23 10:58:34 -04:00
|
|
|
static void ConvertToSequencePlayerPure(const FAnimNodeReference& Node, FSequencePlayerReference& SequencePlayer, bool& Result)
|
|
|
|
|
{
|
|
|
|
|
EAnimNodeReferenceConversionResult ConversionResult;
|
|
|
|
|
SequencePlayer = ConvertToSequencePlayer(Node, ConversionResult);
|
|
|
|
|
Result = (ConversionResult == EAnimNodeReferenceConversionResult::Succeeded);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-17 08:58:34 -04:00
|
|
|
/** Set the current accumulated time of the sequence player */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-06-21 07:54:03 -04:00
|
|
|
static FSequencePlayerReference SetAccumulatedTime(const FSequencePlayerReference& SequencePlayer, float Time);
|
2021-06-17 08:58:34 -04:00
|
|
|
|
2022-02-28 10:29:40 -05:00
|
|
|
/**
|
|
|
|
|
* Set the start position of the sequence player.
|
|
|
|
|
* If this is called from On Become Relevant or On Initial Update then it should be accompanied by a call to
|
|
|
|
|
* SetAccumulatedTime to achieve the desired effect of resetting the play time of a sequence player.
|
|
|
|
|
*/
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-06-21 07:54:03 -04:00
|
|
|
static FSequencePlayerReference SetStartPosition(const FSequencePlayerReference& SequencePlayer, float StartPosition);
|
2021-06-17 08:58:34 -04:00
|
|
|
|
2021-06-22 04:50:11 -04:00
|
|
|
/** Set the play rate of the sequence player */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-06-21 07:54:03 -04:00
|
|
|
static FSequencePlayerReference SetPlayRate(const FSequencePlayerReference& SequencePlayer, float PlayRate);
|
2021-06-22 04:50:11 -04:00
|
|
|
|
|
|
|
|
/** Set the current sequence of the sequence player */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-06-22 04:50:11 -04:00
|
|
|
static FSequencePlayerReference SetSequence(const FSequencePlayerReference& SequencePlayer, UAnimSequenceBase* Sequence);
|
|
|
|
|
|
|
|
|
|
/** Set the current sequence of the sequence player with an inertial blend time */
|
2021-09-16 22:34:04 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-06-22 04:50:11 -04:00
|
|
|
static FSequencePlayerReference SetSequenceWithInertialBlending(const FAnimUpdateContext& UpdateContext, const FSequencePlayerReference& SequencePlayer, UAnimSequenceBase* Sequence, float BlendTime = 0.2f);
|
2022-02-04 08:48:06 -05:00
|
|
|
|
|
|
|
|
/** Get the current sequence of the sequence player - DEPRECATED, please use pure version */
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Sequence Player", meta = (BlueprintThreadSafe, DeprecatedFunction))
|
|
|
|
|
static FSequencePlayerReference GetSequence(const FSequencePlayerReference& SequencePlayer, UPARAM(Ref) UAnimSequenceBase*& SequenceBase);
|
2021-06-22 04:50:11 -04:00
|
|
|
|
2022-01-21 15:23:50 -05:00
|
|
|
/** Get the current sequence of the sequence player */
|
2022-02-04 08:48:06 -05:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe, DisplayName = "Get Sequence"))
|
|
|
|
|
static UAnimSequenceBase* GetSequencePure(const FSequencePlayerReference& SequencePlayer);
|
2022-01-21 15:23:50 -05:00
|
|
|
|
2021-09-16 22:34:04 -04:00
|
|
|
/** Gets the current accumulated time of the sequence player */
|
2022-02-04 08:48:06 -05:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-09-16 22:34:04 -04:00
|
|
|
static float GetAccumulatedTime(const FSequencePlayerReference& SequencePlayer);
|
|
|
|
|
|
|
|
|
|
/** Get the start position of the sequence player */
|
2022-02-04 08:48:06 -05:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-09-16 22:34:04 -04:00
|
|
|
static float GetStartPosition(const FSequencePlayerReference& SequencePlayer);
|
|
|
|
|
|
|
|
|
|
/** Get the play rate of the sequence player */
|
2022-02-04 08:48:06 -05:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-09-16 22:34:04 -04:00
|
|
|
static float GetPlayRate(const FSequencePlayerReference& SequencePlayer);
|
|
|
|
|
|
|
|
|
|
/** Get the looping state of the sequence player */
|
2022-02-04 08:48:06 -05:00
|
|
|
UFUNCTION(BlueprintPure, Category = "Sequence Player", meta = (BlueprintThreadSafe))
|
2021-09-16 22:34:04 -04:00
|
|
|
static bool GetLoopAnimation(const FSequencePlayerReference& SequencePlayer);
|
2021-06-17 08:58:34 -04:00
|
|
|
};
|