4#include "CoreMinimal.h"
6#include "DlgMemory.generated.h"
11 GENERATED_USTRUCT_BODY()
15 void Add(int32 NodeIndex,
const FGuid& NodeGUID)
19 VisitedNodeIndices.
Add(NodeIndex);
21 if (NodeGUID.IsValid())
23 VisitedNodeGUIDs.Add(NodeGUID);
59 bool CanUseGUIDForSearch()
const
61 return VisitedNodeGUIDs.Num() >= VisitedNodeIndices.Num();
64 bool Contains(int32 NodeIndex,
const FGuid& NodeGUID)
const
67 if (CanUseGUIDForSearch() && NodeGUID.IsValid())
69 return VisitedNodeGUIDs.Contains(NodeGUID);
73 return VisitedNodeIndices.Contains(NodeIndex);
82 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Dialogue|History")
83 TSet<int32> VisitedNodeIndices;
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Dialogue|History")
88 TSet<FGuid> VisitedNodeGUIDs;
96 GENERATED_USTRUCT_BODY()
106 auto* Instance = GetInstance();
107 check(Instance !=
nullptr);
112 void Empty() { HistoryMap.Empty(); }
115 void SetEntry(
const FGuid& DialogueGUID,
const FDlgHistory& History)
119 if (OldEntry ==
nullptr)
121 HistoryMap.
Add(DialogueGUID, History);
130 FDlgHistory* GetEntry(
const FGuid& DialogueGUID) {
return HistoryMap.Find(DialogueGUID); }
132 void SetNodeVisited(
const FGuid& DialogueGUID, int32 NodeIndex,
const FGuid& NodeGUID)
135 FDlgHistory* History = HistoryMap.Find(DialogueGUID);
136 if (History ==
nullptr)
138 History = &HistoryMap.
Add(DialogueGUID);
141 History->
Add(NodeIndex, NodeGUID);
144 bool IsNodeVisited(
const FGuid& DialogueGUID, int32 NodeIndex,
const FGuid& NodeGUID)
const
147 const FDlgHistory* History = HistoryMap.Find(DialogueGUID);
148 if (History ==
nullptr)
153 return History->
Contains(NodeIndex, NodeGUID);
156 bool IsNodeIndexVisited(
const FGuid& DialogueGUID, int32 NodeIndex)
const
159 const FDlgHistory* History = HistoryMap.Find(DialogueGUID);
160 if (History ==
nullptr)
168 bool IsNodeGUIDVisited(
const FGuid& DialogueGUID,
const FGuid& NodeGUID)
const
171 const FDlgHistory* History = HistoryMap.Find(DialogueGUID);
172 if (History ==
nullptr)
180 const TMap<FGuid, FDlgHistory>& GetHistoryMaps()
const {
return HistoryMap; }
181 void SetHistoryMap(
const TMap<FGuid, FDlgHistory>& Map) { HistoryMap = Map; }
195 WithIdenticalViaEquality =
true
TSet< FGuid > VisitedNodeGUIDs
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|History")
void Add(int32 NodeIndex, const FGuid &NodeGUID)
bool Contains(int32 NodeIndex, const FGuid &NodeGUID) const
bool CanUseGUIDForSearch() const
TSet< int32 > VisitedNodeIndices
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|History")
const TMap< FGuid, FDlgHistory > & GetHistoryMaps() const
void SetEntry(const FGuid &DialogueGUID, const FDlgHistory &History)
static FDlgMemory * GetInstance()
TMap< FGuid, FDlgHistory > HistoryMap
UPROPERTY()
bool IsNodeVisited(const FGuid &DialogueGUID, int32 NodeIndex, const FGuid &NodeGUID) const
bool IsNodeIndexVisited(const FGuid &DialogueGUID, int32 NodeIndex) const
bool IsNodeGUIDVisited(const FGuid &DialogueGUID, const FGuid &NodeGUID) const
void SetNodeVisited(const FGuid &DialogueGUID, int32 NodeIndex, const FGuid &NodeGUID)
void SetHistoryMap(const TMap< FGuid, FDlgHistory > &Map)
static FDlgMemory & Get()
FDlgHistory * GetEntry(const FGuid &DialogueGUID)