From 3558936f869ae6d9982a2331559f87b6983c0ce7 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Wed, 24 Jan 2024 20:52:44 +0000 Subject: [PATCH] WIP Refactoring Main Bounty and Bounty Classes to Fit New Save System --- .../.idea.EndlessVendetta/.idea/workspace.xml | 49 +++++++----- .../Content/Ships/BP_HomeShip.uasset | 4 +- .../HDRI/HDRI_Epic_Courtyard_Daylight.uasset | 4 +- .../Props/MaterialSphere.uasset | 4 +- .../BountySystem/BountyClass.cpp | 76 +++++++++---------- .../BountySystem/BountyClass.h | 65 +++++++++++----- .../BountySystem/MainBountyClass.cpp | 2 +- .../BountySystem/MainBountyClass.h | 40 ++++++++++ .../Characters/BountyHunterCharacter.cpp | 15 +++- .../Characters/BountyHunterCharacter.h | 9 ++- 10 files changed, 175 insertions(+), 93 deletions(-) diff --git a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml index 0712731c..077ae932 100644 --- a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml +++ b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml @@ -9,6 +9,14 @@ + + + + + + + + @@ -32,28 +40,28 @@ - { + "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" }, - "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" + "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" ] } -}]]> +} @@ -128,7 +136,8 @@ - + + diff --git a/EndlessVendetta/Content/Ships/BP_HomeShip.uasset b/EndlessVendetta/Content/Ships/BP_HomeShip.uasset index 2fcb8256..f47c8e96 100644 --- a/EndlessVendetta/Content/Ships/BP_HomeShip.uasset +++ b/EndlessVendetta/Content/Ships/BP_HomeShip.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5adf54f06d91186e171b05251396919a7994ee9c88964a4a49a4743058b2df8b -size 38469 +oid sha256:9b365fc235303095ae9a94177656b3e5294012ada186a2f0d89de08cb38bf2d3 +size 38349 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index 18f8607f..0f990580 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5157054a7a77739110951ad6d64e24c93647e7665eef16e6944fd1481d4d750a -size 66790690 +oid sha256:bc35eb2d43a47427d30aba0196f9eac90d089dd3abca319528c5d25c83510d0d +size 72364642 diff --git a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset index 56bddfc9..9e0086d5 100644 --- a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset +++ b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a8777c01491888bba9f40eda9d2bed76a611f0e80f75917501ce69c1a321342 -size 47333 +oid sha256:15d4eb8d338ada66c517c7456f15f4382c8b63ccb2bb10170cd5b6b9a7fae19e +size 47710 diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp index 7ef3ff9d..e96b02ca 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp @@ -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() diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.h index 35b33288..a0216f7d 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.h @@ -14,15 +14,53 @@ class ENDLESSVENDETTA_API ABountyClass : public AActor { GENERATED_BODY() - // Used to temp store value of incoming replacement checkpoint class - TSubclassOf ReplacementCheckpointClass; +// ------------------- ATTRIBUTES ------------------------------ + + // Array of Checkpoint Classes to Spawn for this Bounty + UPROPERTY(EditDefaultsOnly, Category = "Bounty") + TArray> 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 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> 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 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) diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp index cab4f924..71fd48fc 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp @@ -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" diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h index 6ec84be1..c4021f06 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h @@ -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 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> SideBountiesToSpawn; @@ -47,6 +85,8 @@ public: { return SideBountiesToSpawn; } + + // ------------- Custom Bounty Alterations ------------- UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") diff --git a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp index 2e412a0f..61d9e08f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp @@ -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(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) diff --git a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h index 1a0f9d3c..f3a4eacf 100644 --- a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.h @@ -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();