2021-11-30 12:12:43 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
# include "CoreMinimal.h"
# include "Animation/AnimExecutionContext.h"
# include "Kismet/BlueprintFunctionLibrary.h"
# include "Animation/AnimNodeReference.h"
2022-02-09 20:29:20 -05:00
# include "Animation/AnimStateMachineTypes.h"
2021-11-30 12:12:43 -05:00
# include "AnimationStateMachineLibrary.generated.h"
2022-02-09 14:20:43 -05:00
struct FAnimNode_StateMachine ;
2021-11-30 12:12:43 -05:00
struct FAnimNode_StateResult ;
USTRUCT ( BlueprintType , DisplayName = " Animation State Reference " )
struct FAnimationStateResultReference : public FAnimNodeReference
{
GENERATED_BODY ( )
typedef FAnimNode_StateResult FInternalNodeType ;
} ;
2022-02-09 14:20:43 -05:00
USTRUCT ( BlueprintType , DisplayName = " Animation State Machine " )
struct FAnimationStateMachineReference : public FAnimNodeReference
{
GENERATED_BODY ( )
typedef FAnimNode_StateMachine FInternalNodeType ;
} ;
2021-11-30 12:12:43 -05:00
// Exposes operations to be performed on anim state machine node contexts
2023-06-17 18:14:12 -04:00
UCLASS ( Experimental , MinimalAPI )
class UAnimationStateMachineLibrary : public UBlueprintFunctionLibrary
2021-11-30 12:12:43 -05:00
{
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 " ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API void ConvertToAnimationStateResult ( const FAnimNodeReference & Node , FAnimationStateResultReference & AnimationState , EAnimNodeReferenceConversionResult & Result ) ;
2021-11-30 12:12:43 -05:00
/** 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 ;
2022-02-09 14:20:43 -05:00
ConvertToAnimationStateResult ( Node , AnimationState , ConversionResult ) ;
2021-11-30 12:12:43 -05:00
Result = ( ConversionResult = = EAnimNodeReferenceConversionResult : : Succeeded ) ;
}
2022-02-09 14:20:43 -05:00
/** 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 " ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API void ConvertToAnimationStateMachine ( const FAnimNodeReference & Node , FAnimationStateMachineReference & AnimationState , EAnimNodeReferenceConversionResult & Result ) ;
2022-02-09 14:20:43 -05:00
/** 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 ) ;
}
2021-11-30 12:12:43 -05:00
/** Returns whether the state the node belongs to is blending in */
UFUNCTION ( BlueprintPure , Category = " State Machine " , meta = ( BlueprintThreadSafe ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API bool IsStateBlendingIn ( const FAnimUpdateContext & UpdateContext , const FAnimationStateResultReference & Node ) ;
2021-11-30 12:12:43 -05:00
/** Returns whether the state the node belongs to is blending out */
UFUNCTION ( BlueprintPure , Category = " State Machine " , meta = ( BlueprintThreadSafe ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API bool IsStateBlendingOut ( const FAnimUpdateContext & UpdateContext , const FAnimationStateResultReference & Node ) ;
2022-02-09 14:20:43 -05:00
/** 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 " ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API void SetState ( const FAnimUpdateContext & UpdateContext , const FAnimationStateMachineReference & Node , FName TargetState , float Duration
2022-02-09 14:20:43 -05:00
, 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 ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API FName GetState ( const FAnimUpdateContext & UpdateContext , const FAnimationStateMachineReference & Node ) ;
2022-05-19 09:57:01 -04:00
/** Returns the remaining animation time of the state's most relevant asset player */
UFUNCTION ( BlueprintPure , Category = " State Machine " , meta = ( BlueprintThreadSafe ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API float GetRelevantAnimTimeRemaining ( const FAnimUpdateContext & UpdateContext , const FAnimationStateResultReference & Node ) ;
2022-05-19 09:57:01 -04:00
/** 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 ) )
2023-06-17 18:14:12 -04:00
static ANIMGRAPHRUNTIME_API float GetRelevantAnimTimeRemainingFraction ( const FAnimUpdateContext & UpdateContext , const FAnimationStateResultReference & Node ) ;
} ;