Updated DialogueNPC to Add Ids for Dialogue Paths

This commit is contained in:
Philip W 2023-02-09 17:01:03 +00:00
parent d1fab9f9a1
commit 9bfb07fbba
2 changed files with 51 additions and 6 deletions

View File

@ -106,11 +106,34 @@ void UDialogueNPC::EndDialogue()
PlayerController->bShowMouseCursor = false;
}
TArray<FString> UDialogueNPC::AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput)
FDialoguePath UDialogueNPC::CreateRootDialoguePath()
{
if (TextInput.IsEmpty()) return DialogueArrayInput;
DialogueArrayInput.Add(TextInput.ToString());
return DialogueArrayInput;
return FDialoguePath();
}
FDialoguePath UDialogueNPC::CreateDialoguePath(FDialoguePath ParentDialoguePath)
{
return FDialoguePath("#" + FString::FromInt(DialoguePaths.Num()));
}
bool UDialogueNPC::GotoDialoguePath(FString PathId)
{
for each (FDialoguePath DialogPath in DialoguePaths)
{
if (DialogPath.Dialogue[0] == PathId)
{
CurrentDialoguePath = DialogPath.Dialogue;
return true;
}
}
return false;
}
FDialoguePath UDialogueNPC::AddDialogue(FText TextInput, FDialoguePath DialoguePath)
{
if (TextInput.IsEmpty()) return DialoguePath;
DialoguePath.Dialogue.Add(TextInput.ToString());
return DialoguePath;
}
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)

View File

@ -24,7 +24,17 @@ struct FDialoguePath
UPROPERTY()
TArray<FString> Dialogue;
explicit FDialoguePath(const TArray<FString> Dialogue)
FDialoguePath()
{
Dialogue.Add("#ROOT");
}
FDialoguePath(FString Id)
{
Dialogue.Add(Id);
}
explicit FDialoguePath(TArray<FString> Dialogue)
{
this->Dialogue = Dialogue;
}
@ -91,7 +101,19 @@ public:
void EndDialogue();
UFUNCTION(BlueprintPure)
TArray<FString> AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput);
FDialoguePath CreateRootDialoguePath();
UFUNCTION()
FDialoguePath CreateDialoguePath(FDialoguePath ParentDialoguePath);
UFUNCTION(BlueprintPure)
void CreateDialogueChoice(FDialoguePath PreviousDialoguePath);
UFUNCTION()
bool GotoDialoguePath(FString PathId);
UFUNCTION(BlueprintPure)
FDialoguePath AddDialogue(FText TextInput, FDialoguePath DialoguePath);
UFUNCTION(BlueprintCallable)
void GetFinalDialogue(TArray<FString> DialogueArray);