From 9809c365134c835f8b96409d1c7f7f817abd0a44 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Sun, 10 Sep 2023 20:27:10 -0400 Subject: [PATCH] Added some extra helper functions to UComboInputAsset, and cleaned up some others. --- Source/ComboInput/Public/ComboInputAssets.h | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Source/ComboInput/Public/ComboInputAssets.h b/Source/ComboInput/Public/ComboInputAssets.h index 64ceddc..43be266 100644 --- a/Source/ComboInput/Public/ComboInputAssets.h +++ b/Source/ComboInput/Public/ComboInputAssets.h @@ -3,7 +3,9 @@ #pragma once #include "CoreMinimal.h" + #include "Engine/DataAsset.h" + #include "ComboInputAssets.generated.h" @@ -72,15 +74,11 @@ public: // action group. bool MatchesInputAction(const class UInputAction* Action) const { - if (this->ActionGroup.Num() == 1 && this->ActionGroup.Contains(Action)) - { - return true; - } - return false; + return (this->ActionGroup.Num() == 1 && this->ActionGroup.Contains(Action)); } // Checks if this combo input's action group contains all of the given actions, and no // others. - bool MatchesInputActions(TSet Actions) const + bool MatchesInputActions(TSet Actions) const { if (this->ActionGroup.Num() == Actions.Num()) { @@ -95,6 +93,23 @@ public: } 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 Actions) const + { + for (const UInputAction *Action : Actions) + { + if (this->ActionGroup.Contains(Action)) + { + return true; + } + } + return false; + } // Human-readable name of this combo input. UPROPERTY(BlueprintReadWrite, EditAnywhere)