Resolve Money duplication between ANakedDesireCharacter and UGlobalSaveGameData
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include "NakedDesire/Clothing/ClothingItemData.h"
|
||||
#include "NakedDesire/Clothing/ClothingList.h"
|
||||
|
||||
UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing)
|
||||
UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing, float InMoney)
|
||||
{
|
||||
UGlobalSaveGameData* NewSave = Cast<UGlobalSaveGameData>(
|
||||
UGameplayStatics::CreateSaveGameObject(UGlobalSaveGameData::StaticClass())
|
||||
@@ -19,11 +19,13 @@ UGlobalSaveGameData* UGlobalSaveGameData::CreateNewSaveGame(TArray<UClothingItem
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewSave->Money = InMoney;
|
||||
|
||||
for (const UClothingItemData* Item : CurrentWardrobeClothing)
|
||||
{
|
||||
NewSave->WardrobeClothing.Add(Item->ToSaveData());
|
||||
}
|
||||
|
||||
|
||||
for (const UClothingItemData* Item : CurrentPlayerClothing)
|
||||
{
|
||||
NewSave->PlayerClothing.Add(Item->ToSaveData());
|
||||
@@ -44,7 +46,7 @@ UGlobalSaveGameData* UGlobalSaveGameData::LoadOrCreateSaveGame(UClothingList* De
|
||||
UGlobalSaveGameData* NewSave = nullptr;
|
||||
if (DefaultWardrobeClothing && DefaultPlayerClothing)
|
||||
{
|
||||
NewSave = CreateNewSaveGame(DefaultWardrobeClothing->ClothingItems, DefaultPlayerClothing->ClothingItems);
|
||||
NewSave = CreateNewSaveGame(DefaultWardrobeClothing->ClothingItems, DefaultPlayerClothing->ClothingItems, STARTING_MONEY);
|
||||
}
|
||||
|
||||
if (NewSave)
|
||||
@@ -56,11 +58,11 @@ UGlobalSaveGameData* UGlobalSaveGameData::LoadOrCreateSaveGame(UClothingList* De
|
||||
}
|
||||
|
||||
bool UGlobalSaveGameData::SaveGame(const TArray<UClothingItemData*> CurrentWardrobeClothing,
|
||||
const TArray<UClothingItemData*> CurrentPlayerClothing)
|
||||
const TArray<UClothingItemData*> CurrentPlayerClothing, int32 Money)
|
||||
{
|
||||
if (UGlobalSaveGameData* SaveGame = CreateNewSaveGame(CurrentWardrobeClothing, CurrentPlayerClothing))
|
||||
if (UGlobalSaveGameData* Save = CreateNewSaveGame(CurrentWardrobeClothing, CurrentPlayerClothing, (float)Money))
|
||||
{
|
||||
return UGameplayStatics::SaveGameToSlot(SaveGame, SLOT_NAME, SLOT_PLAYER);
|
||||
return UGameplayStatics::SaveGameToSlot(Save, SLOT_NAME, SLOT_PLAYER);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
static UGlobalSaveGameData* LoadOrCreateSaveGame(UClothingList* DefaultPlayerClothing, UClothingList* DefaultWardrobeClothing);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
static bool SaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing);
|
||||
static bool SaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing, int32 Money);
|
||||
|
||||
private:
|
||||
static UGlobalSaveGameData* CreateNewSaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing);
|
||||
static UGlobalSaveGameData* CreateNewSaveGame(TArray<UClothingItemData*> CurrentWardrobeClothing, TArray<UClothingItemData*> CurrentPlayerClothing, float InMoney);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user