added session loss sequence, added energy and stamina to HUD, added home location trigger

This commit is contained in:
2026-06-04 18:59:04 +03:00
parent f2fcd42edf
commit 034694695a
26 changed files with 404 additions and 24 deletions
@@ -31,7 +31,18 @@ void UTimeOfDaySubsystem::OnWorldBeginPlay(UWorld& InWorld)
void UTimeOfDaySubsystem::Tick(float DeltaTime)
{
if (!bBegunPlay || IsPaused())
if (!bBegunPlay)
return;
// The sleep sweep owns the clock while it runs — it drives AdvanceClock itself, so
// skip the normal real-time advancement (and ignore pause, which sleep doesn't honor).
if (bSleeping)
{
TickSleep(DeltaTime);
return;
}
if (IsPaused())
return;
AdvanceClock(static_cast<double>(DeltaTime) * INGAME_MINUTES_PER_REAL_SECOND);
@@ -91,7 +102,41 @@ void UTimeOfDaySubsystem::SkipToNextMorning()
void UTimeOfDaySubsystem::Sleep()
{
SkipTime(SLEEP_DURATION_HOURS * MINUTES_PER_HOUR);
if (bSleeping)
return; // already sweeping; ignore re-entrant interacts
// Kick off the animated sweep — Tick advances the clock a slice at a time so the sky
// sun/lighting interpolate across the 8 hours instead of snapping. Energy restore and
// autosave are deferred to FinishSleep() so they land on the final time, not the start.
const double TotalMinutes = SLEEP_DURATION_HOURS * MINUTES_PER_HOUR;
SleepMinutesRemaining = TotalMinutes;
SleepMinutesPerRealSecond = TotalMinutes / FMath::Max(SLEEP_TRANSITION_SECONDS, KINDA_SMALL_NUMBER);
bSleeping = true;
}
void UTimeOfDaySubsystem::TickSleep(float DeltaTime)
{
// Clamp the final slice so we land exactly on +8h rather than overshooting.
double Step = SleepMinutesPerRealSecond * static_cast<double>(DeltaTime);
if (Step >= SleepMinutesRemaining)
Step = SleepMinutesRemaining;
SleepMinutesRemaining -= Step;
// Throttled push (bForceSkyPush=false) keeps the sky at the smooth 30fps cadence; the
// per-hour boundaries (phase flip, day-roll, rent) still fire as each hour is crossed.
AdvanceClock(Step);
if (SleepMinutesRemaining <= 0.0)
FinishSleep();
}
void UTimeOfDaySubsystem::FinishSleep()
{
bSleeping = false;
SleepMinutesRemaining = 0.0;
SleepMinutesPerRealSecond = 0.0;
PushTimeToSky(/*bForce=*/true); // snap the sky to the exact final time
RestorePlayerEnergy();
// TODO(§9.8 / Phase 9): charge the equipped phone to 100% as part of the sleep cycle.
// TODO(§7.3): sleep does NOT reset hunger / effective-max decay — only eating does.