Authoritative World Time, Calendar, and Environmental Scheduler
What This System Is
World time replaces subsystem-specific clock calculations with one server-authoritative calendar and recurrence source. The preview-only schedule simulator remains available as a debug override, while production rules live in assets/gameplay/world_time_catalog.json.
How Authors Use It
Authors edit the world-time catalog to define calendars, zones, weather profiles, lighting profiles, and scheduled targets. Use the Scene Lighting world-time preview to scrub day and minute, inspect weather and lighting output, and preview scheduled targets due in the next 24 hours.
Rules And Invariants
Clock
WorldClockState stores the absolute world minute, last observed real timestamp, fractional remainder, pause state, and revision. Advancement preserves fractional real time so repeated short ticks do not drift. Offline advancement is capped by an explicit catch-up limit and reports truncated minutes for operational visibility.
Calendar
Calendars define an epoch year, clock rate, named weekdays, variable-length months, seasons, and holidays. Absolute world minutes project deterministically into year, month, day, weekday, time of day, season, and holiday IDs without relying on the host machine's locale or wall clock.
Zones and weather
Zones select a calendar, local minute offset, weather profile, and lighting profile. Weather profiles contain season-specific weighted states and transition intervals. Selection uses a stable hash of the profile seed, zone, season, and time bucket, producing identical weather on clients, servers, tests, and editor previews.
Scheduler
Schedules support daily, weekly, monthly, yearly, and fixed-interval recurrence. Targets include world events, scene phases, NPC routines, encounters, vendor rotations, farming ticks, and runtime events.
Each schedule declares an offline catch-up policy:
skipignores missed occurrences;latestemits only the newest missed occurrence;boundedemits at most an authored count;allemits every missed occurrence.
Every occurrence has a deterministic claim key. WorldScheduleClaimRegistry permits the first claim and rejects duplicate execution after retries, reconnects, or authority handoff.
Editor preview
Open Scene → Detailed Scene Tools → Scene Lighting → Authoritative World Time. Scrub day and minute or jump to dawn, noon, and night. The panel displays the authored date, weekday, season, holiday, deterministic zone weather, lighting profile, and scheduled targets due within the next 24 hours.
The NPC Routine Timeline consumes this same preview instant, so changing world time immediately updates scheduled NPC activities and destinations. Scene-phase candidates continue to compose with the resulting NPC preview.
Validation And Debugging
Server startup requires the world-time catalog. Validation covers clock rates, calendar structure, month and holiday dates, recurrence ranges, weather weights, zone references, and scheduled world-event, scene-phase, and NPC-routine targets. The authoring dependency graph records those targets and every zone scene.
Examples
Use a bounded catch-up schedule for farming ticks that should process only a limited number of missed occurrences after downtime. Use a deterministic weather profile for a zone so clients, servers, tests, and editor previews agree on the same weather at the same world minute.