Define whether most recent is disabled per state

This commit is contained in:
Kevin Poretti 2023-11-24 22:44:37 -05:00
parent d7920802cf
commit afc6781f5c
4 changed files with 21 additions and 13 deletions

View File

@ -36,6 +36,10 @@ bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSe
switch (RequiredButtonState) switch (RequiredButtonState)
{ {
// TODO: should it be (PrevInput & RequiredButtons) == RequiredButtons or what we have now? // TODO: should it be (PrevInput & RequiredButtons) == RequiredButtons or what we have now?
// TODO: If you have a sequence that is defined as something like button 1 pressed + button 2 pressed
// and the buttons are pressed on the same exact frame, then this implementation will not
// account for that. We should keep checking the sequences against the current frame's
// inputs until no sequences are detected, then continue on checking through the input buffer.
case EFFButtonState::BTNS_Pressed: case EFFButtonState::BTNS_Pressed:
if(!(PrevInput & RequiredButtons | PrevDisable) && if(!(PrevInput & RequiredButtons | PrevDisable) &&
CurrInput & RequiredButtons & ~CurrDisable) CurrInput & RequiredButtons & ~CurrDisable)

View File

@ -65,6 +65,15 @@ void UFFState::Enter(const FFFStateContext& InStateContext)
{ {
PlayMontage(InStateContext); PlayMontage(InStateContext);
if(bDisableMostRecentInputOnEntry)
{
IFFStateOwnerInterface* PC = Cast<IFFStateOwnerInterface>(InStateContext.Owner);
if(PC)
{
PC->DisableMostRecentInput();
}
}
OnEnter(InStateContext); OnEnter(InStateContext);
} }

View File

@ -112,6 +112,13 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
TArray<FFFInputSequence> InputSequences; TArray<FFFInputSequence> InputSequences;
/**
* Should the most recent input in the controlling player's input buffer be disabled when
* entering this state?
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
bool bDisableMostRecentInputOnEntry = true;
/** /**
* If true the state can transition from itself into itself without having to go through * If true the state can transition from itself into itself without having to go through
* another state like Idle * another state like Idle

View File

@ -103,18 +103,6 @@ void UFFStateMachineComponent::GoToState(UFFState* NewState, EFFStateFinishReaso
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(), StateFinishReason); CurrentState->Exit(GetCurrentStateContext(), StateFinishReason);
TicksInState = 0; TicksInState = 0;
OnLandedTick = 0; OnLandedTick = 0;