A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DlgEvent.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "DlgEventCustom.h"
6
7#include "DlgEvent.generated.h"
8
9class UDlgContext;
10
11UENUM(BlueprintType)
12enum class EDlgEventType : uint8
13{
14 // Calls OnDialogueEvent on the Participant
15 Event UMETA(DisplayName = "Event"),
16
17 // Calls ModifyIntValue on the Participant
18 ModifyInt UMETA(DisplayName = "Modify Dialogue Int Value"),
19
20 // Calls ModifyFloatValue on the Participant
21 ModifyFloat UMETA(DisplayName = "Modify Dialogue Float Value"),
22
23 // Calls ModifyBoolValue on the Participant
24 ModifyBool UMETA(DisplayName = "Modify Dialogue Bool Value"),
25
26 // Calls ModifyNameValue on the Participant
27 ModifyName UMETA(DisplayName = "Modify Dialogue Name Value"),
28
29 // Modifies the value from the Participant Int Variable
30 ModifyClassIntVariable UMETA(DisplayName = "Modify Class Int Variable"),
31
32 // Modifies the value from the Participant Float Variable
33 ModifyClassFloatVariable UMETA(DisplayName = "Modify Class Float Variable"),
34
35 // Modifies the value from the Participant Bool Variable
36 ModifyClassBoolVariable UMETA(DisplayName = "Modify Class Bool Variable"),
37
38 // Modifies the value from the Participant Name Variable
39 ModifyClassNameVariable UMETA(DisplayName = "Modify Class Name Variable"),
40
41 // User Defined Event, calls EnterEvent on the custom event object.
42 //
43 // 1. Create a new Blueprint derived from DlgEventCustom (or DlgEventCustomHideCategories)
44 // 2. Override EnterEvent
45 Custom UMETA(DisplayName = "Custom Event")
46};
47
48
49// Events are executed via calling IDlgDialogueParticipant methods on dialogue participants
50// They must be handled in game side, can be used to modify game state based on dialogue
51USTRUCT(BlueprintType)
52struct DLGSYSTEM_API FDlgEvent
53{
54 GENERATED_USTRUCT_BODY()
55
56public:
57 //
58 // ICppStructOps Interface
59 //
61 bool operator==(const FDlgEvent& Other) const
62 {
63 return ParticipantName == Other.ParticipantName &&
64 EventName == Other.EventName &&
65 IntValue == Other.IntValue &&
66 FMath::IsNearlyEqual(FloatValue, Other.FloatValue, KINDA_SMALL_NUMBER) &&
67 bDelta == Other.bDelta &&
68 bValue == Other.bValue &&
69 EventType == Other.EventType &&
70 CustomEvent == Other.CustomEvent;
71 }
72
73 //
74 // Own methods
75 //
76
77 // Executes the event
78 // Participant is expected to implement IDlgDialogueParticipant interface
79 void Call(UDlgContext& Context, const FString& ContextString, UObject* Participant) const;
80
81 FString GetCustomEventName() const
82 {
83 return CustomEvent ? CustomEvent->GetName() : TEXT("INVALID");
84 }
85
86 static FString EventTypeToString(EDlgEventType Type);
88 // Is this a Condition which has a Dialogue Value
89 // NOTE: without EDlgConditionType::EventCall, for that call HasParticipantInterfaceValue
90 static bool HasDialogueValue(EDlgEventType Type)
91 {
92 return Type == EDlgEventType::ModifyBool
96 }
97
98 // Same as HasDialogueValue but also Has the Event
99 static bool HasParticipantInterfaceValue(EDlgEventType Type)
100 {
101 return Type == EDlgEventType::Event || HasDialogueValue(Type);
102 }
103
104 // Is this a Condition which has a Class Variable
105 static bool HasClassVariable(EDlgEventType Type)
106 {
112
113protected:
114 bool ValidateIsParticipantValid(const UDlgContext& Context, const FString& ContextString, const UObject* Participant) const;
115
116 // Is the participant required?
117 bool MustHaveParticipant() const { return EventType != EDlgEventType::Custom; }
118
119public:
120 // Name of the participant (speaker) the event is called on.
121 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
122 FName ParticipantName;
124 // Type of the event, can be a simple event or a call to modify a bool/int/float variable
125 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
126 EDlgEventType EventType = EDlgEventType::Event;
127
128 // Name of the relevant variable or event
129 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
130 FName EventName;
131
132 // The value the participant gets
133 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
134 int32 IntValue = 0;
135
136 // The value the participant gets
137 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
138 float FloatValue = 0.f;
139
140 // The value the participant gets
141 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
142 FName NameValue;
143
144 // Weather to add the value to the existing one, or simply override it
145 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
146 bool bDelta = false;
147
148 // The value the participant gets
149 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
150 bool bValue = false;
151
152 // User Defined Event, calls EnterEvent on the custom event object.
153 //
154 // 1. Create a new Blueprint derived from DlgEventCustom (or DlgEventCustomHideCategories)
155 // 2. Override EnterEvent
156 UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, Category = "Dialogue|Event")
157 UDlgEventCustom* CustomEvent = nullptr;
158};
159
160template<>
161struct TStructOpsTypeTraits<FDlgEvent> : public TStructOpsTypeTraitsBase2<FDlgEvent>
162{
163 enum
165 WithIdenticalViaEquality = true
166 };
167};
EDlgEventType
UENUM(BlueprintType)
Definition DlgEvent.h:16
@ ModifyClassFloatVariable
UCLASS(BlueprintType)
Definition DlgContext.h:96
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
USTRUCT(BlueprintType)
Definition DlgEvent.h:59
static bool HasDialogueValue(EDlgEventType Type)
Definition DlgEvent.h:96
bool MustHaveParticipant() const
Definition DlgEvent.h:123
FName NameValue
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
Definition DlgEvent.h:172
FName EventName
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
Definition DlgEvent.h:148
FString GetCustomEventName() const
Definition DlgEvent.h:87
static bool HasClassVariable(EDlgEventType Type)
Definition DlgEvent.h:111
bool operator==(const FDlgEvent &Other) const
Definition DlgEvent.h:67
static bool HasParticipantInterfaceValue(EDlgEventType Type)
Definition DlgEvent.h:105
GENERATED_USTRUCT_BODY()
FName ParticipantName
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Event")
Definition DlgEvent.h:132