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"> <component name="ChangeListManager">
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment=""> <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$/.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.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" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" />
</list> </list>
@ -32,28 +40,28 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"C++ Project.EndlessVendetta.executor": "Run", &quot;C++ Project.EndlessVendetta.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"git-widget-placeholder": "Bounty-System-Rework", &quot;git-widget-placeholder&quot;: &quot;Bounty-System-Rework&quot;,
"ignore.virus.scanning.warn.message": "true", &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}, },
"keyToStringList": { &quot;keyToStringList&quot;: {
"rider.external.source.directories": [ &quot;rider.external.source.directories&quot;: [
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache", &quot;C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache&quot;,
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache", &quot;C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache&quot;,
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src" &quot;C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src&quot;
] ]
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project"> <configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
<configuration_1> <configuration_1>
@ -128,7 +136,8 @@
<workItem from="1705685813496" duration="6457000" /> <workItem from="1705685813496" duration="6457000" />
<workItem from="1705756768038" duration="3821000" /> <workItem from="1705756768038" duration="3821000" />
<workItem from="1705856571902" duration="3954000" /> <workItem from="1705856571902" duration="3954000" />
<workItem from="1706036726146" duration="5225000" /> <workItem from="1706036726146" duration="5339000" />
<workItem from="1706101472121" duration="11152000" />
</task> </task>
<servers /> <servers />
</component> </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(); if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
SpawnCheckpoints();
} BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
void ABountyClass::Tick(float DeltaTime) BountyCheckpoints[0]->CheckpointActivated();
{ BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
Super::Tick(DeltaTime);
} }
void ABountyClass::SpawnCheckpoints() void ABountyClass::SpawnCheckpoints()
@ -46,49 +42,45 @@ void ABountyClass::SpawnCheckpoints()
BountyCheckpoints.Add(SpawnedCheckpoint); BountyCheckpoints.Add(SpawnedCheckpoint);
} }
// Activate the first checkpoint and listen for its completion ActivateFirstCheckpoint();
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
} }
void ABountyClass::IncrementBountyCheckpoint() void ABountyClass::IncrementBountyCheckpoint()
{ {
// ---------------------------------------------------------------------------------------------------------------------
// Broadcast that the first Checkpoint has been completed so that side bounties can be destroyed // Broadcast that the first Checkpoint has been completed so that side bounties can be destroyed
if (!BountyStarted) // if (!BountyStarted)
{ // {
BountyStarted = true; // BountyStarted = true;
CompletedFirstCheckpoint.Broadcast(); // CompletedFirstCheckpoint.Broadcast();
} // }
//
// Bounty Completion Condition // // Bounty Completion Condition
if (BountyCheckpoints.Num() <= 1) // if (BountyCheckpoints.Num() <= 1)
{ // {
Completed = true; // Completed = true;
BountyCheckpoints[0]->Active = false; // BountyCheckpoints[0]->Active = false;
BountyCheckpoints[0]->Destroy(); // BountyCheckpoints[0]->Destroy();
BountyCheckpoints.RemoveAt(0); // BountyCheckpoints.RemoveAt(0);
UE_LOG(LogTemp, Warning, TEXT(" You've Completed the Bounty!! Well done")); // UE_LOG(LogTemp, Warning, TEXT(" You've Completed the Bounty!! Well done"));
return; // return;
} // }
//
if (BountyCheckpoints[0] == nullptr) // if (BountyCheckpoints[0] == nullptr)
{ // {
UE_LOG(LogTemp, Fatal, TEXT("Missing checkpoint in bounty checkpoints, could've failed to spawn or cast")); // UE_LOG(LogTemp, Fatal, TEXT("Missing checkpoint in bounty checkpoints, could've failed to spawn or cast"));
return; // return;
} // }
//---------------------------------------------------------------------------------------------------------------------
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
// Destroy Actor and Shrink Array // Destroy Actor and Shrink Array
BountyCheckpoints[0]->Active = false; BountyCheckpoints[0]->Active = false;
BountyCheckpoints[0]->Destroy(); BountyCheckpoints[0]->Destroy();
BountyCheckpoints.RemoveAt(0); BountyCheckpoints.RemoveAt(0);
// Set the new checkpoint in pos 0 to be active and listen for it's completion ActivateFirstCheckpoint();
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
} }
void ABountyClass::CollectRewards_Implementation() void ABountyClass::CollectRewards_Implementation()

View File

@ -14,15 +14,53 @@ class ENDLESSVENDETTA_API ABountyClass : public AActor
{ {
GENERATED_BODY() GENERATED_BODY()
// Used to temp store value of incoming replacement checkpoint class // ------------------- ATTRIBUTES ------------------------------
TSubclassOf<ACheckpointClass> ReplacementCheckpointClass;
// 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; bool BountyStarted = false;
protected: protected:
// ------- Properties Set in Editor -------------- // ------- Properties Set in Editor --------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ACheckpointClass>> CheckpointsToSpawn;
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int RewardMoney = 0; int RewardMoney = 0;
@ -34,22 +72,16 @@ protected:
FString BountyDesc; 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: public:
// Broadcast when first checkpoint from this bounty is completed // Broadcast when first checkpoint from this bounty is completed
FCompletedFirstCheckpoint CompletedFirstCheckpoint; FCompletedFirstCheckpoint CompletedFirstCheckpoint;
// ------ Getters for Bounty and Checkpoint Properties ------ // ------ Getters for Bounty and Checkpoint Properties ------
bool IsCompleted() 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 // Collect Money in C++, any other special reward will be implemented in BP if neccessary
UFUNCTION(BlueprintCallable, BlueprintNativeEvent) 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" #include "MainBountyClass.h"

View File

@ -15,8 +15,46 @@ class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
{ {
GENERATED_BODY() 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; 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: protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn; TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
@ -47,6 +85,8 @@ public:
{ {
return SideBountiesToSpawn; return SideBountiesToSpawn;
} }
// ------------- Custom Bounty Alterations ------------- // ------------- Custom Bounty Alterations -------------
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")

View File

@ -3,9 +3,21 @@
#include "BountyHunterCharacter.h" #include "BountyHunterCharacter.h"
#include "Kismet/GameplayStatics.h"
void ABountyHunterCharacter::SpawnBounties() 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() void ABountyHunterCharacter::CompleteCurrentMainBounty()
@ -15,7 +27,8 @@ void ABountyHunterCharacter::CompleteCurrentMainBounty()
void ABountyHunterCharacter::BeginPlay() void ABountyHunterCharacter::BeginPlay()
{ {
Super::BeginPlay(); SpawnBounties();
Super::BeginPlay();
} }
void ABountyHunterCharacter::Tick(float DeltaTime) void ABountyHunterCharacter::Tick(float DeltaTime)

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h" #include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "EndlessVendetta/BountySystem/MainBountyClass.h"
#include "BountyHunterCharacter.generated.h" #include "BountyHunterCharacter.generated.h"
/** /**
@ -21,10 +22,14 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
// Reference to the Currently Active Main Bounty // Reference to the Currently Active Main Bounty
UPROPERTY(VisibleAnywhere, Category = "Bounty Hunter") UPROPERTY(VisibleAnywhere, Category = "Bounty Hunter")
AMainBountyClass* ActiveMainBounty; AMainBountyClass* CurrentMainBounty;
// Index of Currently Active Main Bounty, Used for MainBountyClasses // Index of Currently Active Main Bounty, Used for MainBountyClasses
int CurrentMainBountyIndex = 0; 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: protected:
@ -34,7 +39,7 @@ public:
// ------------------- METHODS --------------------------------- // ------------------- METHODS ---------------------------------
private: 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") UFUNCTION(BlueprintCallable, Category = "Bounty Hunter")
void SpawnBounties(); void SpawnBounties();