WIP Refactoring Main Bounty and Bounty Classes to Fit New Save System

This commit is contained in:
Rafal Swierczek 2024-01-24 20:52:44 +00:00
parent 9c48ae9465
commit 3558936f86
10 changed files with 175 additions and 93 deletions

View File

@ -9,6 +9,14 @@
<component name="ChangeListManager">
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/ControlTutorialLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/ControlTutorialLevel.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Ships/BP_HomeShip.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Ships/BP_HomeShip.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Props/MaterialSphere.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Props/MaterialSphere.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" />
</list>
@ -32,28 +40,28 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"C++ Project.EndlessVendetta.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "Bounty-System-Rework",
"ignore.virus.scanning.warn.message": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;C++ Project.EndlessVendetta.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;Bounty-System-Rework&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"rider.external.source.directories": [
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
&quot;keyToStringList&quot;: {
&quot;rider.external.source.directories&quot;: [
&quot;C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache&quot;,
&quot;C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache&quot;,
&quot;C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src&quot;
]
}
}]]></component>
}</component>
<component name="RunManager">
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
<configuration_1>
@ -128,7 +136,8 @@
<workItem from="1705685813496" duration="6457000" />
<workItem from="1705756768038" duration="3821000" />
<workItem from="1705856571902" duration="3954000" />
<workItem from="1706036726146" duration="5225000" />
<workItem from="1706036726146" duration="5339000" />
<workItem from="1706101472121" duration="11152000" />
</task>
<servers />
</component>

Binary file not shown.

Binary file not shown.

View File

@ -11,18 +11,14 @@ ABountyClass::ABountyClass()
}
void ABountyClass::BeginPlay()
void ABountyClass::ActivateFirstCheckpoint()
{
Super::BeginPlay();
SpawnCheckpoints();
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
}
void ABountyClass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
}
void ABountyClass::SpawnCheckpoints()
@ -46,49 +42,45 @@ void ABountyClass::SpawnCheckpoints()
BountyCheckpoints.Add(SpawnedCheckpoint);
}
// Activate the first checkpoint and listen for its completion
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
ActivateFirstCheckpoint();
}
void ABountyClass::IncrementBountyCheckpoint()
{
// ---------------------------------------------------------------------------------------------------------------------
// Broadcast that the first Checkpoint has been completed so that side bounties can be destroyed
if (!BountyStarted)
{
BountyStarted = true;
CompletedFirstCheckpoint.Broadcast();
}
// Bounty Completion Condition
if (BountyCheckpoints.Num() <= 1)
{
Completed = true;
BountyCheckpoints[0]->Active = false;
BountyCheckpoints[0]->Destroy();
BountyCheckpoints.RemoveAt(0);
UE_LOG(LogTemp, Warning, TEXT(" You've Completed the Bounty!! Well done"));
return;
}
if (BountyCheckpoints[0] == nullptr)
{
UE_LOG(LogTemp, Fatal, TEXT("Missing checkpoint in bounty checkpoints, could've failed to spawn or cast"));
return;
}
// if (!BountyStarted)
// {
// BountyStarted = true;
// CompletedFirstCheckpoint.Broadcast();
// }
//
// // Bounty Completion Condition
// if (BountyCheckpoints.Num() <= 1)
// {
// Completed = true;
// BountyCheckpoints[0]->Active = false;
// BountyCheckpoints[0]->Destroy();
// BountyCheckpoints.RemoveAt(0);
// UE_LOG(LogTemp, Warning, TEXT(" You've Completed the Bounty!! Well done"));
// return;
// }
//
// if (BountyCheckpoints[0] == nullptr)
// {
// UE_LOG(LogTemp, Fatal, TEXT("Missing checkpoint in bounty checkpoints, could've failed to spawn or cast"));
// return;
// }
//---------------------------------------------------------------------------------------------------------------------
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
// Destroy Actor and Shrink Array
BountyCheckpoints[0]->Active = false;
BountyCheckpoints[0]->Destroy();
BountyCheckpoints.RemoveAt(0);
// Set the new checkpoint in pos 0 to be active and listen for it's completion
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
ActivateFirstCheckpoint();
}
void ABountyClass::CollectRewards_Implementation()

View File

@ -14,15 +14,53 @@ class ENDLESSVENDETTA_API ABountyClass : public AActor
{
GENERATED_BODY()
// Used to temp store value of incoming replacement checkpoint class
TSubclassOf<ACheckpointClass> ReplacementCheckpointClass;
// ------------------- ATTRIBUTES ------------------------------
// Array of Checkpoint Classes to Spawn for this Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ACheckpointClass>> CheckpointsToSpawn;
protected:
// Has a Get Func, Used for Identifying if the Bounty has been Completed
bool Completed = false;
// Array of References to the Spawned in Checkpoints for this Bounty
TArray<ACheckpointClass*> BountyCheckpoints;
public:
// ------------------- METHODS ---------------------------------
private:
// Activate the First Checkpoint in Bounty Checkpoints and Listen for its Completion
void ActivateFirstCheckpoint();
protected:
// Called when a checkpoint is completed, handles moving onto next checkpoint and discarding the old one
UFUNCTION()
virtual void IncrementBountyCheckpoint();
public:
// Sets default values for this actor's properties
ABountyClass();
// Spawns and stores this Bounties Checkpoints in order
void SpawnCheckpoints();
// ------------------- LEGACY CODE TO BE REWORKED ---------------------------------
bool BountyStarted = false;
protected:
// ------- Properties Set in Editor --------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ACheckpointClass>> CheckpointsToSpawn;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int RewardMoney = 0;
@ -34,22 +72,16 @@ protected:
FString BountyDesc;
// -----------------------------------------------
bool Completed = false;
// Spawned in Checkpoints for this Bounty
TArray<ACheckpointClass*> BountyCheckpoints;
// Spawns and stores this Bounties Checkpoints in order
void SpawnCheckpoints();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Broadcast when first checkpoint from this bounty is completed
FCompletedFirstCheckpoint CompletedFirstCheckpoint;
// ------ Getters for Bounty and Checkpoint Properties ------
bool IsCompleted()
{
@ -102,16 +134,7 @@ public:
}
// ----------------------------------------------------------
// Sets default values for this actor's properties
ABountyClass();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called when a checkpoint is completed, handles moving onto next checkpoint and discarding the old one
UFUNCTION()
virtual void IncrementBountyCheckpoint();
// Collect Money in C++, any other special reward will be implemented in BP if neccessary
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)

View File

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

View File

@ -15,8 +15,46 @@ class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
{
GENERATED_BODY()
// ------------------- ATTRIBUTES ------------------------------
// Used to Spawn Open World Checkpoint for this Main Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<ACheckpointClass> OpenWorldCheckpointClass;
// Only Function of this Checkpoint is to Guide the Player to the Bounty Start Area
ACheckpointClass* OpenWorldCheckpointRef;
protected:
public:
// ------------------- METHODS ---------------------------------
private:
// Overrides to Display Correct Tip for Checkpoint
void IncrementBountyCheckpoint() override;
protected:
// Sets completed to true when last checkpoint broadcasts completion
UFUNCTION()
void CompletedMainBounty()
{
Completed = true;
}
public:
// Spawns the Single Checkpoint in the Open World for this Main Bounty
void SpawnOpenWorldCheckpoint()
{
UE_LOG(LogTemp, Warning, TEXT("Spawning Open World Checkpoint"));
}
// ------------------- LEGACY CODE TO BE REWORKED ---------------------------------
protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
@ -47,6 +85,8 @@ public:
{
return SideBountiesToSpawn;
}
// ------------- Custom Bounty Alterations -------------
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")

View File

@ -3,9 +3,21 @@
#include "BountyHunterCharacter.h"
#include "Kismet/GameplayStatics.h"
void ABountyHunterCharacter::SpawnBounties()
{
if (MainBountyClasses.IsEmpty() || !IsValid(MainBountyClasses[CurrentMainBountyIndex])) return;
UE_LOG(LogTemp, Warning, TEXT("Spawning Bounty..."));
UGameplayStatics::save
CurrentMainBounty = GetWorld()->SpawnActor<AMainBountyClass>(MainBountyClasses[CurrentMainBountyIndex]);
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
AttachToComponent(GetRootComponent(), AttachmentTransformRules);
UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName ? CurrentMainBounty->SpawnOpenWorldCheckpoint() : CurrentMainBounty->SpawnCheckpoints();
}
void ABountyHunterCharacter::CompleteCurrentMainBounty()
@ -15,7 +27,8 @@ void ABountyHunterCharacter::CompleteCurrentMainBounty()
void ABountyHunterCharacter::BeginPlay()
{
Super::BeginPlay();
SpawnBounties();
Super::BeginPlay();
}
void ABountyHunterCharacter::Tick(float DeltaTime)

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "EndlessVendetta/BountySystem/MainBountyClass.h"
#include "BountyHunterCharacter.generated.h"
/**
@ -21,10 +22,14 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
// Reference to the Currently Active Main Bounty
UPROPERTY(VisibleAnywhere, Category = "Bounty Hunter")
AMainBountyClass* ActiveMainBounty;
AMainBountyClass* CurrentMainBounty;
// Index of Currently Active Main Bounty, Used for MainBountyClasses
int CurrentMainBountyIndex = 0;
// Name of open world, so that the correct bounties can be spawned based on level
UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter")
FString OpenWorldLevelName = "ControlTutorialLevel";
protected:
@ -34,7 +39,7 @@ public:
// ------------------- METHODS ---------------------------------
private:
// Spawns Main Bounty from MainBountyClasses at the CurrentMainBountyIndex, along with its Side Bounties
// Spawns Current Main Bounty along with its Side Bounties, and spawns its appropriate CP's based on level
UFUNCTION(BlueprintCallable, Category = "Bounty Hunter")
void SpawnBounties();