Fixed issues with correctly recognising whether a multi-press input should be locked, or whether it supercedes an active input.

This commit is contained in:
Jamie Greunbaum 2023-09-12 01:36:50 -04:00
parent d18e77082e
commit 3e71bb31ae
3 changed files with 10 additions and 14 deletions

View File

@ -75,12 +75,12 @@ void UInputBufferLocalPlayerSubsystem::ActivateComboInput(const UComboInputAsset
{
checkf(ComboInput, TEXT("Invalid %s."), *UComboInputAsset::StaticClass()->GetName());
const bool bNewInputLocked = this->LockedComboInputs.Contains(ComboInput);
const bool bNewSupercedesActive = (this->InputBufferActive && this->InputBufferActive->ContainsOneOf(ComboInput->ActionGroup) && !bNewInputLocked);
// Make this combo input active if it isn't being locked, or if we are
// overwriting a previous combo input with a multi-press combo input.
const bool bMultiPressTimerActive = this->GetWorld()->GetTimerManager().IsTimerActive(this->MultiPressTimerHandle);
const bool bActiveInputLocked = this->LockedComboInputs.Contains(this->InputBufferActive);
const bool bNewInputLocked = this->LockedComboInputs.Contains(ComboInput);
if ((bMultiPressTimerActive && !bActiveInputLocked) || !bNewInputLocked)
if (bNewSupercedesActive || !bNewInputLocked)
{
if (!ComboInput->LockedComboInputs.IsEmpty())
{
@ -88,11 +88,7 @@ void UInputBufferLocalPlayerSubsystem::ActivateComboInput(const UComboInputAsset
this->InputBufferActive = ComboInput;
this->LockedComboInputs = ComboInput->LockedComboInputs;
// Make sure the hold is clear if we're coming off of a multi-press action.
if (bMultiPressTimerActive)
{
this->InputBufferHold = nullptr;
}
UE_LOG(LogInputBufferLocalPlayerSubsystem, Verbose, TEXT("%s is active."), *ComboInput->ComboInputName.ToString());
}
@ -105,16 +101,16 @@ void UInputBufferLocalPlayerSubsystem::ActivateComboInput(const UComboInputAsset
}
else
{
this->HoldComboInput(ComboInput, bNewInputLocked);
this->HoldComboInput(ComboInput);
}
}
void UInputBufferLocalPlayerSubsystem::HoldComboInput(const UComboInputAsset *ComboInput, const bool &bLocked)
void UInputBufferLocalPlayerSubsystem::HoldComboInput(const UComboInputAsset *ComboInput)
{
this->InputBufferHold = ComboInput;
UE_SUPPRESS(LogInputBufferLocalPlayerSubsystem, Verbose,
{
if (bLocked)
if (this->LockedComboInputs.Contains(ComboInput))
{
UE_LOG(LogInputBufferLocalPlayerSubsystem, Verbose, TEXT("%s is locked and won't be activated yet."), *ComboInput->ComboInputName.ToString());
}

View File

@ -119,7 +119,7 @@ public:
// within a short time of one another. If only one is present, then
// this combo input asset will simply represent that action.
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TSet<TObjectPtr<const class UInputAction>> ActionGroup;
TSet<const class UInputAction*> ActionGroup;
// Combo inputs that should be prevented from occurring during this
// action. These will be locked when the action is broadcast, and

View File

@ -33,7 +33,7 @@ private:
void ExpireAction(const FInputActionValue &Value, const class UInputAction *Action);
void ActivateComboInput(const class UComboInputAsset *ComboInput);
void HoldComboInput(const class UComboInputAsset *ComboInput, const bool &bLocked);
void HoldComboInput(const class UComboInputAsset *ComboInput);
void ClearMultiPresses();
void ExpireBufferedActions();