// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "Components/Button.h" #include "Components/TextBlock.h" #include "Components/Image.h" #include "../Quest/Quest.h" #include "DialogueNPC.generated.h" UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class UDialoguePath : public UObject { GENERATED_BODY() public: UPROPERTY(BlueprintReadWrite) TArray Dialogue; UPROPERTY(BlueprintReadWrite) TArray Choices; UPROPERTY() FText ChoiceText1; UPROPERTY() FText ChoiceText2; UPROPERTY() FText ChoiceText3; }; UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class THE_TWILIGHT_ABYSS_API UDialogueNPC : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UDialogueNPC(); UPROPERTY(EditAnywhere) FString NPCName; UPROPERTY(BlueprintReadWrite) UDialoguePath* RootDialoguePath; UPROPERTY() UDialoguePath* CurrentDialoguePath; TArray CurrentDialogueStringPath; UPROPERTY(EditAnywhere) UTexture2D* NPCPortrait; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced) TArray ItemsToGive; UPROPERTY(EditAnywhere) float TextAnimationSpeed = 0.05f; UPROPERTY(BlueprintReadOnly) bool bIsInDialogue = false; protected: // Called when the game starts virtual void BeginPlay() override; UPROPERTY() TSubclassOf DialogueWidget; private: UPROPERTY() UUserWidget* DialogueWidgetInstance; UPROPERTY() UTextBlock* NPCNameText; UPROPERTY() UTextBlock* DialogueText; UPROPERTY() UImage* NPCPortraitImage; UPROPERTY() UButton* Choice1Button; UPROPERTY() UButton* Choice2Button; UPROPERTY() UButton* Choice3Button; UPROPERTY() UTextBlock* Choice1Text; UPROPERTY() UTextBlock* Choice2Text; UPROPERTY() UTextBlock* Choice3Text; UPROPERTY() UTextBlock* NextArrow; UPROPERTY() UButton* NextButton; UPROPERTY() int DialogueIndex = 1; UPROPERTY() FString CurrentDialogue; UPROPERTY() FTimerHandle TextAnimationTimerHandle; UFUNCTION() void NextCharacter(); UPROPERTY() TMap Quests; UPROPERTY() TMap BlueprintFunctions; UPROPERTY() TMap ItemIndexes; UPROPERTY() TMap QuestFlags; UPROPERTY() bool bResetUserControls = true; void ResetDialogueUI(); public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; UFUNCTION(BlueprintCallable) void StartDialogue(); UFUNCTION(BlueprintCallable) void EndDialogue(); UFUNCTION(BlueprintCallable) void NextDialogue(); UFUNCTION(BlueprintCallable) UDialoguePath* CreateRootDialoguePath(bool ResetUserControls = true); UFUNCTION(BlueprintCallable) UDialoguePath* AddDialogue(UDialoguePath* DialoguePath, FText TextInput); UFUNCTION(BlueprintCallable) void AddChoices(UDialoguePath* ParentPath, FText ChoiceText1, FText ChoiceText2, FText ChoiceText3, UDialoguePath*& ChoicePath1, UDialoguePath*& ChoicePath2, UDialoguePath*& ChoicePath3); UFUNCTION(BlueprintCallable) UDialoguePath* AddQuest(UDialoguePath* DialoguePath, UQuest* Quest); UFUNCTION(BlueprintCallable) UDialoguePath* CallBlueprintFunction(UDialoguePath* DialoguePath, FString FunctionName); UFUNCTION(BlueprintCallable) UDialoguePath* AddItem(UDialoguePath* DialoguePath, int ItemIndex); UFUNCTION(BlueprintCallable) UDialoguePath* AddQuestFlag(UDialoguePath* DialoguePath, FString Flag); UFUNCTION() void Choice1(); UFUNCTION() void Choice2(); UFUNCTION() void Choice3(); };