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


#include "FinalCheckpoint.h"
#include "EndlessVendetta/EVGameInstance.h"
#include "EndlessVendetta/Characters/BountyHunterCharacter.h"
#include "Kismet/GameplayStatics.h"

void AFinalCheckpoint::CompleteBounty()
{
	UEVGameInstance* GI = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
	if (!IsValid(GI)) return;

	GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave++;
	UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);

	FName OpnWrldLvlName = FName(Cast<ABountyHunterCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetOpenWorldLevelName());
	UGameplayStatics::OpenLevel(GetWorld(), OpnWrldLvlName);
}
