Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/AnimationStateMachineLibrary.h
frederick lupien cde944102b Add GetRelevantAnimTimeRemaining & GetRelevantAnimTimeRemainingFraction to FAnimNode_StateMachine API
Add GetRelevantAnimTimeRemaining & GetRelevantAnimTimeRemainingFraction to AnimationStateMachineLibrary

[REVIEW] [at]Thomas.Sarkanen, [at]Aaron.Cox

#ROBOMERGE-OWNER: frederick.lupien
#ROBOMERGE-AUTHOR: frederick.lupien
#ROBOMERGE-SOURCE: CL 20278729 via CL 20278746 via CL 20278801 via CL 20278827
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 20279575 by frederick lupien in ue5-main branch]
2022-05-19 09:57:01 -04:00

91 lines
4.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimExecutionContext.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Animation/AnimNodeReference.h"
#include "Animation/AnimStateMachineTypes.h"
#include "AnimationStateMachineLibrary.generated.h"
struct FAnimNode_StateMachine;
struct FAnimNode_StateResult;
USTRUCT(BlueprintType, DisplayName = "Animation State Reference")
struct FAnimationStateResultReference : public FAnimNodeReference
{
GENERATED_BODY()
typedef FAnimNode_StateResult FInternalNodeType;
};
USTRUCT(BlueprintType, DisplayName = "Animation State Machine")
struct FAnimationStateMachineReference : public FAnimNodeReference
{
GENERATED_BODY()
typedef FAnimNode_StateMachine FInternalNodeType;
};
// Exposes operations to be performed on anim state machine node contexts
UCLASS(Experimental)
class ANIMGRAPHRUNTIME_API UAnimationStateMachineLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/** Get an anim state reference from an anim node reference */
UFUNCTION(BlueprintCallable, Category = "State Machine", meta=(BlueprintThreadSafe, DisplayName = "Convert to Animation State", ExpandEnumAsExecs = "Result"))
static void ConvertToAnimationStateResult(const FAnimNodeReference& Node, FAnimationStateResultReference& AnimationState, EAnimNodeReferenceConversionResult& Result);
/** Get an anim state reference from an anim node reference (pure) */
UFUNCTION(BlueprintPure, Category = "State Machine", meta=(BlueprintThreadSafe, DisplayName = "Convert to Animation State"))
static void ConvertToAnimationStateResultPure(const FAnimNodeReference& Node, FAnimationStateResultReference& AnimationState, bool& Result)
{
EAnimNodeReferenceConversionResult ConversionResult;
ConvertToAnimationStateResult(Node, AnimationState, ConversionResult);
Result = (ConversionResult == EAnimNodeReferenceConversionResult::Succeeded);
}
/** Get an anim state machine from an anim node reference */
UFUNCTION(BlueprintCallable, Category = "State Machine", meta=(BlueprintThreadSafe, DisplayName = "Convert to Animation State Machine", ExpandEnumAsExecs = "Result"))
static void ConvertToAnimationStateMachine(const FAnimNodeReference& Node, FAnimationStateMachineReference& AnimationState, EAnimNodeReferenceConversionResult& Result);
/** Get an anim state machine from an anim node reference (pure) */
UFUNCTION(BlueprintPure, Category = "State Machine", meta = (BlueprintThreadSafe, DisplayName = "Convert to Animation State Machine"))
static void ConvertToAnimationStateMachinePure(const FAnimNodeReference& Node, FAnimationStateMachineReference& AnimationState, bool& Result)
{
EAnimNodeReferenceConversionResult ConversionResult;
ConvertToAnimationStateMachine(Node, AnimationState, ConversionResult);
Result = (ConversionResult == EAnimNodeReferenceConversionResult::Succeeded);
}
/** Returns whether the state the node belongs to is blending in */
UFUNCTION(BlueprintPure, Category = "State Machine", meta=(BlueprintThreadSafe))
static bool IsStateBlendingIn(const FAnimUpdateContext& UpdateContext, const FAnimationStateResultReference& Node);
/** Returns whether the state the node belongs to is blending out */
UFUNCTION(BlueprintPure, Category = "State Machine", meta=(BlueprintThreadSafe))
static bool IsStateBlendingOut(const FAnimUpdateContext& UpdateContext, const FAnimationStateResultReference& Node);
/** Manually set the current state of the state machine
NOTE: Custom blend type is not supported */
UFUNCTION(BlueprintCallable, Category = "State Machine", meta=(BlueprintThreadSafe, AdvancedDisplay = "4"))
static void SetState(const FAnimUpdateContext& UpdateContext, const FAnimationStateMachineReference& Node, FName TargetState, float Duration
, TEnumAsByte<ETransitionLogicType::Type> BlendType, UBlendProfile* BlendProfile, EAlphaBlendOption AlphaBlendOption, UCurveFloat* CustomBlendCurve);
/** Returns the name of the current state of this state machine */
UFUNCTION(BlueprintPure, Category = "State Machine", meta=(BlueprintThreadSafe))
static FName GetState(const FAnimUpdateContext& UpdateContext, const FAnimationStateMachineReference& Node);
/** Returns the remaining animation time of the state's most relevant asset player */
UFUNCTION(BlueprintPure, Category = "State Machine", meta = (BlueprintThreadSafe))
static float GetRelevantAnimTimeRemaining(const FAnimUpdateContext& UpdateContext, const FAnimationStateResultReference& Node);
/** Returns the remaining animation time as a fraction of the duration for the state's most relevant asset player */
UFUNCTION(BlueprintPure, Category = "State Machine", meta = (BlueprintThreadSafe))
static float GetRelevantAnimTimeRemainingFraction(const FAnimUpdateContext& UpdateContext, const FAnimationStateResultReference& Node);
};