AzureAbyss/Source/the_twilight_abyss/Quest/QuestSystem.h

93 lines
2.3 KiB
C
Raw Normal View History

2023-03-13 05:19:13 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
2023-03-13 18:11:42 +00:00
#include "Components/TextBlock.h"
#include "Blueprint/UserWidget.h"
2023-03-29 16:36:24 +00:00
#include "Quest.h"
#include "WorldState.h"
2023-05-02 04:42:48 +00:00
#include "../BaseItems/InventoryComponent.h"
2023-05-04 04:04:37 +00:00
#include "Components/Border.h"
#include "Components/RichTextBlock.h"
2023-03-13 05:19:13 +00:00
#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();
2023-05-02 04:42:48 +00:00
UPROPERTY(EditAnywhere, BlueprintReadOnly)
2023-03-29 16:36:24 +00:00
TArray<UQuest*> ActiveQuests;
2023-05-02 04:42:48 +00:00
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
2023-03-29 16:36:24 +00:00
TArray<UQuest*> CompletedQuests;
2023-05-02 04:42:48 +00:00
UPROPERTY(EditAnywhere)
2023-03-29 16:36:24 +00:00
TMap<FString, bool> QuestFlags;
2023-05-04 04:04:37 +00:00
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
bool bHasSubQuest = false;
UPROPERTY()
UUserWidget* QuestWidgetInstance;
2023-03-13 05:19:13 +00:00
protected:
// Called when the game starts
virtual void BeginPlay() override;
2023-03-13 18:11:42 +00:00
UPROPERTY()
TSubclassOf<UUserWidget> QuestWidget;
2023-05-04 04:04:37 +00:00
UPROPERTY()
TSubclassOf<UUserWidget> QuestCompletionWidget;
UPROPERTY()
UUserWidget* QuestCompletionWidgetInstance;
2023-03-13 18:11:42 +00:00
2023-03-29 16:36:24 +00:00
FJsonObject WorldStateJsonTemplate;
2023-03-13 05:19:13 +00:00
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
2023-03-29 16:36:24 +00:00
void CheckActiveQuestConditions();
2023-05-02 04:42:48 +00:00
UWorldState* GetWorldState() const;
UFUNCTION(BlueprintCallable)
bool AddQuest(UQuest* Quest);
2023-05-02 04:42:48 +00:00
UFUNCTION(BlueprintCallable)
void AddQuestFlag(FString FlagName, bool FlagValue);
UFUNCTION(BlueprintPure)
bool CheckPreConditions(UQuest* Quest) const;
UFUNCTION(BlueprintCallable)
bool HasActiveQuest(UQuest* Quest) const;
2023-05-04 05:31:59 +00:00
UFUNCTION(BlueprintCallable)
bool HasQuestFlag(FString FlagName) const;
2023-05-02 04:42:48 +00:00
private:
UPROPERTY()
2023-05-02 04:42:48 +00:00
UInventoryComponent* PlayerInventory;
2023-05-04 04:04:37 +00:00
// 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;
2023-03-13 05:19:13 +00:00
};