Updated Waypoints to Display Bounty Titles Instead of Checkpoint Descriptions

This commit is contained in:
Rafal Swierczek 2024-01-10 21:31:10 +00:00
parent cc68442e46
commit 39ed880d6b
4 changed files with 14 additions and 10 deletions

View File

@ -48,7 +48,7 @@ void ABountyClass::SpawnCheckpoints()
// Activate the first checkpoint and listen for its completion // Activate the first checkpoint and listen for its completion
BountyCheckpoints[0]->Active = true; BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(); BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated(); BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint); BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
} }
@ -87,7 +87,7 @@ void ABountyClass::IncrementBountyCheckpoint()
// Set the new checkpoint in pos 0 to be active and listen for it's completion // Set the new checkpoint in pos 0 to be active and listen for it's completion
BountyCheckpoints[0]->Active = true; BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(); BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated(); BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint); BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);

View File

@ -8,6 +8,7 @@ ACheckpointClass::ACheckpointClass()
{ {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
BountyTitle = "";
} }
@ -17,23 +18,24 @@ void ACheckpointClass::BeginPlay()
Super::BeginPlay(); Super::BeginPlay();
} }
void ACheckpointClass::SpawnWaypoint() void ACheckpointClass::SpawnWaypoint(const FString& CurrentBountyTitle)
{ {
if (!IsValid(WaypointActorClass)) return; if (!IsValid(WaypointActorClass)) return;
BountyTitle = CurrentBountyTitle;
FActorSpawnParameters SpawnParams; FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams)); WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams));
WaypointActor->SetupWaypoint(WaypointIcon, CheckpointDescription); WaypointActor->SetupWaypoint(WaypointIcon, BountyTitle);
} }
void ACheckpointClass::UpdateChecpointWaypoint(FString WaypointDesc, FVector WaypointNewLoc) void ACheckpointClass::UpdateChecpointWaypoint(FVector WaypointNewLoc)
{ {
FActorSpawnParameters SpawnParams; FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
if (WaypointActor) WaypointActor->Destroy(); if (WaypointActor) WaypointActor->Destroy();
WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointNewLoc, GetActorRotation(), SpawnParams)); WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointNewLoc, GetActorRotation(), SpawnParams));
WaypointActor->SetupWaypoint(WaypointIcon, WaypointDesc); WaypointActor->SetupWaypoint(WaypointIcon, BountyTitle);
} }
// Called every frame // Called every frame

View File

@ -16,6 +16,8 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor
{ {
GENERATED_BODY() GENERATED_BODY()
FString BountyTitle;
// ------ Properties set from Editor ------ // ------ Properties set from Editor ------
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint") UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
FString CheckpointDescription; FString CheckpointDescription;
@ -41,7 +43,7 @@ protected:
} }
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void UpdateChecpointWaypoint(FString WaypointDesc, FVector WaypointNewLoc); void UpdateChecpointWaypoint(FVector WaypointNewLoc);
// Called when the game starts or when spawned // Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;
@ -53,7 +55,7 @@ public:
UPROPERTY(BlueprintReadOnly, Category = "Checkpoint") UPROPERTY(BlueprintReadOnly, Category = "Checkpoint")
bool Active = false; bool Active = false;
void SpawnWaypoint(); void SpawnWaypoint(const FString& BountyTitle);
UFUNCTION(BlueprintImplementableEvent) UFUNCTION(BlueprintImplementableEvent)
void CheckpointActivated(); void CheckpointActivated();