From 50650aa7964be38d6ab4f73f24e21f3e2a66ad09 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Fri, 26 Jan 2024 02:22:54 +0000 Subject: [PATCH] Implemented Working Save System without Gameplay Functionality --- .../.idea.EndlessVendetta/.idea/workspace.xml | 17 +++++++----- .../Content/Levels/MainMenuLevel.umap | 4 +-- .../Content/Levels/TempOpenWorld.umap | 4 +-- .../Content/MainMenu/BP_MainSaveGame.uasset | 4 +-- .../Gameplay/MainMenuPlayerController.uasset | 4 +-- .../Architecture/Floor_400x400.uasset | 4 +-- .../StarterContent/Audio/Collapse01.uasset | 4 +-- .../BountySystem/MainBountyClass.h | 1 - .../Characters/BountyHunterCharacter.cpp | 26 +++++++++++++++---- .../Characters/BountyHunterCharacter.h | 2 +- .../Source/EndlessVendetta/EVGameInstance.cpp | 19 ++++++++++++++ .../Source/EndlessVendetta/EVGameInstance.h | 10 +++++++ .../EndlessVendetta/MainSaveGameClass.h | 5 ++-- 13 files changed, 76 insertions(+), 28 deletions(-) diff --git a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml index 49e89891..36cea23c 100644 --- a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml +++ b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml @@ -9,13 +9,17 @@ - - + + - - - + + + + + + + diff --git a/EndlessVendetta/Content/Levels/MainMenuLevel.umap b/EndlessVendetta/Content/Levels/MainMenuLevel.umap index 3680fc8b..410d9bd5 100644 --- a/EndlessVendetta/Content/Levels/MainMenuLevel.umap +++ b/EndlessVendetta/Content/Levels/MainMenuLevel.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb7901ee6817276134b5a654dd76bdffbeec528eb8c6d20e2632dc2109b84a1b -size 299666 +oid sha256:4e347eab07faf7d90209e7e64ba12694fe4804e27f840b4e171fd428466e9803 +size 299618 diff --git a/EndlessVendetta/Content/Levels/TempOpenWorld.umap b/EndlessVendetta/Content/Levels/TempOpenWorld.umap index 5f12a7eb..1c06f05b 100644 --- a/EndlessVendetta/Content/Levels/TempOpenWorld.umap +++ b/EndlessVendetta/Content/Levels/TempOpenWorld.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6aa987a4adaa4132382a1af348224f2ba5f444a7b030773bf82793802838143b -size 13860728 +oid sha256:dfdc199106ad2fca8d90af627e6c092483714378c3e4014dd6124fb5538b36b5 +size 13860679 diff --git a/EndlessVendetta/Content/MainMenu/BP_MainSaveGame.uasset b/EndlessVendetta/Content/MainMenu/BP_MainSaveGame.uasset index 7293f3ec..c0d71a60 100644 --- a/EndlessVendetta/Content/MainMenu/BP_MainSaveGame.uasset +++ b/EndlessVendetta/Content/MainMenu/BP_MainSaveGame.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b13376b6f65cf5b384ddd7fed1bf5e9493e3781fdf90fab77ac437d77400f8ea -size 6083 +oid sha256:c9d27472d220a66dded1121bfbd0e985360e88d0a86dc6f88894db11aa2e117a +size 9426 diff --git a/EndlessVendetta/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset b/EndlessVendetta/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset index b4ff8728..78014c4e 100644 --- a/EndlessVendetta/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset +++ b/EndlessVendetta/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e53b5a7db63663ecc7aa6f67855b9933f0a7e19b00d5f828c45e44e44729a0ca -size 138439 +oid sha256:97f269934ce59b24b2c67b91559683c19b2f22cbcc081c843655f7dc3320fe2f +size 146848 diff --git a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset index c2a34afc..8d790d9a 100644 --- a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset +++ b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c0ecf0ac0702cc2bd355ec050232a61c49e10f102448efbeb735a51824adef6 -size 14948 +oid sha256:6038bf29408d4c5be111de70be0878efba11fba22cfe715ed745704d48e6c243 +size 14831 diff --git a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset index 77bff400..5e3ff30e 100644 --- a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset +++ b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:daf33f5c8c538d4454a1c4e29006d0c94de0bdb68e394a4364edf543b61905d3 -size 353648 +oid sha256:85c827023ee4b466228ec65e92b4b4a0415a106de041ac1c2cab481a2a5dfa8d +size 348532 diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h index c4021f06..bd7f8016 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h @@ -27,7 +27,6 @@ protected: public: - // ------------------- METHODS --------------------------------- private: diff --git a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp index c43e3494..cf60bf68 100644 --- a/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp @@ -3,14 +3,30 @@ #include "BountyHunterCharacter.h" +#include "EndlessVendetta/EVGameInstance.h" #include "Kismet/GameplayStatics.h" void ABountyHunterCharacter::SpawnBounties() { + UE_LOG(LogTemp, Warning, TEXT("Spawning Bounty...")); + + UEVGameInstance* GI = Cast(GetGameInstance()); + + if (!IsValid(GI->MainSaveGameInstanceRef)) + { + UE_LOG(LogTemp, Warning, TEXT("Main save Game Object isnt initialized in GI")); + return; + } + + int TestNum = GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave; + UE_LOG(LogTemp, Warning, TEXT("Current Index is set to....%d"), TestNum); + + GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave = 40; + + UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0); + if (MainBountyClasses.IsEmpty() || !IsValid(MainBountyClasses[CurrentMainBountyIndex])) return; - UE_LOG(LogTemp, Warning, TEXT("Spawning Bounty...")); - CurrentMainBounty = GetWorld()->SpawnActor(MainBountyClasses[CurrentMainBountyIndex]); const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true); AttachToComponent(GetRootComponent(), AttachmentTransformRules); @@ -20,13 +36,13 @@ void ABountyHunterCharacter::SpawnBounties() void ABountyHunterCharacter::CompleteCurrentMainBounty() { - + UE_LOG(LogTemp, Warning, TEXT("Would be collecting reward for completing bounty and moving onto next if possible")); } void ABountyHunterCharacter::BeginPlay() { - SpawnBounties(); - Super::BeginPlay(); + if (UGameplayStatics::DoesSaveGameExist("MainSave", 0)) 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 f3a4eacf..6001ab9b 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/MainSaveGameClass.h" #include "EndlessVendetta/BountySystem/MainBountyClass.h" #include "BountyHunterCharacter.generated.h" @@ -35,7 +36,6 @@ protected: public: - // ------------------- METHODS --------------------------------- private: diff --git a/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp b/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp index bdaaddab..0dee7d08 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp @@ -3,6 +3,25 @@ #include "EVGameInstance.h" +#include "Kismet/GameplayStatics.h" + +void UEVGameInstance::CreateNewSaveGameInstance() +{ + if (UGameplayStatics::DoesSaveGameExist("MainSave", 0)) UGameplayStatics::DeleteGameInSlot("MainSave", 0); + + UE_LOG(LogTemp, Warning, TEXT("Creating new save game instance")); + MainSaveGameInstanceRef = Cast(UGameplayStatics::CreateSaveGameObject(UMainSaveGameClass::StaticClass())); + MainSaveGameInstanceRef->CurrentMainBountyIndexSave = 20; + UGameplayStatics::SaveGameToSlot(MainSaveGameInstanceRef, "MainSave", 0); +} + +void UEVGameInstance::LoadSaveGameInstance() +{ + if (!UGameplayStatics::DoesSaveGameExist("MainSave", 0)) return; + UE_LOG(LogTemp, Warning, TEXT("Loading Game Save into GI")); + MainSaveGameInstanceRef = Cast(UGameplayStatics::LoadGameFromSlot("MainSave", 0)); +} + void UEVGameInstance::OnStart() { Super::OnStart(); diff --git a/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h b/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h index ec749839..208cf308 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h +++ b/EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Engine/GameInstance.h" #include "Http.h" +#include "MainSaveGameClass.h" #include "EVGameInstance.generated.h" /** @@ -19,6 +20,15 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry") FString GlobalSessionID = "AAAAA"; + UPROPERTY() + UMainSaveGameClass* MainSaveGameInstanceRef; + + UFUNCTION(BlueprintCallable) + void CreateNewSaveGameInstance(); + + UFUNCTION(BlueprintCallable) + void LoadSaveGameInstance(); + protected: virtual void OnStart() override; diff --git a/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h b/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h index 3f9d5606..8059f8d7 100644 --- a/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/MainSaveGameClass.h @@ -15,8 +15,7 @@ class ENDLESSVENDETTA_API UMainSaveGameClass : public USaveGame GENERATED_BODY() public: - bool HasCompletedCurrentMainBounty_Save; - - int CurrentMainBountyIndex_Save; + UPROPERTY() + int CurrentMainBountyIndexSave; };