Fix for watering every hour and seed bed texture fixes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -121,14 +121,7 @@ void ATimeOfDayManager::Tick(float DeltaTime)
|
|||||||
QueuedWeatherPreset = GetWeatherDistributionValue();
|
QueuedWeatherPreset = GetWeatherDistributionValue();
|
||||||
K2_WeatherFadeStart(QueuedWeatherPreset->bIsRain);
|
K2_WeatherFadeStart(QueuedWeatherPreset->bIsRain);
|
||||||
|
|
||||||
if (QueuedWeatherPreset->bIsRain)
|
WaterSeedBedsIfRaining();
|
||||||
{
|
|
||||||
// Rain refills the soil of every plant, the game state also reaches the beds that are streamed out
|
|
||||||
if (AEleriGameState* GameState = AEleriGameState::Get(this))
|
|
||||||
{
|
|
||||||
GameState->WaterAllSeedBeds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -393,6 +386,28 @@ void ATimeOfDayManager::CheckLateHours()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ATimeOfDayManager::IsRaining()
|
||||||
|
{
|
||||||
|
// While a weather change is blending, the queue is the weather the world is heading into, which is the same
|
||||||
|
// preset the rain toggle is already driven with, so rain reads as active from the first blended frame on
|
||||||
|
const UWeatherPresetDataAsset* ActivePreset = QueuedWeatherPreset ? QueuedWeatherPreset : CurrentWeatherPreset;
|
||||||
|
return IsValid(ActivePreset) && ActivePreset->bIsRain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATimeOfDayManager::WaterSeedBedsIfRaining()
|
||||||
|
{
|
||||||
|
if (!IsRaining())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The game state owns the cache, so the beds that are streamed out are watered along with the loaded ones
|
||||||
|
if (AEleriGameState* GameState = AEleriGameState::Get(this))
|
||||||
|
{
|
||||||
|
GameState->WaterAllSeedBeds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ATimeOfDayManager::GoToSleep()
|
void ATimeOfDayManager::GoToSleep()
|
||||||
{
|
{
|
||||||
if (currentHours == 0 || currentHours == 1 || currentHours == 2)
|
if (currentHours == 0 || currentHours == 1 || currentHours == 2)
|
||||||
@@ -451,6 +466,11 @@ void ATimeOfDayManager::AddMinutes(float minutes)
|
|||||||
for (int32 HourIndex = AbsoluteHoursBefore; HourIndex < AbsoluteHoursAfter; ++HourIndex)
|
for (int32 HourIndex = AbsoluteHoursBefore; HourIndex < AbsoluteHoursAfter; ++HourIndex)
|
||||||
{
|
{
|
||||||
OnHourPassed.Broadcast();
|
OnHourPassed.Broadcast();
|
||||||
|
|
||||||
|
// Sitting behind the broadcast makes the order deterministic: the beds have already drained a moisture
|
||||||
|
// hour and checked their plants for this hour, rain now refills the soil of every planted seed instead
|
||||||
|
// of only doing it once when the rain started
|
||||||
|
WaterSeedBedsIfRaining();
|
||||||
}
|
}
|
||||||
|
|
||||||
NextWeatherChangeMinutes -= minutes;
|
NextWeatherChangeMinutes -= minutes;
|
||||||
|
|||||||
@@ -335,8 +335,11 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
||||||
void GoToSleep();
|
void GoToSleep();
|
||||||
|
|
||||||
|
/** True while the weather the world is in, or is blending into, is a rain preset.
|
||||||
|
* The Raining property this used to read was never written anywhere, so the weather preset is the only
|
||||||
|
* live source of truth and it matches the bIsRain flag the rain toggle is driven with. */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
||||||
bool IsRaining() { return Raining; }
|
bool IsRaining();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
UFUNCTION(BlueprintCallable, Category = "Time of day")
|
||||||
void ToggleTimeActive(bool bNewActive);
|
void ToggleTimeActive(bool bNewActive);
|
||||||
@@ -365,6 +368,9 @@ protected:
|
|||||||
void SetSkylightIntensity(const float &_rotator);
|
void SetSkylightIntensity(const float &_rotator);
|
||||||
void CheckLateHours();
|
void CheckLateHours();
|
||||||
|
|
||||||
|
/** Refills the soil of every planted seed of every seed bed for the hour that just passed in the rain. */
|
||||||
|
void WaterSeedBedsIfRaining();
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user