A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DlgContext.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "DlgObject.h"
5#include "DlgDialogue.h"
6#include "Nodes/DlgNode.h"
7#include "DlgMemory.h"
8
9#include "DlgContext.generated.h"
10
12
13class USoundWave;
14class USoundBase;
15class UDialogueWave;
16class UTexture2D;
17class UDlgNodeData;
18class UDlgNode;
20
21// Used to store temporary state of edges
22// This represents a const version of an Edge
23USTRUCT(BlueprintType)
24struct DLGSYSTEM_API FDlgEdgeData
25{
26 GENERATED_USTRUCT_BODY()
27public:
28 FDlgEdgeData() {}
29 FDlgEdgeData(bool bInSatisfied, const FDlgEdge& InEdge) : bSatisfied(bInSatisfied), Edge(InEdge) {};
30
31 bool IsValid() const { return Edge.IsValid(); }
32 bool IsSatisfied() const { return bSatisfied; }
33 const FDlgEdge& GetEdge() const { return Edge; }
35 static const FDlgEdgeData& GetInvalidEdge()
36 {
37 static FDlgEdgeData DlgEdge{false, FDlgEdge::GetInvalidEdge()};
38 return DlgEdge;
39 }
40
41 // FDlgEdge& GetMutableEdge() { return *EdgePtr; }
42
43protected:
44 UPROPERTY(BlueprintReadOnly, Category = "Dialogue|Edge")
45 bool bSatisfied = false;
46
47 UPROPERTY(BlueprintReadOnly, Category = "Dialogue|Edge")
48 FDlgEdge Edge;
49};
50
52UENUM()
53enum class EDlgValidateStatus : uint8
54{
55 Valid = 0,
56
57 // Either the participant or dialogue is invalid
60
61 // Is an instance but does not implement the UDlgDialogueParticipant interface
63
64 // Is a blueprint class from the content browser and does not implement the UDlgDialogueParticipant interface
66
67 // The Participant does not exist in the Dialogue
68 // DialogueDoesNotContainParticipant
69};
70
80UCLASS(BlueprintType)
81class DLGSYSTEM_API UDlgContext : public UDlgObject
82{
83 GENERATED_BODY()
84public:
85
86 //
87 // UObject Interface
88 //
89
90 void PostInitProperties() override { Super::PostInitProperties(); }
91
92 UDlgContext(const FObjectInitializer& ObjectInitializer);
93
94 // Network support
95 bool IsSupportedForNetworking() const override { return true; };
96 void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
98 //
99 // Own methods
100 //
101
102 UFUNCTION()
103 void OnRep_SerializedParticipants();
104 void SerializeParticipants();
105
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);
119
126 UFUNCTION(BlueprintCallable, Category = "Dialogue|Control")
127 bool ChooseSpeechSequenceOptionFromReplicated(int32 OptionIndex);
128
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); }
132
137 UFUNCTION(BlueprintCallable, Category = "Dialogue|Control|All")
138 bool ChooseOptionBasedOnAllOptionIndex(int32 Index);
139
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(); }
143
148 UFUNCTION(BlueprintCallable, Category = "Dialogue|Control")
149 bool ReevaluateOptions();
150
151 UFUNCTION(BlueprintPure, Category = "Dialogue|Control")
152 bool HasDialogueEnded() const { return bDialogueEnded; }
153
154 //
155 // Use these functions if you don't care about unsatisfied player options:
156 //
157
158 // Gets the number of options with satisfied conditions (number of options)
159 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
160 int32 GetOptionsNum() const { return AvailableChildren.Num(); }
161
162 // Is the OptionIndex valid index for the satisfied conditions?
163 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
164 bool IsValidOptionIndex(int32 OptionIndex) const { return AvailableChildren.IsValidIndex(OptionIndex); }
165
166 // Gets the Text of the (satisfied) option with index OptionIndex
167 // NOTE: This is just a helper method, you could have called GetOption
168 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
169 const FText& GetOptionText(int32 OptionIndex) const;
170
171 // Gets the SpeakerState of the (satisfied) edge with index OptionIndex
172 // NOTE: This is just a helper method, you could have called GetOption
173 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
174 FName GetOptionSpeakerState(int32 OptionIndex) const;
175
176 // Gets the Enter Conditions of the (satisfied) edge with index OptionIndex
177 // NOTE: This is just a helper method, you could have called GetOption
178 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
179 const TArray<FDlgCondition>& GetOptionEnterConditions(int32 OptionIndex) const;
180
181 // Gets the edge representing a player option from the satisfied options
182 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
183 const FDlgEdge& GetOption(int32 OptionIndex) const;
184
185 // Gets all satisfied edges
186 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
187 const TArray<FDlgEdge>& GetOptionsArray() const { return AvailableChildren; }
188 TArray<FDlgEdge>& GetMutableOptionsArray() { return AvailableChildren; }
189
190 //
191 // Use these functions bellow if you don't care about unsatisfied player options:
192 // DO NOT missuse the indices above and bellow! The functions above expect < GetOptionsNum(), bellow < GetAllOptionsNum()
193 //
194
195 // Gets the number of options (both satisfied and unsatisfied ones are counted)
196 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
197 int32 GetAllOptionsNum() const { return AllChildren.Num(); }
198
199 // Is the Index valid index for both satisfied and unsatisfied conditions
200 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
201 bool IsValidAllOptionIndex(int32 Index) const { return AllChildren.IsValidIndex(Index); }
202
203 // Gets the Text of an option from the all list, which includes the unsatisfied ones as well
204 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
205 const FText& GetOptionTextFromAll(int32 Index) const;
206
207 // Is the option at Index satisfied? (Does it meet all the conditions)
208 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
209 bool IsOptionSatisfied(int32 Index) const;
211 // Gets the SpeakerState of the edge with index OptionIndex
212 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
213 FName GetOptionSpeakerStateFromAll(int32 Index) const;
214
215 // Gets the edge representing a player option from all options
216 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
217 const FDlgEdgeData& GetOptionFromAll(int32 Index) const;
218
219 // Gets all edges (both satisfied and unsatisfied)
220 UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
221 const TArray<FDlgEdgeData>& GetAllOptionsArray() const { return AllChildren; }
222 TArray<FDlgEdgeData>& GetAllMutableOptionsArray() { return AllChildren; }
223
234 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
235 bool IsOptionConnectedToVisitedNode(int32 Index, bool bLocalHistory = false, bool bIndexSkipsUnsatisfiedEdges = true) const;
236
246 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
247 bool IsOptionConnectedToEndNode(int32 Index, bool bIndexSkipsUnsatisfiedEdges = true) const;
250 //
251 // Active Node
252 //
253
254 // Gets the Text of the active node index
255 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
256 const FText& GetActiveNodeText() const;
257
258 // Gets the SpeakerState of the active node index
259 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
260 FName GetActiveNodeSpeakerState() const;
262 // Gets the Voice as a Sound Wave of the active node index
263 // This will get cast to USoundWave from a USoundBase
264 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
265 USoundWave* GetActiveNodeVoiceSoundWave() const;
266
267 // Same as GetActiveNodeVoiceSoundWave but this just returns the variable without casting it
268 // to a USoundWave
269 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
270 USoundBase* GetActiveNodeVoiceSoundBase() const;
271
272 // Gets the Voice as a Dialogue Wave of the active node index
273 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
274 UDialogueWave* GetActiveNodeVoiceDialogueWave() const;
275
276 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
277 UObject* GetActiveNodeGenericData() const;
278
279 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
280 UDlgNodeData* GetActiveNodeData() const;
281
282 // Gets the Icon associated with the active node participant name (owner name).
283 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
284 UTexture2D* GetActiveNodeParticipantIcon() const;
285
286 // Gets the Object associated with the active node participant name (owner name).
287 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
288 UObject* GetActiveNodeParticipant() const;
289
290 // Gets the active node participant name (owner name).
291 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
292 FName GetActiveNodeParticipantName() const;
293
294 // Gets the active participant display name
295 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
296 FText GetActiveNodeParticipantDisplayName() const;
297
298 UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Participant")
299 UObject* GetMutableParticipant(FName ParticipantName) const;
300 const UObject* GetParticipant(FName ParticipantName) const;
301
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; }
307
308 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
309 FGuid GetActiveNodeGUID() const { return GetNodeGUIDForIndex(ActiveNodeIndex); }
310
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); }
314
315 // Just a helper method for GetActiveNode that casts to UDlgNode_SpeechSequence
316 UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode", DisplayName = "Get Active Node As Speech Sequence")
317 UDlgNode_SpeechSequence* GetMutableActiveNodeAsSpeechSequence() const;
318 const UDlgNode_SpeechSequence* GetActiveNodeAsSpeechSequence() const;
319
320 //
321 // Data
322 //
323
324 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
325 bool IsValidNodeIndex(int32 NodeIndex) const;
326
327 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
328 bool IsValidNodeGUID(const FGuid& NodeGUID) const;
329
330 // Gets the GUID for the Node at NodeIndex
331 UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Node GUID For Index")
332 FGuid GetNodeGUIDForIndex(int32 NodeIndex) const;
333
334 // Gets the corresponding Node Index for the supplied NodeGUID
335 // Returns -1 (INDEX_NONE) if the Node GUID does not exist.
336 UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Node Index For GUID")
337 int32 GetNodeIndexForGUID(const FGuid& NodeGUID) const;
338
339 // Returns the indices which were visited inside this single context. For global data check DlgMemory
340 // NOTE: You should use GetVisitedNodeGUIDs
341 UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History")
342 const TSet<int32>& GetVisitedNodeIndices() const { return History.VisitedNodeIndices; }
343
344 // Returns the GUIDs which were visited inside this single context. For global data check DlgMemory
345 UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History")
346 const TSet<FGuid>& GetVisitedNodeGUIDs() const { return History.VisitedNodeGUIDs; }
347
348 // Helper methods to get some Dialogue properties
349 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
350 UDlgDialogue* GetDialogue() const { return Dialogue; }
351
352 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
353 FName GetDialogueName() const { check(Dialogue); return Dialogue->GetDialogueFName(); }
354
355 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
356 FGuid GetDialogueGUID() const { check(Dialogue); return Dialogue->GetGUID(); }
357
358 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
359 FString GetDialoguePathName() const { check(Dialogue); return Dialogue->GetPathName(); }
360
361 UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
362 const TMap<FName, UObject*>& GetParticipants() const { return Participants; }
363
364
365 // the Dialogue jumps to the defined node, or the function returns with false, if the conversation is over
366 // the Dialogue jumps to the defined node, or the function returns with false if the conversation is over
367 // Depending on the node the EnterNode() call can lead to other EnterNode() calls - having NodeIndex as active node after the call
368 // is not granted
369 // Conditions are not checked here - they are expected to be satisfied
370 bool EnterNode(int32 NodeIndex, TSet<const UDlgNode*> NodesEnteredWithThisStep);
371
372 // Adds the node as visited in the current dialogue memory
373 void SetNodeVisited(int32 NodeIndex, const FGuid& NodeGUID);
374
375 // Gets the Node at the NodeIndex index
376 UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Node From Index")
377 UDlgNode* GetMutableNodeFromIndex(int32 NodeIndex) const;
378 const UDlgNode* GetNodeFromIndex(int32 NodeIndex) const;
379
380 UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Node From GUID")
381 UDlgNode* GetMutableNodeFromGUID(const FGuid& NodeGUID) const;
382 const UDlgNode* GetNodeFromGUID(const FGuid& NodeGUID) const;
383
384 // Was the node Index visited in the lifetime of this context?
385 // NOTE: you should most likely use WasNodeGUIDVisitedInThisContext
386 UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History", DisplayName = "Was Node Index Visited In This Context")
387 bool WasNodeIndexVisitedInThisContext(int32 NodeIndex) const
388 {
389 return History.VisitedNodeIndices.Contains(NodeIndex);
390 }
391
392 // Was the node GUID visited in the lifetime of this context?
393 UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History", DisplayName = "Was Node GUID Visited In This Context")
394 bool WasNodeGUIDVisitedInThisContext(const FGuid& NodeGUID) const
395 {
396 return History.VisitedNodeGUIDs.Contains(NodeGUID);
397 }
398
399 // Gets the History of this context
400 const FDlgHistory& GetHistoryOfThisContext() const { return History; }
401
402 // Checks the enter conditions of the node.
403 // return false if they are not satisfied or if the index is invalid
404 bool IsNodeEnterable(int32 NodeIndex, TSet<const UDlgNode*> AlreadyVisitedNodes) const;
405
406 // Initializes/Starts the context, the first (start) node is selected and the first valid child node is entered.
407 // Called by the UDlgManager which creates the context
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);
410
411 //
412 // Initializes/Start the context using the given node as entry point
413 // This is useful to resume a dialogue
414 //
415
416 // Variant that works with only the NodeIndex
417 // NOTE: This is not safe, please use StartFromNodeGUID
418 bool StartFromNodeIndex(
419 UDlgDialogue* InDialogue,
420 const TMap<FName, UObject*>& InParticipants,
421 int32 StartNodeIndex,
422 const FDlgHistory& StartHistory,
423 bool bFireEnterEvents
424 )
425 {
426 return StartWithContextFromNodeIndex(
427 TEXT(""),
428 InDialogue,
429 InParticipants,
430 StartNodeIndex,
431 StartHistory,
432 bFireEnterEvents
433 );
434 }
435 bool StartWithContextFromNodeIndex(
436 const FString& ContextString,
437 UDlgDialogue* InDialogue,
438 const TMap<FName, UObject*>& InParticipants,
439 int32 StartNodeIndex,
440 const FDlgHistory& StartHistory,
441 bool bFireEnterEvents
443 {
444 const FString ContextMessage = ContextString.IsEmpty()
445 ? TEXT("StartFromNodeIndex")
446 : FString::Printf(TEXT("%s - StartFromNodeIndex"), *ContextString);
447
448 return StartWithContextFromNode(
449 ContextMessage,
450 InDialogue,
451 InParticipants,
452 StartNodeIndex,
453 FGuid{},
454 StartHistory,
455 bFireEnterEvents
456 );
457 }
458
459 // Variant that works with only the NodeGUID
460 bool StartFromNodeGUID(
461 UDlgDialogue* InDialogue,
462 const TMap<FName, UObject*>& InParticipants,
463 const FGuid& StartNodeGUID,
464 const FDlgHistory& StartHistory,
465 bool bFireEnterEvents
466 )
467 {
468 return StartWithContextFromNodeGUID(
469 TEXT(""),
470 InDialogue,
471 InParticipants,
472 StartNodeGUID,
473 StartHistory,
474 bFireEnterEvents
475 );
476 }
477 bool StartWithContextFromNodeGUID(
478 const FString& ContextString,
479 UDlgDialogue* InDialogue,
480 const TMap<FName, UObject*>& InParticipants,
481 const FGuid& StartNodeGUID,
482 const FDlgHistory& StartHistory,
483 bool bFireEnterEvents
484 )
485 {
486 const FString ContextMessage = ContextString.IsEmpty()
487 ? TEXT("StartFromNodeGUID")
488 : FString::Printf(TEXT("%s - StartFromNodeGUID"), *ContextString);
489
490 return StartWithContextFromNode(
491 ContextMessage,
492 InDialogue,
493 InParticipants,
494 INDEX_NONE,
495 StartNodeGUID,
496 StartHistory,
497 bFireEnterEvents
498 );
499 }
500
501 // Generic variant that accepts both NodeIndex and NodeGUID
502 // If NodeGUID is valid this will be used to get the correct Node
503 // Otherwise fallback to the NodeIndex
504 bool StartFromNode(
505 UDlgDialogue* InDialogue,
506 const TMap<FName, UObject*>& InParticipants,
507 int32 StartNodeIndex,
508 const FGuid& StartNodeGUID,
509 const FDlgHistory& StartHistory,
510 bool bFireEnterEvents
511 )
512 {
513 return StartWithContextFromNode(
514 TEXT(""),
515 InDialogue,
516 InParticipants,
517 StartNodeIndex,
518 StartNodeGUID,
519 StartHistory,
520 bFireEnterEvents
521 );
523 bool StartWithContextFromNode(
524 const FString& ContextString,
525 UDlgDialogue* InDialogue,
526 const TMap<FName, UObject*>& InParticipants,
527 int32 StartNodeIndex,
528 const FGuid& StartNodeGUID,
529 const FDlgHistory& StartHistory,
530 bool bFireEnterEvents
531 );
532
533 // Create a copy of the current Context
534 UDlgContext* CreateCopy() const;
535
536 // Checks if the context could be started, used to check if there is any reachable node from the start node
537 static bool CanBeStarted(UDlgDialogue* InDialogue, const TMap<FName, UObject*>& InParticipants);
538
539 UFUNCTION(BlueprintPure, Category = "Dialogue|Context")
540 FString GetContextString() const;
541
542 // Checks if the Participant object is a valid participant for starting the Dialogue
543 static EDlgValidateStatus IsValidParticipantForDialogue(const UDlgDialogue* Dialogue, const UObject* Participant);
544
545 // Same as IsValidParticipantForDialogue but this just returns a bool and logs to the output log if something is wrong
546 // If bLog = true then this act exactly as IsValidParticipantForDialogue
547 static bool ValidateParticipantForDialogue(
548 const FString& ContextString,
549 const UDlgDialogue* Dialogue,
550 const UObject* Participant,
551 bool bLog = true
552 );
553
554 // Same as ValidateParticipantForDialogue but works on a Map of Participants
555 static bool ValidateParticipantsMapForDialogue(
556 const FString& ContextString,
557 const UDlgDialogue* Dialogue,
558 const TMap<FName, UObject*>& ParticipantsMap,
559 bool bLog = true
560 );
561
562 // Just converts the array to a map, this does minimal checking just for the conversion to work
563 // NOTE: this outputs to log if an error occurs
564 static bool ConvertArrayOfParticipantsToMap(
565 const FString& ContextString,
566 const UDlgDialogue* Dialogue,
567 const TArray<UObject*>& ParticipantsArray,
568 TMap<FName, UObject*>& OutParticipantsMap,
569 bool bLog = true
570 );
571
572protected:
573 // bool StartInternal(UDlgDialogue* InDialogue, const TMap<FName, UObject*>& InParticipants, bool bLog, FString& OutErrorMessage);
574 void LogErrorWithContext(const FString& ErrorMessage) const;
575 FString GetErrorMessageWithContext(const FString& ErrorMessage) const;
576
577 void SetParticipants(const TMap<FName, UObject*>& InParticipants)
579 Participants = InParticipants;
580 SerializeParticipants();
581 }
582
583protected:
584 // Current Dialogue used in this context at runtime.
585 UPROPERTY(Replicated)
586 UDlgDialogue* Dialogue = nullptr;
587
588 // Helper array to serialize to Participants map for clients as well
589 UPROPERTY(Replicated, ReplicatedUsing = OnRep_SerializedParticipants)
590 TArray<UObject*> SerializedParticipants;
591
592 // All object is expected to implement the IDlgDialogueParticipant interface
593 // the key is the return value of IDlgDialogueParticipant::GetParticipantName()
594 UPROPERTY()
595 TMap<FName, UObject*> Participants;
596
597 // The index of the active node in the dialogues Nodes array
598 int32 ActiveNodeIndex = INDEX_NONE;
599
600 // Options of the active node with satisfied conditions - the options the player can choose from
601 TArray<FDlgEdge> AvailableChildren;
608 TArray<FDlgEdgeData> AllChildren;
609
610 // Node indices visited in this specific Dialogue instance (isn't serialized)
611 // History for this Context only
612 FDlgHistory History;
613
614 // cache the result of the last ChooseOption call
615 bool bDialogueEnded = false;
616
617public:
618 UPROPERTY(BlueprintAssignable, Category = "Events")
619 FOnNodeEntered OnNodeEntered;
620};
EDlgValidateStatus
UENUM()
Definition DlgContext.h:65
@ ParticipantIsABlueprintClassAndDoesNotImplementInterface
@ ParticipantDoesNotImplementInterface
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnNodeEntered)
UCLASS(BlueprintType)
Definition DlgContext.h:96
const TArray< FDlgEdge > & GetOptionsArray() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
Definition DlgContext.h:248
void SetParticipants(const TMap< FName, UObject * > &InParticipants)
Definition DlgContext.h:764
bool StartWithContextFromNodeIndex(const FString &ContextString, UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants, int32 StartNodeIndex, const FDlgHistory &StartHistory, bool bFireEnterEvents)
Definition DlgContext.h:619
const TMap< FName, UObject * > & GetParticipants() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:534
const TSet< FGuid > & GetVisitedNodeGUIDs() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History")
Definition DlgContext.h:503
bool WasNodeIndexVisitedInThisContext(int32 NodeIndex) const
UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History", DisplayName = "Was Node Index Visited...
Definition DlgContext.h:568
int32 GetOptionsNum() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
Definition DlgContext.h:203
const TMap< FName, UObject * > & GetParticipantsMap() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:430
const TSet< int32 > & GetVisitedNodeIndices() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History")
Definition DlgContext.h:496
TMap< FName, UObject * > Participants
UPROPERTY()
Definition DlgContext.h:790
TArray< UObject * > SerializedParticipants
UPROPERTY(Replicated, ReplicatedUsing = OnRep_SerializedParticipants)
Definition DlgContext.h:783
const FDlgHistory & GetHistoryOfThisContext() const
Definition DlgContext.h:584
int32 GetActiveNodeIndex() const
UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
Definition DlgContext.h:436
FOnNodeEntered OnNodeEntered
UPROPERTY(BlueprintAssignable, Category = "Events")
Definition DlgContext.h:817
const TArray< FDlgEdgeData > & GetAllOptionsArray() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
Definition DlgContext.h:303
TArray< FDlgEdge > & GetMutableOptionsArray()
Definition DlgContext.h:249
UDlgDialogue * GetDialogue() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:510
TArray< FDlgEdgeData > AllChildren
Definition DlgContext.h:803
bool StartFromNode(UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants, int32 StartNodeIndex, const FGuid &StartNodeGUID, const FDlgHistory &StartHistory, bool bFireEnterEvents)
Definition DlgContext.h:688
bool HasDialogueEnded() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Control")
Definition DlgContext.h:192
FGuid GetActiveNodeGUID() const
UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode")
Definition DlgContext.h:442
void PostInitProperties() override
Definition DlgContext.h:104
FGuid GetDialogueGUID() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:522
bool Start(UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants)
Definition DlgContext.h:592
bool IsSupportedForNetworking() const override
Definition DlgContext.h:109
int32 GetAllOptionsNum() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
Definition DlgContext.h:261
FString GetDialoguePathName() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:528
bool StartFromNodeGUID(UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants, const FGuid &StartNodeGUID, const FDlgHistory &StartHistory, bool bFireEnterEvents)
Definition DlgContext.h:644
bool IsValidOptionIndex(int32 OptionIndex) const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|Satisfied")
Definition DlgContext.h:210
const UDlgNode * GetActiveNode() const
Definition DlgContext.h:449
FDlgHistory History
Definition DlgContext.h:807
bool WasNodeGUIDVisitedInThisContext(const FGuid &NodeGUID) const
UFUNCTION(BlueprintPure, Category = "Dialogue|Context|History", DisplayName = "Was Node GUID Visited ...
Definition DlgContext.h:578
FName GetDialogueName() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data")
Definition DlgContext.h:516
UDlgNode * GetMutableActiveNode() const
UFUNCTION(BlueprintPure, Category = "Dialogue|ActiveNode", DisplayName = "Get Active Node")
Definition DlgContext.h:448
bool IsValidAllOptionIndex(int32 Index) const
UFUNCTION(BlueprintPure, Category = "Dialogue|Options|All")
Definition DlgContext.h:268
bool StartFromNodeIndex(UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants, int32 StartNodeIndex, const FDlgHistory &StartHistory, bool bFireEnterEvents)
Definition DlgContext.h:602
bool StartWithContextFromNodeGUID(const FString &ContextString, UDlgDialogue *InDialogue, const TMap< FName, UObject * > &InParticipants, const FGuid &StartNodeGUID, const FDlgHistory &StartHistory, bool bFireEnterEvents)
Definition DlgContext.h:661
TArray< FDlgEdgeData > & GetAllMutableOptionsArray()
Definition DlgContext.h:304
TArray< FDlgEdge > AvailableChildren
Definition DlgContext.h:796
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
Definition DlgDialogue.h:85
UCLASS(BlueprintType, ClassGroup = "Dialogue")
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
Definition DlgNodeData.h:18
UCLASS(BlueprintType, Abstract, EditInlineNew, ClassGroup = "Dialogue")
Definition DlgNode.h:40
UCLASS(Abstract, ClassGroup = "Dialogue", HideCategories = ("DoNotShow"), AutoExpandCategories = ("De...
Definition DlgObject.h:13
USTRUCT(Blueprintable)
USTRUCT(BlueprintType)
Definition DlgContext.h:28
static const FDlgEdgeData & GetInvalidEdge()
Definition DlgContext.h:38
GENERATED_USTRUCT_BODY()
bool IsSatisfied() const
Definition DlgContext.h:35
FDlgEdge Edge
UPROPERTY(BlueprintReadOnly, Category = "Dialogue|Edge")
Definition DlgContext.h:57
bool IsValid() const
Definition DlgContext.h:34
const FDlgEdge & GetEdge() const
Definition DlgContext.h:36
FDlgEdgeData(bool bInSatisfied, const FDlgEdge &InEdge)
Definition DlgContext.h:32
USTRUCT(BlueprintType)
Definition DlgEdge.h:25
static const FDlgEdge & GetInvalidEdge()
Definition DlgEdge.h:109
USTRUCT(BlueprintType)
Definition DlgMemory.h:13