I have tried using the following however this will not work, and result notfound even when the key is present.
FORCEINLINE uint32 GetTypeHash(const FGameplayTagContainer& TagContainer)
{
uint32 Hash = 0;
for (const FGameplayTag& Tag : TagContainer)
{
Hash = HashCombine(Hash, GetTypeHash(Tag));
}
return Hash;
}
I’ve added a wrapper around it and it works, but it is really stupid to have to do it.
// TODO: Remove
// https://forums.unrealengine.com/t/please-allow-fgameplaytagcontainer-as-key-in-tmap/1686489
USTRUCT(BlueprintType)
struct FGameplayTagContainerKeyableWrapper
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere)
FGameplayTagContainer Tags;
//UPROPERTY()
//FActiveGameplayEffectHandle Handle;
FGameplayTagContainerKeyableWrapper() {}
//// This allows implicit and explicit conversion from FGameplayAbilitySpecHandle to FHealerAbilitySpecHandle
FGameplayTagContainerKeyableWrapper(const FGameplayTagContainer& InTags)
: Tags(InTags)
{}
TArray<FGameplayTag>::TConstIterator begin() { return Tags.CreateConstIterator(); }
TArray<FGameplayTag>::TConstIterator end() { return TArray<FGameplayTag>::TConstIterator(Tags.GetGameplayTagArray(), Tags.Num()); }
TArray<FGameplayTag>::TConstIterator begin() const { return Tags.CreateConstIterator(); }
TArray<FGameplayTag>::TConstIterator end() const { return TArray<FGameplayTag>::TConstIterator(Tags.GetGameplayTagArray(), Tags.Num()); }
operator FGameplayTagContainer() const { return Tags; }
operator bool() const { return Tags.IsEmpty(); }
// Define the == operator so Unreal can compare two keys for equality.
bool operator==(const FGameplayTagContainerKeyableWrapper& Other) const
{
return COURAGE_OTHER_EQUALS(Other, Tags);
}
};
1 Like
Also it would be great if the FGameplayTagContainer sort tags automatically so that the key is deterministic.