Merge branch 'Quest-&-Dialogue-System' into dev

# Conflicts:
#	Content/Levels/Build.umap
This commit is contained in:
Philip W 2023-04-17 15:04:52 +01:00
commit 60fa3a720b
6 changed files with 80 additions and 10 deletions

Binary file not shown.

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Quest.h"
bool UQuest::CheckConditions(FJsonObject WorldState)
{
if (Conditions.Values.IsEmpty()) return true;
return false;
}
bool UQuest::CheckPreConditions(FJsonObject WorldState)
{
if (PreConditions.Values.IsEmpty()) return true;
return false;
}
void UQuest::ApplyRewards()
{
}

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "../PlayerTemp/TempCharacter.h"
#include "Quest.generated.h"
/**
*
*/
UCLASS()
class THE_TWILIGHT_ABYSS_API UQuest : public UObject
{
GENERATED_BODY()
public:
FText Title;
FText Description;
FString QuestLine;
UQuest* ParentQuest;
FJsonObject Conditions;
FJsonObject PreConditions;
//TODO: Rewards
bool CheckConditions(FJsonObject WorldState);
bool CheckPreConditions(FJsonObject WorldState);
void ApplyRewards();
//TODO: CreateQuest
};

View File

@ -32,3 +32,21 @@ void UQuestSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom
}
void UQuestSystem::CheckActiveQuestConditions()
{
for (UQuest* Quest : ActiveQuests)
{
if (Quest->CheckConditions(GetWorldState()))
{
CompletedQuests.Add(Quest);
Quest->ApplyRewards();
}
}
}
FJsonObject UQuestSystem::GetWorldState()
{
FJsonObject WorldState = FJsonObject();
return WorldState;
}

View File

@ -6,17 +6,9 @@
#include "Components/ActorComponent.h"
#include "Components/TextBlock.h"
#include "Blueprint/UserWidget.h"
#include "Quest.h"
#include "QuestSystem.generated.h"
// UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
// class UQuest : public UObject
// {
// GENERATED_BODY()
//
// public:
//
// };
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class THE_TWILIGHT_ABYSS_API UQuestSystem : public UActorComponent
{
@ -26,6 +18,11 @@ public:
// Sets default values for this component's properties
UQuestSystem();
TArray<UQuest*> ActiveQuests;
TArray<UQuest*> CompletedQuests;
TArray<FString> CompletedQuestLines;
TMap<FString, bool> QuestFlags;
protected:
// Called when the game starts
virtual void BeginPlay() override;
@ -33,7 +30,11 @@ protected:
UPROPERTY()
TSubclassOf<UUserWidget> QuestWidget;
FJsonObject WorldStateJsonTemplate;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void CheckActiveQuestConditions();
FJsonObject GetWorldState();
};

View File

@ -8,7 +8,7 @@ public class the_twilight_abyss : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule", "Json" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });