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);
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());
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);
}

View File

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

View File

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

View File

@ -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<int, TSubclassOf<ACheckpointClass>> ReplacementCheckpoints;
protected:
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
int FavoursEarnedForCompletion = 1;
virtual void BeginPlay() override;
public:
FCompletedSideBounty CompletedSideBounty;
int ActiveSBC_Index;
TMap<int, TSubclassOf<ACheckpointClass>> GetReplacementCheckpoints()
{
return ReplacementCheckpoints;
}
virtual void IncrementBountyCheckpoint() override;
void DestroyCheckpoints();
};