Persist applied weather debug state

This commit is contained in:
2026-05-16 00:16:32 -07:00
parent 3740eb32bf
commit 26ddf8ea8e
11 changed files with 256 additions and 2 deletions
+30
View File
@@ -49,6 +49,13 @@ AAgrarianGameState::AAgrarianGameState()
ActiveGrowingSeason.MinAverageGrowingTempC = 7.0f;
ActiveGrowingSeason.CropSafetyBufferDays = 14;
ActiveGrowingSeason.ClimateProfile = TEXT("coastal_mediterranean_mild");
ActiveWeatherInputs.TileId = ActiveSolarTileId;
ActiveWeatherInputs.Latitude = ActiveTileLatitude;
ActiveWeatherInputs.Longitude = ActiveTileLongitude;
ActiveWeatherDebug.TileId = ActiveSolarTileId;
ActiveWeatherDebug.Latitude = ActiveTileLatitude;
ActiveWeatherDebug.Longitude = ActiveTileLongitude;
ActiveWeatherDebug.AppliedWeather = Weather;
}
void AAgrarianGameState::BeginPlay()
@@ -99,6 +106,7 @@ void AAgrarianGameState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& O
DOREPLIFETIME(AAgrarianGameState, bHasRegionalObservedTemperature);
DOREPLIFETIME(AAgrarianGameState, RegionalWeatherSource);
DOREPLIFETIME(AAgrarianGameState, ActiveWeatherInputs);
DOREPLIFETIME(AAgrarianGameState, ActiveWeatherDebug);
DOREPLIFETIME(AAgrarianGameState, DaysPerAgrarianYear);
DOREPLIFETIME(AAgrarianGameState, ActiveSolarTileId);
DOREPLIFETIME(AAgrarianGameState, ActiveTileLatitude);
@@ -130,6 +138,7 @@ void AAgrarianGameState::SetWeather(EAgrarianWeatherType NewWeather)
if (HasAuthority())
{
Weather = NewWeather;
ActiveWeatherDebug.AppliedWeather = NewWeather;
UpdateAmbientTemperature();
OnRep_Weather();
}
@@ -180,6 +189,22 @@ void AAgrarianGameState::ApplyMappedWeatherInputs(const FAgrarianMappedWeatherIn
ActiveWeatherInputs.VisibilityMeters = FMath::Max(0.0f, ActiveWeatherInputs.VisibilityMeters);
ActiveWeatherInputs.bHasProviderData = true;
ActiveWeatherDebug.TileId = ActiveWeatherInputs.TileId != NAME_None ? ActiveWeatherInputs.TileId : ActiveSolarTileId;
ActiveWeatherDebug.Latitude = ActiveWeatherInputs.TileId != NAME_None ? ActiveWeatherInputs.Latitude : ActiveTileLatitude;
ActiveWeatherDebug.Longitude = ActiveWeatherInputs.TileId != NAME_None ? ActiveWeatherInputs.Longitude : ActiveTileLongitude;
ActiveWeatherDebug.Provider = ActiveWeatherInputs.Provider;
ActiveWeatherDebug.ProviderTimestamp = ActiveWeatherInputs.ProviderTimestamp;
ActiveWeatherDebug.AppliedWeather = ActiveWeatherInputs.MappedWeather;
ActiveWeatherDebug.ProviderWeatherCode = ActiveWeatherInputs.ProviderWeatherCode;
ActiveWeatherDebug.TemperatureC = ActiveWeatherInputs.TemperatureC;
ActiveWeatherDebug.PrecipitationMm = ActiveWeatherInputs.PrecipitationMm;
ActiveWeatherDebug.WindSpeedKmh = ActiveWeatherInputs.WindSpeedKmh;
ActiveWeatherDebug.CloudCoverPercent = ActiveWeatherInputs.CloudCoverPercent;
ActiveWeatherDebug.RelativeHumidityPercent = ActiveWeatherInputs.RelativeHumidityPercent;
ActiveWeatherDebug.PressureMslHpa = ActiveWeatherInputs.PressureMslHpa;
ActiveWeatherDebug.VisibilityMeters = ActiveWeatherInputs.VisibilityMeters;
ActiveWeatherDebug.bHasProviderData = ActiveWeatherInputs.bHasProviderData;
SetRegionalTemperatureProfile(ActiveWeatherInputs.DailyLowTemperatureC, ActiveWeatherInputs.DailyHighTemperatureC);
SetRegionalObservedTemperature(
ActiveWeatherInputs.TemperatureC,
@@ -188,6 +213,11 @@ void AAgrarianGameState::ApplyMappedWeatherInputs(const FAgrarianMappedWeatherIn
SetWeather(ActiveWeatherInputs.MappedWeather);
}
FAgrarianWeatherDebugSnapshot AAgrarianGameState::GetWeatherDebugSnapshot() const
{
return ActiveWeatherDebug;
}
float AAgrarianGameState::GetClearSkyTemperatureForHour(float HourOfDay) const
{
const float LowTemperature = FMath::Min(RegionalDailyLowTemperatureC, RegionalDailyHighTemperatureC);