From 147dcaef6f98a631321a399d5cefccf58c9dcb04 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Tue, 10 Oct 2023 18:21:54 +0100 Subject: [PATCH] Implemented Side Bounties Awarding Favours --- .../BountySystem/BountyDirector.cpp | 9 ++++++++- .../BountySystem/BountyDirector.h | 3 +++ .../BountySystem/SideBountyClass.cpp | 3 +-- .../BountySystem/SideBountyClass.h | 18 +++++------------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp index f14f4580..6f1a7cab 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp @@ -67,7 +67,8 @@ void ABountyDirector::SpawnBountyAndItsSideBounties() SideBountyActor->AttachToComponent(BountyAttachmentPoint, AttachmentTransformRules); ASideBountyClass* SideBounty = Cast(SideBountyActor); 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!!!!! } } @@ -119,5 +120,11 @@ void ABountyDirector::DestroyActiveSideBounties() UpdateBountyDisplay(); } +void ABountyDirector::EarnFavours(int FavoursEarned) +{ + UE_LOG(LogTemp, Warning, TEXT("Earned %d favours"), FavoursEarned); +} + + diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h index 14534e75..04c04f42 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h @@ -52,6 +52,9 @@ protected: UFUNCTION() void DestroyActiveSideBounties(); + UFUNCTION() + void EarnFavours(int FavoursEarned); + public: // Called every frame virtual void Tick(float DeltaTime) override; diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp index 7d63f3ba..b104f604 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp @@ -16,8 +16,7 @@ void ASideBountyClass::IncrementBountyCheckpoint() if (Completed) { - - CompletedSideBounty.Broadcast(ActiveSBC_Index); + CompletedSideBounty.Broadcast(FavoursEarnedForCompletion); } } diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.h index 9c0dd1e2..35d481fd 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/SideBountyClass.h @@ -6,30 +6,22 @@ #include "BountyClass.h" #include "SideBountyClass.generated.h" -DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_Index); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, FavoursEarned); UCLASS() class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass { GENERATED_BODY() - - UPROPERTY(EditDefaultsOnly, Category = "Side Bounty") - TMap> ReplacementCheckpoints; - + protected: + UPROPERTY(EditDefaultsOnly, Category = "Side Bounty") + int FavoursEarnedForCompletion = 1; + virtual void BeginPlay() override; public: FCompletedSideBounty CompletedSideBounty; - int ActiveSBC_Index; - - TMap> GetReplacementCheckpoints() - { - return ReplacementCheckpoints; - } - virtual void IncrementBountyCheckpoint() override; - void DestroyCheckpoints(); };