Implemented Working Save System without Gameplay Functionality

This commit is contained in:
Rafal Swierczek 2024-01-26 02:22:54 +00:00
parent 75a2b43ef2
commit 50650aa796
13 changed files with 76 additions and 28 deletions

View File

@ -9,13 +9,17 @@
<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/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/TempOpenWorld.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/TempOpenWorld.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/MainMenu/BP_MainSaveGame.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/MainMenu/BP_MainSaveGame.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/MainMenu/Gameplay/MainMenuPlayerController.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/MainMenu/Widgets/WBP_MainMenu.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/MainMenu/Widgets/WBP_MainMenu.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$/Content/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.uasset" 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" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -134,7 +138,8 @@
<workItem from="1705756768038" duration="3821000" />
<workItem from="1705856571902" duration="3954000" />
<workItem from="1706036726146" duration="5339000" />
<workItem from="1706101472121" duration="14409000" />
<workItem from="1706101472121" duration="21314000" />
<workItem from="1706203836052" duration="7461000" />
</task>
<servers />
</component>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fb7901ee6817276134b5a654dd76bdffbeec528eb8c6d20e2632dc2109b84a1b
size 299666
oid sha256:4e347eab07faf7d90209e7e64ba12694fe4804e27f840b4e171fd428466e9803
size 299618

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6aa987a4adaa4132382a1af348224f2ba5f444a7b030773bf82793802838143b
size 13860728
oid sha256:dfdc199106ad2fca8d90af627e6c092483714378c3e4014dd6124fb5538b36b5
size 13860679

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e53b5a7db63663ecc7aa6f67855b9933f0a7e19b00d5f828c45e44e44729a0ca
size 138439
oid sha256:97f269934ce59b24b2c67b91559683c19b2f22cbcc081c843655f7dc3320fe2f
size 146848

Binary file not shown.

View File

@ -27,7 +27,6 @@ protected:
public:
// ------------------- METHODS ---------------------------------
private:

View File

@ -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<UEVGameInstance>(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<AMainBountyClass>(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)

View File

@ -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:

View File

@ -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<UMainSaveGameClass>(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<UMainSaveGameClass>(UGameplayStatics::LoadGameFromSlot("MainSave", 0));
}
void UEVGameInstance::OnStart()
{
Super::OnStart();

View File

@ -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;

View File

@ -15,8 +15,7 @@ class ENDLESSVENDETTA_API UMainSaveGameClass : public USaveGame
GENERATED_BODY()
public:
bool HasCompletedCurrentMainBounty_Save;
int CurrentMainBountyIndex_Save;
UPROPERTY()
int CurrentMainBountyIndexSave;
};