Added starting save data

This commit is contained in:
koritsa
2026-05-27 19:43:00 +03:00
committed by koritsa
parent 23f709bd61
commit 435bb68f7e
12 changed files with 109 additions and 53 deletions
@@ -10,38 +10,23 @@ UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame()
UGlobalSaveGameData* NewSave = Cast<UGlobalSaveGameData>(UGameplayStatics::CreateSaveGameObject(StaticClass()));
if (!NewSave)
return nullptr;
NewSave->Money = STARTING_MONEY;
return NewSave;
}
UGlobalSaveGameData* UGlobalSaveGameData::LoadOrCreateSaveGame(const FString& SlotName)
{
if (UGlobalSaveGameData* ExistingSave = LoadGame(SlotName))
return ExistingSave;
UGlobalSaveGameData* NewSave = CreateNewSaveGame();
if (NewSave)
{
UGameplayStatics::SaveGameToSlot(NewSave, SlotName, SLOT_PLAYER);
}
return NewSave;
}
UGlobalSaveGameData* UGlobalSaveGameData::LoadGame(const FString& SlotName)
{
if (UGameplayStatics::DoesSaveGameExist(SlotName, SLOT_PLAYER))
{
return Cast<UGlobalSaveGameData>(UGameplayStatics::LoadGameFromSlot(SlotName, SLOT_PLAYER));
}
return nullptr;
}
bool UGlobalSaveGameData::SaveGame(UGlobalSaveGameData* SaveGameData, const FString& SlotName)
{
return UGameplayStatics::SaveGameToSlot(SaveGameData, SlotName, SLOT_PLAYER);
}
}