From 9f16901de68ba028127a87c4d2ba4421b8cc974e Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Fri, 30 Jun 2023 19:38:34 -0400 Subject: [PATCH] Detect if an input sequence is in the buffer and valid --- .../Input/FFInputBufferComponent.cpp | 25 ++++++++++++++++--- .../Input/FFPlayerController.cpp | 1 - 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp index a1f9b9c..f767b1d 100644 --- a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp +++ b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp @@ -14,11 +14,30 @@ void UFFInputBufferComponent::AddInput(const FFFInputState& InputState) bool UFFInputBufferComponent::CheckInputSequence(const FFFInputCondition& InputCondition) { + int CondIdx = InputCondition.Sequence.Num() - 1; + int FramesSinceValidInput = 0; for(int InpIdx = 0; InpIdx < InputBuffer.Num(); InpIdx++) { - // read input sequence - FFFInputState CurrInput = InputBuffer[InpIdx]; + int32 CurrCondition = InputCondition.Sequence[CondIdx].Buttons; + 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; } diff --git a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp index 57c5b7d..9d40713 100644 --- a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp +++ b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp @@ -29,7 +29,6 @@ void AFFPlayerController::FixedTick(float OneFrame) { //UnacknowledgedInputs.Push(RawInput); InputBuffer->AddInput(ModifiedInput); - //SendInputsToRemote(); }