本文整理汇总了C++中FGameplayTag类的典型用法代码示例。如果您正苦于以下问题:C++ FGameplayTag类的具体用法?C++ FGameplayTag怎么用?C++ FGameplayTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FGameplayTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ABILITY_LOG
bool FMinimalReplicationTagCountMap::NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
const int32 CountBits = UAbilitySystemGlobals::Get().MinimalReplicationTagCountBits;
const int32 MaxCount = ((1 << CountBits)-1);
if (Ar.IsSaving())
{
int32 Count = TagMap.Num();
if (Count > MaxCount)
{
ABILITY_LOG(Error, TEXT("FMinimapReplicationTagCountMap has too many tags (%d). This will cause tags to not replicate. See FMinimapReplicationTagCountMap::NetSerialize"), TagMap.Num());
Count = MaxCount;
}
Ar.SerializeBits(&Count, CountBits);
for(auto& It : TagMap)
{
FGameplayTag& Tag = It.Key;
Tag.NetSerialize(Ar, Map, bOutSuccess);
if (--Count <= 0)
{
break;
}
}
}
else
{
int32 Count = TagMap.Num();
Ar.SerializeBits(&Count, CountBits);
// Reset our local map
for(auto& It : TagMap)
{
It.Value = 0;
}
// See what we have
while(Count-- > 0)
{
FGameplayTag Tag;
Tag.NetSerialize(Ar, Map, bOutSuccess);
TagMap.FindOrAdd(Tag) = 1;
}
if (Owner)
{
// Update our tags with owner tags
for(auto& It : TagMap)
{
Owner->SetTagMapCount(It.Key, It.Value);
}
}
}
bOutSuccess = true;
return true;
}
示例2: IsTagChecked
ECheckBoxState SGameplayTagWidget::IsTagChecked(TSharedPtr<FGameplayTagNode> Node) const
{
int32 NumValidAssets = 0;
int32 NumAssetsTagIsAppliedTo = 0;
if (Node.IsValid())
{
UGameplayTagsManager& TagsManager = IGameplayTagsModule::Get().GetGameplayTagsManager();
for (int32 ContainerIdx = 0; ContainerIdx < TagContainers.Num(); ++ContainerIdx)
{
FGameplayTagContainer* Container = TagContainers[ContainerIdx].TagContainer;
if (Container)
{
NumValidAssets++;
FGameplayTag Tag = TagsManager.RequestGameplayTag(Node->GetCompleteTag(), false);
if (Tag.IsValid())
{
if (Container->HasTag(Tag, EGameplayTagMatchType::Explicit, EGameplayTagMatchType::Explicit))
{
++NumAssetsTagIsAppliedTo;
}
}
}
}
}
if (NumAssetsTagIsAppliedTo == 0)
{
// Check if any children are tagged
for (auto It = Node->GetChildTagNodes().CreateConstIterator(); It; ++It)
{
if (IsTagChecked(*It) == ECheckBoxState::Checked)
{
return ECheckBoxState::Checked;
}
}
return ECheckBoxState::Unchecked;
}
else if (NumAssetsTagIsAppliedTo == NumValidAssets)
{
return ECheckBoxState::Checked;
}
else
{
return ECheckBoxState::Undetermined;
}
}
示例3: TranslateTag
void FGameplayCueTranslationManager::TranslateTag(FGameplayTag& Tag, AActor* TargetActor, const FGameplayCueParameters& Parameters)
{
if (FGameplayCueTranslatorNode* Node = GetTranslationNodeForTag(Tag))
{
TranslateTag_Internal(*Node, Tag, Tag.GetTagName(), TargetActor, Parameters);
}
}
示例4: Serialize
bool FGameplayTagContainer::Serialize(FArchive& Ar)
{
const bool bOldTagVer = Ar.UE4Ver() < VER_UE4_GAMEPLAY_TAG_CONTAINER_TAG_TYPE_CHANGE;
if (bOldTagVer)
{
Ar << Tags_DEPRECATED;
}
else
{
Ar << GameplayTags;
}
if (Ar.IsLoading())
{
UGameplayTagsManager& TagManager = IGameplayTagsModule::GetGameplayTagsManager();
// If loading old version, add old tags to the new gameplay tags array so they can be saved out with the new version
// This needs to happen
// NOTE: DeprecatedTagNamesNotFoundInTagMap should be removed along with the bOldTagVer when we remove backwards
// compatibility, and the signature of RedirectTagsForContainer (below) should be changed appropriately as well.
TSet<FName> DeprecatedTagNamesNotFoundInTagMap;
if (bOldTagVer)
{
for (auto It = Tags_DEPRECATED.CreateConstIterator(); It; ++It)
{
const bool bErrorIfNotFound = false;
FGameplayTag Tag = TagManager.RequestGameplayTag(*It, bErrorIfNotFound);
if (Tag.IsValid())
{
TagManager.AddLeafTagToContainer(*this, Tag);
}
else
{ // For tags not found in the current table, add them to a list to be checked when handling
// redirection (below).
DeprecatedTagNamesNotFoundInTagMap.Add(*It);
}
}
}
// Rename any tags that may have changed by the ini file. Redirects can happen regardless of version.
// Regardless of version, want loading to have a chance to handle redirects
TagManager.RedirectTagsForContainer(*this, DeprecatedTagNamesNotFoundInTagMap);
}
return true;
}
示例5: TEXT
void FFrontendFilter_GameplayTags::LoadSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString)
{
IGameplayTagsModule& GameplayTagModule = IGameplayTagsModule::Get();
TArray<FString> TagStrings;
GConfig->GetArray(*IniSection, *(SettingsString + TEXT(".Tags")), /*out*/ TagStrings, IniFilename);
TagContainer->RemoveAllTags();
for (const FString& TagString : TagStrings)
{
FGameplayTag NewTag = GameplayTagModule.RequestGameplayTag(*TagString, /*bErrorIfNotFound=*/ false);
if (NewTag.IsValid())
{
TagContainer->AddTag(NewTag);
}
}
}
示例6: SCOPE_CYCLE_COUNTER
void FGameplayTagContainer::AddTag(const FGameplayTag& TagToAdd)
{
SCOPE_CYCLE_COUNTER(STAT_FGameplayTagContainer_AddTag);
if (TagToAdd.IsValid())
{
// Don't want duplicate tags
GameplayTags.AddUnique(TagToAdd);
}
}
示例7: FunctionCategory
void UK2Node_GameplayCueEvent::GetMenuEntries(FGraphContextMenuBuilder& Context) const
{
Super::GetMenuEntries(Context);
if (!IsCompatibleWithGraph(Context.CurrentGraph))
{
return;
}
const FString FunctionCategory(TEXT("GameplayCue Event"));
IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
FGameplayTag RootTag = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTag(FName(TEXT("GameplayCue")));
FGameplayTagContainer CueTags = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTagChildren(RootTag);
// Add a root GameplayCue function as a default
CueTags.AddTag(RootTag);
// Fixme: need to check if this function is already defined so that it can be reimplemented
// -Checking MyBlueprint->GeneratedClass isn't enough since they may have added an event and not recompiled
// -FEdGraphSchemaAction_K2AddCustomEvent does not check names/always ensures a valid name
// -FEdGraphSchemaAction_K2AddEvent does check and recenters - but it looks at EventSignatureName/EventSignatureClass for equality and that
// won't work here.
//
// Probably need a new EdGraphSchemaAction to do this properly. For now this is ok since they will get a compile error if they do drop in
// two of the same GameplayCue even Nodes and it should be pretty clear that they can't do that.
for (auto It = CueTags.CreateConstIterator(); It; ++It)
{
FGameplayTag Tag = *It;
UK2Node_GameplayCueEvent* NodeTemplate = Context.CreateTemplateNode<UK2Node_GameplayCueEvent>();
NodeTemplate->CustomFunctionName = Tag.GetTagName();
const FString Category = FunctionCategory;
const FText MenuDesc = NodeTemplate->GetNodeTitle(ENodeTitleType::ListView);
const FString Tooltip = NodeTemplate->GetTooltipText().ToString();
const FString Keywords = NodeTemplate->GetKeywords();
TSharedPtr<FEdGraphSchemaAction_K2NewNode> NodeAction = FK2ActionMenuBuilder::AddNewNodeAction(Context, Category, MenuDesc, Tooltip, 0, Keywords);
NodeAction->NodeTemplate = NodeTemplate;
}
}
示例8: TEXT
void FGameplayTagCustomization::OnPropertyValueChanged()
{
TagName = TEXT("");
if (StructPropertyHandle.IsValid() && EditableContainers.Num() > 0)
{
TArray<void*> RawStructData;
StructPropertyHandle->AccessRawData(RawStructData);
if (RawStructData.Num() > 0)
{
FGameplayTag* Tag = (FGameplayTag*)(RawStructData[0]);
FGameplayTagContainer* Container = EditableContainers[0].TagContainer;
if (Tag && Container)
{
Container->RemoveAllTags();
Container->AddTag(*Tag);
TagName = Tag->ToString();
}
}
}
}
示例9: BuildEditableContainerList
void FGameplayTagCustomization::BuildEditableContainerList()
{
EditableContainers.Empty();
if(StructPropertyHandle.IsValid())
{
TArray<void*> RawStructData;
StructPropertyHandle->AccessRawData(RawStructData);
TArray<UObject*> OuterObjects;
StructPropertyHandle->GetOuterObjects(OuterObjects);
FGameplayTag* Tag = (FGameplayTag*)(RawStructData[0]);
if (Tag->IsValid())
{
TagName = Tag->ToString();
TagContainer->AddTag(*Tag);
}
EditableContainers.Add(SGameplayTagWidget::FEditableGameplayTagContainerDatum(OuterObjects[0], TagContainer.Get()));
}
}
示例10: BuildEditableContainerList
void FGameplayTagCustomization::BuildEditableContainerList()
{
EditableContainers.Empty();
if(StructPropertyHandle.IsValid() && StructPropertyHandle->GetProperty())
{
TArray<void*> RawStructData;
StructPropertyHandle->AccessRawData(RawStructData);
if (RawStructData.Num() > 0)
{
FGameplayTag* Tag = (FGameplayTag*)(RawStructData[0]);
if (Tag->IsValid())
{
TagName = Tag->ToString();
TagContainer->AddTag(*Tag);
}
}
EditableContainers.Add(SGameplayTagWidget::FEditableGameplayTagContainerDatum(nullptr, TagContainer.Get()));
}
}
示例11: HandleGameplayCue
void UGameplayCueManager::HandleGameplayCue(AActor* TargetActor, FGameplayTag GameplayCueTag, EGameplayCueEvent::Type EventType, const FGameplayCueParameters& Parameters)
{
if (DisableGameplayCues)
{
return;
}
if (GameplayCueRunOnDedicatedServer == 0 && IsDedicatedServerForGameplayCue())
{
return;
}
#if WITH_EDITOR
if (GIsEditor && TargetActor == nullptr && UGameplayCueManager::PreviewComponent)
{
TargetActor = Cast<AActor>(AActor::StaticClass()->GetDefaultObject());
}
#endif
if (TargetActor == nullptr)
{
ABILITY_LOG(Warning, TEXT("UGameplayCueManager::HandleGameplayCue called on null TargetActor. GameplayCueTag: %s."), *GameplayCueTag.ToString());
return;
}
IGameplayCueInterface* GameplayCueInterface = Cast<IGameplayCueInterface>(TargetActor);
bool bAcceptsCue = true;
if (GameplayCueInterface)
{
bAcceptsCue = GameplayCueInterface->ShouldAcceptGameplayCue(TargetActor, GameplayCueTag, EventType, Parameters);
}
if (DisplayGameplayCues)
{
FString DebugStr = FString::Printf(TEXT("%s - %s"), *GameplayCueTag.ToString(), *EGameplayCueEventToString(EventType) );
FColor DebugColor = FColor::Green;
DrawDebugString(TargetActor->GetWorld(), FVector(0.f, 0.f, 100.f), DebugStr, TargetActor, DebugColor, DisplayGameplayCueDuration);
}
CurrentWorld = TargetActor->GetWorld();
// Don't handle gameplay cues when world is tearing down
if (!GetWorld() || GetWorld()->bIsTearingDown)
{
return;
}
// Give the global set a chance
check(GlobalCueSet);
if (bAcceptsCue)
{
GlobalCueSet->HandleGameplayCue(TargetActor, GameplayCueTag, EventType, Parameters);
}
// Use the interface even if it's not in the map
if (GameplayCueInterface && bAcceptsCue)
{
GameplayCueInterface->HandleGameplayCue(TargetActor, GameplayCueTag, EventType, Parameters);
}
CurrentWorld = nullptr;
}
示例12: ABILITY_LOG
void UGameplayCueManager::BuildCuesToAddToGlobalSet(const TArray<FAssetData>& AssetDataList, FName TagPropertyName, bool bAsyncLoadAfterAdd, TArray<FGameplayCueReferencePair>& OutCuesToAdd, FOnGameplayCueNotifySetLoaded OnLoaded, FShouldLoadGCNotifyDelegate ShouldLoad)
{
IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
TArray<FStringAssetReference> AssetsToLoad;
AssetsToLoad.Reserve(AssetDataList.Num());
for (FAssetData Data: AssetDataList)
{
// If ShouldLoad delegate is bound and it returns false, don't load this one
if (ShouldLoad.IsBound() && (ShouldLoad.Execute(Data) == false))
{
continue;
}
const FString* FoundGameplayTag = Data.TagsAndValues.Find(TagPropertyName);
if (FoundGameplayTag && FoundGameplayTag->Equals(TEXT("None")) == false)
{
const FString* GeneratedClassTag = Data.TagsAndValues.Find(TEXT("GeneratedClass"));
if (GeneratedClassTag == nullptr)
{
ABILITY_LOG(Warning, TEXT("Unable to find GeneratedClass value for AssetData %s"), *Data.ObjectPath.ToString());
continue;
}
ABILITY_LOG(Log, TEXT("GameplayCueManager Found: %s / %s"), **FoundGameplayTag, **GeneratedClassTag);
FGameplayTag GameplayCueTag = GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTag(FName(**FoundGameplayTag), false);
if (GameplayCueTag.IsValid())
{
// Add a new NotifyData entry to our flat list for this one
FStringAssetReference StringRef;
StringRef.SetPath(FPackageName::ExportTextPathToObjectPath(*GeneratedClassTag));
OutCuesToAdd.Add(FGameplayCueReferencePair(GameplayCueTag, StringRef));
AssetsToLoad.Add(StringRef);
}
else
{
ABILITY_LOG(Warning, TEXT("Found GameplayCue tag %s in asset %s but there is no corresponding tag in the GameplayTagManager."), **FoundGameplayTag, *Data.PackageName.ToString());
}
}
}
if (bAsyncLoadAfterAdd)
{
auto ForwardLambda = [](TArray<FStringAssetReference> AssetList, FOnGameplayCueNotifySetLoaded OnLoadedDelegate)
{
OnLoadedDelegate.ExecuteIfBound(AssetList);
};
if (AssetsToLoad.Num() > 0)
{
StreamableManager.RequestAsyncLoad(AssetsToLoad, FStreamableDelegate::CreateStatic( ForwardLambda, AssetsToLoad, OnLoaded));
}
else
{
// Still fire the delegate even if nothing was found to load
OnLoaded.ExecuteIfBound(AssetsToLoad);
}
}
}
示例13: GetTranslationIndexForTag
FGameplayCueTranslatorNodeIndex FGameplayCueTranslationManager::GetTranslationIndexForTag(const FGameplayTag& Tag, bool CreateIfInvalid)
{
return GetTranslationIndexForName(Tag.GetTagName(), CreateIfInvalid);
}
示例14: UE_LOG
bool FGameplayCueTranslationManager::BuildTagTranslationTable_r(const FName& TagName, const TArray<FName>& SplitNames)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (CVarGameplyCueTranslatorDebugTag->GetString().IsEmpty() == false && TagName.ToString().Contains(CVarGameplyCueTranslatorDebugTag->GetString()))
{
//
UE_LOG(LogGameplayCueTranslator, Log, TEXT("....."));
}
#endif
bool HasValidRootTag = false;
TArray<FName> SwappedNames;
SwappedNames.Reserve(10);
// Every NameSwap Rule/Class that gave us data
for (FNameSwapData& NameSwapData : AllNameSwaps)
{
// Avoid rule recursion
{
if (FGameplayCueTranslatorNode* ChildNode = GetTranslationNodeForName(TagName, false))
{
if (ChildNode->UsedTranslators.Contains(NameSwapData.ClassCDO))
{
continue;
}
}
}
// Every Swap that this Rule/Class gave us
for (int32 SwapRuleIdx=0; SwapRuleIdx < NameSwapData.NameSwaps.Num(); ++SwapRuleIdx)
{
const FGameplayCueTranslationNameSwap& SwapRule = NameSwapData.NameSwaps[SwapRuleIdx];
#if WITH_EDITOR
if (SwapRule.EditorData.Enabled == false)
{
continue;
}
#endif
// Walk through the original tag's elements
for (int32 TagIdx=0; TagIdx < SplitNames.Num(); ++TagIdx)
{
// Walk through the potential new tag's elemnts
for (int32 ToNameIdx=0; ToNameIdx < SwapRule.ToNames.Num() && TagIdx < SplitNames.Num(); ++ToNameIdx)
{
// If they match
if (SwapRule.ToNames[ToNameIdx] == SplitNames[TagIdx])
{
// If we are at the end
if (ToNameIdx == SwapRule.ToNames.Num()-1)
{
// *Possible* tag translation found! This tag can be derived from out name swapping rules,
// but we don't know if there actually is a tag that matches the tag which it would be translated *from*
// Don't operator on SplitNames, since subsequent rules and name swaps use the same array
SwappedNames = SplitNames;
// Remove the "To Names" from the SwappedNames array, replace with the single "From Name"
// E.g, GC.{Steel.Master} -> GC.{Hero}
int32 NumRemoves = SwapRule.ToNames.Num(); // We are going to remove as many tags
int32 RemoveAtIdx = TagIdx - (SwapRule.ToNames.Num() - 1);
check(SwappedNames.IsValidIndex(RemoveAtIdx));
SwappedNames.RemoveAt(RemoveAtIdx, NumRemoves, false);
SwappedNames.Insert(SwapRule.FromName, RemoveAtIdx);
// Compose a string from the new name
FString ComposedString = SwappedNames[0].ToString();
for (int32 ComposeIdx=1; ComposeIdx < SwappedNames.Num(); ++ ComposeIdx)
{
ComposedString += FString::Printf(TEXT(".%s"), *SwappedNames[ComposeIdx].ToString());
}
UE_LOG(LogGameplayCueTranslator, Log, TEXT("Found possible expanded tag. Original Child Tag: %s. Possible Parent Tag: %s"), *TagName.ToString(), *ComposedString);
FName ComposedName = FName(*ComposedString);
// Look for this tag - is it an actual real tag? If not, continue on
{
FGameplayTag ComposedTag = TagManager->RequestGameplayTag(ComposedName, false);
if (ComposedTag.IsValid() == false)
{
UE_LOG(LogGameplayCueTranslator, Log, TEXT(" No tag match found, recursing..."));
FGameplayCueTranslatorNodeIndex ParentIdx = GetTranslationIndexForName( ComposedName, false );
if (ParentIdx.IsValid() == false)
{
ParentIdx = GetTranslationIndexForName( ComposedName, true );
check(ParentIdx.IsValid());
TranslationLUT[ParentIdx].UsedTranslators.Add( NameSwapData.ClassCDO );
HasValidRootTag |= BuildTagTranslationTable_r(ComposedName, SwappedNames);
}
}
else
{
HasValidRootTag = true;
}
//.........这里部分代码省略.........
示例15: MakeShareable
void UGameplayTagsManager::ConstructGameplayTagTree()
{
if (!GameplayRootTag.IsValid())
{
GameplayRootTag = MakeShareable(new FGameplayTagNode());
{
#if STATS
FString PerfMessage = FString::Printf(TEXT("UGameplayTagsManager::ConstructGameplayTagTree: Construct from data asset"));
SCOPE_LOG_TIME_IN_SECONDS(*PerfMessage, nullptr)
#endif
for (auto It(GameplayTagTables.CreateIterator()); It; It++)
{
if (*It)
{
PopulateTreeFromDataTable(*It);
}
}
}
if (ShouldImportTagsFromINI())
{
#if STATS
FString PerfMessage = FString::Printf(TEXT("UGameplayTagsManager::ConstructGameplayTagTree: ImportINI"));
SCOPE_LOG_TIME_IN_SECONDS(*PerfMessage, nullptr)
#endif
// Update path: Check for old tags in DefaultEngine.ini (we'll push them to the UGameplayTagSettings class).
TArray<FString> EngineConfigTags;
GConfig->GetArray(TEXT("/Script/GameplayTags.GameplayTagsSettings"), TEXT("GameplayTags"), EngineConfigTags, GEngineIni);
if (EngineConfigTags.Num() > 0)
{
UGameplayTagsSettings* MutableDefault = GetMutableDefault<UGameplayTagsSettings>();
if (MutableDefault->GameplayTags.Num() == 0)
{
MutableDefault->GameplayTags.Append(EngineConfigTags);
}
}
// Load any GameplayTagSettings from config (their default object)
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* Class = *ClassIt;
if (!Class->IsChildOf<UGameplayTagsSettings>() || Class->HasAnyClassFlags(CLASS_Abstract))
{
continue;
}
#if WITH_EDITOR
Class->GetDefaultObject<UGameplayTagsSettings>()->SortTags();
#endif
for (FString TagStr : Class->GetDefaultObject<UGameplayTagsSettings>()->GameplayTags)
{
FGameplayTagTableRow TableRow;
TableRow.Tag = TagStr;
AddTagTableRow(TableRow);
}
}
GameplayRootTag->GetChildTagNodes().Sort(FCompareFGameplayTagNodeByTag());
}
if (ShouldUseFastReplication())
{
#if STATS
FString PerfMessage = FString::Printf(TEXT("UGameplayTagsManager::ConstructGameplayTagTree: Reconstruct NetIndex"));
SCOPE_LOG_TIME_IN_SECONDS(*PerfMessage, nullptr)
#endif
ConstructNetIndex();
}
{
#if STATS
FString PerfMessage = FString::Printf(TEXT("UGameplayTagsManager::ConstructGameplayTagTree: GameplayTagTreeChangedEvent.Broadcast"));
SCOPE_LOG_TIME_IN_SECONDS(*PerfMessage, nullptr)
#endif
GameplayTagTreeChangedEvent.Broadcast();
}
// Update the TagRedirects map
TagRedirects.Empty();
FConfigSection* PackageRedirects = GConfig->GetSectionPrivate(TEXT("/Script/Engine.Engine"), false, true, GEngineIni);
for (FConfigSection::TIterator It(*PackageRedirects); It; ++It)
{
if (It.Key() == TEXT("GameplayTagRedirects"))
{
FName OldTagName = NAME_None;
FName NewTagName;
if (FParse::Value(*It.Value(), TEXT("OldTagName="), OldTagName))
{
if (FParse::Value(*It.Value(), TEXT("NewTagName="), NewTagName))
{
if (ensureMsgf(!TagRedirects.Contains(OldTagName), TEXT("Old tag %s is being redirected to more than one tag. Please remove all the redirections except for one."), *OldTagName.ToString()))
{
FGameplayTag OldTag = RequestGameplayTag(OldTagName, false); //< This only succeeds if OldTag is in the Table!
if (OldTag.IsValid())
{
UE_LOG(LogGameplayTags, Warning,
TEXT("Old tag (%s) which is being redirected still exists in the table! Generally you should "
//.........这里部分代码省略.........