Persist applied weather debug state
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "AgrarianPersistenceSubsystem.h"
|
||||
#include "AgrarianGameCharacter.h"
|
||||
#include "AgrarianGameState.h"
|
||||
#include "AgrarianInventoryComponent.h"
|
||||
#include "AgrarianPersistentActorComponent.h"
|
||||
#include "AgrarianSaveGame.h"
|
||||
@@ -120,6 +121,44 @@ int32 UAgrarianPersistenceSubsystem::RestoreWorldActors(const UAgrarianSaveGame*
|
||||
return RestoredCount;
|
||||
}
|
||||
|
||||
bool UAgrarianPersistenceSubsystem::CaptureWorldState(UAgrarianSaveGame* SaveGame) const
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
AAgrarianGameState* GameState = World ? World->GetGameState<AAgrarianGameState>() : nullptr;
|
||||
if (!SaveGame || !GameState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SaveGame->WorldHours = GameState->WorldHours;
|
||||
SaveGame->Weather = GameState->Weather;
|
||||
SaveGame->WeatherInputs = GameState->ActiveWeatherInputs;
|
||||
SaveGame->WeatherDebug = GameState->GetWeatherDebugSnapshot();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UAgrarianPersistenceSubsystem::RestoreWorldState(const UAgrarianSaveGame* SaveGame) const
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
AAgrarianGameState* GameState = World ? World->GetGameState<AAgrarianGameState>() : nullptr;
|
||||
if (!SaveGame || !GameState || !GameState->HasAuthority())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GameState->WorldHours = SaveGame->WorldHours;
|
||||
if (SaveGame->WeatherInputs.bHasProviderData)
|
||||
{
|
||||
GameState->ApplyMappedWeatherInputs(SaveGame->WeatherInputs);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameState->SetWeather(SaveGame->Weather);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32 UAgrarianPersistenceSubsystem::CapturePlayers(UAgrarianSaveGame* SaveGame) const
|
||||
{
|
||||
if (!SaveGame)
|
||||
@@ -209,6 +248,7 @@ bool UAgrarianPersistenceSubsystem::SaveCurrentWorld() const
|
||||
return false;
|
||||
}
|
||||
|
||||
CaptureWorldState(SaveGame);
|
||||
CapturePlayers(SaveGame);
|
||||
CaptureWorldActors(SaveGame);
|
||||
return WriteSave(SaveGame);
|
||||
|
||||
Reference in New Issue
Block a user