95 bool IsSupportedForNetworking()
const override {
return true; };
96 void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps)
const override;
103 void OnRep_SerializedParticipants();
104 void SerializeParticipants();
106 UE_DEPRECATED(4.22, "ChooseChild has been deprecated in Favour of ChooseOption")
107 UFUNCTION(BlueprintCallable, Category = "
Dialogue|Control", meta = (DeprecatedFunction, DeprecationMessage = "ChooseChild has been deprecated in favour of ChooseOption"))
108 bool ChooseChild(int32 OptionIndex) {
return ChooseOption(OptionIndex); }
117 UFUNCTION(BlueprintCallable, Category =
"Dialogue|Control")
118 bool ChooseOption(int32 OptionIndex);
126 UFUNCTION(BlueprintCallable, Category = "
Dialogue|Control")
127 bool ChooseSpeechSequenceOptionFromReplicated(int32 OptionIndex);
129 UE_DEPRECATED(4.22, "ChooseChildBasedOnAllOptionIndex has been deprecated in Favour of ChooseOptionBasedOnAllOptionIndex")
130 UFUNCTION(BlueprintCallable, Category = "
Dialogue|Control|
All", meta = (DeprecatedFunction, DeprecationMessage = "ChooseChildBasedOnAllOptionIndex has been deprecated in Favour of ChooseOptionBasedOnAllOptionIndex"))
131 bool ChooseChildBasedOnAllOptionIndex(int32 Index) {
return ChooseOptionBasedOnAllOptionIndex(Index); }
137 UFUNCTION(BlueprintCallable, Category =
"Dialogue|Control|All")
138 bool ChooseOptionBasedOnAllOptionIndex(int32 Index);
140 UE_DEPRECATED(4.22, "ReevaluateChildren has been deprecated in Favour of ReevaluateOptions")
141 UFUNCTION(BlueprintCallable, Category = "
Dialogue|Control", meta = (DeprecatedFunction, DeprecationMessage = "ReevaluateChildren has been deprecated in Favour of ReevaluateOptions"))
142 bool ReevaluateChildren() {
return ReevaluateOptions(); }
148 UFUNCTION(BlueprintCallable, Category =
"Dialogue|Control")
149 bool ReevaluateOptions();
151 UFUNCTION(BlueprintPure, Category = "
Dialogue|Control")
152 bool HasDialogueEnded()
const {
return bDialogueEnded; }
159 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|Satisfied")
160 int32 GetOptionsNum()
const {
return AvailableChildren.Num(); }
163 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|Satisfied")
164 bool IsValidOptionIndex(int32 OptionIndex)
const {
return AvailableChildren.IsValidIndex(OptionIndex); }
168 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|Satisfied")
169 const
FText& GetOptionText(int32 OptionIndex) const;
173 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|Satisfied")
174 FName GetOptionSpeakerState(int32 OptionIndex) const;
178 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|Satisfied")
179 const TArray<
FDlgCondition>& GetOptionEnterConditions(int32 OptionIndex) const;
182 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|Satisfied")
183 const
FDlgEdge& GetOption(int32 OptionIndex) const;
186 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|Satisfied")
187 const TArray<
FDlgEdge>& GetOptionsArray()
const {
return AvailableChildren; }
188 TArray<FDlgEdge>& GetMutableOptionsArray() {
return AvailableChildren; }
196 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|All")
197 int32 GetAllOptionsNum()
const {
return AllChildren.Num(); }
200 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|All")
201 bool IsValidAllOptionIndex(int32 Index)
const {
return AllChildren.IsValidIndex(Index); }
204 UFUNCTION(BlueprintPure, Category =
"Dialogue|Options|All")
205 const
FText& GetOptionTextFromAll(int32 Index) const;
208 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|
All")
209 bool IsOptionSatisfied(int32 Index) const;
212 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|
All")
213 FName GetOptionSpeakerStateFromAll(int32 Index) const;
216 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|
All")
217 const
FDlgEdgeData& GetOptionFromAll(int32 Index) const;
220 UFUNCTION(BlueprintPure, Category = "
Dialogue|Options|
All")
221 const TArray<
FDlgEdgeData>& GetAllOptionsArray()
const {
return AllChildren; }
222 TArray<FDlgEdgeData>& GetAllMutableOptionsArray() {
return AllChildren; }
234 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
235 bool IsOptionConnectedToVisitedNode(int32 Index,
bool bLocalHistory = false,
bool bIndexSkipsUnsatisfiedEdges = true) const;
246 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data")
247 bool IsOptionConnectedToEndNode(int32 Index,
bool bIndexSkipsUnsatisfiedEdges = true) const;
255 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
256 const
FText& GetActiveNodeText() const;
259 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
260 FName GetActiveNodeSpeakerState() const;
264 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
265 USoundWave* GetActiveNodeVoiceSoundWave() const;
269 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
270 USoundBase* GetActiveNodeVoiceSoundBase() const;
273 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
274 UDialogueWave* GetActiveNodeVoiceDialogueWave() const;
276 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
277 UObject* GetActiveNodeGenericData() const;
279 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
283 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
284 UTexture2D* GetActiveNodeParticipantIcon() const;
287 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
288 UObject* GetActiveNodeParticipant() const;
291 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
292 FName GetActiveNodeParticipantName() const;
295 UFUNCTION(BlueprintPure, Category = "
Dialogue|ActiveNode")
296 FText GetActiveNodeParticipantDisplayName() const;
299 UObject* GetMutableParticipant(FName ParticipantName) const;
300 const
UObject* GetParticipant(FName ParticipantName) const;
302 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data")
303 const TMap<FName,
UObject*>& GetParticipantsMap()
const {
return Participants; }
305 UFUNCTION(BlueprintPure, Category =
"Dialogue|ActiveNode")
306 int32 GetActiveNodeIndex()
const {
return ActiveNodeIndex; }
308 UFUNCTION(BlueprintPure, Category =
"Dialogue|ActiveNode")
309 FGuid GetActiveNodeGUID()
const {
return GetNodeGUIDForIndex(ActiveNodeIndex); }
311 UFUNCTION(BlueprintPure, Category =
"Dialogue|ActiveNode",
DisplayName =
"Get Active Node")
312 UDlgNode* GetMutableActiveNode()
const {
return GetMutableNodeFromIndex(ActiveNodeIndex); }
313 const UDlgNode* GetActiveNode()
const {
return GetNodeFromIndex(ActiveNodeIndex); }
316 UFUNCTION(BlueprintPure, Category =
"Dialogue|ActiveNode",
DisplayName =
"Get Active Node As Speech Sequence")
324 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data")
325 bool IsValidNodeIndex(int32 NodeIndex) const;
327 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data")
328 bool IsValidNodeGUID(const FGuid& NodeGUID) const;
331 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data",
DisplayName = "Get Node GUID For Index")
332 FGuid GetNodeGUIDForIndex(int32 NodeIndex) const;
336 UFUNCTION(BlueprintPure, Category = "
Dialogue|Data",
DisplayName = "Get Node Index For GUID")
337 int32 GetNodeIndexForGUID(const FGuid& NodeGUID) const;
341 UFUNCTION(BlueprintPure, Category = "
Dialogue|Context|History")
342 const TSet<int32>& GetVisitedNodeIndices()
const {
return History.VisitedNodeIndices; }
345 UFUNCTION(BlueprintPure, Category =
"Dialogue|Context|History")
346 const TSet<FGuid>& GetVisitedNodeGUIDs()
const {
return History.VisitedNodeGUIDs; }
349 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
352 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
353 FName GetDialogueName()
const { check(
Dialogue);
return Dialogue->GetDialogueFName(); }
355 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
356 FGuid GetDialogueGUID()
const { check(
Dialogue);
return Dialogue->GetGUID(); }
358 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
359 FString GetDialoguePathName()
const { check(
Dialogue);
return Dialogue->GetPathName(); }
361 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data")
362 const TMap<FName,
UObject*>& GetParticipants()
const {
return Participants; }
370 bool EnterNode(int32 NodeIndex, TSet<const UDlgNode*> NodesEnteredWithThisStep);
373 void SetNodeVisited(int32 NodeIndex,
const FGuid& NodeGUID);
376 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data",
DisplayName =
"Get Node From Index")
377 UDlgNode* GetMutableNodeFromIndex(int32 NodeIndex) const;
378 const
UDlgNode* GetNodeFromIndex(int32 NodeIndex) const;
381 UDlgNode* GetMutableNodeFromGUID(const FGuid& NodeGUID) const;
382 const
UDlgNode* GetNodeFromGUID(const FGuid& NodeGUID) const;
386 UFUNCTION(BlueprintPure, Category = "
Dialogue|Context|History",
DisplayName = "Was Node Index Visited In This Context")
387 bool WasNodeIndexVisitedInThisContext(int32 NodeIndex)
const
389 return History.VisitedNodeIndices.Contains(NodeIndex);
393 UFUNCTION(BlueprintPure, Category =
"Dialogue|Context|History",
DisplayName =
"Was Node GUID Visited In This Context")
394 bool WasNodeGUIDVisitedInThisContext(const FGuid& NodeGUID)
const
396 return History.VisitedNodeGUIDs.Contains(NodeGUID);
400 const FDlgHistory& GetHistoryOfThisContext()
const {
return History; }
404 bool IsNodeEnterable(int32 NodeIndex, TSet<const UDlgNode*> AlreadyVisitedNodes)
const;
408 bool Start(
UDlgDialogue* InDialogue,
const TMap<FName, UObject*>& InParticipants) {
return StartWithContext(TEXT(
""), InDialogue, InParticipants); }
409 bool StartWithContext(
const FString& ContextString,
UDlgDialogue* InDialogue,
const TMap<FName, UObject*>& InParticipants);
418 bool StartFromNodeIndex(
420 const TMap<FName, UObject*>& InParticipants,
421 int32 StartNodeIndex,
423 bool bFireEnterEvents
426 return StartWithContextFromNodeIndex(
435 bool StartWithContextFromNodeIndex(
436 const FString& ContextString,
438 const TMap<FName, UObject*>& InParticipants,
439 int32 StartNodeIndex,
441 bool bFireEnterEvents
444 const FString ContextMessage = ContextString.IsEmpty()
445 ? TEXT(
"StartFromNodeIndex")
446 : FString::Printf(TEXT(
"%s - StartFromNodeIndex"), *ContextString);
448 return StartWithContextFromNode(
460 bool StartFromNodeGUID(
462 const TMap<FName, UObject*>& InParticipants,
463 const FGuid& StartNodeGUID,
465 bool bFireEnterEvents
468 return StartWithContextFromNodeGUID(
477 bool StartWithContextFromNodeGUID(
478 const FString& ContextString,
480 const TMap<FName, UObject*>& InParticipants,
481 const FGuid& StartNodeGUID,
483 bool bFireEnterEvents
486 const FString ContextMessage = ContextString.IsEmpty()
487 ? TEXT(
"StartFromNodeGUID")
488 : FString::Printf(TEXT(
"%s - StartFromNodeGUID"), *ContextString);
490 return StartWithContextFromNode(
506 const TMap<FName, UObject*>& InParticipants,
507 int32 StartNodeIndex,
508 const FGuid& StartNodeGUID,
510 bool bFireEnterEvents
513 return StartWithContextFromNode(
523 bool StartWithContextFromNode(
524 const FString& ContextString,
526 const TMap<FName, UObject*>& InParticipants,
527 int32 StartNodeIndex,
528 const FGuid& StartNodeGUID,
530 bool bFireEnterEvents
537 static bool CanBeStarted(
UDlgDialogue* InDialogue,
const TMap<FName, UObject*>& InParticipants);
539 UFUNCTION(BlueprintPure, Category =
"Dialogue|Context")
540 FString GetContextString() const;
547 static
bool ValidateParticipantForDialogue(
548 const FString& ContextString,
555 static
bool ValidateParticipantsMapForDialogue(
556 const FString& ContextString,
558 const TMap<FName,
UObject*>& ParticipantsMap,
564 static
bool ConvertArrayOfParticipantsToMap(
565 const FString& ContextString,
567 const TArray<
UObject*>& ParticipantsArray,
574 void LogErrorWithContext(const FString& ErrorMessage) const;
575 FString GetErrorMessageWithContext(const FString& ErrorMessage) const;
577 void SetParticipants(const TMap<FName,
UObject*>& InParticipants)
579 Participants = InParticipants;
580 SerializeParticipants();
585 UPROPERTY(Replicated)
589 UPROPERTY(Replicated, ReplicatedUsing = OnRep_SerializedParticipants)
590 TArray<UObject*> SerializedParticipants;
595 TMap<FName,
UObject*> Participants;
598 int32 ActiveNodeIndex = INDEX_NONE;
615 bool bDialogueEnded = false;
618 UPROPERTY(BlueprintAssignable, Category = "Events")
619 FOnNodeEntered OnNodeEntered;