안녕하세요. FGameplayTagCountContainer::Reset() 호출 후 태그 카운트가 의도와 다르게 구해지는 부분이 있어 문의드립니다.
<br/>
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_My_Test, "My.Test");
namespace
{
void TestTagCount()
{
FGameplayTag Tag = TAG_My_Test;
FGameplayTagCountContainer Container;
Container.UpdateTagCount(Tag, 1, EGameplayTagReplicationState::None);
UE_LOG(LogTemp, Log, TEXT("Tag Count: %d"), Container.GetExplicitTagCount(Tag)); // prints 1
// reset container and update tag once more
Container.Reset();
Container.UpdateTagCount(Tag, 1, EGameplayTagReplicationState::None);
UE_LOG(LogTemp, Log, TEXT("Tag Count: %d"), Container.GetExplicitTagCount(Tag)); // expected to print 1 but prints 2
}
}
위와 같은 코드를 추가하고 TestTagCount() 를 호출했을 때 두 번째 GetExplicitTagCount() 에서 1이 아닌 2가 구해지고 있는데요,
<br/>
void FGameplayTagCountContainer::Reset(bool bResetCallbacks)
{
GameplayTagCountMap.Reset();
if (bResetCallbacks)
{
GameplayTagEventMap.Reset();
OnAnyTagChangeDelegate.Clear();
}
}
inline int32 GetExplicitTagCount(const FGameplayTag& Tag) const
{
const int32 Idx = Items.Find(Tag);
if (Idx != INDEX_NONE)
{
return Items[Idx].Count;
}
return 0;
}
Reset() 에서 Items 은 초기화하지 않아 Reset() 을 해도 Items 의 카운트는 쌓이고 있어서
Items 를 이용하는 GetExplicitTagCount() 등의 로직에서는 의도하지 않은 카운트가 구해지는 것으로 보입니다.
<br/>
Reset() 이 Items 나 ExplicitTags 는 초기화 하지 않는 것이 의도된 동작이 맞을지,
그렇다면 FGameplayTagCountContainer 를 초기화하려면 어떤 방법을 쓰는게 설계 의도에 맞을지 안내해주시면 감사하겠습니다.
[Attachment Removed]