-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
73cecb2
commit beba60f
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// OpenPF2 for UE Game Logic, Copyright 2023, Guy Elsmore-Paddock. All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not | ||
// distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#include "Libraries/PF2TagLibrary.h" | ||
|
||
FGameplayTag UPF2TagLibrary::FindChildTag(const FGameplayTagContainer& AllTags, | ||
const FGameplayTag& ParentTag, | ||
bool& bMatchFound) | ||
{ | ||
FGameplayTag Result; | ||
const FGameplayTagContainer AllChildren = AllTags.Filter(FGameplayTagContainer(ParentTag)); | ||
|
||
if (AllChildren.IsEmpty()) | ||
{ | ||
bMatchFound = false; | ||
} | ||
else | ||
{ | ||
Result = AllChildren.First(); | ||
bMatchFound = true; | ||
|
||
if (AllChildren.Num() > 1) | ||
{ | ||
UE_LOG( | ||
LogPf2Core, | ||
Warning, | ||
TEXT("More than one child tag ('%s') matched parent tag ('%s')."), | ||
*(AllChildren.ToStringSimple()), | ||
*(ParentTag.ToString()) | ||
); | ||
} | ||
} | ||
|
||
return Result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// OpenPF2 for UE Game Logic, Copyright 2023, Guy Elsmore-Paddock. All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not | ||
// distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// ReSharper disable CppUEBlueprintCallableFunctionUnused | ||
#pragma once | ||
|
||
#include <GameplayTagContainer.h> | ||
|
||
#include <Kismet/BlueprintFunctionLibrary.h> | ||
|
||
#include "PF2TagLibrary.generated.h" | ||
|
||
// ===================================================================================================================== | ||
// Forward Declarations (to minimize header dependencies) | ||
// ===================================================================================================================== | ||
|
||
// ===================================================================================================================== | ||
// Normal Declarations | ||
// ===================================================================================================================== | ||
/** | ||
* Function library for working with gameplay abilities in OpenPF2. | ||
*/ | ||
UCLASS() | ||
class OPENPF2CORE_API UPF2TagLibrary final : public UBlueprintFunctionLibrary | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
/** | ||
* Locates the tag within the specified tag container that is a child of another tag. | ||
* | ||
* If there are multiple tags in the container that are children or grandchildren of the given tag, only the first | ||
* one gets returned. | ||
* | ||
* @param [in] AllTags | ||
* The tags to search. | ||
* @param [in] ParentTag | ||
* The parent (or grandparent) tag of the desired tag. | ||
* @param [out] bMatchFound | ||
* Whether a tag was found that is a child of the specified tag. | ||
* | ||
* @return | ||
* Either the matching tag; or a gameplay tag that is not valid if there is no tag that matches. | ||
*/ | ||
UFUNCTION(BlueprintCallable, BlueprintPure, meta=(AutoCreateRefTerm="ParentTag"), Category="OpenPF2|Gameplay Tags") | ||
static FGameplayTag FindChildTag(const FGameplayTagContainer& AllTags, | ||
const FGameplayTag& ParentTag, | ||
bool& bMatchFound); | ||
}; |