Skip to content

Core — Runtime / Time

Folder Overview

This folder holds the default time providers shared across RevFramework.

Two kinds of time are kept apart:

  • game time via ITimeProvider (used while running)
  • wall-clock time via IWallClockProvider (used for offline logic)

This keeps runtime behaviour deterministic, testable, and independent of Unity static APIs. These providers live in Core rather than inside a system because more than one system needs them, and because a system's runtime should not depend on Unity-facing glue to tell the time.


What Lives Here

Type Role
UnityTimeProvider default ITimeProvider — scaled, unscaled, fixed and realtime values, plus UTC epoch milliseconds
SystemWallClock default IWallClockProvider — UTC epoch seconds

Both are in the RevGaming.RevFramework.Core.Time namespace.

The contracts they implement live next door in Runtime/Core/Abstractions/Time/ (RevGaming.RevFramework.Core.Abstractions.Time).


Who Uses These

Crafting and Currency both consume these providers today. Crafting is the heaviest user: it selects a game-time source via CraftTimeMode (Runtime/Systems/Crafting/Core/Contracts/) and uses wall-clock time for offline progress.

Because these are shared, replacing them affects every system that tells the time — not just the one you are working on.


Purpose

These abstractions provide a consistent way to:

  • track progress during runtime
  • compute elapsed time while offline
  • restore state safely after reload

They separate runtime ticking from real-world time.


Usage Guidance

Game Time

Provided via ITimeProvider.

Used for:

  • ticking work in progress
  • progress calculation
  • duration tracking

Which game-time value is read is the consumer's choice — Crafting selects one via CraftTimeMode.


Wall-Clock Time

Provided via IWallClockProvider.

Used for:

  • capturing timestamps
  • computing offline elapsed time
  • determining offline completion

If a consuming service is not given one, it falls back to SystemWallClock.


Default Implementation

SystemWallClock

Defined here, in SystemWallClock.cs:

public sealed class SystemWallClock : IWallClockProvider
{
    public long UtcNowSeconds => System.DateTimeOffset.UtcNow.ToUnixTimeSeconds();
}
  • uses system UTC time
  • returns Unix epoch seconds
  • stateless and allocation-free

Important Notes

  • wall-clock values should be non-negative UTC seconds
  • incorrect values may affect offline calculations
  • Crafting records timestamps rather than caching provider values

Not for Production Use

These abstractions measure time, they do not schedule work

The time providers do not include:

  • gameplay logic
  • scheduling rules
  • persistence systems

  • Core Abstractions — the ITimeProvider and IWallClockProvider contracts
  • Crafting Core (job execution and persistence) — the heaviest consumer

Design Notes

  • separates runtime and real-world time
  • supports offline progress without coupling to Unity APIs

If custom behaviour is required, provide your own time providers.