// 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 "DialogueNPC.generated.h" UENUM(BlueprintType) enum class EChoices : uint8 { Choice1 UMETA(DisplayName="Choice 1"), Choice2 UMETA(DisplayName="Choice 2"), Choice3 UMETA(DisplayName="Choice 3"), }; 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() TArray Dialogue; UPROPERTY(EditAnywhere) float TextAnimationSpeed = 0.05f; protected: // Called when the game starts virtual void BeginPlay() override; UPROPERTY() TSubclassOf DialogueWidget; private: UPROPERTY() UUserWidget* DialogueWidgetInstance; UPROPERTY() UTextBlock* NPCNameText; UPROPERTY() UTextBlock* DialogueText; UPROPERTY() UButton* NextButton; int DialogueIndex = 1; FString CurrentDialogue; UPROPERTY() FTimerHandle TextAnimationTimerHandle; UFUNCTION() void NextDialogue(); void NextCharacter(); public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; UFUNCTION(BlueprintCallable) void StartDialogue(); UFUNCTION(BlueprintCallable) void EndDialogue(); UFUNCTION(BlueprintPure) TArray AddDialogue(FText TextInput, TArray DialogueArrayInput); UFUNCTION(BlueprintCallable) void GetFinalDialogue(TArray DialogueArray); };