Update Save System

This commit is contained in:
baz 2024-05-30 16:54:25 +01:00
parent 804a752aa5
commit 2b5d67346a
4 changed files with 22 additions and 2 deletions

View File

@ -50,8 +50,8 @@ bool UNakatomiGameInstance::SaveGame(bool ResetDefaults)
{
APlayerCharacter* Player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
SaveGameObject->PlayerHealth = Player->GetCurrentHealthCount();
SaveGameObject->WeaponInventory = Player->WeaponInventory;
SaveGameObject->CurrentInventorySlot = Player->GetCurrentInventorySlot();
// SaveGameObject->CurrentInventorySlot = Player->GetCurrentInventorySlot();
SaveGameObject->ThrowableInventory = Player->ThrowableInventory;
}
SaveGameObject->LevelName = GetWorld()->GetMapName();

View File

@ -3,6 +3,8 @@
#pragma once
#include "CoreMinimal.h"
#include "Weapon.h"
#include "Throwable.h"
#include "NakatomiSaveFileInfo.generated.h"
/**
@ -24,4 +26,13 @@ struct FNakatomiSaveFileInfo
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
FString DateTimeSaved;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
TArray<AWeapon*> WeaponInventory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Info")
int CurrentInventorySlot = 0;
};

View File

@ -28,6 +28,9 @@ public:
UPROPERTY(VisibleAnywhere, Category = Player)
TArray<AWeapon*> WeaponInventory;
UPROPERTY(VisibleAnywhere, Category = Player)
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
UPROPERTY(VisibleAnywhere, Category = Player)
int CurrentInventorySlot = 0;

View File

@ -87,6 +87,12 @@ void APlayerCharacter::BeginPlay()
{
//TODO: More loading here
GetHealthComponent()->SetCurrentHealth(Save->PlayerHealth);
if (Save->ThrowableInventory.Num() > 0)
{
ThrowableInventory.Empty();
ThrowableInventory = Save->ThrowableInventory;
}
}
}