Implemented Side Bounties Awarding Favours

This commit is contained in:
Rafal Swierczek 2023-10-10 18:21:54 +01:00
parent fa679b06b4
commit 147dcaef6f
4 changed files with 17 additions and 16 deletions

View File

@ -67,7 +67,8 @@ void ABountyDirector::SpawnBountyAndItsSideBounties()
SideBountyActor->AttachToComponent(BountyAttachmentPoint, AttachmentTransformRules); SideBountyActor->AttachToComponent(BountyAttachmentPoint, AttachmentTransformRules);
ASideBountyClass* SideBounty = Cast<ASideBountyClass>(SideBountyActor); ASideBountyClass* SideBounty = Cast<ASideBountyClass>(SideBountyActor);
if (!IsValid(SideBounty)) UE_LOG(LogTemp, Fatal, TEXT("A SideBounty for %s has been set to a wrong type"), *ActiveBounty->GetBountyTitle()); if (!IsValid(SideBounty)) UE_LOG(LogTemp, Fatal, TEXT("A SideBounty for %s has been set to a wrong type"), *ActiveBounty->GetBountyTitle());
ActiveSideBounties.Add(SideBounty); int i = ActiveSideBounties.Add(SideBounty);
ActiveSideBounties[i]->CompletedSideBounty.AddDynamic(this, &ABountyDirector::EarnFavours);
// ONCE AGAIN WHEN MARCEL STOPS PLAYING WITH THE CHARACTER, ADD THIS SIDE BOUNTY TO PLAYERS ARRAY OF ACTIVE BOUNTIES!!!!! // ONCE AGAIN WHEN MARCEL STOPS PLAYING WITH THE CHARACTER, ADD THIS SIDE BOUNTY TO PLAYERS ARRAY OF ACTIVE BOUNTIES!!!!!
} }
} }
@ -119,5 +120,11 @@ void ABountyDirector::DestroyActiveSideBounties()
UpdateBountyDisplay(); UpdateBountyDisplay();
} }
void ABountyDirector::EarnFavours(int FavoursEarned)
{
UE_LOG(LogTemp, Warning, TEXT("Earned %d favours"), FavoursEarned);
}

View File

@ -52,6 +52,9 @@ protected:
UFUNCTION() UFUNCTION()
void DestroyActiveSideBounties(); void DestroyActiveSideBounties();
UFUNCTION()
void EarnFavours(int FavoursEarned);
public: public:
// Called every frame // Called every frame
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;

View File

@ -16,8 +16,7 @@ void ASideBountyClass::IncrementBountyCheckpoint()
if (Completed) if (Completed)
{ {
CompletedSideBounty.Broadcast(FavoursEarnedForCompletion);
CompletedSideBounty.Broadcast(ActiveSBC_Index);
} }
} }

View File

@ -6,30 +6,22 @@
#include "BountyClass.h" #include "BountyClass.h"
#include "SideBountyClass.generated.h" #include "SideBountyClass.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_Index); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, FavoursEarned);
UCLASS() UCLASS()
class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass
{ {
GENERATED_BODY() GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
TMap<int, TSubclassOf<ACheckpointClass>> ReplacementCheckpoints;
protected: protected:
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
int FavoursEarnedForCompletion = 1;
virtual void BeginPlay() override; virtual void BeginPlay() override;
public: public:
FCompletedSideBounty CompletedSideBounty; FCompletedSideBounty CompletedSideBounty;
int ActiveSBC_Index;
TMap<int, TSubclassOf<ACheckpointClass>> GetReplacementCheckpoints()
{
return ReplacementCheckpoints;
}
virtual void IncrementBountyCheckpoint() override; virtual void IncrementBountyCheckpoint() override;
void DestroyCheckpoints(); void DestroyCheckpoints();
}; };