Added some extra helper functions to UComboInputAsset, and cleaned up some others.

This commit is contained in:
Jamie Greunbaum 2023-09-10 20:27:10 -04:00
parent 2032b8d23b
commit 9809c36513

View File

@ -3,7 +3,9 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/DataAsset.h" #include "Engine/DataAsset.h"
#include "ComboInputAssets.generated.h" #include "ComboInputAssets.generated.h"
@ -72,11 +74,7 @@ public:
// action group. // action group.
bool MatchesInputAction(const class UInputAction* Action) const bool MatchesInputAction(const class UInputAction* Action) const
{ {
if (this->ActionGroup.Num() == 1 && this->ActionGroup.Contains(Action)) return (this->ActionGroup.Num() == 1 && this->ActionGroup.Contains(Action));
{
return true;
}
return false;
} }
// Checks if this combo input's action group contains all of the given actions, and no // Checks if this combo input's action group contains all of the given actions, and no
// others. // others.
@ -95,6 +93,23 @@ public:
} }
return false; return false;
} }
// Checks if this combo input's action group contains the given action.
bool ContainsAction(const class UInputAction* Action) const
{
return this->ActionGroup.Contains(Action);
}
// Checks if this combo input's action group contains any of the given actions.
bool ContainsOneOf(TSet<const class UInputAction*> Actions) const
{
for (const UInputAction *Action : Actions)
{
if (this->ActionGroup.Contains(Action))
{
return true;
}
}
return false;
}
// Human-readable name of this combo input. // Human-readable name of this combo input.
UPROPERTY(BlueprintReadWrite, EditAnywhere) UPROPERTY(BlueprintReadWrite, EditAnywhere)