Reworked Open World Checkpoint System to Allow Multiple Checkpoints

This commit is contained in:
Rafal Swierczek 2024-03-18 21:07:48 +00:00
parent 530c9580ff
commit fbff6fdd62
18 changed files with 98 additions and 31 deletions

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d96dde71ce13d7ed2661e3fe8d0531e67453e81644492f026f7577c12af0acf9
size 35286

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a6edb31abcafeab6442cb285181905031da2635eb7c6444b529d9c8636ee9496
size 29747

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7367fb8f5ccaf3e4ae6e34133debe0d5efbaedf33024d14cf37b1f4f5ff7fb1c
size 39283

View File

@ -33,6 +33,7 @@ protected:
public: public:
FCompletedACheckpoint CompletedACheckpoint; FCompletedACheckpoint CompletedACheckpoint;
// Used to update Displayed Tip
FCheckpointActivated CheckpointActivated; FCheckpointActivated CheckpointActivated;
// Gets the Reward Money for Completing this Bounty, used by Players Character // Gets the Reward Money for Completing this Bounty, used by Players Character

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "OpenWorldCheckpoint.h"

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "EndlessVendetta/BountySystem/CheckpointClass.h"
#include "OpenWorldCheckpoint.generated.h"
/**
*
*/
UCLASS()
class ENDLESSVENDETTA_API AOpenWorldCheckpoint : public ACheckpointClass
{
GENERATED_BODY()
protected:
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
FTransform RespawnTransform;
};

View File

@ -0,0 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "OpenWorldInteractableCheckpoint.h"
void AOpenWorldInteractableCheckpoint::Interact()
{
PlayerInteracted();
}

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "OpenWorldCheckpoint.h"
#include "OpenWorldInteractableCheckpoint.generated.h"
/**
*
*/
UCLASS()
class ENDLESSVENDETTA_API AOpenWorldInteractableCheckpoint : public AOpenWorldCheckpoint, public IInteractionInterface
{
GENERATED_BODY()
void Interact() override;
protected:
UFUNCTION(BlueprintImplementableEvent)
void PlayerInteracted();
};

View File

@ -15,7 +15,7 @@ void AMainBountyClass::IncrementBountyCheckpoint()
void AMainBountyClass::ActivateFirstCheckpoint() void AMainBountyClass::ActivateFirstCheckpoint()
{ {
Super::ActivateFirstCheckpoint(); Super::ActivateFirstCheckpoint();
if (IsValid(OpenWorldcheckpoint)) OpenWorldcheckpoint->SpawnWaypoint(MainBountyStruct.TargetName); //if (IsValid(OpenWorldcheckpoint)) OpenWorldcheckpoint->SpawnWaypoint(MainBountyStruct.TargetName);
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return; if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
BountyCheckpoints[0]->SpawnWaypoint(MainBountyStruct.TargetName); BountyCheckpoints[0]->SpawnWaypoint(MainBountyStruct.TargetName);
} }
@ -23,19 +23,22 @@ void AMainBountyClass::ActivateFirstCheckpoint()
void AMainBountyClass::DeActivateFirstCheckpoint() void AMainBountyClass::DeActivateFirstCheckpoint()
{ {
Super::DeActivateFirstCheckpoint(); Super::DeActivateFirstCheckpoint();
if (IsValid(OpenWorldcheckpoint)) OpenWorldcheckpoint->DestroyWaypoint(); //if (IsValid(OpenWorldcheckpoint)) OpenWorldcheckpoint->DestroyWaypoint();
} }
void AMainBountyClass::SpawnOpenWorldCheckpoint() void AMainBountyClass::SpawnOpenWorldCheckpoint()
{ {
if (!IsValid(OpenWorldCheckpointClass)) return; if (OpenWorldCheckpointClasses.IsEmpty()) return;
for (TSubclassOf<ACheckpointClass> OpenWorldCheckpointClass : OpenWorldCheckpointClasses)
{
if (OpenWorldCheckpointClass == nullptr) continue;
FActorSpawnParameters SpawnParameters; FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FVector Loc = OpenWorldCheckpointClass.GetDefaultObject()->GetCheckpointSpawnTransform().GetLocation(); FVector Loc = OpenWorldCheckpointClass.GetDefaultObject()->GetCheckpointSpawnTransform().GetLocation();
FRotator Rot = OpenWorldCheckpointClass.GetDefaultObject()->GetCheckpointSpawnTransform().GetRotation().Rotator(); FRotator Rot = OpenWorldCheckpointClass.GetDefaultObject()->GetCheckpointSpawnTransform().GetRotation().Rotator();
BountyCheckpoints.Add(GetWorld()->SpawnActor<ACheckpointClass>(OpenWorldCheckpointClass, Loc, Rot, SpawnParameters));
OpenWorldcheckpoint = GetWorld()->SpawnActor<ACheckpointClass>(OpenWorldCheckpointClass, Loc, Rot, SpawnParameters); }
ActivateFirstCheckpoint(); ActivateFirstCheckpoint();
} }

View File

@ -42,10 +42,10 @@ class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
// ------------------- ATTRIBUTES ------------------------------ // ------------------- ATTRIBUTES ------------------------------
// Used to Spawn Open World Checkpoint for this Main Bounty // Used to Spawn Open World Checkpoint for this Main Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<ACheckpointClass> OpenWorldCheckpointClass; TArray<TSubclassOf<ACheckpointClass>> OpenWorldCheckpointClasses;
// Used to Store Ref for Bounty Tracking Functionality // Used to Store Ref for Bounty Tracking Functionality
ACheckpointClass* OpenWorldcheckpoint; //TArray<ACheckpointClass*> OpenWorldcheckpoints;
// Used by Players Character to Determine where to Spawn in the Open World after Completing Main Bounty // Used by Players Character to Determine where to Spawn in the Open World after Completing Main Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
@ -95,10 +95,10 @@ public:
void DeActivateFirstCheckpoint() override; void DeActivateFirstCheckpoint() override;
// Returns open world checkpoints tip // Returns open world checkpoints tip
FString GetOpenWorldCheckpointTip() // FString GetOpenWorldCheckpointTip()
{ // {
return OpenWorldcheckpoint->GetCheckpointTip(); // return OpenWorldcheckpoint->GetCheckpointTip();
} // }

View File

@ -60,7 +60,6 @@ void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI)
EarnMoney(MoneyEarned); EarnMoney(MoneyEarned);
BountyCompletedDisplay(MoneyEarned, 0); BountyCompletedDisplay(MoneyEarned, 0);
if (IsValid(PauseMenu)) PauseMenu->UpdatePlayerStatistics(Money, Favours); if (IsValid(PauseMenu)) PauseMenu->UpdatePlayerStatistics(Money, Favours);
UE_LOG(LogTemp, Warning, TEXT("Would be collecting reward for completing bounty %d"), CurrentMainBountyIndex);
// Saves players spawn now as players location is set after spawn main bounty finishes running in begin play // Saves players spawn now as players location is set after spawn main bounty finishes running in begin play
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform(); GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform();

View File

@ -285,7 +285,7 @@ private:
{ {
DeActivateAllBounties(); DeActivateAllBounties();
CurrentMainBounty->ActivateFirstCheckpoint(); CurrentMainBounty->ActivateFirstCheckpoint();
DisplayCheckpointTip(CurrentMainBounty->GetOpenWorldCheckpointTip()); //DisplayCheckpointTip(CurrentMainBounty->GetOpenWorldCheckpointTip());
} }
UFUNCTION() UFUNCTION()