Detect if an input sequence is in the buffer and valid
This commit is contained in:
parent
a85a9a7005
commit
9f16901de6
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
FramesSinceValidInput++;
|
||||||
|
if(FramesSinceValidInput > InputCondition.Lenience)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ void AFFPlayerController::FixedTick(float OneFrame)
|
|||||||
{
|
{
|
||||||
//UnacknowledgedInputs.Push(RawInput);
|
//UnacknowledgedInputs.Push(RawInput);
|
||||||
InputBuffer->AddInput(ModifiedInput);
|
InputBuffer->AddInput(ModifiedInput);
|
||||||
|
|
||||||
//SendInputsToRemote();
|
//SendInputsToRemote();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user