From 127d382b297fd504d16b262222aa6640fa8c2241 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Sat, 10 Feb 2024 00:55:08 -0500 Subject: [PATCH] Different events for taking a hit and a hit from your attack landing --- Source/UnrealFightingFramework/State/FFState.cpp | 14 ++++++++++---- Source/UnrealFightingFramework/State/FFState.h | 14 ++++++++++---- .../State/FFStateMachineComponent.cpp | 10 ++++++++++ .../State/FFStateMachineComponent.h | 11 ++++++++++- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Source/UnrealFightingFramework/State/FFState.cpp b/Source/UnrealFightingFramework/State/FFState.cpp index b0ee349..e164bd2 100644 --- a/Source/UnrealFightingFramework/State/FFState.cpp +++ b/Source/UnrealFightingFramework/State/FFState.cpp @@ -143,15 +143,21 @@ void UFFState::MovementModeChanged(EMovementMode PrevMovementMode, uint8 Previou } -void UFFState::Hit(const FFFStateContext& InStateContext) +void UFFState::AttackHit(const FHitResult& HitResult, const FFFStateContext& InStateContext) { - OnHit(InStateContext); + OnAttackHit(HitResult, InStateContext); } -void UFFState::Block(const FFFStateContext& InStateContext) +void UFFState::HitTaken(const FFFStateContext& InStateContext) { - OnBlock(InStateContext); + OnHitTaken(InStateContext); +} + + +void UFFState::BlockTaken(const FFFStateContext& InStateContext) +{ + OnBlockTaken(InStateContext); } diff --git a/Source/UnrealFightingFramework/State/FFState.h b/Source/UnrealFightingFramework/State/FFState.h index 484d37a..2481d2e 100644 --- a/Source/UnrealFightingFramework/State/FFState.h +++ b/Source/UnrealFightingFramework/State/FFState.h @@ -207,15 +207,18 @@ public: virtual void MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode, EMovementMode NewMovementMode, uint8 NewCustomMode, const FFFStateContext& InStateContext); + // TODO: document + virtual void AttackHit(const FHitResult& HitResult, const FFFStateContext& InStateContext); + // TODO: document // TODO: call this callback when the avatar is hit // TODO: pass in hitdata struct as well - virtual void Hit(const FFFStateContext& InStateContext); + virtual void HitTaken(/*const FHitParams& HitParams,*/ const FFFStateContext& InStateContext); // TODO: document // TODO: call this callback when the avatar blocks a hit // TODO: pass in hitdata struct as well - virtual void Block(const FFFStateContext& InStateContext); + virtual void BlockTaken(const FFFStateContext& InStateContext); /** * Called when you want to exit from this state but no eligible transitions exist to other states, @@ -299,12 +302,15 @@ public: // TODO: document // TODO: pass in hitdata struct as well UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events") - void OnHit(const FFFStateContext& InStateContext); + void OnAttackHit(const FHitResult& Hit, const FFFStateContext& InStateContext); + UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events") + void OnHitTaken(/*const FHitParams,*/ const FFFStateContext& InStateContext); + // TODO: document // TODO: pass in hitdata struct as well UFUNCTION(BlueprintImplementableEvent, Category="UFF|State|Events") - void OnBlock(const FFFStateContext& InStateContext); + void OnBlockTaken(/*const FHitParams,*/ const FFFStateContext& InStateContext); // UObject interface virtual UWorld* GetWorld() const override; diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp index 6011e39..510b13e 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp @@ -174,6 +174,16 @@ void UFFStateMachineComponent::MovementModeChanged(EMovementMode PrevMovementMod NewMovementMode, NewCustomMode, GetCurrentStateContext()); } +void UFFStateMachineComponent::AttackHit(const FHitResult& HitResult) +{ + check(CurrentState) + CurrentState->AttackHit(HitResult, GetCurrentStateContext()); +} + +void UFFStateMachineComponent::TakeHit() +{ + CurrentState->HitTaken(GetCurrentStateContext()); +} void UFFStateMachineComponent::FixedTick(float OneFrame) { diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.h b/Source/UnrealFightingFramework/State/FFStateMachineComponent.h index e365498..65f9a5f 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.h +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.h @@ -132,16 +132,25 @@ public: void SetSubStateLabel(FName InSubStateLabel); /** - * + * TODO: document */ FFFStateContext GetCurrentStateContext(); // Events + // TODO: document virtual void Landed(const FHitResult& Hit); + // TODO: document virtual void MovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode, EMovementMode NewMovementMode, uint8 NewCustomMode); + // TODO: document + virtual void AttackHit(const FHitResult& HitResult); + + // TODO: document + // TODO: bring HitParams struct into FightingFramework + virtual void TakeHit(/* const FHitParams& HitParams*/); + FOnStateTransitionSignature OnStateTransition; // IFFSystemInterface interface