refactor(runtime): own world environment state

This commit is contained in:
Erik 2026-07-26 16:45:04 +02:00
parent b972f539f7
commit 902076c0a4
27 changed files with 886 additions and 295 deletions

View file

@ -123,18 +123,17 @@ public static class DerethDateTime
/// Morntide-and-Half". This is a fallback — retail reads
/// <c>GameTime.ZeroTimeOfYear</c> from the Region dat (verified
/// <c>3600</c> in Dereth, 2026-04-23 live dump) and uses that as
/// the additive offset. We override <see cref="OriginOffsetTicks"/>
/// once the dat loads; this constant is only for offline tests.
/// the additive offset. Production installs that value on its
/// instance <see cref="DerethCalendar"/>; this constant remains the
/// offline/static-helper default.
/// </summary>
public const double DayFractionOriginOffsetTicks = (7.0 / 16.0) * DayTicks; // 3333.75
/// <summary>
/// Additive tick offset applied before every calendar extraction
/// (DayFraction / Year / DayOfYear / AbsoluteYear). Populated from
/// the Region dat's <c>GameTime.ZeroTimeOfYear</c> via
/// <see cref="SetOriginOffsetFromDat"/> at Region load. Defaults to
/// <see cref="DayFractionOriginOffsetTicks"/> for offline tests and
/// for the boot window before the dat parses.
/// Compatibility origin used by the pure static helpers. Production
/// worlds use an instance <see cref="DerethCalendar"/> carrying their
/// Region DAT origin, so multiple sessions never share mutable calendar
/// state.
///
/// <para>
/// Live Dereth dat value: <c>3600</c>. Retail's
@ -148,17 +147,7 @@ public static class DerethDateTime
/// corrected and broke DG selection; reverted in the same commit.)
/// </para>
/// </summary>
public static double OriginOffsetTicks { get; private set; } = DayFractionOriginOffsetTicks;
/// <summary>
/// Adopt the Region dat's <c>GameTime.ZeroTimeOfYear</c> as the
/// calendar-extraction offset. Idempotent; safe to call on every
/// Region reload (though in practice Dereth is the only region).
/// </summary>
public static void SetOriginOffsetFromDat(double zeroTimeOfYear)
{
OriginOffsetTicks = zeroTimeOfYear;
}
public const double OriginOffsetTicks = DayFractionOriginOffsetTicks;
/// <summary>
/// Day fraction [0, 1): 0 = Darktide (midnight), 0.5 =