Different events for taking a hit and a hit from your attack landing

This commit is contained in:
Kevin Poretti 2024-02-10 00:55:08 -05:00
parent b66a93d108
commit 127d382b29
4 changed files with 40 additions and 9 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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