Locking inputs now happens without being tied to lists in combo input assets.

This commit is contained in:
Jamie Greunbaum 2023-09-21 16:02:27 -04:00
parent b1ef780086
commit 74411baaea
3 changed files with 13 additions and 18 deletions

View File

@ -84,19 +84,12 @@ void UInputBufferLocalPlayerSubsystem::ActivateComboInput(const UComboInputAsset
{
// Set the combo input as active.
this->InputBufferActive = ComboInput;
this->InputBufferHold = nullptr;
// If we have inputs to lock, prepare the buffer.
if (!ComboInput->LockedComboInputs.IsEmpty())
const UInputBufferSubsystemGlobalSettings *Settings = GetDefault<UInputBufferSubsystemGlobalSettings>();
for (const TSoftObjectPtr<const UComboInputAsset> &LockedAsset : Settings->ComboActions)
{
this->LockedComboInputs = ComboInput->LockedComboInputs;
this->InputBufferHold = nullptr;
UE_LOG(LogInputBufferLocalPlayerSubsystem, Verbose, TEXT("%s is active."), *ComboInput->ComboInputName.ToString());
}
else
{
UE_LOG(LogInputBufferLocalPlayerSubsystem, Verbose, TEXT("%s is active and won't lock inputs."), *ComboInput->ComboInputName.ToString());
this->LockComboInput(LockedAsset.Get());
}
this->OnNewComboInput.Execute(ComboInput, EComboActionTriggerEvent::Activated);
@ -107,6 +100,8 @@ void UInputBufferLocalPlayerSubsystem::ActivateComboInput(const UComboInputAsset
{
this->OnNewComboInput.Execute(ComboInput, EComboActionTriggerEvent::Released);
}
UE_LOG(LogInputBufferLocalPlayerSubsystem, Verbose, TEXT("%s is active."), *ComboInput->ComboInputName.ToString());
}
else
{
@ -131,6 +126,11 @@ void UInputBufferLocalPlayerSubsystem::HoldComboInput(const UComboInputAsset *Co
);
}
void UInputBufferLocalPlayerSubsystem::LockComboInput(const UComboInputAsset *Input)
{
this->LockedComboInputs.Emplace(Input);
}
void UInputBufferLocalPlayerSubsystem::UnlockComboInput(const UComboInputAsset *Unlocked)
{
// Remove the newly-unlocked asset from the locked combo inputs.

View File

@ -120,11 +120,4 @@ public:
// this combo input asset will simply represent that action.
UPROPERTY(BlueprintReadWrite, EditAnywhere)
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
// should be unlocked by the receiving actor by sending an unlock
// event.
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TSet<TObjectPtr<const class UComboInputAsset>> LockedComboInputs;
};

View File

@ -25,6 +25,8 @@ public:
void AttachComboManager(class UComboManagerComponent *ComboManager, class UEnhancedInputComponent *InputComponent);
UFUNCTION(BlueprintCallable)
void LockComboInput(const class UComboInputAsset *Input);
UFUNCTION(BlueprintCallable)
void UnlockComboInput(const class UComboInputAsset *Unlocked);