Added starting save data
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user