Space Plunder
Loading...
Searching...
No Matches
AQuestLocation Class Reference

#include <QuestLocation.h>

Inheritance diagram for AQuestLocation:

Public Member Functions

 AQuestLocation ()
 
void OnOverlapWithQuestActor (AActor *QuestActor)
 

Protected Member Functions

virtual void BeginPlay () override
 
void OnOverlapBegin (UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepHitResult)
 
void OnOverlapEnd (UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex)
 

Protected Attributes

TObjectPtr< class UQuestGoalComponent > QuestGoalComponent
 
TObjectPtr< USceneComponent > SceneComponent
 
TObjectPtr< class UBoxComponent > BoxComponent
 
bool bDebuggingMode = true
 
bool bPenalty = false
 
AActor * CurrentQuestPlayer = nullptr
 

Constructor & Destructor Documentation

◆ AQuestLocation()

AQuestLocation::AQuestLocation ( )
12{
13 PrimaryActorTick.bCanEverTick = false;
14 SceneComponent = CreateDefaultSubobject<USceneComponent>("Scene Component");
15 RootComponent = SceneComponent;
16 BoxComponent = CreateDefaultSubobject<UBoxComponent>("Box Component");
17 BoxComponent->SetupAttachment(SceneComponent);
18 BoxComponent->OnComponentBeginOverlap.AddUniqueDynamic(this, &AQuestLocation::OnOverlapBegin);
19 BoxComponent->OnComponentEndOverlap.AddUniqueDynamic(this, &AQuestLocation::OnOverlapEnd);
20
21 QuestGoalComponent = CreateDefaultSubobject<UQuestGoalComponent>("Quest Goal Component");
22}
TObjectPtr< class UBoxComponent > BoxComponent
Definition QuestLocation.h:35
void OnOverlapBegin(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepHitResult)
Definition QuestLocation.cpp:39
void OnOverlapEnd(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex)
Definition QuestLocation.cpp:101
TObjectPtr< USceneComponent > SceneComponent
Definition QuestLocation.h:33
TObjectPtr< class UQuestGoalComponent > QuestGoalComponent
Definition QuestLocation.h:31

Member Function Documentation

◆ BeginPlay()

void AQuestLocation::BeginPlay ( )
overrideprotectedvirtual
25{
26 Super::BeginPlay();
27 BoxComponent->OnComponentBeginOverlap.AddUniqueDynamic(this, &AQuestLocation::OnOverlapBegin);
28 BoxComponent->OnComponentEndOverlap.AddUniqueDynamic(this, &AQuestLocation::OnOverlapEnd);
30 {
31 if(BoxComponent != nullptr)
32 {
33 BoxComponent->SetVisibleFlag(true);
34 BoxComponent->SetHiddenInGame(false);
35 }
36 }
37}
bool bDebuggingMode
Definition QuestLocation.h:38

◆ OnOverlapBegin()

void AQuestLocation::OnOverlapBegin ( UPrimitiveComponent * OverlappedComponent,
AActor * OtherActor,
UPrimitiveComponent * OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult & SweepHitResult )
protected
41{
42 if(OtherActor == nullptr || OtherActor->GetInstigatorController() == nullptr || QuestGoalComponent == nullptr){return;}
43 if(HasAuthority())
44 {
45 if(CurrentQuestPlayer == OtherActor){return;}
46 const IQuestPlayer* QuestPlayer = UQuestBPLib::GetPlayerQuestComponent(OtherActor);
47 // const IQuestPlayer* QuestPlayer = Cast<IQuestPlayer>(OtherActor->GetInstigatorController());
48 if(QuestPlayer == nullptr){return;}
49 CurrentQuestPlayer = OtherActor;
50 OnOverlapWithQuestActor(OtherActor);
51 if(bPenalty)
52 {
53 QuestGoalComponent->ReportQuestObjectivePenaltyAmount(QuestGoalComponent->QuestItemData.ObjectiveAmount);
54 }
55 else
56 {
57 QuestGoalComponent->ReportQuestObjectiveAmount(QuestGoalComponent->QuestItemData.ObjectiveAmount);
58 }
59 UE_LOG(LogTemp, Warning, TEXT("Quest Overlay Location, AUTH"));
60 if(QuestGoalComponent->GetShouldAddQuest(OtherActor))
61 {
62 QuestGoalComponent->AddQuest(OtherActor);
63 //@TODO Check, Shouldn't remove the Quest, incase it's repeatable, but should report that it should be activated again once complete
64 // QuestGoalComponent->RemoveQuestID();
65
66
67 // if(QuestGoalComponent->QuestsToAdd.Num() > 1)
68 // {
69 // QuestPlayer->AddMultipleQuests(QuestGoalComponent->QuestsToAdd);
70 // }
71 // else
72 // {
73 // for(const auto QuestID : QuestGoalComponent->QuestToAdd)
74 // {
75 // bool bSuccess;
76 // FQuestInfo QuestToStart = UQuestBPLib::GetQuestInfo(this, QuestID, bSuccess);
77 // if(bSuccess == false){UE_LOG(LogQuestSystem, Warning, TEXT("AQuestLocation::OnOverlapBegin Quest Invalid %s"), *QuestID);continue;}
78 // QuestGoalComponent->RemoveQuestID(QuestID);
79 // QuestPlayer->AddQuest(QuestToStart, true);
80 // }
81 // }
82 }
83 }
84 // if(QuestGoalComponent->bQuestGoal)
85 // {
86 // for(const FQuestGoal& QuestGoal : QuestGoalComponent->QuestGoals)
87 // {
88 // QuestActor->AddObjectiveAmount(QuestGoal.ObjectiveID, QuestGoal.ObjectiveAmount);
89 // }
90 // }
91 // if(QuestGoalComponent->bQuestPenalty)
92 // {
93 // for(const FQuestGoal& QuestPenalty : QuestGoalComponent->QuestPenalties)
94 // {
95 // QuestActor->AddObjectivePenalty(QuestPenalty.ObjectiveID, QuestPenalty.ObjectiveAmount);
96 // }
97 // }
98
99}
bool bPenalty
Definition QuestLocation.h:41
AActor * CurrentQuestPlayer
Definition QuestLocation.h:45
void OnOverlapWithQuestActor(AActor *QuestActor)
Definition QuestPlayer.h:27
static IQuestPlayer * GetPlayerQuestComponent(const AActor *Actor)
Definition QuestBPLib.cpp:21

◆ OnOverlapEnd()

void AQuestLocation::OnOverlapEnd ( UPrimitiveComponent * OverlappedComponent,
AActor * OtherActor,
UPrimitiveComponent * OtherComp,
int32 OtherBodyIndex )
protected
103{
104 //@TODO Have Cooldown if it's a obejctive
105 if(OtherActor == nullptr || OtherActor->GetInstigatorController() == nullptr || QuestGoalComponent == nullptr){return;}
106 if(HasAuthority())
107 {
108 if(CurrentQuestPlayer == OtherActor)
109 {
110 CurrentQuestPlayer = nullptr;
111 }
112 }
113}

◆ OnOverlapWithQuestActor()

void AQuestLocation::OnOverlapWithQuestActor ( AActor * QuestActor)

Member Data Documentation

◆ bDebuggingMode

bool AQuestLocation::bDebuggingMode = true
protected

◆ BoxComponent

TObjectPtr<class UBoxComponent> AQuestLocation::BoxComponent
protected

◆ bPenalty

bool AQuestLocation::bPenalty = false
protected

◆ CurrentQuestPlayer

AActor* AQuestLocation::CurrentQuestPlayer = nullptr
protected

◆ QuestGoalComponent

TObjectPtr<class UQuestGoalComponent> AQuestLocation::QuestGoalComponent
protected

◆ SceneComponent

TObjectPtr<USceneComponent> AQuestLocation::SceneComponent
protected

The documentation for this class was generated from the following files: