forked from orfeasel/UE4-Cpp-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogSystemCharacter.h
125 lines (92 loc) · 3.86 KB
/
DialogSystemCharacter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Character.h"
#include "AICharacter.h"
#include "DialogUI.h"
#include "DialogSystemCharacter.generated.h"
UCLASS(config=Game)
class ADialogSystemCharacter : public ACharacter
{
GENERATED_BODY()
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;
private:
/*True if the player is currently talking with any pawn*/
bool bIsTalking;
/*True if the player is inside a valid range to start talking to a pawn*/
bool bIsInTalkRange;
/*Initiates or terminates a conversation*/
void ToggleTalking();
/*The pawn that the player is currently talking to*/
AAICharacter* AssociatedPawn;
/*A reference to our lines - retrieved from the associated pawn*/
UDataTable* AvailableLines;
/*Searches in the given row inside the specified table*/
FDialog* RetrieveDialog(UDataTable* TableToSearch, FName RowName);
public:
/*Generates the player lines*/
void GeneratePlayerLines(UDataTable& PlayerLines);
/*This array is essentially an Array of Excerpts from our dialogs!*/
UPROPERTY(BlueprintReadOnly)
TArray<FString> Questions;
/*Performs the actual talking - informs the associated pawn if necessary in order to answer
The subtitles array contain all the subtitles for this talk - it should be passed to our UI*/
UFUNCTION(BlueprintCallable, Category = DialogSystem)
void Talk(FString Excerpt, TArray<FSubtitle>& Subtitles);
/*Enables / disables our talk ability. The player can't talk if he's not in a valid range*/
void SetTalkRangeStatus(bool Status) { bIsInTalkRange = Status; }
/*Sets a new associated pawn*/
void SetAssociatedPawn(AAICharacter* Pawn) { AssociatedPawn = Pawn; }
/*Retrieves the UI reference*/
UDialogUI* GetUI() { return UI; }
protected:
/*The component responsible for playing our SFX*/
UPROPERTY(VisibleAnywhere)
UAudioComponent* AudioComp;
/*Opens or closes the conversation UI*/
UFUNCTION(BlueprintImplementableEvent, Category = DialogSystem)
void ToggleUI();
/*UI Reference*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UDialogUI* UI;
public:
ADialogSystemCharacter();
/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseTurnRate;
/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseLookUpRate;
protected:
/** Called for forwards/backward input */
void MoveForward(float Value);
/** Called for side to side input */
void MoveRight(float Value);
/**
* Called via input to turn at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void TurnAtRate(float Rate);
/**
* Called via input to turn look up/down at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void LookUpAtRate(float Rate);
/** Handler for when a touch input begins. */
void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location);
/** Handler for when a touch input stops. */
void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);
protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
// End of APawn interface
public:
/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};