// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "Components/TextBlock.h" #include "Blueprint/UserWidget.h" #include "Quest.h" #include "WorldState.h" #include "../BaseItems/InventoryComponent.h" #include "Components/Border.h" #include "Components/RichTextBlock.h" #include "QuestSystem.generated.h" UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class THE_TWILIGHT_ABYSS_API UQuestSystem : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UQuestSystem(); UPROPERTY(EditAnywhere, BlueprintReadOnly) TArray ActiveQuests; UPROPERTY(VisibleAnywhere, BlueprintReadOnly) TArray CompletedQuests; UPROPERTY(EditAnywhere) TMap QuestFlags; UPROPERTY(VisibleAnywhere, BlueprintReadOnly) bool bHasSubQuest = false; UPROPERTY() UUserWidget* QuestWidgetInstance; protected: // Called when the game starts virtual void BeginPlay() override; UPROPERTY() TSubclassOf QuestWidget; UPROPERTY() TSubclassOf QuestCompletionWidget; UPROPERTY() UUserWidget* QuestCompletionWidgetInstance; FJsonObject WorldStateJsonTemplate; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; void CheckActiveQuestConditions(); UWorldState* GetWorldState() const; UFUNCTION(BlueprintCallable) bool AddQuest(UQuest* Quest); UFUNCTION(BlueprintCallable) void AddQuestFlag(FString FlagName, bool FlagValue); UFUNCTION(BlueprintPure) bool CheckPreConditions(UQuest* Quest) const; UFUNCTION(BlueprintCallable) bool HasActiveQuest(UQuest* Quest) const; UFUNCTION(BlueprintCallable) bool HasQuestFlag(FString FlagName) const; private: UPROPERTY() UInventoryComponent* PlayerInventory; // Quest Widget UPROPERTY() UBorder* MainQuestBorder; UPROPERTY() UBorder* SubQuestBorder; UPROPERTY() UTextBlock* MainQuestTitle; UPROPERTY() UTextBlock* SubQuestTitle; UPROPERTY() URichTextBlock* MainQuestGoals; UPROPERTY() URichTextBlock* SubQuestGoals; // Quest Completion Widget UPROPERTY() UTextBlock* QuestCompletionTitle; void UpdateQuestGoalsUI(const UQuest* Quest) const; };