52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
// © 2025 Naked People Team. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "NakedDesire/Global/Constants.h"
|
|
#include "Subsystems/GameInstanceSubsystem.h"
|
|
#include "SaveSubsystem.generated.h"
|
|
|
|
class UGlobalSaveGameData;
|
|
struct FItemSaveRecord;
|
|
|
|
UCLASS()
|
|
class NAKEDDESIRE_API USaveSubsystem : public UGameInstanceSubsystem
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
void LoadGame(const FString& SlotName = DefaultSaveSlotName);
|
|
bool SaveGame(const FString& SlotName = DefaultSaveSlotName) const;
|
|
|
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
|
|
|
UGlobalSaveGameData* GetCurrentSave();
|
|
|
|
// True when a persisted save exists in the active slot — drives the main-menu
|
|
// Continue button's enabled state.
|
|
UFUNCTION(BlueprintPure, Category = "Save")
|
|
bool DoesSaveExist() const;
|
|
|
|
// Wipes the active slot and reseeds a fresh save from StartingSaveData, replacing
|
|
// the cached CurrentSave so the next GetCurrentSave returns the new game. Call before
|
|
// opening the gameplay level from the main-menu "New Game" flow.
|
|
UFUNCTION(BlueprintCallable, Category = "Save")
|
|
void StartNewGame();
|
|
|
|
protected:
|
|
UFUNCTION(BlueprintCallable)
|
|
void BP_LoadGame();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void BP_SaveGame();
|
|
|
|
private:
|
|
void PopulateStartingData(UGlobalSaveGameData* Save) const;
|
|
|
|
UPROPERTY()
|
|
FString ActiveSlotName = DefaultSaveSlotName;
|
|
|
|
UPROPERTY()
|
|
TObjectPtr<UGlobalSaveGameData> CurrentSave;
|
|
}; |