Only disable most recent input if transition into state is successful
This commit is contained in:
parent
bd195c7ee8
commit
6c06611901
@ -59,9 +59,6 @@ bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSe
|
|||||||
// All conditions were met
|
// All conditions were met
|
||||||
if(CondIdx == -1)
|
if(CondIdx == -1)
|
||||||
{
|
{
|
||||||
// disable most recent input
|
|
||||||
InputBuffer[InputBuffer.Num() - 1].DisabledButtons |= InputBuffer[InputBuffer.Num() - 1].Buttons;
|
|
||||||
InputBuffer[InputBuffer.Num() - 2].DisabledButtons |= InputBuffer[InputBuffer.Num() - 2].Buttons;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,3 +71,9 @@ bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSe
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UFFInputBufferComponent::DisableMostRecentInput()
|
||||||
|
{
|
||||||
|
InputBuffer[InputBuffer.Num() - 1].DisabledButtons |= InputBuffer[InputBuffer.Num() - 1].Buttons;
|
||||||
|
InputBuffer[InputBuffer.Num() - 2].DisabledButtons |= InputBuffer[InputBuffer.Num() - 2].Buttons;
|
||||||
|
}
|
||||||
|
@ -94,6 +94,8 @@ public:
|
|||||||
|
|
||||||
bool CheckInputSequence(const FFFInputSequence& InputSequence);
|
bool CheckInputSequence(const FFFInputSequence& InputSequence);
|
||||||
|
|
||||||
|
void DisableMostRecentInput();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** The underlying buffer data structure for holding past input states */
|
/** The underlying buffer data structure for holding past input states */
|
||||||
TCircleBuffer<FFFInputState, 120> InputBuffer;
|
TCircleBuffer<FFFInputState, 120> InputBuffer;
|
||||||
|
@ -56,6 +56,11 @@ bool AFFPlayerController::CheckInputSequences(const TArray<FFFInputSequence>& In
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AFFPlayerController::DisableMostRecentInput()
|
||||||
|
{
|
||||||
|
InputBuffer->DisableMostRecentInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AFFPlayerController::SetupInputComponent()
|
void AFFPlayerController::SetupInputComponent()
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,8 @@ public:
|
|||||||
virtual bool CheckInputSequence(const FFFInputSequence& InInputSequence) override;
|
virtual bool CheckInputSequence(const FFFInputSequence& InInputSequence) override;
|
||||||
|
|
||||||
virtual bool CheckInputSequences(const TArray<FFFInputSequence>& InputSequences) override;
|
virtual bool CheckInputSequences(const TArray<FFFInputSequence>& InputSequences) override;
|
||||||
|
|
||||||
|
virtual void DisableMostRecentInput() override;
|
||||||
// End of IFFStateOwnerInterface
|
// End of IFFStateOwnerInterface
|
||||||
|
|
||||||
// APlayerController interface
|
// APlayerController interface
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
// FF includes
|
// FF includes
|
||||||
#include "FFState.h"
|
#include "FFState.h"
|
||||||
|
#include "Input/FFPlayerController.h"
|
||||||
|
|
||||||
#if !UE_BUILD_SHIPPING
|
#if !UE_BUILD_SHIPPING
|
||||||
static int32 StateMachineDebug = 0;
|
static int32 StateMachineDebug = 0;
|
||||||
@ -100,6 +101,18 @@ void UFFStateMachineComponent::GoToState(UFFState* NewState)
|
|||||||
check(CurrentState);
|
check(CurrentState);
|
||||||
check(NewState);
|
check(NewState);
|
||||||
|
|
||||||
|
// if state being transitioned into requires an input sequence we need to disable the most
|
||||||
|
// recent input in the player controller input buffer to prevent unwanted "double firing" of
|
||||||
|
// actions that have short durations but very lenient required input sequences
|
||||||
|
if(NewState->InputSequences.Num() > 0)
|
||||||
|
{
|
||||||
|
IFFStateOwnerInterface* PC = Cast<IFFStateOwnerInterface>(Owner);
|
||||||
|
if(PC)
|
||||||
|
{
|
||||||
|
PC->DisableMostRecentInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CurrentState->Exit(GetCurrentStateContext());
|
CurrentState->Exit(GetCurrentStateContext());
|
||||||
CurrentState = NewState;
|
CurrentState = NewState;
|
||||||
CurrentState->Enter(GetCurrentStateContext());
|
CurrentState->Enter(GetCurrentStateContext());
|
||||||
|
@ -24,4 +24,6 @@ public:
|
|||||||
virtual bool CheckInputSequence(const FFFInputSequence& InInputSequence) = 0;
|
virtual bool CheckInputSequence(const FFFInputSequence& InInputSequence) = 0;
|
||||||
|
|
||||||
virtual bool CheckInputSequences(const TArray<FFFInputSequence>& InInputSequences) = 0;
|
virtual bool CheckInputSequences(const TArray<FFFInputSequence>& InInputSequences) = 0;
|
||||||
|
|
||||||
|
virtual void DisableMostRecentInput() = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user