diff --git a/Source/UnrealFightingFramework/State/FFState.cpp b/Source/UnrealFightingFramework/State/FFState.cpp index 962480f..3afcf08 100644 --- a/Source/UnrealFightingFramework/State/FFState.cpp +++ b/Source/UnrealFightingFramework/State/FFState.cpp @@ -63,15 +63,8 @@ bool UFFState::CanTransition(const FFFStateContext& InStateContext) void UFFState::Enter(const FFFStateContext& InStateContext) { - if(InStateContext.Avatar) - { - USkeletalMeshComponent* SMC = InStateContext.Avatar->GetComponentByClass(); - if(SMC && MontageToPlay) - { - SMC->GetAnimInstance()->Montage_Play(MontageToPlay); - } - } - + PlayMontage(InStateContext); + OnEnter(InStateContext); } @@ -180,6 +173,11 @@ void UFFState::RegisterInputHandler(const FFFInputSequence& InRequiredSequence, InputHandlers.Add(TempHandler); } +void UFFState::PlayMontage(const FFFStateContext& InStateContext) +{ + OnPlayMontage(InStateContext); +} + void UFFState::OnInit_Implementation(const FFFStateContext& InStateContext) { @@ -192,6 +190,19 @@ bool UFFState::OnCanTransition_Implementation(const FFFStateContext& InStateCont } +void UFFState::OnPlayMontage_Implementation(const FFFStateContext& InStateContext) +{ + if(InStateContext.Avatar) + { + USkeletalMeshComponent* SMC = InStateContext.Avatar->GetComponentByClass(); + if(SMC && MontageToPlay) + { + SMC->GetAnimInstance()->Montage_Play(MontageToPlay); + } + } +} + + UWorld* UFFState::GetWorld() const { UFFStateMachineComponent* SMC = Cast(GetOuter()); diff --git a/Source/UnrealFightingFramework/State/FFState.h b/Source/UnrealFightingFramework/State/FFState.h index 6fe99ce..693d4ae 100644 --- a/Source/UnrealFightingFramework/State/FFState.h +++ b/Source/UnrealFightingFramework/State/FFState.h @@ -228,6 +228,16 @@ public: UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events") void OnUpdate(float OneFrame, const FFFStateContext& InStateContext); + UFUNCTION(BlueprintCallable, Category="UFF|State|Animations") + void PlayMontage(const FFFStateContext& InStateContext); + + /** + * Blueprint hook for overriding the logic for when a anim montage plays at the start of a state + * @param InStateContext + */ + UFUNCTION(BlueprintNativeEvent, Category="UFF|State|Events") + void OnPlayMontage(const FFFStateContext& InStateContext); + // TODO: document UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events") void OnLanded(const FHitResult& Hit, const FFFStateContext& InStateContext);