// Fill out your copyright notice in the Description page of Project Settings.


#include "SideBountyClass.h"


void ASideBountyClass::BeginPlay()
{
	SideBountyStruct.SideBountyUID = GetUniqueID();
	SideBountyStruct.MoneyEarnedForCompletion = RewardMoney;
	Super::BeginPlay();
}

void ASideBountyClass::ActivateFirstCheckpoint()
{
	Super::ActivateFirstCheckpoint();
	if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
	BountyCheckpoints[0]->SpawnWaypoint(SideBountyStruct.BountyTitle);
}

void ASideBountyClass::IncrementBountyCheckpoint()
{
	Super::IncrementBountyCheckpoint();

	if (BountyCheckpoints.IsEmpty())
	{
		CompletedSideBounty.Broadcast(GetUniqueID());
	}
}

void ASideBountyClass::DestroyCheckpoints()
{
	for (int i = 0; i < BountyCheckpoints.Num(); i++)
	{
		if (BountyCheckpoints[i] == nullptr)
		{
			continue;
		}

		BountyCheckpoints[i]->Destroy();
	}
}

