Detect if an input sequence is in the buffer and valid

This commit is contained in:
Kevin Poretti 2023-06-30 19:38:34 -04:00
parent a85a9a7005
commit 9f16901de6
2 changed files with 22 additions and 4 deletions

View File

@ -14,11 +14,30 @@ void UFFInputBufferComponent::AddInput(const FFFInputState& InputState)
bool UFFInputBufferComponent::CheckInputSequence(const FFFInputCondition& InputCondition) bool UFFInputBufferComponent::CheckInputSequence(const FFFInputCondition& InputCondition)
{ {
int CondIdx = InputCondition.Sequence.Num() - 1;
int FramesSinceValidInput = 0;
for(int InpIdx = 0; InpIdx < InputBuffer.Num(); InpIdx++) for(int InpIdx = 0; InpIdx < InputBuffer.Num(); InpIdx++)
{ {
// read input sequence int32 CurrCondition = InputCondition.Sequence[CondIdx].Buttons;
FFFInputState CurrInput = InputBuffer[InpIdx]; int32 ThisInput = InputBuffer[InpIdx].Buttons;
if(ThisInput & CurrCondition)
{
CondIdx--;
FramesSinceValidInput = 0;
} }
// All conditions were met
if(CondIdx == -1)
{
return true; return true;
}
FramesSinceValidInput++;
if(FramesSinceValidInput > InputCondition.Lenience)
{
return false;
}
}
return false;
} }

View File

@ -29,7 +29,6 @@ void AFFPlayerController::FixedTick(float OneFrame)
{ {
//UnacknowledgedInputs.Push(RawInput); //UnacknowledgedInputs.Push(RawInput);
InputBuffer->AddInput(ModifiedInput); InputBuffer->AddInput(ModifiedInput);
//SendInputsToRemote(); //SendInputsToRemote();
} }